linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
@ 2015-10-21 15:52 Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 1/8] acpi: Honor ACPI _CCA attribute setting Suravee Suthikulpanit
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit

This patch series adds support to setup DMA coherency for PCI device using
the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
support for ARM64 which is currently in development.  Also, this should
not affect other architectures that does not define 
CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.

In the process, this series also introduces enum dev_dma_attr and a set
of APIs to query device DMA attribute. These APIs replace the obsolete
device_dma_is_coherent(), and acpi_check_dma().

I have also included a patch from Jeremy posted here:
    http://www.spinics.net/lists/linux-usb/msg128582.html

This patch series  has been tested on AMD Seattle RevB platform.
The git tree containing tested code and pre-req patches are posted here:

    http://github.com/ssuthiku/linux.git pci-cca-v4

Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
    * Clean up suggested by Bjorn
    * Introduce enum dev_dma_attr
    * Replace device_dma_is_coherent() and acpi_check_dma() with
      new APIs.

Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
    * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
    * Add WARN() when fail to setup DMA for PCI device when booting
      ACPI (per Arnd's suggestion)
    * Added Acked-by from Rob.
    * Minor clean up

Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
    * Include patch 1 from Jeremy to enable support for _CCA=0
    * Clean up acpi_check_dma() per Bjorn suggestions
    * Split the original V1 patch into two patches (patch 3 and 4)

Jeremy Linton (1):
  Honor ACPI _CCA attribute setting

Suravee Suthikulpanit (7):
  device property: Introducing enum dev_dma_attr
  acpi: Adding DMA Attribute APIs for ACPI Device
  device property: Adding DMA Attribute APIs for Generic Devices
  device property: acpi: Make use of the new DMA Attribute APIs
  device property: acpi: Remove unused DMA APIs
  PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
  PCI: ACPI: Add support for PCI device DMA coherency

 drivers/acpi/acpi_platform.c              |  7 +++++-
 drivers/acpi/glue.c                       |  8 +++---
 drivers/acpi/scan.c                       | 42 +++++++++++++++++++++++++++++++
 drivers/base/property.c                   | 32 +++++++++++++++++------
 drivers/crypto/ccp/ccp-platform.c         |  9 ++++++-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c |  9 ++++++-
 drivers/of/of_pci.c                       | 20 ---------------
 drivers/pci/probe.c                       | 36 ++++++++++++++++++++++++--
 include/acpi/acpi_bus.h                   | 36 +++-----------------------
 include/linux/acpi.h                      |  7 +++++-
 include/linux/of_pci.h                    |  3 ---
 include/linux/property.h                  | 10 +++++++-
 12 files changed, 145 insertions(+), 74 deletions(-)

-- 
2.1.0


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

* [PATCH V4 1/8] acpi: Honor ACPI _CCA attribute setting
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-27 14:41   ` Bjorn Helgaas
  2015-10-21 15:52 ` [PATCH V4 2/8] device property: Introducing enum dev_dma_attr Suravee Suthikulpanit
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Jeremy Linton,
	Suravee Suthikulpanit, Rob Herring

From: Jeremy Linton <jeremy.linton@arm.com>

ACPI configurations can now mark devices as noncoherent,
support that choice.

NOTE: This is required to support USB on ARM Juno Development Board.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
CC: Bjorn Helgaas <bhelgaas@google.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Rob Herring <robh+dt@kernel.org>
CC: Will Deacon <will.deacon@arm.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
---
 include/acpi/acpi_bus.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 5ba8fb6..5a42204 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -395,7 +395,7 @@ static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
 	 * case 1. Do not support and disable DMA.
 	 * case 2. Support but rely on arch-specific cache maintenance for
 	 *         non-coherence DMA operations.
-	 * Currently, we implement case 1 above.
+	 * Currently, we implement case 2 above.
 	 *
 	 * For the case when _CCA is missing (i.e. cca_seen=0) and
 	 * platform specifies ACPI_CCA_REQUIRED, we do not support DMA,
@@ -403,7 +403,8 @@ static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
 	 *
 	 * See acpi_init_coherency() for more info.
 	 */
-	if (adev->flags.coherent_dma) {
+	if (adev->flags.coherent_dma ||
+	    (adev->flags.cca_seen && IS_ENABLED(CONFIG_ARM64))) {
 		ret = true;
 		if (coherent)
 			*coherent = adev->flags.coherent_dma;
-- 
2.1.0


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

* [PATCH V4 2/8] device property: Introducing enum dev_dma_attr
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 1/8] acpi: Honor ACPI _CCA attribute setting Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 3/8] acpi: Adding DMA Attribute APIs for ACPI Device Suravee Suthikulpanit
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit

A device could have one of the following DMA attributes:
    * DMA not supported
    * DMA non-coherent
    * DMA coherent

So, this patch introduces enum dev_dma_attribute. This will be used by
new APIs introduced in later patches.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
CC: Bjorn Helgaas <bhelgaas@google.com>
---
 include/linux/property.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/property.h b/include/linux/property.h
index a59c6ee..522c1bf 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -27,6 +27,12 @@ enum dev_prop_type {
 	DEV_PROP_MAX,
 };
 
+enum dev_dma_attr {
+	DEV_DMA_NOT_SUPPORTED,
+	DEV_DMA_NON_COHERENT,
+	DEV_DMA_COHERENT,
+};
+
 bool device_property_present(struct device *dev, const char *propname);
 int device_property_read_u8_array(struct device *dev, const char *propname,
 				  u8 *val, size_t nval);
-- 
2.1.0


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

* [PATCH V4 3/8] acpi: Adding DMA Attribute APIs for ACPI Device
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 1/8] acpi: Honor ACPI _CCA attribute setting Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 2/8] device property: Introducing enum dev_dma_attr Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 4/8] device property: Adding DMA Attribute APIs for Generic Devices Suravee Suthikulpanit
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit

Adding acpi_get_dma_attr() to query DMA attributes of ACPI devices.
It returns the enum dev_dma_attr, which communicates DMA information
more clearly. This API replaces the acpi_check_dma(), which will be
removed in subsequent patch.

This patch also provides a convenient function, acpi_dma_supported(),
to check DMA support of the specified ACPI device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
---
 drivers/acpi/scan.c     | 42 ++++++++++++++++++++++++++++++++++++++++++
 include/acpi/acpi_bus.h |  3 +++
 include/linux/acpi.h    | 10 ++++++++++
 3 files changed, 55 insertions(+)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 01136b8..3be213e 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1328,6 +1328,48 @@ void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
 	kfree(pnp->unique_id);
 }
 
+/**
+ * acpi_dma_supported - Check DMA support for the specified device.
+ * @adev: The pointer to acpi device
+ *
+ * Return false if DMA is not supported. Otherwise, return true
+ */
+bool acpi_dma_supported(struct acpi_device *adev)
+{
+	if (!adev)
+		return false;
+
+	if (adev->flags.cca_seen)
+		return true;
+
+	/*
+	* Per ACPI 6.0 sec 6.2.17, assume devices can do cache-coherent
+	* DMA on "Intel platforms".  Presumably that includes all x86 and
+	* ia64, and other arches will set CONFIG_ACPI_CCA_REQUIRED=y.
+	*/
+	if (!IS_ENABLED(CONFIG_ACPI_CCA_REQUIRED))
+		return true;
+
+	return false;
+}
+
+/**
+ * acpi_get_dma_attr - Check the supported DMA attr for the specified device.
+ * @adev: The pointer to acpi device
+ *
+ * Return enum dev_dma_attr.
+ */
+enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
+{
+	if (!acpi_dma_supported(adev))
+		return DEV_DMA_NOT_SUPPORTED;
+
+	if (adev->flags.coherent_dma)
+		return DEV_DMA_COHERENT;
+	else
+		return DEV_DMA_NON_COHERENT;
+}
+
 static void acpi_init_coherency(struct acpi_device *adev)
 {
 	unsigned long long cca = 0;
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 5a42204..13417d0 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -567,6 +567,9 @@ struct acpi_pci_root {
 
 /* helper */
 
+bool acpi_dma_supported(struct acpi_device *adev);
+enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev);
+
 struct acpi_device *acpi_find_child_device(struct acpi_device *parent,
 					   u64 address, bool check_children);
 int acpi_is_root_bridge(acpi_handle);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index dd39202..c47892c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -569,6 +569,16 @@ static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
 	return false;
 }
 
+static inline bool acpi_dma_supported(struct acpi_device *adev)
+{
+	return false;
+}
+
+static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
+{
+	return DEV_DMA_NOT_SUPPORTED;
+}
+
 #define ACPI_PTR(_ptr)	(NULL)
 
 #endif	/* !CONFIG_ACPI */
-- 
2.1.0


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

* [PATCH V4 4/8] device property: Adding DMA Attribute APIs for Generic Devices
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
                   ` (2 preceding siblings ...)
  2015-10-21 15:52 ` [PATCH V4 3/8] acpi: Adding DMA Attribute APIs for ACPI Device Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 5/8] device property: acpi: Make use of the new DMA Attribute APIs Suravee Suthikulpanit
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit

The function device_dma_is_coherent() does not sufficiently
communicate device DMA attributes. Instead, this patch introduces
device_get_dma_attr(), which returns enum dev_dma_attr.
It replaces the acpi_check_dma(), which will be removed in
subsequent patch.

This also provides a convenient function, device_dma_supported(),
to check DMA support of the specified device.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
---
 drivers/base/property.c  | 29 +++++++++++++++++++++++++++++
 include/linux/property.h |  4 ++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index 2d75366..baac186 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -547,6 +547,35 @@ bool device_dma_is_coherent(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(device_dma_is_coherent);
 
+bool device_dma_supported(struct device *dev)
+{
+	/* For DT, this is always supported.
+	 * For ACPI, this depends on CCA, which
+	 * is determined by the acpi_dma_supported().
+	 */
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node)
+		return true;
+
+	return acpi_dma_supported(ACPI_COMPANION(dev));
+}
+EXPORT_SYMBOL_GPL(device_dma_supported);
+
+enum dev_dma_attr device_get_dma_attr(struct device *dev)
+{
+	enum dev_dma_attr attr = DEV_DMA_NOT_SUPPORTED;
+
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
+		if (of_dma_is_coherent(dev->of_node))
+			attr = DEV_DMA_COHERENT;
+		else
+			attr = DEV_DMA_NON_COHERENT;
+	} else
+		attr = acpi_get_dma_attr(ACPI_COMPANION(dev));
+
+	return attr;
+}
+EXPORT_SYMBOL_GPL(device_get_dma_attr);
+
 /**
  * device_get_phy_mode - Get phy mode for given device
  * @dev:	Pointer to the given device
diff --git a/include/linux/property.h b/include/linux/property.h
index 522c1bf..bde8de3 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -172,6 +172,10 @@ void device_add_property_set(struct device *dev, struct property_set *pset);
 
 bool device_dma_is_coherent(struct device *dev);
 
+bool device_dma_supported(struct device *dev);
+
+enum dev_dma_attr device_get_dma_attr(struct device *dev);
+
 int device_get_phy_mode(struct device *dev);
 
 void *device_get_mac_address(struct device *dev, char *addr, int alen);
-- 
2.1.0


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

* [PATCH V4 5/8] device property: acpi: Make use of the new DMA Attribute APIs
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
                   ` (3 preceding siblings ...)
  2015-10-21 15:52 ` [PATCH V4 4/8] device property: Adding DMA Attribute APIs for Generic Devices Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 6/8] device property: acpi: Remove unused DMA APIs Suravee Suthikulpanit
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit

Now that we have the new DMA attribute APIs, we can replace the older
acpi_check_dma() and device_dma_is_coherent().

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
CC: Tom Lendacky <thomas.lendacky@amd.com>
CC: Herbert Xu <herbert@gondor.apana.org.au>
CC: David S. Miller <davem@davemloft.net>
---
 drivers/acpi/acpi_platform.c              | 7 ++++++-
 drivers/acpi/glue.c                       | 8 +++++---
 drivers/crypto/ccp/ccp-platform.c         | 9 ++++++++-
 drivers/net/ethernet/amd/xgbe/xgbe-main.c | 9 ++++++++-
 4 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 06a67d5..296b7a1 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -103,7 +103,12 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
 	pdevinfo.res = resources;
 	pdevinfo.num_res = count;
 	pdevinfo.fwnode = acpi_fwnode_handle(adev);
-	pdevinfo.dma_mask = acpi_check_dma(adev, NULL) ? DMA_BIT_MASK(32) : 0;
+
+	if (acpi_dma_supported(adev))
+		pdevinfo.dma_mask = DMA_BIT_MASK(32);
+	else
+		pdevinfo.dma_mask = 0;
+
 	pdev = platform_device_register_full(&pdevinfo);
 	if (IS_ERR(pdev))
 		dev_err(&adev->dev, "platform device creation failed: %ld\n",
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index b9657af..a66e776 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
 	struct list_head *physnode_list;
 	unsigned int node_id;
 	int retval = -EINVAL;
-	bool coherent;
+	enum dev_dma_attr attr;
 
 	if (has_acpi_companion(dev)) {
 		if (acpi_dev) {
@@ -225,8 +225,10 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
 	if (!has_acpi_companion(dev))
 		ACPI_COMPANION_SET(dev, acpi_dev);
 
-	if (acpi_check_dma(acpi_dev, &coherent))
-		arch_setup_dma_ops(dev, 0, 0, NULL, coherent);
+	attr = acpi_get_dma_attr(acpi_dev);
+	if (attr != DEV_DMA_NOT_SUPPORTED)
+		arch_setup_dma_ops(dev, 0, 0, NULL,
+				   attr == DEV_DMA_COHERENT);
 
 	acpi_physnode_link_name(physical_node_name, node_id);
 	retval = sysfs_create_link(&acpi_dev->dev.kobj, &dev->kobj,
diff --git a/drivers/crypto/ccp/ccp-platform.c b/drivers/crypto/ccp/ccp-platform.c
index bb241c3..edd9e16 100644
--- a/drivers/crypto/ccp/ccp-platform.c
+++ b/drivers/crypto/ccp/ccp-platform.c
@@ -96,6 +96,7 @@ static int ccp_platform_probe(struct platform_device *pdev)
 	struct ccp_platform *ccp_platform;
 	struct device *dev = &pdev->dev;
 	struct acpi_device *adev = ACPI_COMPANION(dev);
+	enum dev_dma_attr attr;
 	struct resource *ior;
 	int ret;
 
@@ -122,13 +123,19 @@ static int ccp_platform_probe(struct platform_device *pdev)
 	}
 	ccp->io_regs = ccp->io_map;
 
+	attr = device_get_dma_attr(dev);
+	if (attr == DEV_DMA_NOT_SUPPORTED) {
+		dev_err(dev, "DMA is not supported");
+		goto e_err;
+	}
+	ccp_platform->coherent = (attr == DEV_DMA_COHERENT);
+
 	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
 	if (ret) {
 		dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
 		goto e_err;
 	}
 
-	ccp_platform->coherent = device_dma_is_coherent(ccp->dev);
 	if (ccp_platform->coherent)
 		ccp->axcache = CACHE_WB_NO_ALLOC;
 	else
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index e83bd76..b596c7f 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -342,6 +342,7 @@ static int xgbe_probe(struct platform_device *pdev)
 	struct resource *res;
 	const char *phy_mode;
 	unsigned int i, phy_memnum, phy_irqnum;
+	enum dev_dma_attr attr;
 	int ret;
 
 	DBGPR("--> xgbe_probe\n");
@@ -608,8 +609,14 @@ static int xgbe_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_io;
 
+	attr = device_get_dma_attr(dev);
+	if (attr == DEV_DMA_NOT_SUPPORTED) {
+		dev_err(dev, "DMA is not supported");
+		goto err_io;
+	}
+	pdata->coherent = (attr == DEV_DMA_COHERENT);
+
 	/* Set the DMA coherency values */
-	pdata->coherent = device_dma_is_coherent(pdata->dev);
 	if (pdata->coherent) {
 		pdata->axdomain = XGBE_DMA_OS_AXDOMAIN;
 		pdata->arcache = XGBE_DMA_OS_ARCACHE;
-- 
2.1.0


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

* [PATCH V4 6/8] device property: acpi: Remove unused DMA APIs
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
                   ` (4 preceding siblings ...)
  2015-10-21 15:52 ` [PATCH V4 5/8] device property: acpi: Make use of the new DMA Attribute APIs Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-21 15:52 ` [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure() Suravee Suthikulpanit
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit

These DMA APIs are replaced with the newer versions, which return
the enum dev_dma_attr. So, we can safely remove them.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
---
 drivers/base/property.c  | 13 -------------
 include/acpi/acpi_bus.h  | 34 ----------------------------------
 include/linux/acpi.h     |  5 -----
 include/linux/property.h |  2 --
 4 files changed, 54 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index baac186..c79611e 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -534,19 +534,6 @@ unsigned int device_get_child_node_count(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(device_get_child_node_count);
 
-bool device_dma_is_coherent(struct device *dev)
-{
-	bool coherent = false;
-
-	if (IS_ENABLED(CONFIG_OF) && dev->of_node)
-		coherent = of_dma_is_coherent(dev->of_node);
-	else
-		acpi_check_dma(ACPI_COMPANION(dev), &coherent);
-
-	return coherent;
-}
-EXPORT_SYMBOL_GPL(device_dma_is_coherent);
-
 bool device_dma_supported(struct device *dev)
 {
 	/* For DT, this is always supported.
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 13417d0..273b909 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -378,40 +378,6 @@ struct acpi_device {
 	void (*remove)(struct acpi_device *);
 };
 
-static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
-{
-	bool ret = false;
-
-	if (!adev)
-		return ret;
-
-	/**
-	 * Currently, we only support _CCA=1 (i.e. coherent_dma=1)
-	 * This should be equivalent to specifyig dma-coherent for
-	 * a device in OF.
-	 *
-	 * For the case when _CCA=0 (i.e. coherent_dma=0 && cca_seen=1),
-	 * There are two cases:
-	 * case 1. Do not support and disable DMA.
-	 * case 2. Support but rely on arch-specific cache maintenance for
-	 *         non-coherence DMA operations.
-	 * Currently, we implement case 2 above.
-	 *
-	 * For the case when _CCA is missing (i.e. cca_seen=0) and
-	 * platform specifies ACPI_CCA_REQUIRED, we do not support DMA,
-	 * and fallback to arch-specific default handling.
-	 *
-	 * See acpi_init_coherency() for more info.
-	 */
-	if (adev->flags.coherent_dma ||
-	    (adev->flags.cca_seen && IS_ENABLED(CONFIG_ARM64))) {
-		ret = true;
-		if (coherent)
-			*coherent = adev->flags.coherent_dma;
-	}
-	return ret;
-}
-
 static inline bool is_acpi_node(struct fwnode_handle *fwnode)
 {
 	return fwnode && fwnode->type == FWNODE_ACPI;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index c47892c..08bd395 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -564,11 +564,6 @@ static inline int acpi_device_modalias(struct device *dev,
 	return -ENODEV;
 }
 
-static inline bool acpi_check_dma(struct acpi_device *adev, bool *coherent)
-{
-	return false;
-}
-
 static inline bool acpi_dma_supported(struct acpi_device *adev)
 {
 	return false;
diff --git a/include/linux/property.h b/include/linux/property.h
index bde8de3..8b69a88 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -170,8 +170,6 @@ struct property_set {
 
 void device_add_property_set(struct device *dev, struct property_set *pset);
 
-bool device_dma_is_coherent(struct device *dev);
-
 bool device_dma_supported(struct device *dev);
 
 enum dev_dma_attr device_get_dma_attr(struct device *dev);
-- 
2.1.0


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

* [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
                   ` (5 preceding siblings ...)
  2015-10-21 15:52 ` [PATCH V4 6/8] device property: acpi: Remove unused DMA APIs Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-24  7:44   ` Hanjun Guo
  2015-10-27 14:38   ` Bjorn Helgaas
  2015-10-21 15:52 ` [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency Suravee Suthikulpanit
                   ` (2 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit,
	Murali Karicheri

This patch move of_pci_dma_configure() to a more generic
pci_dma_configure(), which can be extended by non-OF code (e.g. ACPI).

This has no functional change.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Acked-by: Rob Herring <robh+dt@kernel.org>
CC: Bjorn Helgaas <bhelgaas@google.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Will Deacon <will.deacon@arm.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
CC: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/of/of_pci.c    | 20 --------------------
 drivers/pci/probe.c    | 27 +++++++++++++++++++++++++--
 include/linux/of_pci.h |  3 ---
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c
index 5751dc5..b66ee4e 100644
--- a/drivers/of/of_pci.c
+++ b/drivers/of/of_pci.c
@@ -117,26 +117,6 @@ int of_get_pci_domain_nr(struct device_node *node)
 }
 EXPORT_SYMBOL_GPL(of_get_pci_domain_nr);
 
-/**
- * of_pci_dma_configure - Setup DMA configuration
- * @dev: ptr to pci_dev struct of the PCI device
- *
- * Function to update PCI devices's DMA configuration using the same
- * info from the OF node of host bridge's parent (if any).
- */
-void of_pci_dma_configure(struct pci_dev *pci_dev)
-{
-	struct device *dev = &pci_dev->dev;
-	struct device *bridge = pci_get_host_bridge_device(pci_dev);
-
-	if (!bridge->parent)
-		return;
-
-	of_dma_configure(dev, bridge->parent->of_node);
-	pci_put_host_bridge_device(bridge);
-}
-EXPORT_SYMBOL_GPL(of_pci_dma_configure);
-
 #if defined(CONFIG_OF_ADDRESS)
 /**
  * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index eea8b42..09264f8 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -6,12 +6,14 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/pci.h>
-#include <linux/of_pci.h>
+#include <linux/of_device.h>
 #include <linux/pci_hotplug.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/cpumask.h>
 #include <linux/pci-aspm.h>
+#include <linux/acpi.h>
+#include <linux/property.h>
 #include <asm-generic/pci-bridge.h>
 #include "pci.h"
 
@@ -1635,6 +1637,27 @@ static void pci_set_msi_domain(struct pci_dev *dev)
 				   dev_get_msi_domain(&dev->bus->dev));
 }
 
+/**
+ * pci_dma_configure - Setup DMA configuration
+ * @dev: ptr to pci_dev struct of the PCI device
+ *
+ * Function to update PCI devices's DMA configuration using the same
+ * info from the OF node of host bridge's parent (if any).
+ */
+static void pci_dma_configure(struct pci_dev *dev)
+{
+	struct device *bridge = pci_get_host_bridge_device(dev);
+
+	if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) {
+		if (!bridge->parent)
+			return;
+
+		of_dma_configure(&dev->dev, bridge->parent->of_node);
+	}
+
+	pci_put_host_bridge_device(bridge);
+}
+
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 {
 	int ret;
@@ -1648,7 +1671,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 	dev->dev.dma_mask = &dev->dma_mask;
 	dev->dev.dma_parms = &dev->dma_parms;
 	dev->dev.coherent_dma_mask = 0xffffffffull;
-	of_pci_dma_configure(dev);
+	pci_dma_configure(dev);
 
 	pci_set_dma_max_seg_size(dev, 65536);
 	pci_set_dma_seg_boundary(dev, 0xffffffff);
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h
index 29fd3fe..ce0e5ab 100644
--- a/include/linux/of_pci.h
+++ b/include/linux/of_pci.h
@@ -16,7 +16,6 @@ int of_pci_get_devfn(struct device_node *np);
 int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin);
 int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
 int of_get_pci_domain_nr(struct device_node *node);
-void of_pci_dma_configure(struct pci_dev *pci_dev);
 #else
 static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq)
 {
@@ -51,8 +50,6 @@ of_get_pci_domain_nr(struct device_node *node)
 {
 	return -1;
 }
-
-static inline void of_pci_dma_configure(struct pci_dev *pci_dev) { }
 #endif
 
 #if defined(CONFIG_OF_ADDRESS)
-- 
2.1.0


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

* [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
                   ` (6 preceding siblings ...)
  2015-10-21 15:52 ` [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure() Suravee Suthikulpanit
@ 2015-10-21 15:52 ` Suravee Suthikulpanit
  2015-10-24  7:47   ` Hanjun Guo
  2015-10-27 14:48   ` Bjorn Helgaas
  2015-10-24  7:51 ` [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Hanjun Guo
  2015-10-27 14:52 ` Bjorn Helgaas
  9 siblings, 2 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-21 15:52 UTC (permalink / raw)
  To: bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Suravee Suthikulpanit,
	Rob Herring, Murali Karicheri

This patch adds support for setting up PCI device DMA coherency from
ACPI _CCA object that should normally be specified in the DSDT node
of its PCI host bridge.

Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
CC: Bjorn Helgaas <bhelgaas@google.com>
CC: Catalin Marinas <catalin.marinas@arm.com>
CC: Rob Herring <robh+dt@kernel.org>
CC: Will Deacon <will.deacon@arm.com>
CC: Rafael J. Wysocki <rjw@rjwysocki.net>
CC: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/pci/probe.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 09264f8..6e9f7e6 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1642,17 +1642,26 @@ static void pci_set_msi_domain(struct pci_dev *dev)
  * @dev: ptr to pci_dev struct of the PCI device
  *
  * Function to update PCI devices's DMA configuration using the same
- * info from the OF node of host bridge's parent (if any).
+ * info from the OF node or ACPI node of host bridge's parent (if any).
  */
 static void pci_dma_configure(struct pci_dev *dev)
 {
 	struct device *bridge = pci_get_host_bridge_device(dev);
 
 	if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) {
-		if (!bridge->parent)
-			return;
-
-		of_dma_configure(&dev->dev, bridge->parent->of_node);
+		if (bridge->parent)
+			of_dma_configure(&dev->dev,
+					 bridge->parent->of_node);
+	} else if (has_acpi_companion(bridge)) {
+		struct acpi_device *adev = to_acpi_node(bridge->fwnode);
+		enum dev_dma_attr attr = acpi_get_dma_attr(adev);
+
+		if (attr != DEV_DMA_NOT_SUPPORTED)
+			arch_setup_dma_ops(&dev->dev, 0, 0, NULL,
+					   attr == DEV_DMA_COHERENT);
+		else
+			WARN(1, FW_BUG "PCI device %s fail to setup DMA.\n",
+			     pci_name(dev));
 	}
 
 	pci_put_host_bridge_device(bridge);
-- 
2.1.0


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

* Re: [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
  2015-10-21 15:52 ` [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure() Suravee Suthikulpanit
@ 2015-10-24  7:44   ` Hanjun Guo
  2015-10-28 18:12     ` Suravee Suthikulpanit
  2015-10-27 14:38   ` Bjorn Helgaas
  1 sibling, 1 reply; 22+ messages in thread
From: Hanjun Guo @ 2015-10-24  7:44 UTC (permalink / raw)
  To: Suravee Suthikulpanit, bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: thomas.lendacky, herbert, linux-pci, linux-kernel, linux-acpi,
	Murali Karicheri, hanjun.guo, davem, linux-arm-kernel

Hi Suravee,

Some minor comments  below:

On 2015/10/21 23:52, Suravee Suthikulpanit wrote:
[...]
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index eea8b42..09264f8 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -6,12 +6,14 @@
>  #include <linux/delay.h>
>  #include <linux/init.h>
>  #include <linux/pci.h>
> -#include <linux/of_pci.h>
> +#include <linux/of_device.h>

Seems it's needed for GICv2m patch but not this one?

>  #include <linux/pci_hotplug.h>
>  #include <linux/slab.h>
>  #include <linux/module.h>
>  #include <linux/cpumask.h>
>  #include <linux/pci-aspm.h>
> +#include <linux/acpi.h>

I think acpi.h should be introduced by the next patch.

> +#include <linux/property.h>

And property.h is also not needed for this patch set.

Thanks
Hanjun


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

* Re: [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency
  2015-10-21 15:52 ` [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency Suravee Suthikulpanit
@ 2015-10-24  7:47   ` Hanjun Guo
  2015-10-27 14:48   ` Bjorn Helgaas
  1 sibling, 0 replies; 22+ messages in thread
From: Hanjun Guo @ 2015-10-24  7:47 UTC (permalink / raw)
  To: Suravee Suthikulpanit, bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel, Rob Herring,
	Murali Karicheri

On 2015/10/21 23:52, Suravee Suthikulpanit wrote:
> This patch adds support for setting up PCI device DMA coherency from
> ACPI _CCA object that should normally be specified in the DSDT node
> of its PCI host bridge.
>
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> CC: Bjorn Helgaas <bhelgaas@google.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Rob Herring <robh+dt@kernel.org>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> CC: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/pci/probe.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 09264f8..6e9f7e6 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1642,17 +1642,26 @@ static void pci_set_msi_domain(struct pci_dev *dev)
>   * @dev: ptr to pci_dev struct of the PCI device
>   *
>   * Function to update PCI devices's DMA configuration using the same
> - * info from the OF node of host bridge's parent (if any).
> + * info from the OF node or ACPI node of host bridge's parent (if any).
>   */
>  static void pci_dma_configure(struct pci_dev *dev)
>  {
>  	struct device *bridge = pci_get_host_bridge_device(dev);
>  
>  	if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) {
> -		if (!bridge->parent)
> -			return;
> -
> -		of_dma_configure(&dev->dev, bridge->parent->of_node);
> +		if (bridge->parent)
> +			of_dma_configure(&dev->dev,
> +					 bridge->parent->of_node);
> +	} else if (has_acpi_companion(bridge)) {
> +		struct acpi_device *adev = to_acpi_node(bridge->fwnode);

It's to_acpi_device_node() now in Rafael's tree.

Thanks
Hanjun


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

* Re: [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
                   ` (7 preceding siblings ...)
  2015-10-21 15:52 ` [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency Suravee Suthikulpanit
@ 2015-10-24  7:51 ` Hanjun Guo
  2015-10-27 14:52 ` Bjorn Helgaas
  9 siblings, 0 replies; 22+ messages in thread
From: Hanjun Guo @ 2015-10-24  7:51 UTC (permalink / raw)
  To: Suravee Suthikulpanit, bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: hanjun.guo, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel

On 2015/10/21 23:52, Suravee Suthikulpanit wrote:
> This patch series adds support to setup DMA coherency for PCI device using
> the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
> is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
> support for ARM64 which is currently in development.  Also, this should
> not affect other architectures that does not define 
> CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.
>
> In the process, this series also introduces enum dev_dma_attr and a set
> of APIs to query device DMA attribute. These APIs replace the obsolete
> device_dma_is_coherent(), and acpi_check_dma().
>
> I have also included a patch from Jeremy posted here:
>     http://www.spinics.net/lists/linux-usb/msg128582.html
>
> This patch series  has been tested on AMD Seattle RevB platform.
> The git tree containing tested code and pre-req patches are posted here:
>
>     http://github.com/ssuthiku/linux.git pci-cca-v4
>
> Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
>     * Clean up suggested by Bjorn
>     * Introduce enum dev_dma_attr
>     * Replace device_dma_is_coherent() and acpi_check_dma() with
>       new APIs.
>
> Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
>     * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
>     * Add WARN() when fail to setup DMA for PCI device when booting
>       ACPI (per Arnd's suggestion)
>     * Added Acked-by from Rob.
>     * Minor clean up
>
> Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
>     * Include patch 1 from Jeremy to enable support for _CCA=0
>     * Clean up acpi_check_dma() per Bjorn suggestions
>     * Split the original V1 patch into two patches (patch 3 and 4)
>
> Jeremy Linton (1):
>   Honor ACPI _CCA attribute setting
>
> Suravee Suthikulpanit (7):
>   device property: Introducing enum dev_dma_attr
>   acpi: Adding DMA Attribute APIs for ACPI Device
>   device property: Adding DMA Attribute APIs for Generic Devices
>   device property: acpi: Make use of the new DMA Attribute APIs
>   device property: acpi: Remove unused DMA APIs
>   PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
>   PCI: ACPI: Add support for PCI device DMA coherency

If the minor comments for patch 7,8 are addressed,

Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>

Thanks
Hanjun



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

* Re: [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
  2015-10-21 15:52 ` [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure() Suravee Suthikulpanit
  2015-10-24  7:44   ` Hanjun Guo
@ 2015-10-27 14:38   ` Bjorn Helgaas
  1 sibling, 0 replies; 22+ messages in thread
From: Bjorn Helgaas @ 2015-10-27 14:38 UTC (permalink / raw)
  To: Suravee Suthikulpanit
  Cc: bhelgaas, rjw, lenb, catalin.marinas, will.deacon, hanjun.guo,
	thomas.lendacky, herbert, davem, linux-acpi, linux-pci,
	linux-kernel, linux-arm-kernel, Murali Karicheri

Hi Suravee,

On Wed, Oct 21, 2015 at 08:52:10AM -0700, Suravee Suthikulpanit wrote:
> This patch move of_pci_dma_configure() to a more generic
> pci_dma_configure(), which can be extended by non-OF code (e.g. ACPI).

> -void of_pci_dma_configure(struct pci_dev *pci_dev)
> -{
> -	struct device *dev = &pci_dev->dev;
> -	struct device *bridge = pci_get_host_bridge_device(pci_dev);
> -
> -	if (!bridge->parent)
> -		return;
> -
> -	of_dma_configure(dev, bridge->parent->of_node);
> -	pci_put_host_bridge_device(bridge);
> -}

> +static void pci_dma_configure(struct pci_dev *dev)
> +{
> +	struct device *bridge = pci_get_host_bridge_device(dev);
> +
> +	if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) {
> +		if (!bridge->parent)
> +			return;

Don't we leak a bridge reference here?  This looks like it was a problem in
the original code, not something you added.  Ideally I guess I would add a
new patch that only fixes the leak in the original code, followed by this
patch that moves it from of_pci_dma_configure() to pci_dma_configure().

> +
> +		of_dma_configure(&dev->dev, bridge->parent->of_node);
> +	}
> +
> +	pci_put_host_bridge_device(bridge);
> +}

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

* Re: [PATCH V4 1/8] acpi: Honor ACPI _CCA attribute setting
  2015-10-21 15:52 ` [PATCH V4 1/8] acpi: Honor ACPI _CCA attribute setting Suravee Suthikulpanit
@ 2015-10-27 14:41   ` Bjorn Helgaas
  0 siblings, 0 replies; 22+ messages in thread
From: Bjorn Helgaas @ 2015-10-27 14:41 UTC (permalink / raw)
  To: Suravee Suthikulpanit
  Cc: bhelgaas, rjw, lenb, catalin.marinas, will.deacon, hanjun.guo,
	thomas.lendacky, herbert, davem, linux-acpi, linux-pci,
	linux-kernel, linux-arm-kernel, Jeremy Linton, Rob Herring

>From "git log --oneline include/acpi/acpi_bus.h", I see the convention is
to capitalize "ACPI:" in the summary (also applies to other patches in this
series).

On Wed, Oct 21, 2015 at 08:52:04AM -0700, Suravee Suthikulpanit wrote:
> From: Jeremy Linton <jeremy.linton@arm.com>
> 
> ACPI configurations can now mark devices as noncoherent,
> support that choice.
> 
> NOTE: This is required to support USB on ARM Juno Development Board.
> 
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> CC: Bjorn Helgaas <bhelgaas@google.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Rob Herring <robh+dt@kernel.org>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> ---
>  include/acpi/acpi_bus.h | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

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

* Re: [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency
  2015-10-21 15:52 ` [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency Suravee Suthikulpanit
  2015-10-24  7:47   ` Hanjun Guo
@ 2015-10-27 14:48   ` Bjorn Helgaas
  1 sibling, 0 replies; 22+ messages in thread
From: Bjorn Helgaas @ 2015-10-27 14:48 UTC (permalink / raw)
  To: Suravee Suthikulpanit
  Cc: bhelgaas, rjw, lenb, catalin.marinas, will.deacon, hanjun.guo,
	thomas.lendacky, herbert, davem, linux-acpi, linux-pci,
	linux-kernel, linux-arm-kernel, Rob Herring, Murali Karicheri

On Wed, Oct 21, 2015 at 08:52:11AM -0700, Suravee Suthikulpanit wrote:
> This patch adds support for setting up PCI device DMA coherency from
> ACPI _CCA object that should normally be specified in the DSDT node
> of its PCI host bridge.
> 
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> CC: Bjorn Helgaas <bhelgaas@google.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Rob Herring <robh+dt@kernel.org>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> CC: Murali Karicheri <m-karicheri2@ti.com>
> ---
>  drivers/pci/probe.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 09264f8..6e9f7e6 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1642,17 +1642,26 @@ static void pci_set_msi_domain(struct pci_dev *dev)
>   * @dev: ptr to pci_dev struct of the PCI device
>   *
>   * Function to update PCI devices's DMA configuration using the same
> - * info from the OF node of host bridge's parent (if any).
> + * info from the OF node or ACPI node of host bridge's parent (if any).
>   */
>  static void pci_dma_configure(struct pci_dev *dev)
>  {
>  	struct device *bridge = pci_get_host_bridge_device(dev);
>  
>  	if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) {
> -		if (!bridge->parent)
> -			return;
> -
> -		of_dma_configure(&dev->dev, bridge->parent->of_node);
> +		if (bridge->parent)
> +			of_dma_configure(&dev->dev,
> +					 bridge->parent->of_node);

This fixes the leak I mentioned earlier, since we now put the bridge
device before returning.  But I guess I'd still prefer to see the leak
fix as a patch by itself instead of fixing it incidentally here.

> +	} else if (has_acpi_companion(bridge)) {
> +		struct acpi_device *adev = to_acpi_node(bridge->fwnode);
> +		enum dev_dma_attr attr = acpi_get_dma_attr(adev);
> +
> +		if (attr != DEV_DMA_NOT_SUPPORTED)
> +			arch_setup_dma_ops(&dev->dev, 0, 0, NULL,
> +					   attr == DEV_DMA_COHERENT);
> +		else
> +			WARN(1, FW_BUG "PCI device %s fail to setup DMA.\n",
> +			     pci_name(dev));

This should use dev_warn() so the format is the same as for other
messages related to "dev".

Personally, I would write this as:

  if (attr == DEV_DMA_NOT_SUPPORTED)
    dev_warn(&dev->dev, "DMA not supported\n");
  else
    arch_setup_dma_ops(...);

to avoid the double negative in the conditional.

>  	}
>  
>  	pci_put_host_bridge_device(bridge);
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
  2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
                   ` (8 preceding siblings ...)
  2015-10-24  7:51 ` [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Hanjun Guo
@ 2015-10-27 14:52 ` Bjorn Helgaas
  2015-10-27 15:27   ` Rafael J. Wysocki
  9 siblings, 1 reply; 22+ messages in thread
From: Bjorn Helgaas @ 2015-10-27 14:52 UTC (permalink / raw)
  To: Suravee Suthikulpanit
  Cc: bhelgaas, rjw, lenb, catalin.marinas, will.deacon, hanjun.guo,
	thomas.lendacky, herbert, davem, linux-acpi, linux-pci,
	linux-kernel, linux-arm-kernel

Hi Suravee,

On Wed, Oct 21, 2015 at 08:52:03AM -0700, Suravee Suthikulpanit wrote:
> This patch series adds support to setup DMA coherency for PCI device using
> the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
> is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
> support for ARM64 which is currently in development.  Also, this should
> not affect other architectures that does not define 
> CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.
> 
> In the process, this series also introduces enum dev_dma_attr and a set
> of APIs to query device DMA attribute. These APIs replace the obsolete
> device_dma_is_coherent(), and acpi_check_dma().
> 
> I have also included a patch from Jeremy posted here:
>     http://www.spinics.net/lists/linux-usb/msg128582.html
> 
> This patch series  has been tested on AMD Seattle RevB platform.
> The git tree containing tested code and pre-req patches are posted here:
> 
>     http://github.com/ssuthiku/linux.git pci-cca-v4
> 
> Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
>     * Clean up suggested by Bjorn
>     * Introduce enum dev_dma_attr
>     * Replace device_dma_is_coherent() and acpi_check_dma() with
>       new APIs.
> 
> Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
>     * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
>     * Add WARN() when fail to setup DMA for PCI device when booting
>       ACPI (per Arnd's suggestion)
>     * Added Acked-by from Rob.
>     * Minor clean up
> 
> Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
>     * Include patch 1 from Jeremy to enable support for _CCA=0
>     * Clean up acpi_check_dma() per Bjorn suggestions
>     * Split the original V1 patch into two patches (patch 3 and 4)
> 
> Jeremy Linton (1):
>   Honor ACPI _CCA attribute setting
> 
> Suravee Suthikulpanit (7):
>   device property: Introducing enum dev_dma_attr
>   acpi: Adding DMA Attribute APIs for ACPI Device
>   device property: Adding DMA Attribute APIs for Generic Devices
>   device property: acpi: Make use of the new DMA Attribute APIs
>   device property: acpi: Remove unused DMA APIs
>   PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
>   PCI: ACPI: Add support for PCI device DMA coherency
> 
>  drivers/acpi/acpi_platform.c              |  7 +++++-
>  drivers/acpi/glue.c                       |  8 +++---
>  drivers/acpi/scan.c                       | 42 +++++++++++++++++++++++++++++++
>  drivers/base/property.c                   | 32 +++++++++++++++++------
>  drivers/crypto/ccp/ccp-platform.c         |  9 ++++++-
>  drivers/net/ethernet/amd/xgbe/xgbe-main.c |  9 ++++++-
>  drivers/of/of_pci.c                       | 20 ---------------
>  drivers/pci/probe.c                       | 36 ++++++++++++++++++++++++--
>  include/acpi/acpi_bus.h                   | 36 +++-----------------------
>  include/linux/acpi.h                      |  7 +++++-
>  include/linux/of_pci.h                    |  3 ---
>  include/linux/property.h                  | 10 +++++++-
>  12 files changed, 145 insertions(+), 74 deletions(-)

I had a couple minor comments.  It's sort of a toss-up, but this feels
more ACPI-flavored than PCI, so I assume Rafael will take this whole
series unless I hear otherwise.

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

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

* Re: [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
  2015-10-27 14:52 ` Bjorn Helgaas
@ 2015-10-27 15:27   ` Rafael J. Wysocki
  2015-10-28 13:54     ` Hanjun Guo
  0 siblings, 1 reply; 22+ messages in thread
From: Rafael J. Wysocki @ 2015-10-27 15:27 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Suravee Suthikulpanit, bhelgaas, lenb, catalin.marinas,
	will.deacon, hanjun.guo, thomas.lendacky, herbert, davem,
	linux-acpi, linux-pci, linux-kernel, linux-arm-kernel

On Tuesday, October 27, 2015 09:52:50 AM Bjorn Helgaas wrote:
> Hi Suravee,
> 
> On Wed, Oct 21, 2015 at 08:52:03AM -0700, Suravee Suthikulpanit wrote:
> > This patch series adds support to setup DMA coherency for PCI device using
> > the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
> > is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
> > support for ARM64 which is currently in development.  Also, this should
> > not affect other architectures that does not define 
> > CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.
> > 
> > In the process, this series also introduces enum dev_dma_attr and a set
> > of APIs to query device DMA attribute. These APIs replace the obsolete
> > device_dma_is_coherent(), and acpi_check_dma().
> > 
> > I have also included a patch from Jeremy posted here:
> >     http://www.spinics.net/lists/linux-usb/msg128582.html
> > 
> > This patch series  has been tested on AMD Seattle RevB platform.
> > The git tree containing tested code and pre-req patches are posted here:
> > 
> >     http://github.com/ssuthiku/linux.git pci-cca-v4
> > 
> > Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
> >     * Clean up suggested by Bjorn
> >     * Introduce enum dev_dma_attr
> >     * Replace device_dma_is_coherent() and acpi_check_dma() with
> >       new APIs.
> > 
> > Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
> >     * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
> >     * Add WARN() when fail to setup DMA for PCI device when booting
> >       ACPI (per Arnd's suggestion)
> >     * Added Acked-by from Rob.
> >     * Minor clean up
> > 
> > Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
> >     * Include patch 1 from Jeremy to enable support for _CCA=0
> >     * Clean up acpi_check_dma() per Bjorn suggestions
> >     * Split the original V1 patch into two patches (patch 3 and 4)
> > 
> > Jeremy Linton (1):
> >   Honor ACPI _CCA attribute setting
> > 
> > Suravee Suthikulpanit (7):
> >   device property: Introducing enum dev_dma_attr
> >   acpi: Adding DMA Attribute APIs for ACPI Device
> >   device property: Adding DMA Attribute APIs for Generic Devices
> >   device property: acpi: Make use of the new DMA Attribute APIs
> >   device property: acpi: Remove unused DMA APIs
> >   PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
> >   PCI: ACPI: Add support for PCI device DMA coherency
> > 
> >  drivers/acpi/acpi_platform.c              |  7 +++++-
> >  drivers/acpi/glue.c                       |  8 +++---
> >  drivers/acpi/scan.c                       | 42 +++++++++++++++++++++++++++++++
> >  drivers/base/property.c                   | 32 +++++++++++++++++------
> >  drivers/crypto/ccp/ccp-platform.c         |  9 ++++++-
> >  drivers/net/ethernet/amd/xgbe/xgbe-main.c |  9 ++++++-
> >  drivers/of/of_pci.c                       | 20 ---------------
> >  drivers/pci/probe.c                       | 36 ++++++++++++++++++++++++--
> >  include/acpi/acpi_bus.h                   | 36 +++-----------------------
> >  include/linux/acpi.h                      |  7 +++++-
> >  include/linux/of_pci.h                    |  3 ---
> >  include/linux/property.h                  | 10 +++++++-
> >  12 files changed, 145 insertions(+), 74 deletions(-)
> 
> I had a couple minor comments.  It's sort of a toss-up, but this feels
> more ACPI-flavored than PCI, so I assume Rafael will take this whole
> series unless I hear otherwise.

I'll do that.

> Acked-by: Bjorn Helgaas <bhelgaas@google.com>

Thanks for the help with reviewing this!

Rafael


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

* Re: [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
  2015-10-27 15:27   ` Rafael J. Wysocki
@ 2015-10-28 13:54     ` Hanjun Guo
  2015-10-28 16:00       ` Rafael J. Wysocki
  0 siblings, 1 reply; 22+ messages in thread
From: Hanjun Guo @ 2015-10-28 13:54 UTC (permalink / raw)
  To: Rafael J. Wysocki, Bjorn Helgaas
  Cc: Suravee Suthikulpanit, bhelgaas, lenb, catalin.marinas,
	will.deacon, thomas.lendacky, herbert, davem, linux-acpi,
	linux-pci, linux-kernel, linux-arm-kernel

Hi Rafael,

On 10/27/2015 11:27 PM, Rafael J. Wysocki wrote:
> On Tuesday, October 27, 2015 09:52:50 AM Bjorn Helgaas wrote:
>> Hi Suravee,
>>
>> On Wed, Oct 21, 2015 at 08:52:03AM -0700, Suravee Suthikulpanit wrote:
>>> This patch series adds support to setup DMA coherency for PCI device using
>>> the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
>>> is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
>>> support for ARM64 which is currently in development.  Also, this should
>>> not affect other architectures that does not define
>>> CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.
>>>
>>> In the process, this series also introduces enum dev_dma_attr and a set
>>> of APIs to query device DMA attribute. These APIs replace the obsolete
>>> device_dma_is_coherent(), and acpi_check_dma().
>>>
>>> I have also included a patch from Jeremy posted here:
>>>      http://www.spinics.net/lists/linux-usb/msg128582.html
>>>
>>> This patch series  has been tested on AMD Seattle RevB platform.
>>> The git tree containing tested code and pre-req patches are posted here:
>>>
>>>      http://github.com/ssuthiku/linux.git pci-cca-v4
>>>
>>> Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
>>>      * Clean up suggested by Bjorn
>>>      * Introduce enum dev_dma_attr
>>>      * Replace device_dma_is_coherent() and acpi_check_dma() with
>>>        new APIs.
>>>
>>> Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
>>>      * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
>>>      * Add WARN() when fail to setup DMA for PCI device when booting
>>>        ACPI (per Arnd's suggestion)
>>>      * Added Acked-by from Rob.
>>>      * Minor clean up
>>>
>>> Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
>>>      * Include patch 1 from Jeremy to enable support for _CCA=0
>>>      * Clean up acpi_check_dma() per Bjorn suggestions
>>>      * Split the original V1 patch into two patches (patch 3 and 4)
>>>
>>> Jeremy Linton (1):
>>>    Honor ACPI _CCA attribute setting
>>>
>>> Suravee Suthikulpanit (7):
>>>    device property: Introducing enum dev_dma_attr
>>>    acpi: Adding DMA Attribute APIs for ACPI Device
>>>    device property: Adding DMA Attribute APIs for Generic Devices
>>>    device property: acpi: Make use of the new DMA Attribute APIs
>>>    device property: acpi: Remove unused DMA APIs
>>>    PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
>>>    PCI: ACPI: Add support for PCI device DMA coherency
>>>
>>>   drivers/acpi/acpi_platform.c              |  7 +++++-
>>>   drivers/acpi/glue.c                       |  8 +++---
>>>   drivers/acpi/scan.c                       | 42 +++++++++++++++++++++++++++++++
>>>   drivers/base/property.c                   | 32 +++++++++++++++++------
>>>   drivers/crypto/ccp/ccp-platform.c         |  9 ++++++-
>>>   drivers/net/ethernet/amd/xgbe/xgbe-main.c |  9 ++++++-
>>>   drivers/of/of_pci.c                       | 20 ---------------
>>>   drivers/pci/probe.c                       | 36 ++++++++++++++++++++++++--
>>>   include/acpi/acpi_bus.h                   | 36 +++-----------------------
>>>   include/linux/acpi.h                      |  7 +++++-
>>>   include/linux/of_pci.h                    |  3 ---
>>>   include/linux/property.h                  | 10 +++++++-
>>>   12 files changed, 145 insertions(+), 74 deletions(-)
>>
>> I had a couple minor comments.  It's sort of a toss-up, but this feels
>> more ACPI-flavored than PCI, so I assume Rafael will take this whole
>> series unless I hear otherwise.
>
> I'll do that.

If Suravee address the comments and send another version,
an it be merged into 4.4?

Thanks
Hanjun

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

* Re: [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
  2015-10-28 13:54     ` Hanjun Guo
@ 2015-10-28 16:00       ` Rafael J. Wysocki
  2015-10-28 17:21         ` Suravee Suthikulpanit
  2015-10-29  6:37         ` Hanjun Guo
  0 siblings, 2 replies; 22+ messages in thread
From: Rafael J. Wysocki @ 2015-10-28 16:00 UTC (permalink / raw)
  To: Hanjun Guo
  Cc: Bjorn Helgaas, Suravee Suthikulpanit, bhelgaas, lenb,
	catalin.marinas, will.deacon, thomas.lendacky, herbert, davem,
	linux-acpi, linux-pci, linux-kernel, linux-arm-kernel

On Wednesday, October 28, 2015 09:54:23 PM Hanjun Guo wrote:
> Hi Rafael,
> 
> On 10/27/2015 11:27 PM, Rafael J. Wysocki wrote:
> > On Tuesday, October 27, 2015 09:52:50 AM Bjorn Helgaas wrote:
> >> Hi Suravee,
> >>
> >> On Wed, Oct 21, 2015 at 08:52:03AM -0700, Suravee Suthikulpanit wrote:
> >>> This patch series adds support to setup DMA coherency for PCI device using
> >>> the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
> >>> is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
> >>> support for ARM64 which is currently in development.  Also, this should
> >>> not affect other architectures that does not define
> >>> CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.
> >>>
> >>> In the process, this series also introduces enum dev_dma_attr and a set
> >>> of APIs to query device DMA attribute. These APIs replace the obsolete
> >>> device_dma_is_coherent(), and acpi_check_dma().
> >>>
> >>> I have also included a patch from Jeremy posted here:
> >>>      http://www.spinics.net/lists/linux-usb/msg128582.html
> >>>
> >>> This patch series  has been tested on AMD Seattle RevB platform.
> >>> The git tree containing tested code and pre-req patches are posted here:
> >>>
> >>>      http://github.com/ssuthiku/linux.git pci-cca-v4
> >>>
> >>> Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
> >>>      * Clean up suggested by Bjorn
> >>>      * Introduce enum dev_dma_attr
> >>>      * Replace device_dma_is_coherent() and acpi_check_dma() with
> >>>        new APIs.
> >>>
> >>> Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
> >>>      * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
> >>>      * Add WARN() when fail to setup DMA for PCI device when booting
> >>>        ACPI (per Arnd's suggestion)
> >>>      * Added Acked-by from Rob.
> >>>      * Minor clean up
> >>>
> >>> Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
> >>>      * Include patch 1 from Jeremy to enable support for _CCA=0
> >>>      * Clean up acpi_check_dma() per Bjorn suggestions
> >>>      * Split the original V1 patch into two patches (patch 3 and 4)
> >>>
> >>> Jeremy Linton (1):
> >>>    Honor ACPI _CCA attribute setting
> >>>
> >>> Suravee Suthikulpanit (7):
> >>>    device property: Introducing enum dev_dma_attr
> >>>    acpi: Adding DMA Attribute APIs for ACPI Device
> >>>    device property: Adding DMA Attribute APIs for Generic Devices
> >>>    device property: acpi: Make use of the new DMA Attribute APIs
> >>>    device property: acpi: Remove unused DMA APIs
> >>>    PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
> >>>    PCI: ACPI: Add support for PCI device DMA coherency
> >>>
> >>>   drivers/acpi/acpi_platform.c              |  7 +++++-
> >>>   drivers/acpi/glue.c                       |  8 +++---
> >>>   drivers/acpi/scan.c                       | 42 +++++++++++++++++++++++++++++++
> >>>   drivers/base/property.c                   | 32 +++++++++++++++++------
> >>>   drivers/crypto/ccp/ccp-platform.c         |  9 ++++++-
> >>>   drivers/net/ethernet/amd/xgbe/xgbe-main.c |  9 ++++++-
> >>>   drivers/of/of_pci.c                       | 20 ---------------
> >>>   drivers/pci/probe.c                       | 36 ++++++++++++++++++++++++--
> >>>   include/acpi/acpi_bus.h                   | 36 +++-----------------------
> >>>   include/linux/acpi.h                      |  7 +++++-
> >>>   include/linux/of_pci.h                    |  3 ---
> >>>   include/linux/property.h                  | 10 +++++++-
> >>>   12 files changed, 145 insertions(+), 74 deletions(-)
> >>
> >> I had a couple minor comments.  It's sort of a toss-up, but this feels
> >> more ACPI-flavored than PCI, so I assume Rafael will take this whole
> >> series unless I hear otherwise.
> >
> > I'll do that.
> 
> If Suravee address the comments and send another version,
> an it be merged into 4.4?

Well, it is likely, but not guaranteed.

We're only a few days from the beginning of the merge window and I'm still
in Seoul.

Thanks,
Rafael


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

* Re: [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
  2015-10-28 16:00       ` Rafael J. Wysocki
@ 2015-10-28 17:21         ` Suravee Suthikulpanit
  2015-10-29  6:37         ` Hanjun Guo
  1 sibling, 0 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-28 17:21 UTC (permalink / raw)
  To: Rafael J. Wysocki, Hanjun Guo
  Cc: Bjorn Helgaas, bhelgaas, lenb, catalin.marinas, will.deacon,
	thomas.lendacky, herbert, davem, linux-acpi, linux-pci,
	linux-kernel, linux-arm-kernel

Thanks all for the review comments. I'll update the V5 and send it out 
later on today.

Suravee

On 10/28/15 11:00, Rafael J. Wysocki wrote:
> On Wednesday, October 28, 2015 09:54:23 PM Hanjun Guo wrote:
>> Hi Rafael,
>>
>> On 10/27/2015 11:27 PM, Rafael J. Wysocki wrote:
>>> On Tuesday, October 27, 2015 09:52:50 AM Bjorn Helgaas wrote:
>>>> Hi Suravee,
>>>>
>>>> On Wed, Oct 21, 2015 at 08:52:03AM -0700, Suravee Suthikulpanit wrote:
>>>>> This patch series adds support to setup DMA coherency for PCI device using
>>>>> the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
>>>>> is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
>>>>> support for ARM64 which is currently in development.  Also, this should
>>>>> not affect other architectures that does not define
>>>>> CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.
>>>>>
>>>>> In the process, this series also introduces enum dev_dma_attr and a set
>>>>> of APIs to query device DMA attribute. These APIs replace the obsolete
>>>>> device_dma_is_coherent(), and acpi_check_dma().
>>>>>
>>>>> I have also included a patch from Jeremy posted here:
>>>>>       http://www.spinics.net/lists/linux-usb/msg128582.html
>>>>>
>>>>> This patch series  has been tested on AMD Seattle RevB platform.
>>>>> The git tree containing tested code and pre-req patches are posted here:
>>>>>
>>>>>       http://github.com/ssuthiku/linux.git pci-cca-v4
>>>>>
>>>>> Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
>>>>>       * Clean up suggested by Bjorn
>>>>>       * Introduce enum dev_dma_attr
>>>>>       * Replace device_dma_is_coherent() and acpi_check_dma() with
>>>>>         new APIs.
>>>>>
>>>>> Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
>>>>>       * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
>>>>>       * Add WARN() when fail to setup DMA for PCI device when booting
>>>>>         ACPI (per Arnd's suggestion)
>>>>>       * Added Acked-by from Rob.
>>>>>       * Minor clean up
>>>>>
>>>>> Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
>>>>>       * Include patch 1 from Jeremy to enable support for _CCA=0
>>>>>       * Clean up acpi_check_dma() per Bjorn suggestions
>>>>>       * Split the original V1 patch into two patches (patch 3 and 4)
>>>>>
>>>>> Jeremy Linton (1):
>>>>>     Honor ACPI _CCA attribute setting
>>>>>
>>>>> Suravee Suthikulpanit (7):
>>>>>     device property: Introducing enum dev_dma_attr
>>>>>     acpi: Adding DMA Attribute APIs for ACPI Device
>>>>>     device property: Adding DMA Attribute APIs for Generic Devices
>>>>>     device property: acpi: Make use of the new DMA Attribute APIs
>>>>>     device property: acpi: Remove unused DMA APIs
>>>>>     PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
>>>>>     PCI: ACPI: Add support for PCI device DMA coherency
>>>>>
>>>>>    drivers/acpi/acpi_platform.c              |  7 +++++-
>>>>>    drivers/acpi/glue.c                       |  8 +++---
>>>>>    drivers/acpi/scan.c                       | 42 +++++++++++++++++++++++++++++++
>>>>>    drivers/base/property.c                   | 32 +++++++++++++++++------
>>>>>    drivers/crypto/ccp/ccp-platform.c         |  9 ++++++-
>>>>>    drivers/net/ethernet/amd/xgbe/xgbe-main.c |  9 ++++++-
>>>>>    drivers/of/of_pci.c                       | 20 ---------------
>>>>>    drivers/pci/probe.c                       | 36 ++++++++++++++++++++++++--
>>>>>    include/acpi/acpi_bus.h                   | 36 +++-----------------------
>>>>>    include/linux/acpi.h                      |  7 +++++-
>>>>>    include/linux/of_pci.h                    |  3 ---
>>>>>    include/linux/property.h                  | 10 +++++++-
>>>>>    12 files changed, 145 insertions(+), 74 deletions(-)
>>>>
>>>> I had a couple minor comments.  It's sort of a toss-up, but this feels
>>>> more ACPI-flavored than PCI, so I assume Rafael will take this whole
>>>> series unless I hear otherwise.
>>>
>>> I'll do that.
>>
>> If Suravee address the comments and send another version,
>> an it be merged into 4.4?
>
> Well, it is likely, but not guaranteed.
>
> We're only a few days from the beginning of the merge window and I'm still
> in Seoul.
>
> Thanks,
> Rafael
>

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

* Re: [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
  2015-10-24  7:44   ` Hanjun Guo
@ 2015-10-28 18:12     ` Suravee Suthikulpanit
  0 siblings, 0 replies; 22+ messages in thread
From: Suravee Suthikulpanit @ 2015-10-28 18:12 UTC (permalink / raw)
  To: Hanjun Guo, bhelgaas, rjw, lenb, catalin.marinas, will.deacon
  Cc: thomas.lendacky, herbert, linux-pci, linux-kernel, linux-acpi,
	Murali Karicheri, hanjun.guo, davem, linux-arm-kernel

Hi Hanjun,

On 10/24/15 02:44, Hanjun Guo wrote:
> Hi Suravee,
>
> Some minor comments  below:
>
> On 2015/10/21 23:52, Suravee Suthikulpanit wrote:
> [...]
>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
>> index eea8b42..09264f8 100644
>> --- a/drivers/pci/probe.c
>> +++ b/drivers/pci/probe.c
>> @@ -6,12 +6,14 @@
>>   #include <linux/delay.h>
>>   #include <linux/init.h>
>>   #include <linux/pci.h>
>> -#include <linux/of_pci.h>
>> +#include <linux/of_device.h>
>
> Seems it's needed for GICv2m patch but not this one?
This one is needed since we are making use of the new of_dma_configure 
instead of the of_pci_dma_configure.

>
>>   #include <linux/pci_hotplug.h>
>>   #include <linux/slab.h>
>>   #include <linux/module.h>
>>   #include <linux/cpumask.h>
>>   #include <linux/pci-aspm.h>
>> +#include <linux/acpi.h>
>
> I think acpi.h should be introduced by the next patch.
You are right. I'll update this one.

>
>> +#include <linux/property.h>
>
> And property.h is also not needed for this patch set.

You are right. I'll remove this

Thanks,
Suravee



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

* Re: [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute
  2015-10-28 16:00       ` Rafael J. Wysocki
  2015-10-28 17:21         ` Suravee Suthikulpanit
@ 2015-10-29  6:37         ` Hanjun Guo
  1 sibling, 0 replies; 22+ messages in thread
From: Hanjun Guo @ 2015-10-29  6:37 UTC (permalink / raw)
  To: Rafael J. Wysocki, Hanjun Guo
  Cc: Bjorn Helgaas, Suravee Suthikulpanit, bhelgaas, lenb,
	catalin.marinas, will.deacon, thomas.lendacky, herbert, davem,
	linux-acpi, linux-pci, linux-kernel, linux-arm-kernel

On 2015/10/29 0:00, Rafael J. Wysocki wrote:
> On Wednesday, October 28, 2015 09:54:23 PM Hanjun Guo wrote:
>> Hi Rafael,
>>
>> On 10/27/2015 11:27 PM, Rafael J. Wysocki wrote:
>>> On Tuesday, October 27, 2015 09:52:50 AM Bjorn Helgaas wrote:
>>>> Hi Suravee,
>>>>
>>>> On Wed, Oct 21, 2015 at 08:52:03AM -0700, Suravee Suthikulpanit wrote:
>>>>> This patch series adds support to setup DMA coherency for PCI device using
>>>>> the ACPI _CCA attribute. According to the ACPI spec, the _CCA attribute
>>>>> is required for ARM64. Therefore, this patch is a pre-req for ACPI PCI
>>>>> support for ARM64 which is currently in development.  Also, this should
>>>>> not affect other architectures that does not define
>>>>> CONFIG_ACPI_CCA_REQUIRED, since the default value is coherent.
>>>>>
>>>>> In the process, this series also introduces enum dev_dma_attr and a set
>>>>> of APIs to query device DMA attribute. These APIs replace the obsolete
>>>>> device_dma_is_coherent(), and acpi_check_dma().
>>>>>
>>>>> I have also included a patch from Jeremy posted here:
>>>>>      http://www.spinics.net/lists/linux-usb/msg128582.html
>>>>>
>>>>> This patch series  has been tested on AMD Seattle RevB platform.
>>>>> The git tree containing tested code and pre-req patches are posted here:
>>>>>
>>>>>      http://github.com/ssuthiku/linux.git pci-cca-v4
>>>>>
>>>>> Changes from V3: (https://lkml.org/lkml/2015/8/26/389)
>>>>>      * Clean up suggested by Bjorn
>>>>>      * Introduce enum dev_dma_attr
>>>>>      * Replace device_dma_is_coherent() and acpi_check_dma() with
>>>>>        new APIs.
>>>>>
>>>>> Changes from V2: (https://lkml.org/lkml/2015/8/25/549)
>>>>>      * Return -ENOSUPP instead of -1 (per Rafael's suggestion)
>>>>>      * Add WARN() when fail to setup DMA for PCI device when booting
>>>>>        ACPI (per Arnd's suggestion)
>>>>>      * Added Acked-by from Rob.
>>>>>      * Minor clean up
>>>>>
>>>>> Changes from V1: (https://lkml.org/lkml/2015/8/13/182)
>>>>>      * Include patch 1 from Jeremy to enable support for _CCA=0
>>>>>      * Clean up acpi_check_dma() per Bjorn suggestions
>>>>>      * Split the original V1 patch into two patches (patch 3 and 4)
>>>>>
>>>>> Jeremy Linton (1):
>>>>>    Honor ACPI _CCA attribute setting
>>>>>
>>>>> Suravee Suthikulpanit (7):
>>>>>    device property: Introducing enum dev_dma_attr
>>>>>    acpi: Adding DMA Attribute APIs for ACPI Device
>>>>>    device property: Adding DMA Attribute APIs for Generic Devices
>>>>>    device property: acpi: Make use of the new DMA Attribute APIs
>>>>>    device property: acpi: Remove unused DMA APIs
>>>>>    PCI: OF: Move of_pci_dma_configure() to pci_dma_configure()
>>>>>    PCI: ACPI: Add support for PCI device DMA coherency
>>>>>
>>>>>   drivers/acpi/acpi_platform.c              |  7 +++++-
>>>>>   drivers/acpi/glue.c                       |  8 +++---
>>>>>   drivers/acpi/scan.c                       | 42 +++++++++++++++++++++++++++++++
>>>>>   drivers/base/property.c                   | 32 +++++++++++++++++------
>>>>>   drivers/crypto/ccp/ccp-platform.c         |  9 ++++++-
>>>>>   drivers/net/ethernet/amd/xgbe/xgbe-main.c |  9 ++++++-
>>>>>   drivers/of/of_pci.c                       | 20 ---------------
>>>>>   drivers/pci/probe.c                       | 36 ++++++++++++++++++++++++--
>>>>>   include/acpi/acpi_bus.h                   | 36 +++-----------------------
>>>>>   include/linux/acpi.h                      |  7 +++++-
>>>>>   include/linux/of_pci.h                    |  3 ---
>>>>>   include/linux/property.h                  | 10 +++++++-
>>>>>   12 files changed, 145 insertions(+), 74 deletions(-)
>>>> I had a couple minor comments.  It's sort of a toss-up, but this feels
>>>> more ACPI-flavored than PCI, so I assume Rafael will take this whole
>>>> series unless I hear otherwise.
>>> I'll do that.
>> If Suravee address the comments and send another version,
>> an it be merged into 4.4?
> Well, it is likely, but not guaranteed.
>
> We're only a few days from the beginning of the merge window and I'm still
> in Seoul.

No problem, it's up to you :), thanks for the quick response.

Hanjun


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

end of thread, other threads:[~2015-10-29  6:37 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-21 15:52 [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Suravee Suthikulpanit
2015-10-21 15:52 ` [PATCH V4 1/8] acpi: Honor ACPI _CCA attribute setting Suravee Suthikulpanit
2015-10-27 14:41   ` Bjorn Helgaas
2015-10-21 15:52 ` [PATCH V4 2/8] device property: Introducing enum dev_dma_attr Suravee Suthikulpanit
2015-10-21 15:52 ` [PATCH V4 3/8] acpi: Adding DMA Attribute APIs for ACPI Device Suravee Suthikulpanit
2015-10-21 15:52 ` [PATCH V4 4/8] device property: Adding DMA Attribute APIs for Generic Devices Suravee Suthikulpanit
2015-10-21 15:52 ` [PATCH V4 5/8] device property: acpi: Make use of the new DMA Attribute APIs Suravee Suthikulpanit
2015-10-21 15:52 ` [PATCH V4 6/8] device property: acpi: Remove unused DMA APIs Suravee Suthikulpanit
2015-10-21 15:52 ` [PATCH V4 7/8] PCI: OF: Move of_pci_dma_configure() to pci_dma_configure() Suravee Suthikulpanit
2015-10-24  7:44   ` Hanjun Guo
2015-10-28 18:12     ` Suravee Suthikulpanit
2015-10-27 14:38   ` Bjorn Helgaas
2015-10-21 15:52 ` [PATCH V4 8/8] PCI: ACPI: Add support for PCI device DMA coherency Suravee Suthikulpanit
2015-10-24  7:47   ` Hanjun Guo
2015-10-27 14:48   ` Bjorn Helgaas
2015-10-24  7:51 ` [PATCH V4 0/8] PCI: ACPI: Setting up DMA coherency for PCI device from _CCA attribute Hanjun Guo
2015-10-27 14:52 ` Bjorn Helgaas
2015-10-27 15:27   ` Rafael J. Wysocki
2015-10-28 13:54     ` Hanjun Guo
2015-10-28 16:00       ` Rafael J. Wysocki
2015-10-28 17:21         ` Suravee Suthikulpanit
2015-10-29  6:37         ` Hanjun Guo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).