Skip to contentSkip to conversation

musb patches (v2)

PATCH In review Felipe Balbi 7 participants 24 messages Mar 25, 2010 – Apr 26, 2010 4 messages not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover musb patches (v2)

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

Now rebasing against Linus' today's master.

Ajay Kumar Gupta (2):
musb: fix power field to hold all possible values
musb: save and restore missing bus control register

Dan Carpenter (1):
musb: potential use after free

Sergei Shtylyov (8):
MUSB: fix DaVinci glue layer dependency
MUSB: Blackfin: don't fake blackfin_interrupt() result
musb_core: don't touch 'musb->clock' in musb_free()
musb_core: don't prevent disabling clock on driver unload
MUSB: DaVinci: fix musb_platform_init() error cleanup path
MUSB: OMAP: don't call clk_put()
musb_core: don't call musb_platform_exit() twice
musb_core: fix musb_init_controller() error cleanup path

 arch/arm/plat-omap/include/plat/usb.h |    2 +-
 drivers/usb/musb/Kconfig              |    2 +-
 drivers/usb/musb/Makefile             |    2 +-
 drivers/usb/musb/blackfin.c           |    8 +---
 drivers/usb/musb/davinci.c            |    2 +
 drivers/usb/musb/musb_core.c          |   77 ++++++++++++++++++--------------
 drivers/usb/musb/musb_core.h          |    2 +-
 drivers/usb/musb/musb_host.c          |    1 +
 drivers/usb/musb/omap2430.c           |    3 -
 9 files changed, 51 insertions(+), 48 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1269515673-27980-1-git-send-email-felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/11 musb: fix power field to hold all possible values

From: Ajay Kumar Gupta <[email protected]>

MUSB can supply upto 500mA such as, AM3517 and OMAP3EVM Rev >=E and thus the 'power' field has to hold values above 255.

---
 arch/arm/plat-omap/include/plat/usb.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/plat-omap/include/plat/usb.h +1 -1
index 568578d..876ca8d 100644
@@ -46,7 +46,7 @@ struct ehci_hcd_omap_platform_data {
 struct omap_musb_board_data {
 	u8	interface_type;
 	u8	mode;
-	u8	power;
+	u16	power;
 };
 
 enum musb_interface    {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI};
Signature · 6 lines
1.7.0.rc0.33.g7c3932

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 2/11 MUSB: fix DaVinci glue layer dependency

In reply to a message not in the archive

From: Sergei Shtylyov <[email protected]>

CONFIG_ARCH_DAVINCI now embraces both the "real" DaVinci and DA8xx/OMAP-L1x -- on which the DaVinci glue layer won't work. Change the Makefile dependency to CONFIG_ARCH_DAVINCI_DMx which corresponds to "real" DaVinci.

---
 drivers/usb/musb/Kconfig  |    2 +-
 drivers/usb/musb/Makefile |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/Kconfig +1 -1
index b4c783c..07fe490 100644
@@ -42,7 +42,7 @@ config USB_MUSB_SOC
 	default y if (BF52x && !BF522 && !BF523)
 
 comment "DaVinci 35x and 644x USB support"
-	depends on USB_MUSB_HDRC && ARCH_DAVINCI
+	depends on USB_MUSB_HDRC && ARCH_DAVINCI_DMx
 
 comment "OMAP 243x high speed USB support"
 	depends on USB_MUSB_HDRC && ARCH_OMAP2430
drivers/usb/musb/Makefile +1 -1
index 85710cc..3a485da 100644
@@ -6,7 +6,7 @@ musb_hdrc-objs := musb_core.o
 
 obj-$(CONFIG_USB_MUSB_HDRC)	+= musb_hdrc.o
 
-ifeq ($(CONFIG_ARCH_DAVINCI),y)
+ifeq ($(CONFIG_ARCH_DAVINCI_DMx),y)
 	musb_hdrc-objs	+= davinci.o
 endif
 
Signature · 6 lines
1.7.0.rc0.33.g7c3932

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH 4/11 musb: save and restore missing bus control register

In reply to a message not in the archive

From: Ajay Kumar Gupta <[email protected]>

Added the missing BUS_CONTROL register in musb
save/restore routines.

---
 drivers/usb/musb/musb_core.c |    2 ++
 drivers/usb/musb/musb_core.h |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/usb/musb/musb_core.c +2 -0
index 0e8b8ab..3342b82 100644
@@ -2176,6 +2176,7 @@ void musb_save_context(struct musb *musb)
 	if (is_host_enabled(musb)) {
 		musb_context.frame = musb_readw(musb_base, MUSB_FRAME);
 		musb_context.testmode = musb_readb(musb_base, MUSB_TESTMODE);
+		musb_context.busctl = musb_read_ulpi_buscontrol(musb->mregs);
 	}
 	musb_context.power = musb_readb(musb_base, MUSB_POWER);
 	musb_context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE);
@@ -2247,6 +2248,7 @@ void musb_restore_context(struct musb *musb)
 	if (is_host_enabled(musb)) {
 		musb_writew(musb_base, MUSB_FRAME, musb_context.frame);
 		musb_writeb(musb_base, MUSB_TESTMODE, musb_context.testmode);
+		musb_write_ulpi_buscontrol(musb->mregs, musb_context.busctl);
 	}
 	musb_writeb(musb_base, MUSB_POWER, musb_context.power);
 	musb_writew(musb_base, MUSB_INTRTXE, musb_context.intrtxe);
drivers/usb/musb/musb_core.h +1 -1
index cd9f4a9..ac17b00 100644
@@ -478,7 +478,7 @@ struct musb_context_registers {
 	u16 frame;
 	u8 index, testmode;
 
-	u8 devctl, misc;
+	u8 devctl, busctl, misc;
 
 	struct musb_csr_regs index_regs[MUSB_C_NUM_EPS];
 };
Signature · 6 lines
1.7.0.rc0.33.g7c3932

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

PATCH 7/11 musb_core: don't prevent disabling clock on driver unload

In reply to a message not in the archive

From: Sergei Shtylyov <[email protected]>

Resetting 'musb->clock' to NULL in musb_shutdown() prevents musb_platform_exit() from properly disabling the clock when unloading the driver -- don't do it.

---
 drivers/usb/musb/musb_core.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/usb/musb/musb_core.c +1 -3
index 03544de..8b68f21 100644
@@ -965,10 +965,8 @@ static void musb_shutdown(struct platform_device *pdev)
 	spin_lock_irqsave(&musb->lock, flags);
 	musb_platform_disable(musb);
 	musb_generic_disable(musb);
-	if (musb->clock) {
+	if (musb->clock)
 		clk_put(musb->clock);
-		musb->clock = NULL;
-	}
 	spin_unlock_irqrestore(&musb->lock, flags);
 
 	/* FIXME power down */
Signature · 6 lines
1.7.0.rc0.33.g7c3932

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

PATCH 10/11 musb_core: don't call musb_platform_exit() twice

In reply to a message not in the archive

From: Sergei Shtylyov <[email protected]>

musb_platform_exit() is called twice from musb_init_controller() iff controller initialization fails. Move the call (and the DevCtl register writes surrounding it) from musb_free() to musb_remove().

Fix mispalced and now incorrect 'goto's in musb_init_controller().

---
 drivers/usb/musb/musb_core.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
drivers/usb/musb/musb_core.c +3 -9
index 8b68f21..508fd58 100644
@@ -1851,10 +1851,6 @@ static void musb_free(struct musb *musb)
 	put_device(musb->xceiv->dev);
 #endif
 
-	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
-	musb_platform_exit(musb);
-	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
-
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
 	usb_put_hcd(musb_to_hcd(musb));
 #else
@@ -2032,8 +2028,6 @@ bad_config:
 		musb->xceiv->state = OTG_STATE_A_IDLE;
 
 		status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
-		if (status)
-			goto fail;
 
 		DBG(1, "%s mode, status %d, devctl %02x %c\n",
 			"HOST", status,
@@ -2048,8 +2042,6 @@ bad_config:
 		musb->xceiv->state = OTG_STATE_B_IDLE;
 
 		status = musb_gadget_setup(musb);
-		if (status)
-			goto fail;
 
 		DBG(1, "%s mode, status %d, dev%02x\n",
 			is_otg_enabled(musb) ? "OTG" : "PERIPHERAL",
@@ -2057,12 +2049,14 @@ bad_config:
 			musb_readb(musb->mregs, MUSB_DEVCTL));
 
 	}
+	if (status < 0)
+		goto fail2;
 
 #ifdef CONFIG_SYSFS
 	status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group);
-#endif
 	if (status)
 		goto fail2;
+#endif
 
 	dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
 			({char *s;
@@ -2125,7 +2119,6 @@ static int __init musb_probe(struct platform_device *pdev)
 	/* clobbered by use_dma=n */
 	orig_dma_mask = dev->dma_mask;
 #endif
#7 lore raw

RE: [patch-2.6.34-rc2+ 10/11] musb_core: don't call musb_platform_exit() twice

Quoted 11 lines · Felipe Balbi

From: Sergei Shtylyov <[email protected]>

musb_platform_exit() is called twice from musb_init_controller() iff controller initialization fails. Move the call (and the DevCtl register writes surrounding it) from musb_free() to musb_remove().

Fix mispalced and now incorrect 'goto's in musb_init_controller().

This one doesn't apply for me. I'm on commit 01e7770 plus gregkh-07-usb-2.6.34-rc1.patch. The first 9 patches apply correctly, but this one fails on hunk 4 of 6.

Felipe - are we on the same base here?

Looking at gregkh-07-usb-2.6.34-rc1.patch, this hunk is already taken care of there.

- Anand

Quoted 81 lines
---
 drivers/usb/musb/musb_core.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
drivers/usb/musb/musb_core.c +7 -10
index 8b68f21..508fd58 100644
@@ -1851,10 +1851,6 @@ static void musb_free(struct musb *musb)
 	put_device(musb->xceiv->dev);
 #endif
 
-	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
-	musb_platform_exit(musb);
-	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
-
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
 	usb_put_hcd(musb_to_hcd(musb));
 #else
@@ -2032,8 +2028,6 @@ bad_config:
 		musb->xceiv->state = OTG_STATE_A_IDLE;
 
 		status = usb_add_hcd(musb_to_hcd(musb), -1, 0);
-		if (status)
-			goto fail;
 
 		DBG(1, "%s mode, status %d, devctl %02x %c\n",
 			"HOST", status,
@@ -2048,8 +2042,6 @@ bad_config:
 		musb->xceiv->state = OTG_STATE_B_IDLE;
 
 		status = musb_gadget_setup(musb);
-		if (status)
-			goto fail;
 
 		DBG(1, "%s mode, status %d, dev%02x\n",
 			is_otg_enabled(musb) ? "OTG" : "PERIPHERAL",
@@ -2057,12 +2049,14 @@ bad_config:
 			musb_readb(musb->mregs, MUSB_DEVCTL));
 
 	}
+	if (status < 0)
+		goto fail2;
 
 #ifdef CONFIG_SYSFS
 	status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group);
-#endif
 	if (status)
 		goto fail2;
+#endif
 
 	dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
 			({char *s;
@@ -2125,7 +2119,6 @@ static int __init musb_probe(struct platform_device *pdev)
 	/* clobbered by use_dma=n */
 	orig_dma_mask = dev->dma_mask;
 #endif
-
 	status = musb_init_controller(dev, irq, base);
 	if (status < 0)
 		iounmap(base);
@@ -2148,6 +2141,10 @@ static int __exit musb_remove(struct platform_device *pdev)
 	if (musb->board_mode == MUSB_HOST)
 		usb_remove_hcd(musb_to_hcd(musb));
 #endif
+	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+	musb_platform_exit(musb);
+	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+
 	musb_free(musb);
 	iounmap(ctrl_base);
 	device_init_wakeup(&pdev->dev, 0);
Signature · 7 lines
1.7.0.rc0.33.g7c3932

--
To unsubscribe from this list: send the line "unsubscribe 
linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#8 lore raw

Re: [patch-2.6.34-rc2+ 10/11] musb_core: don't call musb_platform_exit() twice

Quoted 13 lines · Anand
Quoted 11 lines · Felipe Balbi

From: Sergei Shtylyov <[email protected]>

musb_platform_exit() is called twice from musb_init_controller() iff controller initialization fails. Move the call (and the DevCtl register writes surrounding it) from musb_free() to musb_remove().

Fix mispalced and now incorrect 'goto's in musb_init_controller().

Quoted 8 lines

This one doesn't apply for me. I'm on commit 01e7770 plus gregkh-07-usb-2.6.34-rc1.patch. The first 9 patches apply correctly, but this one fails on hunk 4 of 6.

Felipe - are we on the same base here?

Looking at gregkh-07-usb-2.6.34-rc1.patch, this hunk is already taken care of there.

I'm on today's Linus' tree. Greg's queue doesn't apply there. I tried v2.6.33, v2.6.34-rc1 and v2.6.34-rc2 tags also and couldn't get all patches to apply.

Signature · 1 line
balbi
#9 lore raw

RE: [patch-2.6.34-rc2+ 10/11] musb_core: don't call musb_platform_exit() twice

Quoted 18 lines · Felipe Balbi
Quoted 17 lines · Anand
Quoted 11 lines · Felipe Balbi

From: Sergei Shtylyov <[email protected]>

musb_platform_exit() is called twice from musb_init_controller() iff controller initialization fails. Move the call (and the DevCtl register writes surrounding it) from musb_free() to musb_remove().

Fix mispalced and now incorrect 'goto's in musb_init_controller().

This one doesn't apply for me. I'm on commit 01e7770 plus gregkh-07-usb-2.6.34-rc1.patch. The first 9 patches apply correctly, but this one fails on hunk 4 of 6.

Quoted 8 lines
Quoted 4 lines

Felipe - are we on the same base here?

Looking at gregkh-07-usb-2.6.34-rc1.patch, this hunk is already taken care of there.

I'm on today's Linus' tree. Greg's queue doesn't apply there. I tried v2.6.33, v2.6.34-rc1 and v2.6.34-rc2 tags also and couldn't get all patches to apply.

This is probably a bad idea because Greg's queue currently has patches that touch the same files. That's a sure way to cause a conflict.

Also, Greg's queue cleanly applies on current Linus' tree for me. Not sure why you're having trouble applying his queue.

- Anand

#10 lore raw

Re: [patch-2.6.34-rc2+ 10/11] musb_core: don't call musb_platform_exit() twice

Quoted 5 lines · Anand

This is probably a bad idea because Greg's queue currently has patches that touch the same files. That's a sure way to cause a conflict.

Also, Greg's queue cleanly applies on current Linus' tree for me. Not sure why you're having trouble applying his queue.

Maybe i need to manually quilt push, git quiltimport fails always.

Signature · 1 line
balbi
#11 lore raw

PATCH 11/11 musb_core: fix musb_init_controller() error cleanup path

In reply to a message not in the archive

From: Sergei Shtylyov <[email protected]>

This function forgets to call usb_remove_hcd() or musb_gadget_cleanup() iff sysfs_create_group() fails.

[ [email protected] : review the entire error path
not only when we fail hcd or gadget ]

---
 drivers/usb/musb/musb_core.c |   51 ++++++++++++++++++++++++++++--------------
 1 files changed, 34 insertions(+), 17 deletions(-)
drivers/usb/musb/musb_core.c +34 -17
index 508fd58..705cc4a 100644
@@ -1878,8 +1878,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
 	 */
 	if (!plat) {
 		dev_dbg(dev, "no platform_data?\n");
-		return -ENODEV;
+		status = -ENODEV;
+		goto fail0;
 	}
+
 	switch (plat->mode) {
 	case MUSB_HOST:
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
@@ -1901,13 +1903,16 @@ bad_config:
 #endif
 	default:
 		dev_err(dev, "incompatible Kconfig role setting\n");
-		return -EINVAL;
+		status = -EINVAL;
+		goto fail0;
 	}
 
 	/* allocate */
 	musb = allocate_instance(dev, plat->config, ctrl);
-	if (!musb)
-		return -ENOMEM;
+	if (!musb) {
+		status = -ENOMEM;
+		goto fail0;
+	}
 
 	spin_lock_init(&musb->lock);
 	musb->board_mode = plat->mode;
@@ -1925,7 +1930,7 @@ bad_config:
 		if (IS_ERR(musb->clock)) {
 			status = PTR_ERR(musb->clock);
 			musb->clock = NULL;
-			goto fail;
+			goto fail1;
 		}
 	}
 
@@ -1944,12 +1949,12 @@ bad_config:
 	 */
 	musb->isr = generic_interrupt;
 	status = musb_platform_init(musb);
-
 	if (status < 0)
-		goto fail;
+		goto fail2;
+
 	if (!musb->isr) {
 		status = -ENODEV;
-		goto fail2;
+		goto fail3;
 	}
 
 #ifndef CONFIG_MUSB_PIO_ONLY
@@ -1975,7 +1980,7 @@ bad_config:
 			? MUSB_CONTROLLER_MHDRC
 			: MUSB_CONTROLLER_HDRC, musb);
 	if (status < 0)
-		goto fail2;
+		goto fail3;
 
 #ifdef CONFIG_USB_MUSB_OTG
 	setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
@@ -1988,7 +1993,7 @@ bad_config:
 	if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
 		dev_err(dev, "request_irq %d failed!\n", nIrq);
 		status = -ENODEV;
-		goto fail2;
+		goto fail3;
 	}
 	musb->nIrq = nIrq;
 /* FIXME this handles wakeup irqs wrong */
@@ -2050,12 +2055,12 @@ bad_config:
 
 	}
 	if (status < 0)
-		goto fail2;
+		goto fail3;
 
 #ifdef CONFIG_SYSFS
 	status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group);
 	if (status)
-		goto fail2;
+		goto fail4;
 #endif
 
 	dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
@@ -2072,17 +2077,29 @@ bad_config:
 
 	return 0;
 
-fail2:
+fail4:
+	if (!is_otg_enabled(musb) && is_host_enabled(musb))
+		usb_remove_hcd(musb_to_hcd(musb));
+	else
+		musb_gadget_cleanup(musb);
+
+fail3:
+	if (musb->irq_wake)
+		device_init_wakeup(dev, 0);
 	musb_platform_exit(musb);
-fail:
-	dev_err(musb->controller,
-		"musb_init_controller failed with status %d\n", status);
 
+fail2:
 	if (musb->clock)
 		clk_put(musb->clock);
-	device_init_wakeup(dev, 0);
+
+fail1:
+	dev_err(musb->controller,
+		"musb_init_controller failed with status %d\n", status);
+
 	musb_free(musb);
 
+fail0:
+
 	return status;
 
 }
Signature · 6 lines
1.7.0.rc0.33.g7c3932

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#13 lore raw

PATCH 1/1 usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))

Quoted 7 lines · Greg KH
Quoted 4 lines · Felipe Balbi

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

All queued up, thanks

This compile fix still needs to be queued too. Can also merge via omap tree if you guys ack.

Tony

Quoted 1 line

From 70bc10c9cbfd245b43234f2504eae21ce6b3d73f Mon Sep 17 00:00:00 2001

From: Tony Lindgren <[email protected]>
Date: Wed, 31 Mar 2010 05:02:07 -0700
Subject: [PATCH] usb: Fix tusb6010 for DMA API

Commit 18eabe2347ae7a11b3db768695913724166dfb0e introduced DMA buffer ownership. Fix tusb6010 accordingly.

Also change the order of musb_read_fifo() to happen after dma_cache_maint to have the DMA operations completed before moving the remaining unaligned bytes with PIO. The DMA access and PIO touch different areas of the FIFO, so this change only makes the code a bit easier to follow.

Tested on n810 and g_ether with variable size ping test. The test seems to fail for some ping sizes, but that seems to be a different problem.

drivers/usb/musb/tusb6010.c +13 -0
index ab776a8..60d3938 100644
@@ -29,6 +29,19 @@ static void tusb_source_power(struct musb *musb, int is_on);
 #define TUSB_REV_MAJOR(reg_val)		((reg_val >> 4) & 0xf)
 #define TUSB_REV_MINOR(reg_val)		(reg_val & 0xf)
 
+#ifdef CONFIG_PM
+/* REVISIT: These should be only needed if somebody implements off idle */
+void musb_platform_save_context(struct musb *musb,
+			struct musb_context_registers *musb_context)
+{
+}
+
+void musb_platform_restore_context(struct musb *musb,
+			struct musb_context_registers *musb_context)
+{
+}
+#endif
+
 /*
  * Checks the revision. We need to use the DMA register as 3.0 does not
  * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV.
drivers/usb/musb/tusb6010_omap.c +14 -8
index 1c86809..6f0e943 100644
@@ -38,7 +38,7 @@ struct tusb_omap_dma_ch {
 
 	struct tusb_omap_dma	*tusb_dma;
 
-	void __iomem		*dma_addr;
+	dma_addr_t		dma_addr;
 
 	u32			len;
 	u16			packet_sz;
@@ -125,6 +125,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 	struct tusb_omap_dma_ch	*chdat = to_chdat(channel);
 	struct tusb_omap_dma	*tusb_dma = chdat->tusb_dma;
 	struct musb		*musb = chdat->musb;
+	struct device		*dev = musb->controller;
 	struct musb_hw_ep	*hw_ep = chdat->hw_ep;
 	void __iomem		*ep_conf = hw_ep->conf;
 	void __iomem		*mbase = musb->mregs;
@@ -172,13 +173,15 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 		DBG(3, "Using PIO for remaining %lu bytes\n", pio);
 		buf = phys_to_virt((u32)chdat->dma_addr) + chdat->transfer_len;
 		if (chdat->tx) {
-			dma_cache_maint(phys_to_virt((u32)chdat->dma_addr),
-					chdat->transfer_len, DMA_TO_DEVICE);
+			dma_unmap_single(dev, chdat->dma_addr,
+						chdat->transfer_len,
+						DMA_TO_DEVICE);
 			musb_write_fifo(hw_ep, pio, buf);
 		} else {
+			dma_unmap_single(dev, chdat->dma_addr,
+						chdat->transfer_len,
+						DMA_FROM_DEVICE);
 			musb_read_fifo(hw_ep, pio, buf);
-			dma_cache_maint(phys_to_virt((u32)chdat->dma_addr),
-					chdat->transfer_len, DMA_FROM_DEVICE);
 		}
 		channel->actual_len += pio;
 	}
@@ -223,6 +226,7 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	struct tusb_omap_dma_ch		*chdat = to_chdat(channel);
 	struct tusb_omap_dma		*tusb_dma = chdat->tusb_dma;
 	struct musb			*musb = chdat->musb;
+	struct device			*dev = musb->controller;
 	struct musb_hw_ep		*hw_ep = chdat->hw_ep;
 	void __iomem			*mbase = musb->mregs;
 	void __iomem			*ep_conf = hw_ep->conf;
@@ -298,14 +302,16 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	chdat->packet_sz = packet_sz;
 	chdat->len = len;
 	channel->actual_len = 0;
-	chdat->dma_addr = (void __iomem *)dma_addr;
+	chdat->dma_addr = dma_addr;
 	channel->status = MUSB_DMA_STATUS_BUSY;
 
 	/* Since we're recycling dma areas, we need to clean or invalidate */
 	if (chdat->tx)
-		dma_cache_maint(phys_to_virt(dma_addr), len, DMA_TO_DEVICE);
+		dma_map_single(dev, phys_to_virt(dma_addr), len,
+				DMA_TO_DEVICE);
 	else
-		dma_cache_maint(phys_to_virt(dma_addr), len, DMA_FROM_DEVICE);
+		dma_map_single(dev, phys_to_virt(dma_addr), len,
+				DMA_FROM_DEVICE);
 
 	/* Use 16-bit transfer if dma_addr is not 32-bit aligned */
 	if ((dma_addr & 0x3) == 0) {

A message that is not in the archive (sent off-list or not yet received): [email protected]

#15 lore raw

Re: [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))

Quoted 11 lines · Tony Lindgren
Quoted 7 lines · Greg KH
Quoted 4 lines · Felipe Balbi

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

All queued up, thanks

This compile fix still needs to be queued too. Can also merge via omap tree if you guys ack.

That's up to Felipe. I have no objection to it, it's his call.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by
#16 lore raw

Re: [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))

Quoted 8 lines · Greg KH
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Greg KH
Quoted 4 lines · Felipe Balbi

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

All queued up, thanks

This compile fix still needs to be queued too. Can also merge via omap tree if you guys ack.

That's up to Felipe. I have no objection to it, it's his call.

please Greg take it. I seem to have missed from my queue.

fwiw:

Signature · 1 line
balbi
Acked-by Felipe Balbi
#17 lore raw

Re: [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))

Quoted 14 lines · Felipe Balbi
Quoted 13 lines · Greg KH
Quoted 11 lines · Tony Lindgren
Quoted 7 lines · Greg KH
Quoted 4 lines · Felipe Balbi

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

All queued up, thanks

This compile fix still needs to be queued too. Can also merge via omap tree if you guys ack.

Quoted 7 lines
Quoted 1 line

That's up to Felipe. I have no objection to it, it's his call.

please Greg take it. I seem to have missed from my queue.

fwiw:

Greg, here's the patch for you one more time with updated comments as suggested by Anand regarding the dummy musb_platform_save and restore functions. Also added Felipe's Ack there.

Regards,

Tony

Quoted 1 line

From 0eb7eef01c52f25a7d22c9612ccbd89368941b95 Mon Sep 17 00:00:00 2001

From: Tony Lindgren <[email protected]>
Date: Fri, 23 Apr 2010 17:41:15 -0700
Subject: [PATCH] usb: Fix tusb6010 for DMA API

Commit 18eabe2347ae7a11b3db768695913724166dfb0e introduced DMA buffer ownership. Fix tusb6010 accordingly. To compile, also dummy musb_platform_save and restore functions need to be added.

Also change the order of musb_read_fifo() to happen after dma_cache_maint to have the DMA operations completed before moving the remaining unaligned bytes with PIO. The DMA access and PIO touch different areas of the FIFO, so this change only makes the code a bit easier to follow.

Tested on n810 and g_ether with variable size ping test. The test seems to fail for some ping sizes, but that seems to be a different problem.

drivers/usb/musb/tusb6010.c +13 -0
index ab776a8..60d3938 100644
@@ -29,6 +29,19 @@ static void tusb_source_power(struct musb *musb, int is_on);
 #define TUSB_REV_MAJOR(reg_val)		((reg_val >> 4) & 0xf)
 #define TUSB_REV_MINOR(reg_val)		(reg_val & 0xf)
 
+#ifdef CONFIG_PM
+/* REVISIT: These should be only needed if somebody implements off idle */
+void musb_platform_save_context(struct musb *musb,
+			struct musb_context_registers *musb_context)
+{
+}
+
+void musb_platform_restore_context(struct musb *musb,
+			struct musb_context_registers *musb_context)
+{
+}
+#endif
+
 /*
  * Checks the revision. We need to use the DMA register as 3.0 does not
  * have correct versions for TUSB_PRCM_REV or TUSB_INT_CTRL_REV.
drivers/usb/musb/tusb6010_omap.c +14 -8
index 5afa070..c061a88 100644
@@ -39,7 +39,7 @@ struct tusb_omap_dma_ch {
 
 	struct tusb_omap_dma	*tusb_dma;
 
-	void __iomem		*dma_addr;
+	dma_addr_t		dma_addr;
 
 	u32			len;
 	u16			packet_sz;
@@ -126,6 +126,7 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 	struct tusb_omap_dma_ch	*chdat = to_chdat(channel);
 	struct tusb_omap_dma	*tusb_dma = chdat->tusb_dma;
 	struct musb		*musb = chdat->musb;
+	struct device		*dev = musb->controller;
 	struct musb_hw_ep	*hw_ep = chdat->hw_ep;
 	void __iomem		*ep_conf = hw_ep->conf;
 	void __iomem		*mbase = musb->mregs;
@@ -173,13 +174,15 @@ static void tusb_omap_dma_cb(int lch, u16 ch_status, void *data)
 		DBG(3, "Using PIO for remaining %lu bytes\n", pio);
 		buf = phys_to_virt((u32)chdat->dma_addr) + chdat->transfer_len;
 		if (chdat->tx) {
-			dma_cache_maint(phys_to_virt((u32)chdat->dma_addr),
-					chdat->transfer_len, DMA_TO_DEVICE);
+			dma_unmap_single(dev, chdat->dma_addr,
+						chdat->transfer_len,
+						DMA_TO_DEVICE);
 			musb_write_fifo(hw_ep, pio, buf);
 		} else {
+			dma_unmap_single(dev, chdat->dma_addr,
+						chdat->transfer_len,
+						DMA_FROM_DEVICE);
 			musb_read_fifo(hw_ep, pio, buf);
-			dma_cache_maint(phys_to_virt((u32)chdat->dma_addr),
-					chdat->transfer_len, DMA_FROM_DEVICE);
 		}
 		channel->actual_len += pio;
 	}
@@ -224,6 +227,7 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	struct tusb_omap_dma_ch		*chdat = to_chdat(channel);
 	struct tusb_omap_dma		*tusb_dma = chdat->tusb_dma;
 	struct musb			*musb = chdat->musb;
+	struct device			*dev = musb->controller;
 	struct musb_hw_ep		*hw_ep = chdat->hw_ep;
 	void __iomem			*mbase = musb->mregs;
 	void __iomem			*ep_conf = hw_ep->conf;
@@ -299,14 +303,16 @@ static int tusb_omap_dma_program(struct dma_channel *channel, u16 packet_sz,
 	chdat->packet_sz = packet_sz;
 	chdat->len = len;
 	channel->actual_len = 0;
-	chdat->dma_addr = (void __iomem *)dma_addr;
+	chdat->dma_addr = dma_addr;
 	channel->status = MUSB_DMA_STATUS_BUSY;
 
 	/* Since we're recycling dma areas, we need to clean or invalidate */
 	if (chdat->tx)
-		dma_cache_maint(phys_to_virt(dma_addr), len, DMA_TO_DEVICE);
+		dma_map_single(dev, phys_to_virt(dma_addr), len,
+				DMA_TO_DEVICE);
 	else
-		dma_cache_maint(phys_to_virt(dma_addr), len, DMA_FROM_DEVICE);
+		dma_map_single(dev, phys_to_virt(dma_addr), len,
+				DMA_FROM_DEVICE);
 
 	/* Use 16-bit transfer if dma_addr is not 32-bit aligned */
 	if ((dma_addr & 0x3) == 0) {

A message that is not in the archive (sent off-list or not yet received): [email protected]

#19 lore raw

Re: [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))

Quoted 19 lines · Tony Lindgren
Quoted 18 lines · Felipe Balbi
Quoted 8 lines · Greg KH
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Greg KH
Quoted 4 lines · Felipe Balbi

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

All queued up, thanks

This compile fix still needs to be queued too. Can also merge via omap tree if you guys ack.

That's up to Felipe. I have no objection to it, it's his call.

please Greg take it. I seem to have missed from my queue.

Quoted 7 lines
Quoted 3 lines

fwiw:

Greg, here's the patch for you one more time with updated comments as suggested by Anand regarding the dummy musb_platform_save and restore functions. Also added Felipe's Ack there.

Now queued up.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#21 lore raw

Re: [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))

Quoted 22 lines · Greg KH
Quoted 21 lines · Tony Lindgren
Quoted 20 lines · Felipe Balbi
Quoted 8 lines · Greg KH
Quoted 7 lines · Tony Lindgren
Quoted 6 lines · Greg KH
Quoted 4 lines · Felipe Balbi

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

All queued up, thanks

This compile fix still needs to be queued too. Can also merge via omap tree if you guys ack.

That's up to Felipe. I have no objection to it, it's his call.

please Greg take it. I seem to have missed from my queue.

fwiw:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Greg, here's the patch for you one more time with updated comments as suggested by Anand regarding the dummy musb_platform_save and restore functions. Also added Felipe's Ack there.

Now queued up.

OK, thanks!

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#22 lore raw

RE: [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))

In reply to Tony Lindgren
Quoted 11 lines · Tony Lindgren
Quoted 7 lines · Greg KH
Quoted 4 lines · Felipe Balbi

Hi Greg,

sorry for the last time. There was a bug in my script which caused it to rebased against the wrong branch.

All queued up, thanks

This compile fix still needs to be queued too. Can also merge via omap tree if you guys ack.

Probably a good idea to mention in the changelog that you are also musb_platform_{save,restore}_context for TUSB.

Other than that, looks good.

- Anand

#23 lore raw

PATCH 3/11 MUSB: Blackfin: don't fake blackfin_interrupt() result

In reply to Felipe Balbi

From: Sergei Shtylyov <[email protected]>

Commit a5073b52833e4df8e16c93dc4cbb7e0c558c74a2 (musb_gadget: fix unhandled endpoint 0 IRQs) misses this change to blackfin.c: stop faking successful result of blackfin_interrupt() and emitting a debug message on an unhandled interrupt.

---
 drivers/usb/musb/blackfin.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)
drivers/usb/musb/blackfin.c +1 -7
index bcee133..4688870 100644
@@ -173,13 +173,7 @@ static irqreturn_t blackfin_interrupt(int irq, void *__hci)
 
 	spin_unlock_irqrestore(&musb->lock, flags);
 
-	/* REVISIT we sometimes get spurious IRQs on g_ep0
-	 * not clear why... fall in BF54x too.
-	 */
-	if (retval != IRQ_HANDLED)
-		DBG(5, "spurious?\n");
-
-	return IRQ_HANDLED;
+	return retval;
 }
 
 static void musb_conn_timer_handler(unsigned long _musb)
Signature · 1 line
1.7.0.rc0.33.g7c3932
#24 lore raw

PATCH 5/11 musb: potential use after free

In reply to Felipe Balbi

From: Dan Carpenter <[email protected]>

We assign "urb->hcpriv = qh;" a few lines down. I'm pretty sure we want it "urb->hcpriv" to be NULL not a freed value.

---
 drivers/usb/musb/musb_host.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/usb/musb/musb_host.c +1 -0
index dec896e..877d20b 100644
@@ -2042,6 +2042,7 @@ static int musb_urb_enqueue(
 		 * odd, rare, error prone, but legal.
 		 */
 		kfree(qh);
+		qh = NULL;
 		ret = 0;
 	} else
 		ret = musb_schedule(musb, qh,
Signature · 1 line
1.7.0.rc0.33.g7c3932
#25 lore raw

PATCH 6/11 musb_core: don't touch 'musb->clock' in musb_free()

In reply to Felipe Balbi

From: Sergei Shtylyov <[email protected]>

Remove duplicate/unbalanced calls to clk_disable()/clk_put() in musb_free():

- clk_disable() is called by musb_platform_exit() just prior to this call;
- clk_put() is called by the callers of musb_free() prior to calling it...

---
 drivers/usb/musb/musb_core.c |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
drivers/usb/musb/musb_core.c +0 -5
index 3342b82..03544de 100644
@@ -1857,11 +1857,6 @@ static void musb_free(struct musb *musb)
 	musb_platform_exit(musb);
 	musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
 
-	if (musb->clock) {
-		clk_disable(musb->clock);
-		clk_put(musb->clock);
-	}
-
 #ifdef CONFIG_USB_MUSB_HDRC_HCD
 	usb_put_hcd(musb_to_hcd(musb));
 #else
Signature · 1 line
1.7.0.rc0.33.g7c3932
#26 lore raw

PATCH 8/11 MUSB: DaVinci: fix musb_platform_init() error cleanup path

In reply to Felipe Balbi

From: Sergei Shtylyov <[email protected]>

This function forgets to call clk_disable() iff reading the USB module version register returns 0.

---
 drivers/usb/musb/davinci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/usb/musb/davinci.c +2 -0
index a883f9d..4b0f5be 100644
@@ -445,6 +445,8 @@ int __init musb_platform_init(struct musb *musb)
 	return 0;
 
 fail:
+	clk_disable(musb->clock);
+
 	usb_nop_xceiv_unregister();
 	return -ENODEV;
 }
Signature · 1 line
1.7.0.rc0.33.g7c3932
#27 lore raw

PATCH 9/11 MUSB: OMAP: don't call clk_put()

In reply to Felipe Balbi

From: Sergei Shtylyov <[email protected]>

Remove duplicate/unbalanced call to clk_put() from musb_platform_exit() -- clk_put() gets called from musb_core.c anyway...

---
 drivers/usb/musb/omap2430.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/usb/musb/omap2430.c +0 -3
index 3fe1686..6e1eccb 100644
@@ -332,8 +332,5 @@ int musb_platform_exit(struct musb *musb)
 
 	musb_platform_suspend(musb);
 
-	clk_put(musb->clock);
-	musb->clock = NULL;
-
 	return 0;
 }
Signature · 1 line
1.7.0.rc0.33.g7c3932