Skip to content

Commit 027b25b

Browse files
Lorenzo Pieralisiwildea01
authored andcommitted
ACPI: Add FWNODE_ACPI_STATIC fwnode type
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> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 6eb18d4 commit 027b25b

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

include/linux/acpi.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,27 @@ static inline acpi_handle acpi_device_handle(struct acpi_device *adev)
5656
acpi_fwnode_handle(adev) : NULL)
5757
#define ACPI_HANDLE(dev) acpi_device_handle(ACPI_COMPANION(dev))
5858

59+
static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
60+
{
61+
struct fwnode_handle *fwnode;
62+
63+
fwnode = kzalloc(sizeof(struct fwnode_handle), GFP_KERNEL);
64+
if (!fwnode)
65+
return NULL;
66+
67+
fwnode->type = FWNODE_ACPI_STATIC;
68+
69+
return fwnode;
70+
}
71+
72+
static inline void acpi_free_fwnode_static(struct fwnode_handle *fwnode)
73+
{
74+
if (WARN_ON(!fwnode || fwnode->type != FWNODE_ACPI_STATIC))
75+
return;
76+
77+
kfree(fwnode);
78+
}
79+
5980
/**
6081
* ACPI_DEVICE_CLASS - macro used to describe an ACPI device with
6182
* the PCI-defined class-code information

include/linux/fwnode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ enum fwnode_type {
1717
FWNODE_OF,
1818
FWNODE_ACPI,
1919
FWNODE_ACPI_DATA,
20+
FWNODE_ACPI_STATIC,
2021
FWNODE_PDATA,
21-
FWNODE_IRQCHIP,
22+
FWNODE_IRQCHIP
2223
};
2324

2425
struct fwnode_handle {

0 commit comments

Comments
 (0)