All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: Felipe Balbi <me@felipebalbi.com>
Cc: Greg KH <greg@kroah.com>, Felipe Balbi <felipe.balbi@nokia.com>,
	Anand Gadiyar <gadiyar@ti.com>,
	Linux USB Mailing List <linux-usb@vger.kernel.org>,
	Linux OMAP Mailing List <linux-omap@vger.kernel.org>
Subject: Re: [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2))
Date: Mon, 26 Apr 2010 10:53:24 -0700	[thread overview]
Message-ID: <20100426175324.GE7225@atomide.com> (raw)
In-Reply-To: <20100425133531.GB2219@gandalf>

[-- Attachment #1: Type: text/plain, Size: 1004 bytes --]

* Felipe Balbi <me@felipebalbi.com> [100425 06:30]:
> On Fri, Apr 23, 2010 at 03:08:53PM -0700, Greg KH wrote:
> > On Fri, Apr 23, 2010 at 02:23:08PM -0700, Tony Lindgren wrote:
> > > * Greg KH <greg@kroah.com> [100423 14:05]:
> > > > On Thu, Mar 25, 2010 at 01:14:22PM +0200, Felipe Balbi wrote:
> > > > > 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.
> 
> please Greg take it. I seem to have missed from my queue.
> 
> fwiw:
> 
> Acked-by: Felipe Balbi <felipe.balbi@nokia.com>

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

[-- Attachment #2: tusb-dma.patch --]
[-- Type: text/x-diff, Size: 4403 bytes --]

>From 0eb7eef01c52f25a7d22c9612ccbd89368941b95 Mon Sep 17 00:00:00 2001
From: Tony Lindgren <tony@atomide.com>
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.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Felipe Balbi <felipe.balbi@nokia.com>

diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index ab776a8..60d3938 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -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.
diff --git a/drivers/usb/musb/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c
index 5afa070..c061a88 100644
--- a/drivers/usb/musb/tusb6010_omap.c
+++ b/drivers/usb/musb/tusb6010_omap.c
@@ -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) {

  reply	other threads:[~2010-04-26 17:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-25 11:14 [patch-2.6.34-rc2+ 00/11] musb patches (v2) Felipe Balbi
2010-03-25 11:14 ` [patch-2.6.34-rc2+ 03/11] MUSB: Blackfin: don't fake blackfin_interrupt() result Felipe Balbi
2010-03-25 11:14 ` [patch-2.6.34-rc2+ 05/11] musb: potential use after free Felipe Balbi
2010-03-25 11:14 ` [patch-2.6.34-rc2+ 06/11] musb_core: don't touch 'musb->clock' in musb_free() Felipe Balbi
     [not found] ` <1269515673-27980-1-git-send-email-felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-03-25 11:14   ` [patch-2.6.34-rc2+ 01/11] musb: fix power field to hold all possible values Felipe Balbi
2010-03-25 11:14   ` [patch-2.6.34-rc2+ 02/11] MUSB: fix DaVinci glue layer dependency Felipe Balbi
2010-03-25 11:14   ` [patch-2.6.34-rc2+ 04/11] musb: save and restore missing bus control register Felipe Balbi
2010-03-25 11:14   ` [patch-2.6.34-rc2+ 07/11] musb_core: don't prevent disabling clock on driver unload Felipe Balbi
2010-03-25 11:14   ` [patch-2.6.34-rc2+ 10/11] musb_core: don't call musb_platform_exit() twice Felipe Balbi
2010-03-25 12:34     ` Gadiyar, Anand
2010-03-25 13:05       ` Felipe Balbi
2010-03-29 12:42         ` Gadiyar, Anand
2010-03-29 13:59           ` Felipe Balbi
2010-03-25 11:14   ` [patch-2.6.34-rc2+ 11/11] musb_core: fix musb_init_controller() error cleanup path Felipe Balbi
2010-04-23 21:08   ` [patch-2.6.34-rc2+ 00/11] musb patches (v2) Greg KH
2010-04-23 21:23     ` [PATCH] usb: Fix tusb6010 for DMA API (Re: [patch-2.6.34-rc2+ 00/11] musb patches (v2)) Tony Lindgren
     [not found]       ` <20100423212307.GY18272-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2010-04-23 22:08         ` Greg KH
2010-04-25 13:35           ` Felipe Balbi
2010-04-26 17:53             ` Tony Lindgren [this message]
     [not found]               ` <20100426175324.GE7225-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2010-04-26 19:02                 ` Greg KH
     [not found]                   ` <20100426190246.GA8772-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
2010-04-26 19:10                     ` Tony Lindgren
2010-04-26  3:59       ` Gadiyar, Anand
2010-03-25 11:14 ` [patch-2.6.34-rc2+ 08/11] MUSB: DaVinci: fix musb_platform_init() error cleanup path Felipe Balbi
2010-03-25 11:14 ` [patch-2.6.34-rc2+ 09/11] MUSB: OMAP: don't call clk_put() Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100426175324.GE7225@atomide.com \
    --to=tony@atomide.com \
    --cc=felipe.balbi@nokia.com \
    --cc=gadiyar@ti.com \
    --cc=greg@kroah.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=me@felipebalbi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.