Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-11 Thread tndave



On 10/11/2016 09:38 AM, Christoph Hellwig wrote:

Hi Tushar,

On Fri, Oct 07, 2016 at 01:09:15AM -0700, tndave wrote:

With change made by patch 6/6, dma_addr_t is always 64-bit, no matter if
device DMA mask is 32-bit (i.e. using existing IOMMU) or 64-bit (i.e
using ATU)


But only iff CONFIG_ARCH_ATU is set.  Anyway, I'll wait for your patches
to got in first and will then propose getting rid of
CONFIG_ARCH_DMA_ADDR_T_64BIT separately.

CONFIG_ARCH_ATU is by default set on 'SPARC64'. Therefore
CONFIG_ARCH_DMA_ADDR_T_64BIT is also always set as well on SPARC64.

-Tushar




Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-11 Thread tndave



On 10/11/2016 09:38 AM, Christoph Hellwig wrote:

Hi Tushar,

On Fri, Oct 07, 2016 at 01:09:15AM -0700, tndave wrote:

With change made by patch 6/6, dma_addr_t is always 64-bit, no matter if
device DMA mask is 32-bit (i.e. using existing IOMMU) or 64-bit (i.e
using ATU)


But only iff CONFIG_ARCH_ATU is set.  Anyway, I'll wait for your patches
to got in first and will then propose getting rid of
CONFIG_ARCH_DMA_ADDR_T_64BIT separately.

CONFIG_ARCH_ATU is by default set on 'SPARC64'. Therefore
CONFIG_ARCH_DMA_ADDR_T_64BIT is also always set as well on SPARC64.

-Tushar




Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-11 Thread Christoph Hellwig
Hi Tushar,

On Fri, Oct 07, 2016 at 01:09:15AM -0700, tndave wrote:
> With change made by patch 6/6, dma_addr_t is always 64-bit, no matter if
> device DMA mask is 32-bit (i.e. using existing IOMMU) or 64-bit (i.e
> using ATU)

But only iff CONFIG_ARCH_ATU is set.  Anyway, I'll wait for your patches
to got in first and will then propose getting rid of
CONFIG_ARCH_DMA_ADDR_T_64BIT separately.


Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-11 Thread Christoph Hellwig
Hi Tushar,

On Fri, Oct 07, 2016 at 01:09:15AM -0700, tndave wrote:
> With change made by patch 6/6, dma_addr_t is always 64-bit, no matter if
> device DMA mask is 32-bit (i.e. using existing IOMMU) or 64-bit (i.e
> using ATU)

But only iff CONFIG_ARCH_ATU is set.  Anyway, I'll wait for your patches
to got in first and will then propose getting rid of
CONFIG_ARCH_DMA_ADDR_T_64BIT separately.


Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-07 Thread tndave



On 10/07/2016 12:32 AM, Christoph Hellwig wrote:

On Thu, Oct 06, 2016 at 04:33:36PM -0700, Tushar Dave wrote:

ATU 64bit addressing allows PCIe devices with 64bit DMA capabilities
to use ATU for 64bit DMA.


Any chance to always enable this?  Last I checked sparc was the only
architecture still using a 32-bit dma_addr_t, leading to some fun
breakage in things like the software RDMA drivers that abuse it to
store a kernel pointer..

With change made by patch 6/6, dma_addr_t is always 64-bit, no matter if
device DMA mask is 32-bit (i.e. using existing IOMMU) or 64-bit (i.e
using ATU)

-Tushar





Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-07 Thread tndave



On 10/07/2016 12:32 AM, Christoph Hellwig wrote:

On Thu, Oct 06, 2016 at 04:33:36PM -0700, Tushar Dave wrote:

ATU 64bit addressing allows PCIe devices with 64bit DMA capabilities
to use ATU for 64bit DMA.


Any chance to always enable this?  Last I checked sparc was the only
architecture still using a 32-bit dma_addr_t, leading to some fun
breakage in things like the software RDMA drivers that abuse it to
store a kernel pointer..

With change made by patch 6/6, dma_addr_t is always 64-bit, no matter if
device DMA mask is 32-bit (i.e. using existing IOMMU) or 64-bit (i.e
using ATU)

-Tushar





Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-07 Thread Christoph Hellwig
On Thu, Oct 06, 2016 at 04:33:36PM -0700, Tushar Dave wrote:
> ATU 64bit addressing allows PCIe devices with 64bit DMA capabilities
> to use ATU for 64bit DMA.

Any chance to always enable this?  Last I checked sparc was the only
architecture still using a 32-bit dma_addr_t, leading to some fun
breakage in things like the software RDMA drivers that abuse it to
store a kernel pointer..


Re: [RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-07 Thread Christoph Hellwig
On Thu, Oct 06, 2016 at 04:33:36PM -0700, Tushar Dave wrote:
> ATU 64bit addressing allows PCIe devices with 64bit DMA capabilities
> to use ATU for 64bit DMA.

Any chance to always enable this?  Last I checked sparc was the only
architecture still using a 32-bit dma_addr_t, leading to some fun
breakage in things like the software RDMA drivers that abuse it to
store a kernel pointer..


[RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-06 Thread Tushar Dave
ATU 64bit addressing allows PCIe devices with 64bit DMA capabilities
to use ATU for 64bit DMA.

Signed-off-by: Tushar Dave 
Reviewed-by: chris hyser 
Acked-by: Sowmini Varadhan 
---
 arch/sparc/Kconfig| 4 
 arch/sparc/kernel/iommu.c | 8 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 338282d..78e7556 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -95,6 +95,10 @@ config ARCH_ATU
bool
default y if SPARC64
 
+config ARCH_DMA_ADDR_T_64BIT
+   bool
+   default y if ARCH_ATU
+
 config IOMMU_HELPER
bool
default y if SPARC64
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 5c615ab..852a329 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -760,8 +760,12 @@ int dma_supported(struct device *dev, u64 device_mask)
struct iommu *iommu = dev->archdata.iommu;
u64 dma_addr_mask = iommu->dma_addr_mask;
 
-   if (device_mask >= (1UL << 32UL))
-   return 0;
+   if (device_mask > DMA_BIT_MASK(32)) {
+   if (iommu->atu)
+   dma_addr_mask = iommu->atu->dma_addr_mask;
+   else
+   return 0;
+   }
 
if ((device_mask & dma_addr_mask) == dma_addr_mask)
return 1;
-- 
1.9.1



[RFC PATCH 6/6] sparc64: Enable 64-bit DMA

2016-10-06 Thread Tushar Dave
ATU 64bit addressing allows PCIe devices with 64bit DMA capabilities
to use ATU for 64bit DMA.

Signed-off-by: Tushar Dave 
Reviewed-by: chris hyser 
Acked-by: Sowmini Varadhan 
---
 arch/sparc/Kconfig| 4 
 arch/sparc/kernel/iommu.c | 8 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 338282d..78e7556 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -95,6 +95,10 @@ config ARCH_ATU
bool
default y if SPARC64
 
+config ARCH_DMA_ADDR_T_64BIT
+   bool
+   default y if ARCH_ATU
+
 config IOMMU_HELPER
bool
default y if SPARC64
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 5c615ab..852a329 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -760,8 +760,12 @@ int dma_supported(struct device *dev, u64 device_mask)
struct iommu *iommu = dev->archdata.iommu;
u64 dma_addr_mask = iommu->dma_addr_mask;
 
-   if (device_mask >= (1UL << 32UL))
-   return 0;
+   if (device_mask > DMA_BIT_MASK(32)) {
+   if (iommu->atu)
+   dma_addr_mask = iommu->atu->dma_addr_mask;
+   else
+   return 0;
+   }
 
if ((device_mask & dma_addr_mask) == dma_addr_mask)
return 1;
-- 
1.9.1