On Fri, 18 Jan 2013, Roger Quadros wrote: > Thanks. I used the below code (also attached) and could reproduce > corruption on the first byte at ehci->priv. This is from the the kernel log. > > > [ 30.381774] ehci-omap ehci-omap.0: ehci_hcd_omap_probe a 0x1234abcd, b 0x5679efba > > > [ 122.523468] ehci-omap ehci-omap.0: ehci_hcd_omap_remove a 0x1234abe0, b 0x5679efba > > NOTE: EHCI needs to be running and you need to enumerate some device for > the corruption to happen. > > If I disable CONFIG_USB_DEBUG, then there is no corruption. I tried doing something similar with (using ehci-pci rather than ehci-omap) and didn't get any corruption. My test patch is below. Unforunately you won't be able to utilize the hw_breakpoint mechanism in your testing because it hasn't been set up for OMAP. Here's the log for a test with two EHCI controllers and one device plugged in. (Note: I did have CONFIG_USB_DEBUG enabled, but this log doesn't include any of the debug-level messages.) [ 1217.550517] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver [ 1220.650589] ehci-pci: EHCI PCI platform driver [ 1220.658534] ehci-pci 0000:00:1d.7: EHCI Host Controller [ 1220.662595] ehci-pci 0000:00:1d.7: new USB bus registered, assigned bus number 1 [ 1220.680773] Breakpoint at e993a868 was hit! [ 1220.683678] Pid: 2853, comm: modprobe Tainted: G O 3.7.0AS-00240-g4e405e8-dirty #17 [ 1220.684016] Call Trace: [ 1220.684016] [<c102387b>] ? console_unlock+0x323/0x34c [ 1220.684016] [<f0034137>] ? ehci_hrtimer_func+0xa6/0xa6 [ehci_hcd] [ 1220.684016] [<f003414f>] ehci_hbp_handler+0x18/0x1c [ehci_hcd] [ 1220.684016] [<c106f17f>] __perf_event_overflow+0x183/0x1fb [ 1220.684016] [<c106f33c>] perf_swevent_overflow+0x40/0x5e [ 1220.684016] [<c106f41d>] perf_swevent_event+0xc3/0xcd [ 1220.684016] [<c106faf9>] perf_bp_event+0x86/0x8f [ 1220.684016] [<c10566b5>] ? __lock_acquire+0xc5b/0xc6a [ 1220.684016] [<c10522db>] ? tick_program_event+0x1f/0x24 [ 1220.684016] [<c123405b>] hw_breakpoint_exceptions_notify+0xec/0x17a [ 1220.684016] [<c12350d2>] notifier_call_chain+0x51/0x7a [ 1220.684016] [<c123512d>] __atomic_notifier_call_chain+0x32/0x56 [ 1220.684016] [<c123515d>] atomic_notifier_call_chain+0xc/0xe [ 1220.684016] [<c123518c>] notify_die+0x2d/0x2f [ 1220.684016] [<c12336cd>] do_debug+0x69/0x11b [ 1220.684016] [<c12332e9>] debug_stack_correct+0x2e/0x35 [ 1220.684016] [<f003007b>] ? single_unlink_async+0xc/0x5d [ehci_hcd] [ 1220.684016] [<f0037633>] ? ehci_setup+0x64d/0x6aa [ehci_hcd] [ 1220.684016] [<c100502a>] ? dma_set_mask+0x41/0x41 [ 1220.684016] [<eff742a3>] ehci_pci_setup+0x2a3/0x498 [ehci_pci] [ 1220.684016] [<effe7643>] usb_add_hcd+0x18c/0x5a5 [usbcore] [ 1220.684016] [<efff26a7>] usb_hcd_pci_probe+0x1d3/0x2d8 [usbcore] [ 1220.684016] [<c1145ff3>] pci_device_probe+0x7c/0xd9 [ 1220.684016] [<c119629d>] driver_probe_device+0x8b/0x168 [ 1220.684016] [<c11963c4>] __driver_attach+0x4a/0x66 [ 1220.684016] [<c119503e>] bus_for_each_dev+0x3f/0x61 [ 1220.684016] [<c1195fd3>] driver_attach+0x17/0x1c [ 1220.684016] [<c119637a>] ? driver_probe_device+0x168/0x168 [ 1220.684016] [<c1195ba3>] bus_add_driver+0x8e/0x1b4 [ 1220.684016] [<c11967a8>] driver_register+0x72/0xdd [ 1220.684016] [<c1138107>] ? __raw_spin_lock_init+0x26/0x48 [ 1220.684016] [<c11460e5>] __pci_register_driver+0x45/0x48 [ 1220.684016] [<eff79059>] ehci_pci_init+0x59/0x1000 [ehci_pci] [ 1220.684016] [<c1001183>] do_one_initcall+0x71/0x11a [ 1220.684016] [<eff79000>] ? 0xeff78fff [ 1220.684016] [<c105e01f>] sys_init_module+0x1354/0x1516 [ 1220.684016] [<c1054e98>] ? trace_hardirqs_on_caller+0x13f/0x17e [ 1220.684016] [<c12366fe>] sysenter_do_call+0x12/0x36 [ 1220.796643] ehci-pci 0000:00:1d.7: ehci_setup a 1238abcf b 5679efba [ 1220.799409] ehci-pci 0000:00:1d.7: debug port 1 [ 1220.807738] ehci-pci 0000:00:1d.7: irq 23, io mem 0xfe77bc00 [ 1220.824062] ehci-pci 0000:00:1d.7: USB 2.0 started, EHCI 1.00 [ 1220.835340] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002 [ 1220.838733] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 1220.842190] usb usb1: Product: EHCI Host Controller [ 1220.845492] usb usb1: Manufacturer: Linux 3.7.0AS-00240-g4e405e8-dirty ehci_hcd [ 1220.848827] usb usb1: SerialNumber: 0000:00:1d.7 [ 1220.885420] hub 1-0:1.0: USB hub found [ 1220.889325] hub 1-0:1.0: 8 ports detected [ 1220.940628] ehci-pci 0000:01:01.2: EHCI Host Controller [ 1220.943363] ehci-pci 0000:01:01.2: new USB bus registered, assigned bus number 2 [ 1220.975320] ehci-pci 0000:01:01.2: ehci_setup a 1238abcf b 5679efba [ 1220.985385] ehci-pci 0000:01:01.2: irq 9, io mem 0xfe5dfc00 [ 1221.000070] ehci-pci 0000:01:01.2: USB 2.0 started, EHCI 1.00 [ 1221.011691] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002 [ 1221.015403] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 1221.018738] usb usb2: Product: EHCI Host Controller [ 1221.026111] usb usb2: Manufacturer: Linux 3.7.0AS-00240-g4e405e8-dirty ehci_hcd [ 1221.032874] usb usb2: SerialNumber: 0000:01:01.2 [ 1221.071590] hub 2-0:1.0: USB hub found [ 1221.075524] hub 2-0:1.0: 5 ports detected [ 1221.264193] usb 1-8: new high-speed USB device number 2 using ehci-pci [ 1221.410369] usb 1-8: New USB device found, idVendor=1307, idProduct=0165 [ 1221.414050] usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 1221.417776] usb 1-8: Product: USB Mass Storage Device [ 1221.421381] usb 1-8: Manufacturer: USBest Technology [ 1221.425008] usb 1-8: SerialNumber: 00000000000126 [ 1221.463177] scsi2 : usb-storage 1-8:1.0 [ 1221.483847] scsi 2:0:0:0: Direct-Access Ut165 USB2FlashStorage 0.00 PQ: 0 ANSI: 2 [ 1221.541132] sd 2:0:0:0: [sda] 7892040 512-byte logical blocks: (4.04 GB/3.76 GiB) [ 1221.548327] sd 2:0:0:0: [sda] Write Protect is off [ 1221.555886] sd 2:0:0:0: Attached scsi generic sg0 type 0 [ 1221.565286] sd 2:0:0:0: [sda] Asking for cache data failed [ 1221.569781] sd 2:0:0:0: [sda] Assuming drive cache: write through [ 1221.588258] sd 2:0:0:0: [sda] Asking for cache data failed [ 1221.591436] sd 2:0:0:0: [sda] Assuming drive cache: write through [ 1221.725395] sda: sda1 [ 1221.740587] sd 2:0:0:0: [sda] Asking for cache data failed [ 1221.743764] sd 2:0:0:0: [sda] Assuming drive cache: write through [ 1221.752126] sd 2:0:0:0: [sda] Attached SCSI removable disk [ 1249.712922] ehci-pci 0000:01:01.2: remove, state 4 [ 1249.720586] usb usb2: USB disconnect, device number 1 [ 1249.750506] ehci-pci 0000:01:01.2: ehci_stop a 1238abcf b 5679efba [ 1249.774435] ehci-pci 0000:01:01.2: USB bus 2 deregistered [ 1249.779339] ehci-pci 0000:00:1d.7: remove, state 1 [ 1249.786521] usb usb1: USB disconnect, device number 1 [ 1249.790034] usb 1-8: USB disconnect, device number 2 [ 1249.914699] ehci-pci 0000:00:1d.7: ehci_stop a 1238abcf b 5679efba [ 1249.943361] ehci-pci 0000:00:1d.7: USB bus 1 deregistered The fact that only the first byte of ehci->priv was affected on your system, and that it occurred only with CONFIG_USB_DEBUG, suggests that something involving ehci->debug_dir is messing up. But that field is assigned to in only one spot (create_debug_files), so I don't know what's wrong. I suppose you could try sprinkling some ehci_dbg() statements at various strategic spots in ehci-hcd.c to narrow down where the problem is. Alan Stern Index: usb-3.7/drivers/usb/host/ehci-hcd.c =================================================================== --- usb-3.7.orig/drivers/usb/host/ehci-hcd.c +++ usb-3.7/drivers/usb/host/ehci-hcd.c @@ -45,10 +45,23 @@ #include <asm/irq.h> #include <asm/unaligned.h> +#include <linux/perf_event.h> +#include <linux/hw_breakpoint.h> + +static struct perf_event * __percpu *ehci_hbp; +static void *bp_addr; + #if defined(CONFIG_PPC_PS3) #include <asm/firmware.h> #endif +static void ehci_hbp_handler(struct perf_event *bp, + struct perf_sample_data *data, struct pt_regs *regs) +{ + printk(KERN_INFO "Breakpoint at %p was hit!\n", bp_addr); + dump_stack(); +} + /*-------------------------------------------------------------------------*/ /* @@ -411,9 +424,21 @@ static void ehci_work (struct ehci_hcd * /* * Called when the ehci_hcd module is removed. */ + +struct ehci_test { + unsigned a, b; +}; + static void ehci_stop (struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); + struct ehci_test *p = (struct ehci_test *) ehci->priv; + + ehci_info(ehci, "%s a %x b %x\n", __func__, p->a, p->b); + if (p == bp_addr) { + unregister_wide_hw_breakpoint(ehci_hbp); + bp_addr = NULL; + } ehci_dbg (ehci, "stop\n"); @@ -653,6 +678,26 @@ int ehci_setup(struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci(hcd); int retval; + struct ehci_test *p = (struct ehci_test *) ehci->priv; + + p->a = 0x1234abcd; + p->b = 0x5679efba; + + if (!bp_addr) { + struct perf_event_attr attr; + + hw_breakpoint_init(&attr); + attr.bp_addr = (unsigned long) p; + attr.bp_len = HW_BREAKPOINT_LEN_4; + attr.bp_type = HW_BREAKPOINT_W; + + ehci_hbp = register_wide_hw_breakpoint(&attr, ehci_hbp_handler, NULL); + if (IS_ERR((void __force *) ehci_hbp)) + ehci_info(ehci, "Unable to create breakpoint: %d\n", + (int) PTR_ERR((void __force *) ehci_hbp)); + else + bp_addr = p; + } ehci->regs = (void __iomem *)ehci->caps + HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); @@ -678,6 +723,9 @@ int ehci_setup(struct usb_hcd *hcd) ehci_reset(ehci); + /* Make sure the breakpoint is working */ + p->a = 0x1238abcf; + ehci_info(ehci, "%s a %x b %x\n", __func__, p->a, p->b); return 0; } EXPORT_SYMBOL_GPL(ehci_setup); @@ -1236,6 +1284,7 @@ void ehci_init_driver(struct hc_driver * if (over->reset) drv->reset = over->reset; } + drv->hcd_priv_size += sizeof(struct ehci_test); } EXPORT_SYMBOL_GPL(ehci_init_driver); -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html