All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] PS3: Fix DMA scatter-gather
@ 2007-01-30 23:20 Geoff Levand
  2007-02-06 13:22 ` Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Geoff Levand @ 2007-01-30 23:20 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev

Add the missing pieces to support DMA scatter-gather on the PS3 system bus.

Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>

---

USB mass storage works properly now.

 arch/powerpc/platforms/ps3/system-bus.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

--- ps3-linux-dev.orig/arch/powerpc/platforms/ps3/system-bus.c
+++ ps3-linux-dev/arch/powerpc/platforms/ps3/system-bus.c
@@ -272,10 +272,29 @@ static void ps3_unmap_single(struct devi
 static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int nents,
 	enum dma_data_direction direction)
 {
+	struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
+	int i;
+
 #if defined(CONFIG_PS3_DYNAMIC_DMA)
 	BUG_ON("do");
+	return -EPERM;
+#else
+	for (i = 0; i < nents; i++, sg++) {
+		int result = ps3_dma_map(dev->d_region,
+			page_to_phys(sg->page) + sg->offset, sg->length,
+			&sg->dma_address);
+
+		if (result) {
+			pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
+				__func__, __LINE__, result);
+			return -EINVAL;
+		}
+
+		sg->dma_length = sg->length;
+	}
+
+	return nents;
 #endif
-	return 0;
 }
 
 static void ps3_unmap_sg(struct device *_dev, struct scatterlist *sg,
@@ -288,7 +307,7 @@ static void ps3_unmap_sg(struct device *
 
 static int ps3_dma_supported(struct device *_dev, u64 mask)
 {
-	return 1;
+	return mask >= DMA_32BIT_MASK;
 }
 
 static struct dma_mapping_ops ps3_dma_ops = {

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] PS3: Fix DMA scatter-gather
  2007-01-30 23:20 [PATCH 3/4] PS3: Fix DMA scatter-gather Geoff Levand
@ 2007-02-06 13:22 ` Arnd Bergmann
  2007-02-06 16:43   ` Geoff Levand
  2007-02-07  0:42 ` Benjamin Herrenschmidt
  2007-02-07  7:43 ` Arnd Bergmann
  2 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2007-02-06 13:22 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras

On Wednesday 31 January 2007 00:20, Geoff Levand wrote:
> @@ -272,10 +272,29 @@ static void ps3_unmap_single(struct devi
> =A0static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int=
 nents,
> =A0=A0=A0=A0=A0=A0=A0=A0enum dma_data_direction direction)
> =A0{
> +=A0=A0=A0=A0=A0=A0=A0struct ps3_system_bus_device *dev =3D to_ps3_system=
_bus_device(_dev);
> +=A0=A0=A0=A0=A0=A0=A0int i;
> +
> =A0#if defined(CONFIG_PS3_DYNAMIC_DMA)
> =A0=A0=A0=A0=A0=A0=A0=A0BUG_ON("do");
> +=A0=A0=A0=A0=A0=A0=A0return -EPERM;
> +#else

Do you still need the #ifdef? Since there is no point executing this,
would guess you can just as well keep only the other version, right?

	Arnd <><

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] PS3: Fix DMA scatter-gather
  2007-02-06 13:22 ` Arnd Bergmann
@ 2007-02-06 16:43   ` Geoff Levand
  0 siblings, 0 replies; 5+ messages in thread
From: Geoff Levand @ 2007-02-06 16:43 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev, Paul Mackerras

Arnd Bergmann wrote:
> On Wednesday 31 January 2007 00:20, Geoff Levand wrote:
>> @@ -272,10 +272,29 @@ static void ps3_unmap_single(struct devi
>> =EF=BF=BDstatic int ps3_map_sg(struct device *_dev, struct scatterlist=
 *sg, int nents,
>> =EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=
enum dma_data_direction direction)
>> =EF=BF=BD{
>> +=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BDstruct=
 ps3_system_bus_device *dev =3D to_ps3_system_bus_device(_dev);
>> +=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BDint i;
>> +
>> =EF=BF=BD#if defined(CONFIG_PS3_DYNAMIC_DMA)
>> =EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=
BUG_ON("do");
>> +=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BDreturn=
 -EPERM;
>> +#else
>=20
> Do you still need the #ifdef? Since there is no point executing this,
> would guess you can just as well keep only the other version, right?

I wanted to keep it there in the event someone tries to use a usb device
that needs scatter-gather with CONFIG_PS3_DYNAMIC_DMA=3Dy.  Currently,
CONFIG_PS3_DYNAMIC_DMA=3Dy only supports alloc_coherent and map_single.

I plan to rework the entire CONFIG_PS3_DYNAMIC_DMA to use Ben's fixes for
iommu support, but until then, I think it would be safer to keep this.

-Geoff

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] PS3: Fix DMA scatter-gather
  2007-01-30 23:20 [PATCH 3/4] PS3: Fix DMA scatter-gather Geoff Levand
  2007-02-06 13:22 ` Arnd Bergmann
@ 2007-02-07  0:42 ` Benjamin Herrenschmidt
  2007-02-07  7:43 ` Arnd Bergmann
  2 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-07  0:42 UTC (permalink / raw)
  To: Geoff Levand; +Cc: linuxppc-dev, Paul Mackerras

On Tue, 2007-01-30 at 15:20 -0800, Geoff Levand wrote:
> Add the missing pieces to support DMA scatter-gather on the PS3 system bus.
> 
> Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

I'll help with the dynamic DMA stuff as soon as I find a minute free..

Ben.

> 
> ---
> 
> USB mass storage works properly now.
> 
>  arch/powerpc/platforms/ps3/system-bus.c |   23 +++++++++++++++++++++--
>  1 files changed, 21 insertions(+), 2 deletions(-)
> 
> --- ps3-linux-dev.orig/arch/powerpc/platforms/ps3/system-bus.c
> +++ ps3-linux-dev/arch/powerpc/platforms/ps3/system-bus.c
> @@ -272,10 +272,29 @@ static void ps3_unmap_single(struct devi
>  static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int nents,
>  	enum dma_data_direction direction)
>  {
> +	struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev);
> +	int i;
> +
>  #if defined(CONFIG_PS3_DYNAMIC_DMA)
>  	BUG_ON("do");
> +	return -EPERM;
> +#else
> +	for (i = 0; i < nents; i++, sg++) {
> +		int result = ps3_dma_map(dev->d_region,
> +			page_to_phys(sg->page) + sg->offset, sg->length,
> +			&sg->dma_address);
> +
> +		if (result) {
> +			pr_debug("%s:%d: ps3_dma_map failed (%d)\n",
> +				__func__, __LINE__, result);
> +			return -EINVAL;
> +		}
> +
> +		sg->dma_length = sg->length;
> +	}
> +
> +	return nents;
>  #endif
> -	return 0;
>  }
>  
>  static void ps3_unmap_sg(struct device *_dev, struct scatterlist *sg,
> @@ -288,7 +307,7 @@ static void ps3_unmap_sg(struct device *
>  
>  static int ps3_dma_supported(struct device *_dev, u64 mask)
>  {
> -	return 1;
> +	return mask >= DMA_32BIT_MASK;
>  }
>  
>  static struct dma_mapping_ops ps3_dma_ops = {
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] PS3: Fix DMA scatter-gather
  2007-01-30 23:20 [PATCH 3/4] PS3: Fix DMA scatter-gather Geoff Levand
  2007-02-06 13:22 ` Arnd Bergmann
  2007-02-07  0:42 ` Benjamin Herrenschmidt
@ 2007-02-07  7:43 ` Arnd Bergmann
  2 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2007-02-07  7:43 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras

On Wednesday 31 January 2007 00:20, Geoff Levand wrote:
> Add the missing pieces to support DMA scatter-gather on the PS3 system bus.
> 
> Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
> 
Acked-by: Arnd Bergmann <arnd.bergmann@de.ibm.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-02-07  7:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-30 23:20 [PATCH 3/4] PS3: Fix DMA scatter-gather Geoff Levand
2007-02-06 13:22 ` Arnd Bergmann
2007-02-06 16:43   ` Geoff Levand
2007-02-07  0:42 ` Benjamin Herrenschmidt
2007-02-07  7:43 ` Arnd Bergmann

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.