Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1526504

[PATCH v9 01/16] drivers: acpi: add FWNODE_ACPI_STATIC fwnode type

From Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Newsgroups linux.kernel
Subject [PATCH v9 01/16] drivers: acpi: add FWNODE_ACPI_STATIC fwnode type
Date 2016-11-21 11:10 +0100
Message-ID <sFTHX-8fb-21@gated-at.bofh.it> (permalink)
References <sFTHX-8fb-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On systems booting with a device tree, every struct device is associated
with a struct device_node, that provides its DT firmware representation.
The device node can be used in generic kernel contexts (eg IRQ
translation, IOMMU streamid mapping), to retrieve the properties
associated with the device and carry out kernel operations accordingly.
Owing to the 1:1 relationship between the device and its device_node,
the device_node can also be used as a look-up token for the device (eg
looking up a device through its device_node), to retrieve the device in
kernel paths where the device_node is available.

On systems booting with ACPI, the same abstraction provided by
the device_node is required to provide look-up functionality.

The struct acpi_device, that represents firmware objects in the
ACPI namespace already includes a struct fwnode_handle of
type FWNODE_ACPI as their member; the same abstraction is missing
though for devices that are instantiated out of static ACPI tables
entries (eg ARM SMMU devices).

Add a new fwnode_handle type to associate devices created out
of static ACPI table entries to the respective firmware components
and create a simple ACPI core layer interface to dynamically allocate
and free the corresponding firmware nodes so that kernel subsystems
can use it to instantiate the nodes and associate them with the
respective devices.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
Reviewed-by: Tomasz Nowicki <tn@semihalf.com>
Tested-by: Hanjun Guo <hanjun.guo@linaro.org>
Tested-by: Tomasz Nowicki <tn@semihalf.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
---
 include/linux/acpi.h   | 21 +++++++++++++++++++++
 include/linux/fwnode.h |  3 ++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 61a3d90..996a29c 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -56,6 +56,27 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
 	acpi_fwnode_handle(adev) : NULL)
 #define ACPI_HANDLE(dev)		acpi_device_handle(ACPI_COMPANION(dev))
 
+static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
+{
+	struct fwnode_handle *fwnode;
+
+	fwnode = kzalloc(sizeof(struct fwnode_handle), GFP_KERNEL);
+	if (!fwnode)
+		return NULL;
+
+	fwnode->type = FWNODE_ACPI_STATIC;
+
+	return fwnode;
+}
+
+static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
+{
+	if (WARN_ON(!fwnode || fwnode->type != FWNODE_ACPI_STATIC))
+		return;
+
+	kfree(fwnode);
+}
+
 /**
  * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with
  * the PCI-defined class-code information
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 8516717..8bd28ce 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -17,8 +17,9 @@ enum fwnode_type {
 	FWNODE_OF,
 	FWNODE_ACPI,
 	FWNODE_ACPI_DATA,
+	FWNODE_ACPI_STATIC,
 	FWNODE_PDATA,
-	FWNODE_IRQCHIP,
+	FWNODE_IRQCHIP
 };
 
 struct fwnode_handle {
-- 
2.10.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v9 00/16] ACPI IORT ARM SMMU support Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 16/16] drivers: acpi: iort: introduce iort_iommu_configure Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 13/16] drivers: iommu: arm-smmu: add IORT configuration Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 03/16] drivers: acpi: iort: add support for IOMMU fwnode registration Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 11/16] drivers: iommu: arm-smmu-v3: add IORT configuration Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 04/16] drivers: iommu: make of_iommu_set/get_ops() DT agnostic Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 02/16] drivers: acpi: iort: introduce linker section for IORT entries probing Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 01/16] drivers: acpi: add FWNODE_ACPI_STATIC fwnode type Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 07/16] drivers: acpi: implement acpi_dma_configure Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 09/16] drivers: acpi: iort: add support for ARM SMMU platform devices creation Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 08/16] drivers: acpi: iort: add node match function Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 06/16] drivers: iommu: arm-smmu-v3: convert struct device of_node to fwnode usage Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 12/16] drivers: iommu: arm-smmu: split probe functions into DT/generic portions Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 10/16] drivers: iommu: arm-smmu-v3: split probe functions into DT/generic portions Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 14/16] drivers: acpi: iort: replace rid map type with type mask Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100
  [PATCH v9 15/16] drivers: acpi: iort: add single mapping function Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> - 2016-11-21 11:10 +0100

csiph-web