Re: ehci-hcd compile error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/17/2013 06:10 PM, Alan Stern wrote:
> On Thu, 17 Jan 2013, Roger Quadros wrote:
> 
>> Alan,
>>
>> What tree is your patch based off?
> 
> Roughly speaking, 3.7 plus Greg KH's usb-next branch as of the 3.7
> release.  This should be pretty much the same as 3.8-rc1 as far as the
> USB stack is concerned.  I haven't tried applying the patch to 3.8-rc3,
> but any merge problems should be minimal.
> 
>>  Also, could you please send me your
>> updated patch for ehci-omap.c? I'll then base my work on top of that.
> 
> Attached are two patches: one to convert ehci-omap to the new library
> scheme (based on the stuff I just sent Felipe), and a second (based on
> the first) to illustrate how to allocate additional private space for
> the PHY values.  Thanks to your latest set of changes, you may not need
> to use the second patch.
> 

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.

>From f29533ed9f9c81c9ea2e99397db65222d73069da Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@xxxxxx>
Date: Fri, 18 Jan 2013 15:29:08 +0200
Subject: [PATCH] test ehci->priv corruption

Signed-off-by: Roger Quadros <rogerq@xxxxxx>
---
 drivers/usb/host/ehci-omap.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index fd2f5450..ee1746d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -70,6 +70,10 @@ static const char hcd_name[] = "ehci-omap";

 /*-------------------------------------------------------------------------*/

+struct omap_hcd {
+	int a;
+	int b;
+};

 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -179,6 +183,7 @@ static struct hc_driver __read_mostly
ehci_omap_hc_driver;

 static const struct ehci_driver_overrides ehci_omap_overrides
__initdata = {
 	.reset =		omap_ehci_init,
+	.extra_priv_size	= sizeof (struct omap_hcd),
 };

 /**
@@ -194,6 +199,7 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
 	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
 	struct resource				*res;
 	struct usb_hcd				*hcd;
+	struct omap_hcd				*omap;
 	void __iomem				*regs;
 	int					ret = -ENODEV;
 	int					irq;
@@ -232,6 +238,10 @@ static int ehci_hcd_omap_probe(struct
platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 	hcd->regs = regs;
+	omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
+	omap->a = 0x1234abcd;
+	omap->b = 0x5679efba;
+	dev_info(dev, "%s a 0x%x, b 0x%x\n", __func__, omap->a, omap->b);

 	/* get ehci regulator and enable */
 	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
@@ -295,7 +305,9 @@ static int ehci_hcd_omap_remove(struct
platform_device *pdev)
 {
 	struct device *dev				= &pdev->dev;
 	struct usb_hcd *hcd				= dev_get_drvdata(dev);
+	struct omap_hcd *omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;

+	dev_info(dev, "%s a 0x%x, b 0x%x\n", __func__, omap->a, omap->b);
 	usb_remove_hcd(hcd);
 	disable_put_regulator(dev->platform_data);
 	usb_put_hcd(hcd);
-- 
1.7.4.1


>From f29533ed9f9c81c9ea2e99397db65222d73069da Mon Sep 17 00:00:00 2001
From: Roger Quadros <rogerq@xxxxxx>
Date: Fri, 18 Jan 2013 15:29:08 +0200
Subject: [PATCH] test ehci->priv corruption

Signed-off-by: Roger Quadros <rogerq@xxxxxx>
---
 drivers/usb/host/ehci-omap.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c
index fd2f5450..ee1746d 100644
--- a/drivers/usb/host/ehci-omap.c
+++ b/drivers/usb/host/ehci-omap.c
@@ -70,6 +70,10 @@ static const char hcd_name[] = "ehci-omap";
 
 /*-------------------------------------------------------------------------*/
 
+struct omap_hcd {
+	int a;
+	int b;
+};
 
 static inline void ehci_write(void __iomem *base, u32 reg, u32 val)
 {
@@ -179,6 +183,7 @@ static struct hc_driver __read_mostly ehci_omap_hc_driver;
 
 static const struct ehci_driver_overrides ehci_omap_overrides __initdata = {
 	.reset =		omap_ehci_init,
+	.extra_priv_size	= sizeof (struct omap_hcd),
 };
 
 /**
@@ -194,6 +199,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	struct usbhs_omap_platform_data		*pdata = dev->platform_data;
 	struct resource				*res;
 	struct usb_hcd				*hcd;
+	struct omap_hcd				*omap;
 	void __iomem				*regs;
 	int					ret = -ENODEV;
 	int					irq;
@@ -232,6 +238,10 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev)
 	hcd->rsrc_start = res->start;
 	hcd->rsrc_len = resource_size(res);
 	hcd->regs = regs;
+	omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
+	omap->a = 0x1234abcd;
+	omap->b = 0x5679efba;
+	dev_info(dev, "%s a 0x%x, b 0x%x\n", __func__, omap->a, omap->b);
 
 	/* get ehci regulator and enable */
 	for (i = 0 ; i < OMAP3_HS_USB_PORTS ; i++) {
@@ -295,7 +305,9 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev)
 {
 	struct device *dev				= &pdev->dev;
 	struct usb_hcd *hcd				= dev_get_drvdata(dev);
+	struct omap_hcd *omap = (struct omap_hcd *)hcd_to_ehci(hcd)->priv;
 
+	dev_info(dev, "%s a 0x%x, b 0x%x\n", __func__, omap->a, omap->b);
 	usb_remove_hcd(hcd);
 	disable_put_regulator(dev->platform_data);
 	usb_put_hcd(hcd);
-- 
1.7.4.1


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux