/* Target based USB-Gadget * * UAS protocol handling, target callbacks, configfs handling, * BBB (USB Mass Storage Class Bulk-Only (BBB) and Transport protocol handling. * * Author: Sebastian Andrzej Siewior * License: GPLv2 as published by FSF. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "u_tcm.h" USB_GADGET_COMPOSITE_OPTIONS(); #define UAS_VENDOR_ID 0x0525 /* NetChip */ #define UAS_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ static struct usb_device_descriptor usbg_device_desc = { .bLength = sizeof(usbg_device_desc), .bDescriptorType = USB_DT_DEVICE, /* .bcdUSB = DYNAMIC */ .bDeviceClass = USB_CLASS_PER_INTERFACE, .idVendor = cpu_to_le16(UAS_VENDOR_ID), .idProduct = cpu_to_le16(UAS_PRODUCT_ID), .bNumConfigurations = 1, }; #define USB_G_STR_CONFIG USB_GADGET_FIRST_AVAIL_IDX static struct usb_string usbg_us_strings[] = { [USB_GADGET_MANUFACTURER_IDX].s = "Target Manufactor", [USB_GADGET_PRODUCT_IDX].s = "Target Product", [USB_GADGET_SERIAL_IDX].s = "000000000001", [USB_G_STR_CONFIG].s = "default config", { }, }; static struct usb_gadget_strings usbg_stringtab = { .language = 0x0409, .strings = usbg_us_strings, }; static struct usb_gadget_strings *usbg_strings[] = { &usbg_stringtab, NULL, }; static struct usb_function_instance *fi_tcm; static struct usb_function *f_tcm; static int guas_unbind(struct usb_composite_dev *cdev) { if (!IS_ERR_OR_NULL(f_tcm)) usb_put_function(f_tcm); return 0; } static int tcm_do_config(struct usb_configuration *c) { int status; f_tcm = usb_get_function(fi_tcm); if (IS_ERR(f_tcm)) return PTR_ERR(f_tcm); status = usb_add_function(c, f_tcm); if (status < 0) { usb_put_function(f_tcm); return status; } return 0; } static struct usb_configuration usbg_config_driver = { .label = "Linux Target", .bConfigurationValue = 1, .bmAttributes = USB_CONFIG_ATT_SELFPOWER, }; static int usbg_attach(struct usb_function_instance *f); static void usbg_detach(struct usb_function_instance *f); static int usb_target_bind(struct usb_composite_dev *cdev) { int ret; ret = usb_string_ids_tab(cdev, usbg_us_strings); if (ret) return ret; usbg_device_desc.iManufacturer = usbg_us_strings[USB_GADGET_MANUFACTURER_IDX].id; usbg_device_desc.iProduct = usbg_us_strings[USB_GADGET_PRODUCT_IDX].id; usbg_device_desc.iSerialNumber = usbg_us_strings[USB_GADGET_SERIAL_IDX].id; usbg_config_driver.iConfiguration = usbg_us_strings[USB_G_STR_CONFIG].id; ret = usb_add_config(cdev, &usbg_config_driver, tcm_do_config); if (ret) return ret; usb_composite_overwrite_options(cdev, &coverwrite); return 0; } static struct usb_composite_driver usbg_driver = { .name = "g_target", .dev = &usbg_device_desc, .strings = usbg_strings, .max_speed = USB_SPEED_SUPER, .bind = usb_target_bind, .unbind = guas_unbind, }; static int usbg_attach(struct usb_function_instance *f) { return usb_composite_probe(&usbg_driver); } static void usbg_detach(struct usb_function_instance *f) { usb_composite_unregister(&usbg_driver); } static int __init usb_target_gadget_init(void) { struct f_tcm_opts *tcm_opts; fi_tcm = usb_get_function_instance("tcm"); if (IS_ERR(fi_tcm)) return PTR_ERR(fi_tcm); tcm_opts = container_of(fi_tcm, struct f_tcm_opts, func_inst); mutex_lock(&tcm_opts->dep_lock); tcm_opts->tcm_register_callback = usbg_attach; tcm_opts->tcm_unregister_callback = usbg_detach; tcm_opts->dependent = THIS_MODULE; tcm_opts->can_attach = true; tcm_opts->has_dep = true; mutex_unlock(&tcm_opts->dep_lock); fi_tcm->set_inst_name(fi_tcm, "tcm-legacy"); return 0; } module_init(usb_target_gadget_init); static void __exit usb_target_gadget_exit(void) { if (!IS_ERR_OR_NULL(fi_tcm)) usb_put_function_instance(fi_tcm); } module_exit(usb_target_gadget_exit); MODULE_AUTHOR("Sebastian Andrzej Siewior "); MODULE_DESCRIPTION("usb-gadget fabric"); MODULE_LICENSE("GPL v2"); ue='1'>ssdiff
authorThomas Gleixner <tglx@linutronix.de>2017-01-31 23:58:38 +0100
committerIngo Molnar <mingo@kernel.org>2017-02-01 08:37:27 +0100
commitdd86e373e09fb16b83e8adf5c48c421a4ca76468 (patch)
tree55703c2ea8584e303e342090614e0aab3509ab21 /tools/perf/util/counts.h
parent0b3589be9b98994ce3d5aeca52445d1f5627c4ba (diff)
perf/x86/intel/rapl: Make package handling more robust
The package management code in RAPL relies on package mapping being available before a CPU is started. This changed with: 9d85eb9119f4 ("x86/smpboot: Make logical package management more robust") because the ACPI/BIOS information turned out to be unreliable, but that left RAPL in broken state. This was not noticed because on a regular boot all CPUs are online before RAPL is initialized. A possible fix would be to reintroduce the mess which allocates a package data structure in CPU prepare and when it turns out to already exist in starting throw it away later in the CPU online callback. But that's a horrible hack and not required at all because RAPL becomes functional for perf only in the CPU online callback. That's correct because user space is not yet informed about the CPU being onlined, so nothing caan rely on RAPL being available on that particular CPU. Move the allocation to the CPU online callback and simplify the hotplug handling. At this point the package mapping is established and correct. This also adds a missing check for available package data in the event_init() function. Reported-by: Yasuaki Ishimatsu <yasu.isimatu@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Sebastian Siewior <bigeasy@linutronix.de> Cc: Stephane Eranian <eranian@google.com> Cc: Vince Weaver <vincent.weaver@maine.edu> Fixes: 9d85eb9119f4 ("x86/smpboot: Make logical package management more robust") Link: http://lkml.kernel.org/r/20170131230141.212593966@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/counts.h')