mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/5] ACPI/PCI: Parse PCI root bridge's ACPI resource via ACPI resource functions
@ 2013-10-11  6:52 tianyu.lan
  2013-10-11  6:52 ` [PATCH 3/5] ACPI: Add new acpi_dev_resource_address_space_full() function tianyu.lan
  2013-10-11  6:52 ` [PATCH 5/5] IA64/PCI/ACPI: Rework PCI root bridge ACPI resource conversion tianyu.lan
  0 siblings, 2 replies; 3+ messages in thread
From: tianyu.lan @ 2013-10-11  6:52 UTC (permalink / raw)
  To: lenb, rjw, yinghai, bhelgaas; +Cc: Lan Tianyu, linux-acpi, linux-kernel

From: Lan Tianyu <tianyu.lan@intel.com>

This patchset is to add memory prefecth flag setting and address
translation support in the ACPI resource function. Convert x86/iad64
PCI root bridge's ACPI resource to generic resource via ACPI resource
functions.

PATCH 3 is to add new function acpi_dev_resource_address_space_full()
to meet requirement that ACPI address space info is still needed after
being converted to generic resource.


Lan Tianyu (5):
  ACPI/Resource: Add memory prefetch check support
  ACPI/Resource: Add address translation support
  ACPI: Add new acpi_dev_resource_address_space_full() function
  X86/PCI/ACPI: Rework setup_resource() via functions ACPI resource
    functions
  IA64/PCI/ACPI: Rework PCI root bridge ACPI resource conversion

 arch/ia64/pci/pci.c     | 36 ++++++++++++----------
 arch/x86/pci/acpi.c     | 81 ++++++++-----------------------------------------
 drivers/acpi/resource.c | 54 ++++++++++++++++++++++++---------
 include/linux/acpi.h    |  3 ++
 4 files changed, 74 insertions(+), 100 deletions(-)

-- 
1.8.2.1


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

* [PATCH 3/5] ACPI: Add new acpi_dev_resource_address_space_full() function
  2013-10-11  6:52 [PATCH 0/5] ACPI/PCI: Parse PCI root bridge's ACPI resource via ACPI resource functions tianyu.lan
@ 2013-10-11  6:52 ` tianyu.lan
  2013-10-11  6:52 ` [PATCH 5/5] IA64/PCI/ACPI: Rework PCI root bridge ACPI resource conversion tianyu.lan
  1 sibling, 0 replies; 3+ messages in thread
From: tianyu.lan @ 2013-10-11  6:52 UTC (permalink / raw)
  To: lenb, rjw, yinghai, bhelgaas; +Cc: Lan Tianyu, linux-acpi, linux-kernel

From: Lan Tianyu <tianyu.lan@intel.com>

Make acpi_dev_resource_address_space() to accept struct
acpi_resource_address64 as param and rename it to *_full.

This is for some cases that acpi address info is also needed
after convert from acpi resouce to generic resource.

Add acpi_dev_resource_addres_space() again as a wrapper of new
function for original users.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 drivers/acpi/resource.c | 53 ++++++++++++++++++++++++++++++++++---------------
 include/linux/acpi.h    |  3 +++
 2 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index 84bc3db..2e395ba 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -162,19 +162,21 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res)
 EXPORT_SYMBOL_GPL(acpi_dev_resource_io);
 
 /**
- * acpi_dev_resource_address_space - Extract ACPI address space information.
+ * acpi_dev_resource_address_space_full - Extract ACPI address space information.
  * @ares: Input ACPI resource object.
+ * @addr: Output ACPI resource address64 space object.
  * @res: Output generic resource object.
  *
  * Check if the given ACPI resource object represents an address space resource
- * and if that's the case, use the information in it to populate the generic
- * resource object pointed to by @res.
+ * and if that's the case, convert it to ACPI resource address64 space object
+ * pointed to by @addr and use the information to populate the generic resource
+ * object pointed to by @re.
  */
-bool acpi_dev_resource_address_space(struct acpi_resource *ares,
+bool acpi_dev_resource_address_space_full(struct acpi_resource *ares,
+				     struct acpi_resource_address64 *addr,
 				     struct resource *res)
 {
 	acpi_status status;
-	struct acpi_resource_address64 addr;
 	bool window;
 	u64 len;
 	u8 io_decode;
@@ -188,29 +190,29 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,
 		return false;
 	}
 
-	status = acpi_resource_to_address64(ares, &addr);
+	status = acpi_resource_to_address64(ares, addr);
 	if (ACPI_FAILURE(status))
 		return true;
 
-	res->start = addr.minimum + addr.translation_offset;
-	res->end = addr.maximum + addr.translation_offset;
-	window = addr.producer_consumer == ACPI_PRODUCER;
+	res->start = addr->minimum + addr->translation_offset;
+	res->end = addr->maximum + addr->translation_offset;
+	window = addr->producer_consumer == ACPI_PRODUCER;
 
-	switch(addr.resource_type) {
+	switch (addr->resource_type) {
 	case ACPI_MEMORY_RANGE:
-		len = addr.maximum - addr.minimum + 1;
+		len = addr->maximum - addr->minimum + 1;
 		res->flags = acpi_dev_memresource_flags(len,
-						addr.info.mem.write_protect,
+						addr->info.mem.write_protect,
 						window);
 
-		if (addr.info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
+		if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY)
 			res->flags |= IORESOURCE_PREFETCH;
 		break;
 	case ACPI_IO_RANGE:
-		io_decode = addr.granularity == 0xfff ?
+		io_decode = addr->granularity == 0xfff ?
 				ACPI_DECODE_10 : ACPI_DECODE_16;
-		res->flags = acpi_dev_ioresource_flags(addr.minimum,
-						       addr.maximum,
+		res->flags = acpi_dev_ioresource_flags(addr->minimum,
+						       addr->maximum,
 						       io_decode, window);
 		break;
 	case ACPI_BUS_NUMBER_RANGE:
@@ -222,6 +224,25 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares,
 
 	return true;
 }
+EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space_full);
+
+/**
+ * acpi_dev_resource_address_space - Extract ACPI address space information.
+ * @ares: Input ACPI resource object.
+ * @res: Output generic resource object.
+ *
+ * Check if the given ACPI resource object represents an address space resource
+ * and if that's the case, use the information in it to populate the generic
+ * resource object pointed to by @res.
+ */
+bool acpi_dev_resource_address_space(struct acpi_resource *ares,
+				     struct resource *res)
+{
+	struct acpi_resource_address64 addr;
+
+	return acpi_dev_resource_address_space_full(ares, &addr,
+							 res);
+}
 EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space);
 
 /**
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index a5db4ae..1f6701e 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -260,6 +260,9 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res);
 bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res);
 bool acpi_dev_resource_address_space(struct acpi_resource *ares,
 				     struct resource *res);
+bool acpi_dev_resource_address_space_full(struct acpi_resource *ares,
+				struct acpi_resource_address64 *addr,
+				struct resource *res);
 bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares,
 					 struct resource *res);
 unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);
-- 
1.8.2.1


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

* [PATCH 5/5] IA64/PCI/ACPI: Rework PCI root bridge ACPI resource conversion
  2013-10-11  6:52 [PATCH 0/5] ACPI/PCI: Parse PCI root bridge's ACPI resource via ACPI resource functions tianyu.lan
  2013-10-11  6:52 ` [PATCH 3/5] ACPI: Add new acpi_dev_resource_address_space_full() function tianyu.lan
@ 2013-10-11  6:52 ` tianyu.lan
  1 sibling, 0 replies; 3+ messages in thread
From: tianyu.lan @ 2013-10-11  6:52 UTC (permalink / raw)
  To: tony.luck, bhelgaas, lenb, rjw, yinghai
  Cc: Lan Tianyu, linux-ia64, linux-kernel

From: Lan Tianyu <tianyu.lan@intel.com>

Using ACPI resource functions to convert ACPI resource to generic resource

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
This patch just passes through compilation test due to no ia64 machine on hand.

 arch/ia64/pci/pci.c | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 2326790..14fa175 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -232,8 +232,9 @@ out:
 	return ~0;
 }
 
-static acpi_status resource_to_window(struct acpi_resource *resource,
-				      struct acpi_resource_address64 *addr)
+static acpi_status resource_to_window(struct acpi_resource *ares,
+				      struct acpi_resource_address64 *addr,
+				      struct resource *res)
 {
 	acpi_status status;
 
@@ -244,7 +245,7 @@ static acpi_status resource_to_window(struct acpi_resource *resource,
 	 *	- producers, i.e., the address space is routed downstream,
 	 *	  not consumed by the bridge itself
 	 */
-	status = acpi_resource_to_address64(resource, addr);
+	status = acpi_dev_resource_address_space_full(ares, addr, res);
 	if (ACPI_SUCCESS(status) &&
 	    (addr->resource_type == ACPI_MEMORY_RANGE ||
 	     addr->resource_type == ACPI_IO_RANGE) &&
@@ -255,51 +256,54 @@ static acpi_status resource_to_window(struct acpi_resource *resource,
 	return AE_ERROR;
 }
 
-static acpi_status count_window(struct acpi_resource *resource, void *data)
+static acpi_status count_window(struct acpi_resource *ares, void *data)
 {
 	unsigned int *windows = (unsigned int *) data;
 	struct acpi_resource_address64 addr;
+	struct resource res;
 	acpi_status status;
 
-	status = resource_to_window(resource, &addr);
+	status = resource_to_window(ares, &addr, &res);
 	if (ACPI_SUCCESS(status))
 		(*windows)++;
 
 	return AE_OK;
 }
 
-static acpi_status add_window(struct acpi_resource *res, void *data)
+static acpi_status add_window(struct acpi_resource *ares, void *data)
 {
 	struct pci_root_info *info = data;
-	struct resource *resource;
+	struct resource *resource = &info->res[info->res_num];
 	struct acpi_resource_address64 addr;
 	acpi_status status;
-	unsigned long flags, offset = 0;
+	unsigned long offset = 0;
 	struct resource *root;
 
 	/* Return AE_OK for non-window resources to keep scanning for more */
-	status = resource_to_window(res, &addr);
+	status = resource_to_window(ares, &addr, resource);
 	if (!ACPI_SUCCESS(status))
 		return AE_OK;
 
-	if (addr.resource_type == ACPI_MEMORY_RANGE) {
-		flags = IORESOURCE_MEM;
+	if (resource->flags & IORESOURCE_MEM) {
 		root = &iomem_resource;
 		offset = addr.translation_offset;
-	} else if (addr.resource_type == ACPI_IO_RANGE) {
-		flags = IORESOURCE_IO;
+	} else if (resource->flags & IORESOURCE_IO) {
 		root = &ioport_resource;
 		offset = add_io_space(info, &addr);
 		if (offset == ~0)
 			return AE_OK;
+
+		/*
+		 * io space address translation offset depends
+		 * on the return value of add_io_space(). So
+		 * Repopulate resource->start and end here.
+		 */
+		resource->start = addr.minimum + offset;
+		resource->end = resource->start + addr.address_length - 1;
 	} else
 		return AE_OK;
 
-	resource = &info->res[info->res_num];
 	resource->name = info->name;
-	resource->flags = flags;
-	resource->start = addr.minimum + offset;
-	resource->end = resource->start + addr.address_length - 1;
 	info->res_offset[info->res_num] = offset;
 
 	if (insert_resource(root, resource)) {
-- 
1.8.2.1


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

end of thread, other threads:[~2013-10-11  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-11  6:52 [PATCH 0/5] ACPI/PCI: Parse PCI root bridge's ACPI resource via ACPI resource functions tianyu.lan
2013-10-11  6:52 ` [PATCH 3/5] ACPI: Add new acpi_dev_resource_address_space_full() function tianyu.lan
2013-10-11  6:52 ` [PATCH 5/5] IA64/PCI/ACPI: Rework PCI root bridge ACPI resource conversion tianyu.lan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®