Re: [V5 PATCH 2/5] arm64 : Introduce support for ACPI _CCA object

2015-06-03 Thread Mark Salter
On Wed, 2015-06-03 at 09:37 -0500, Suravee Suthikulanit wrote:
 On 5/28/2015 9:38 PM, Mark Salter wrote:
  On Wed, 2015-05-20 at 17:09 -0500, Suravee Suthikulpanit wrote:
  Fromhttp://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf,
  section 6.2.17 _CCA states that ARM platforms require ACPI _CCA
  object to be specified for DMA-cabpable devices. Therefore, this patch
  specifies ACPI_CCA_REQUIRED in arm64 Kconfig.
  
  In addition, to handle the case when _CCA is missing, arm64 would assign
  dummy_dma_ops to disable DMA capability of the device.
  
  Acked-by: Catalin Marinascatalin.mari...@arm.com
  Signed-off-by: Mark Saltermsal...@redhat.com
  Signed-off-by: Suravee Suthikulpanitsuravee.suthikulpa...@amd.com
  ---
arch/arm64/Kconfig   |  1 +
arch/arm64/include/asm/dma-mapping.h | 18 ++-
arch/arm64/mm/dma-mapping.c  | 92 
   
3 files changed, 109 insertions(+), 2 deletions(-)
  
  diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
  index 4269dba..95307b4 100644
  --- a/arch/arm64/Kconfig
  +++ b/arch/arm64/Kconfig
  @@ -1,5 +1,6 @@
config ARM64
def_bool y
  + select ACPI_CCA_REQUIRED if ACPI
select ACPI_GENERIC_GSI if ACPI
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
  diff --git a/arch/arm64/include/asm/dma-mapping.h 
  b/arch/arm64/include/asm/dma-mapping.h
  index 9437e3d..f0d6d0b 100644
  --- a/arch/arm64/include/asm/dma-mapping.h
  +++ b/arch/arm64/include/asm/dma-mapping.h
  @@ -18,6 +18,7 @@
  
#ifdef __KERNEL__
  
  +#include linux/acpi.h
#include linux/types.h
#include linux/vmalloc.h
  
  ^^^ This hunk causes build issues with a couple of drivers:
 
  drivers/scsi/megaraid/megaraid_sas_fp.c:69:0: warning: FALSE redefined 
  [enabled by default]
#define FALSE 0
^
  In file included from include/acpi/acpi.h:58:0,
from include/linux/acpi.h:37,
from ./arch/arm64/include/asm/dma-mapping.h:21,
from include/linux/dma-mapping.h:86,
from ./arch/arm64/include/asm/pci.h:7,
from include/linux/pci.h:1460,
from drivers/scsi/megaraid/megaraid_sas_fp.c:37:
  include/acpi/actypes.h:433:0: note: this is the location of the previous 
  definition
#define FALSE   (1 == 0)
^
 
 
  In file included from include/acpi/acpi.h:58:0,
from include/linux/acpi.h:37,
from ./arch/arm64/include/asm/dma-mapping.h:21,
from include/linux/dma-mapping.h:86,
from include/scsi/scsi_cmnd.h:4,
from drivers/scsi/ufs/ufshcd.h:60,
from drivers/scsi/ufs/ufshcd.c:43:
  include/acpi/actypes.h:433:41: error: expected identifier before ‘(’ token
#define FALSE   (1 == 0)
^
  drivers/scsi/ufs/unipro.h:203:2: note: in expansion of macro ‘FALSE’
 FALSE = 0,
 ^
 
  This happens because the ACPI definitions of TRUE and FALSE conflict
  with local definitions in megaraid and enum declaration in ufs.
 
 Mark,
 
 Thanks for pointing this out. Although, I would think that the 
 megaraid_sas_fp.c should have had the #ifndef to check before defining 
 the TRUE and FALSE as following.
 
 #ifndef TRUE
 #define TRUE 1
 #endif
 #ifndef FALSE
 #define FALSE 0
 #endif
 
 This seems to be what other drivers are also doing. If this is okay, I 
 can send out a fix-up patch for the megaraid driver.
 

Yeah, or #undef them if defined so megaraid defines them as desired.
And #undef if defined would work for unipro.h as well.


--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [V5 PATCH 2/5] arm64 : Introduce support for ACPI _CCA object

2015-05-28 Thread Mark Salter
On Wed, 2015-05-20 at 17:09 -0500, Suravee Suthikulpanit wrote:
 From http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf,
 section 6.2.17 _CCA states that ARM platforms require ACPI _CCA
 object to be specified for DMA-cabpable devices. Therefore, this patch
 specifies ACPI_CCA_REQUIRED in arm64 Kconfig.
 
 In addition, to handle the case when _CCA is missing, arm64 would assign
 dummy_dma_ops to disable DMA capability of the device.
 
 Acked-by: Catalin Marinas catalin.mari...@arm.com
 Signed-off-by: Mark Salter msal...@redhat.com
 Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
 ---
  arch/arm64/Kconfig   |  1 +
  arch/arm64/include/asm/dma-mapping.h | 18 ++-
  arch/arm64/mm/dma-mapping.c  | 92 
 
  3 files changed, 109 insertions(+), 2 deletions(-)
 
 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
 index 4269dba..95307b4 100644
 --- a/arch/arm64/Kconfig
 +++ b/arch/arm64/Kconfig
 @@ -1,5 +1,6 @@
  config ARM64
   def_bool y
 + select ACPI_CCA_REQUIRED if ACPI
   select ACPI_GENERIC_GSI if ACPI
   select ACPI_REDUCED_HARDWARE_ONLY if ACPI
   select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
 diff --git a/arch/arm64/include/asm/dma-mapping.h 
 b/arch/arm64/include/asm/dma-mapping.h
 index 9437e3d..f0d6d0b 100644
 --- a/arch/arm64/include/asm/dma-mapping.h
 +++ b/arch/arm64/include/asm/dma-mapping.h
 @@ -18,6 +18,7 @@
  
  #ifdef __KERNEL__
  
 +#include linux/acpi.h
  #include linux/types.h
  #include linux/vmalloc.h
  

^^^ This hunk causes build issues with a couple of drivers:

drivers/scsi/megaraid/megaraid_sas_fp.c:69:0: warning: FALSE redefined 
[enabled by default]
 #define FALSE 0
 ^
In file included from include/acpi/acpi.h:58:0,
 from include/linux/acpi.h:37,
 from ./arch/arm64/include/asm/dma-mapping.h:21,
 from include/linux/dma-mapping.h:86,
 from ./arch/arm64/include/asm/pci.h:7,
 from include/linux/pci.h:1460,
 from drivers/scsi/megaraid/megaraid_sas_fp.c:37:
include/acpi/actypes.h:433:0: note: this is the location of the previous 
definition
 #define FALSE   (1 == 0)
 ^


In file included from include/acpi/acpi.h:58:0,
 from include/linux/acpi.h:37,
 from ./arch/arm64/include/asm/dma-mapping.h:21,
 from include/linux/dma-mapping.h:86,
 from include/scsi/scsi_cmnd.h:4,
 from drivers/scsi/ufs/ufshcd.h:60,
 from drivers/scsi/ufs/ufshcd.c:43:
include/acpi/actypes.h:433:41: error: expected identifier before ‘(’ token
 #define FALSE   (1 == 0)
 ^
drivers/scsi/ufs/unipro.h:203:2: note: in expansion of macro ‘FALSE’
  FALSE = 0,
  ^

This happens because the ACPI definitions of TRUE and FALSE conflict
with local definitions in megaraid and enum declaration in ufs.


 @@ -28,13 +29,23 @@
  
  #define DMA_ERROR_CODE   (~(dma_addr_t)0)
  extern struct dma_map_ops *dma_ops;
 +extern struct dma_map_ops dummy_dma_ops;
  
  static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
  {
 - if (unlikely(!dev) || !dev-archdata.dma_ops)
 + if (unlikely(!dev))
   return dma_ops;
 - else
 + else if (dev-archdata.dma_ops)
   return dev-archdata.dma_ops;
 + else if (acpi_disabled)
 + return dma_ops;
 +
 + /*
 +  * When ACPI is enabled, if arch_set_dma_ops is not called,
 +  * we will disable device DMA capability by setting it
 +  * to dummy_dma_ops.
 +  */
 + return dummy_dma_ops;
  }
  
  static inline struct dma_map_ops *get_dma_ops(struct device *dev)
 @@ -48,6 +59,9 @@ static inline struct dma_map_ops *get_dma_ops(struct device 
 *dev)
  static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 
 size,
 struct iommu_ops *iommu, bool coherent)
  {
 + if (!acpi_disabled  !dev-archdata.dma_ops)
 + dev-archdata.dma_ops = dma_ops;
 +
   dev-archdata.dma_coherent = coherent;
  }
  #define arch_setup_dma_ops   arch_setup_dma_ops
 diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
 index ef7d112..6e6d6ad 100644
 --- a/arch/arm64/mm/dma-mapping.c
 +++ b/arch/arm64/mm/dma-mapping.c
 @@ -415,6 +415,98 @@ out:
   return -ENOMEM;
  }
  
 +/
 + * The following APIs are for dummy DMA ops *
 + /
 +
 +static void *__dummy_alloc(struct device *dev, size_t size,
 +dma_addr_t *dma_handle, gfp_t flags,
 +struct dma_attrs *attrs)
 +{
 + return NULL;
 +}
 +
 +static void __dummy_free(struct device *dev, size_t size,
 +  void *vaddr, dma_addr_t dma_handle,
 +  struct dma_attrs 

[V5 PATCH 2/5] arm64 : Introduce support for ACPI _CCA object

2015-05-20 Thread Suravee Suthikulpanit
From http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf,
section 6.2.17 _CCA states that ARM platforms require ACPI _CCA
object to be specified for DMA-cabpable devices. Therefore, this patch
specifies ACPI_CCA_REQUIRED in arm64 Kconfig.

In addition, to handle the case when _CCA is missing, arm64 would assign
dummy_dma_ops to disable DMA capability of the device.

Acked-by: Catalin Marinas catalin.mari...@arm.com
Signed-off-by: Mark Salter msal...@redhat.com
Signed-off-by: Suravee Suthikulpanit suravee.suthikulpa...@amd.com
---
 arch/arm64/Kconfig   |  1 +
 arch/arm64/include/asm/dma-mapping.h | 18 ++-
 arch/arm64/mm/dma-mapping.c  | 92 
 3 files changed, 109 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 4269dba..95307b4 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,5 +1,6 @@
 config ARM64
def_bool y
+   select ACPI_CCA_REQUIRED if ACPI
select ACPI_GENERIC_GSI if ACPI
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
diff --git a/arch/arm64/include/asm/dma-mapping.h 
b/arch/arm64/include/asm/dma-mapping.h
index 9437e3d..f0d6d0b 100644
--- a/arch/arm64/include/asm/dma-mapping.h
+++ b/arch/arm64/include/asm/dma-mapping.h
@@ -18,6 +18,7 @@
 
 #ifdef __KERNEL__
 
+#include linux/acpi.h
 #include linux/types.h
 #include linux/vmalloc.h
 
@@ -28,13 +29,23 @@
 
 #define DMA_ERROR_CODE (~(dma_addr_t)0)
 extern struct dma_map_ops *dma_ops;
+extern struct dma_map_ops dummy_dma_ops;
 
 static inline struct dma_map_ops *__generic_dma_ops(struct device *dev)
 {
-   if (unlikely(!dev) || !dev-archdata.dma_ops)
+   if (unlikely(!dev))
return dma_ops;
-   else
+   else if (dev-archdata.dma_ops)
return dev-archdata.dma_ops;
+   else if (acpi_disabled)
+   return dma_ops;
+
+   /*
+* When ACPI is enabled, if arch_set_dma_ops is not called,
+* we will disable device DMA capability by setting it
+* to dummy_dma_ops.
+*/
+   return dummy_dma_ops;
 }
 
 static inline struct dma_map_ops *get_dma_ops(struct device *dev)
@@ -48,6 +59,9 @@ static inline struct dma_map_ops *get_dma_ops(struct device 
*dev)
 static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 
size,
  struct iommu_ops *iommu, bool coherent)
 {
+   if (!acpi_disabled  !dev-archdata.dma_ops)
+   dev-archdata.dma_ops = dma_ops;
+
dev-archdata.dma_coherent = coherent;
 }
 #define arch_setup_dma_ops arch_setup_dma_ops
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index ef7d112..6e6d6ad 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -415,6 +415,98 @@ out:
return -ENOMEM;
 }
 
+/
+ * The following APIs are for dummy DMA ops *
+ /
+
+static void *__dummy_alloc(struct device *dev, size_t size,
+  dma_addr_t *dma_handle, gfp_t flags,
+  struct dma_attrs *attrs)
+{
+   return NULL;
+}
+
+static void __dummy_free(struct device *dev, size_t size,
+void *vaddr, dma_addr_t dma_handle,
+struct dma_attrs *attrs)
+{
+}
+
+static int __dummy_mmap(struct device *dev,
+   struct vm_area_struct *vma,
+   void *cpu_addr, dma_addr_t dma_addr, size_t size,
+   struct dma_attrs *attrs)
+{
+   return -ENXIO;
+}
+
+static dma_addr_t __dummy_map_page(struct device *dev, struct page *page,
+  unsigned long offset, size_t size,
+  enum dma_data_direction dir,
+  struct dma_attrs *attrs)
+{
+   return DMA_ERROR_CODE;
+}
+
+static void __dummy_unmap_page(struct device *dev, dma_addr_t dev_addr,
+  size_t size, enum dma_data_direction dir,
+  struct dma_attrs *attrs)
+{
+}
+
+static int __dummy_map_sg(struct device *dev, struct scatterlist *sgl,
+ int nelems, enum dma_data_direction dir,
+ struct dma_attrs *attrs)
+{
+   return 0;
+}
+
+static void __dummy_unmap_sg(struct device *dev,
+struct scatterlist *sgl, int nelems,
+enum dma_data_direction dir,
+struct dma_attrs *attrs)
+{
+}
+
+static void __dummy_sync_single(struct device *dev,
+   dma_addr_t dev_addr, size_t size,
+   enum dma_data_direction dir)
+{
+}
+
+static void __dummy_sync_sg(struct device *dev,
+   struct scatterlist *sgl, int nelems,
+