RISC-V: ACPI: Add external interrupt controller support
Sunil V L
maintainerv3 cover RISC-V: ACPI: Add external interrupt controller support
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharing
The series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for fw_devlink for ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.
3) Modified pnp_irq() to try registering the IRQ again if it sees it in disabled state. This solution is similar to how platform_get_irq_optional() works for regular platform devices.
4) Added support for re-ordering the probe of interrupt controllers when IRQCHIP_ACPI_DECLARE is used.
5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!
Changes since RFC v2:
1) Introduced fw_devlink for ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due to fw_devlink support.
3) Dropped pci_set_msi() patch and added a patch in pci_create_root_bus().
4) Updated pnp_irq() patch so that none of the actual PNP drivers need to change.
Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe from core_initcall() to platform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.
To test the series,
1) Qemu should be built using the riscv_acpi_b2_v8 branch at
https://github.com/vlsunil/qemu.git
2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md
3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernel arch/riscv/boot/Image \
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"
To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.
This series is also available in acpi_b2_v3_riscv_aia_v11 branch at
https://github.com/vlsunil/linux.git
Based-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)
Sunil V L (17):
arm64: PCI: Migrate ACPI related functions to pci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Make pci_create_root_bus() declare its reliance on MSI domains
ACPI: Add fw_devlink support for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe in acpi_register_gsi() pnp.h: Reconfigure IRQ in pnp_irq() to support deferred probe
ACPI: scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIA
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Add acpi_riscv_init function
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodel
arch/arm64/kernel/pci.c | 191 --------------------- arch/riscv/Kconfig | 2 + arch/riscv/include/asm/irq.h | 46 +++++ arch/riscv/kernel/acpi.c | 31 ++-- drivers/acpi/bus.c | 4 + drivers/acpi/irq.c | 22 +++ drivers/acpi/property.c | 20 +++ drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 15 ++ drivers/acpi/riscv/init.h | 6 + drivers/acpi/riscv/irq.c | 169 ++++++++++++++++++ drivers/acpi/scan.c | 3 + drivers/irqchip/irq-riscv-aplic-direct.c | 21 ++- drivers/irqchip/irq-riscv-aplic-main.c | 64 ++++--- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 +- drivers/irqchip/irq-riscv-imsic-early.c | 52 +++++- drivers/irqchip/irq-riscv-imsic-platform.c | 51 ++++-- drivers/irqchip/irq-riscv-imsic-state.c | 128 +++++++------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- drivers/irqchip/irq-riscv-intc.c | 96 ++++++++++- drivers/irqchip/irq-sifive-plic.c | 76 ++++++-- drivers/pci/pci-acpi.c | 182 ++++++++++++++++++++ drivers/pci/probe.c | 1 + drivers/pnp/pnpacpi/core.c | 7 + include/linux/acpi.h | 18 ++ include/linux/irqchip/riscv-imsic.h | 10 ++ include/linux/pnp.h | 14 +- 28 files changed, 895 insertions(+), 348 deletions(-) create mode 100644 drivers/acpi/riscv/init.c create mode 100644 drivers/acpi/riscv/init.h create mode 100644 drivers/acpi/riscv/irq.c
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 1/17 arm64: PCI: Migrate ACPI related functions to pci-acpi.c
The functions defined in arm64 for ACPI support are required for RISC-V also. To avoid duplication, move these functions to common location.
--- arch/arm64/kernel/pci.c | 191 ---------------------------------------- drivers/pci/pci-acpi.c | 182 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+), 191 deletions(-)
arch/arm64/kernel/pci.c +0 -191
@@ -6,28 +6,7 @@* Copyright (C) 2014 ARM Ltd. */ -#include <linux/acpi.h> -#include <linux/init.h> -#include <linux/io.h> -#include <linux/kernel.h> -#include <linux/mm.h> #include <linux/pci.h> -#include <linux/pci-acpi.h> -#include <linux/pci-ecam.h> -#include <linux/slab.h> - -#ifdef CONFIG_ACPI -/* -* Try to assign the IRQ number when probing a new device -*/ -int pcibios_alloc_irq (struct pci_dev *dev) -{ -if (!acpi_disabled) -acpi_pci_irq_enable (dev); - -return 0 ; -} -#endif /* * raw_pci_read/write - Platform-specific PCI config space access.
@@ -61,173 +40,3 @@ int pcibus_to_node(struct pci_bus *bus)EXPORT_SYMBOL (pcibus_to_node);#endif - -#ifdef CONFIG_ACPI - -struct acpi_pci_generic_root_info { -struct acpi_pci_root_info common; -struct pci_config_window *cfg;/* config space mapping */ -}; - -int acpi_pci_bus_find_domain_nr (struct pci_bus *bus) -{ -struct pci_config_window *cfg = bus->sysdata; -struct acpi_device *adev =to_acpi_device (cfg->parent); -struct acpi_pci_root *root =acpi_driver_data (adev); - -return root->segment; -} - -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) -{ -struct pci_config_window *cfg; -struct acpi_device *adev; -struct device *bus_dev; - -if (acpi_disabled) -return 0 ; - - cfg = bridge->bus->sysdata; - -/* -* On Hyper-V there is no corresponding ACPI device for a root bridge, -* therefore ->parent is set as NULL by the driver. And set 'adev' as -* NULL in this case because there is no proper ACPI device. -*/ -if (!cfg->parent) - adev =NULL ; -else - adev =to_acpi_device (cfg->parent); - - bus_dev = &bridge->bus->dev; - -ACPI_COMPANION_SET (&bridge->dev, adev); -set_dev_node (bus_dev,acpi_get_node (acpi_device_handle (adev))); - -return 0 ; -} - -static int pci_acpi_root_prepare_resources (struct acpi_pci_root_info *ci) -{ -struct resource_entry *entry, *tmp; -int status; - - status =acpi_pci_probe_root_resources (ci); -resource_list_for_each_entry_safe (entry, tmp, &ci->resources) { -if (!(entry->res->flags &IORESOURCE_WINDOW )) -resource_list_destroy_entry (entry); - } -return status; -} - -/* -* Lookup the bus range for the domain in MCFG, and set up config space -* mapping. -*/ -static struct pci_config_window * -pci_acpi_setup_ecam_mapping (struct acpi_pci_root *root) -{ -struct device *dev = &root->device->dev; -struct resource *bus_res = &root->secondary; -u16 seg = root->segment; -const struct pci_ecam_ops *ecam_ops; -struct resource cfgres; -struct acpi_device *adev; -struct pci_config_window *cfg; -int ret; - - ret =pci_mcfg_lookup (root, &cfgres, &ecam_ops); -if (ret) { -dev_err (dev,"%04x:%pR ECAM region not found\n" , seg, bus_res); -return NULL ; - } - - adev =acpi_resource_consumer (&cfgres); -if (adev) -dev_info (dev,"ECAM area %pR reserved by %s\n" , &cfgres, -dev_name (&adev->dev)); -else -dev_warn (dev,FW_BUG "ECAM area %pR not reserved in ACPI namespace\n" , - &cfgres); - - cfg =pci_ecam_create (dev, &cfgres, bus_res, ecam_ops); -if (IS_ERR (cfg)) { -dev_err (dev,"%04x:%pR error %ld mapping ECAM\n" , seg, bus_res, -PTR_ERR (cfg)); -return NULL ; - } - -return cfg; -} - -/* release_info: free resources allocated by init_info */ -static void pci_acpi_generic_release_info (struct acpi_pci_root_info *ci) -{ -struct acpi_pci_generic_root_info *ri; - - ri = container_of(ci, struct acpi_pci_generic_root_info, common); -pci_ecam_free (ri->cfg); -kfree (ci->ops); -kfree (ri); -} - -/* Interface called from ACPI code to setup PCI host controller */ -struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root) -{ -struct acpi_pci_generic_root_info *ri; -struct pci_bus *bus, *child; -struct acpi_pci_root_ops *root_ops; -struct pci_host_bridge *host; - - ri =kzalloc (sizeof (*ri),GFP_KERNEL ); -if (!ri) -return NULL ; - - root_ops =kzalloc (sizeof (*root_ops),GFP_KERNEL ); -if (!root_ops) { -kfree (ri); -return NULL ; - } - - ri->cfg =pci_acpi_setup_ecam_mapping (root); -if (!ri->cfg) { -kfree (ri); -kfree (root_ops); -return NULL ; - } - - root_ops->release_info = pci_acpi_generic_release_info; - root_ops->prepare_resources = pci_acpi_root_prepare_resources; - root_ops->pci_ops = (struct pci_ops *)&ri->cfg->ops->pci_ops; - bus =acpi_pci_root_create (root, root_ops, &ri->common, ri->cfg); -if (!bus) -return NULL ; - -/* If we must preserve the resource configuration, claim now */ - host =pci_find_host_bridge (bus); -if (host->preserve_config) -pci_bus_claim_resources (bus); - -/* -* Assign whatever was left unassigned. If we didn't claim above, -* this will reassign everything. -*/ -pci_assign_unassigned_root_bus_resources (bus); - -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); - -return bus; -} - -void pcibios_add_bus (struct pci_bus *bus) -{ -acpi_pci_add_bus (bus); -} - -void pcibios_remove_bus (struct pci_bus *bus) -{ -acpi_pci_remove_bus (bus); -} - -#endif
drivers/pci/pci-acpi.c +182 -0
191 lines not on this page · raw message
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 2/17 RISC-V: ACPI: Implement PCI related functionality
In reply to Sunil V LReplace the dummy implementation for PCI related functions with actual implementation. This needs ECAM and MCFG CONFIG options to be enabled for RISC-V.
--- arch/riscv/Kconfig | 2 ++ arch/riscv/kernel/acpi.c | 31 ++++++++++++++----------------- drivers/pci/pci-acpi.c | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-)
arch/riscv/Kconfig +2 -0
@@ -13,6 +13,7 @@ config 32BIT config RISCV def_bool y select ACPI_GENERIC_GSI if ACPI + select ACPI_MCFG if (ACPI && PCI) select ACPI_REDUCED_HARDWARE_ONLY if ACPI select ARCH_DMA_DEFAULT_COHERENT select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
@@ -151,6 +152,7 @@ config RISCV select OF_EARLY_FLATTREE select OF_IRQ select PCI_DOMAINS_GENERIC if PCI + select PCI_ECAM if (ACPI && PCI) select PCI_MSI if PCI select RISCV_ALTERNATIVE if !XIP_KERNEL select RISCV_APLIC
arch/riscv/kernel/acpi.c +14 -17
@@ -223,29 +223,26 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)#ifdef CONFIG_PCI /* -* These interfaces are defined just to enable building ACPI core. -* TODO: Update it with actual implementation when external interrupt -* controller support is added in RISC-V ACPI. +* raw_pci_read/write - Platform-specific PCI config space access. */ -int raw_pci_read (unsigned int domain,unsigned int bus,unsigned int devfn, -int reg,int len,u32 *val) +int raw_pci_read (unsigned int domain,unsigned int bus, +unsigned int devfn,int reg,int len,u32 *val) { -return PCIBIOS_DEVICE_NOT_FOUND ; -} +struct pci_bus *b =pci_find_bus (domain, bus); -int raw_pci_write (unsigned int domain,unsigned int bus,unsigned int devfn, -int reg,int len,u32 val) -{ -return PCIBIOS_DEVICE_NOT_FOUND ; +if (!b) +return PCIBIOS_DEVICE_NOT_FOUND ; +return b->ops->read (b, devfn, reg, len, val); } -int acpi_pci_bus_find_domain_nr (struct pci_bus *bus) +int raw_pci_write (unsigned int domain,unsigned int bus, +unsigned int devfn,int reg,int len,u32 val) { -return -1 ; -} +struct pci_bus *b =pci_find_bus (domain, bus); -struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root) -{ -return NULL ; +if (!b) +return PCIBIOS_DEVICE_NOT_FOUND ; +return b->ops->write (b, devfn, reg, len, val); } +#endif /* CONFIG_PCI */
drivers/pci/pci-acpi.c +1 -1
@@ -1520,7 +1520,7 @@ static int __init acpi_pci_init(void) }arch_initcall (acpi_pci_init); -#if defined(CONFIG_ARM64 ) +#if defined(CONFIG_ARM64 ) || defined(CONFIG_RISCV )/* * Try to assign the IRQ number when probing a new device
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 3/17 PCI: Make pci_create_root_bus() declare its reliance on MSI domains
In reply to Sunil V LSimilar to [1], declare this dependency for PCI probe in ACPI based flow.
This is required especially for RISC-V platforms where MSI controller can be absent.
[1] - https://lore.kernel.org/all/[email protected]/
--- drivers/pci/probe.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/probe.c +1 -0
@@ -3054,6 +3054,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, bridge->sysdata = sysdata; bridge->busnr = bus; bridge->ops = ops; + bridge->msi_domain = true; error =pci_register_host_bridge (bridge);if (error <0 )
Signature · 1 line
2.39.2
Re: [RFC PATCH v3 03/17] PCI: Make pci_create_root_bus() declare its reliance on MSI domains
Quoted 2 lines · Sunil V L
Similar to [1], declare this dependency for PCI probe in ACPI based flow.
It would be better to refer to this as 9ec37efb8783 ("PCI/MSI: Make pci_host_common_probe() declare its reliance on MSI domains") instead of a link to the mailing list archives.
The git SHA1 is part of the git repo, and git can tell us where that SHA1 is included. The lore URL is external and doesn't say anything about what happened to the patch.
Quoted 4 lines
This is required especially for RISC-V platforms where MSI controller can be absent.
Sunil V L
maintainerRe: [RFC PATCH v3 03/17] PCI: Make pci_create_root_bus() declare its reliance on MSI domains
Quoted 4 lines · Bjorn Helgaas
Quoted 2 lines · Sunil V L
Similar to [1], declare this dependency for PCI probe in ACPI based flow.
Quoted 8 lines
It would be better to refer to this as
9ec37efb8783("PCI/MSI: Makepci_host_common_probe()declare its reliance on MSI domains") instead of a link to the mailing list archives.The git SHA1 is part of the git repo, and git can tell us where that SHA1 is included. The lore URL is external and doesn't say anything about what happened to the patch.
Yes!. Let me update in next version. Thanks!
Quoted 4 lines
Quoted 4 lines
This is required especially for RISC-V platforms where MSI controller can be absent.
Sunil V L
maintainerRFC PATCH v3 4/17 ACPI: Add fw_devlink support for ACPI fwnode for IRQ dependency
In reply to Sunil V LCurrently ACPI doesn't support fw_devlink infrastructure which helps in ordering the driver probe in the order of dependencies. One of the dependency between devices in ACPI is GSI interrupt source. This interrupt source can be another device and mentioned as part of ResourceSource in the ASL. Or it can be indirectly determined by the GSI mapping. In either way, adding the link for this dependency avoids modifying all drivers to handle EPROBE_DEFER. So, add this new interface into ACPI's fwnode handlers.
Currently, this is necessary for RISC-V architecture. So, kept the interface functional only for RISC-V. But in future other architectures also can enable this functionality or can be made common.
--- drivers/acpi/irq.c | 18 ++++++++++++++++++ drivers/acpi/property.c | 20 ++++++++++++++++++++ include/linux/acpi.h | 9 +++++++++ 3 files changed, 47 insertions(+)
drivers/acpi/irq.c +18 -0
@@ -354,3 +354,21 @@ struct irq_domain *acpi_irq_create_hierarchy(unsigned int flags, host_data); }EXPORT_SYMBOL_GPL (acpi_irq_create_hierarchy); + +int acpi_get_gsi_parent_fwnode (acpi_handle handle, +unsigned int index, +struct fwnode_handle **parent) +{ +struct irq_fwspec fwspec; +unsigned long flags; +int rc; + + fwspec.fwnode =NULL ; + rc =acpi_irq_parse_one (handle, index, &fwspec, &flags); +if (rc || !fwspec.fwnode) +return 0 ; + + *parent = fwspec.fwnode; +return 1 ; +} +EXPORT_SYMBOL_GPL (acpi_get_gsi_parent_fwnode);
drivers/acpi/property.c +20 -0
@@ -1572,6 +1572,25 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode,return res.start; } +static int acpi_fwnode_add_links (struct fwnode_handle *fwnode) +{ +struct fwnode_handle *parent_fwnode; +unsigned int i; + +/* This is needed primarily for RISC-V. Other architectures can +* be enabled or made this generic if required. +*/ +if (!IS_ENABLED (CONFIG_RISCV )) +return 0 ; + +for (i =0 ; +acpi_get_gsi_parent_fwnode (ACPI_HANDLE_FWNODE (fwnode), i, &parent_fwnode); + i++) +fwnode_link_add (fwnode, parent_fwnode); + +return 0 ; +} +#define DECLARE_ACPI_FWNODE_OPS (ops) \ const struct fwnode_operations ops = { \ .device_is_available = acpi_fwnode_device_is_available, \
@@ -1597,6 +1616,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode, .graph_get_port_parent = acpi_fwnode_get_parent, \ .graph_parse_endpoint = acpi_fwnode_graph_parse_endpoint, \ .irq_get = acpi_fwnode_irq_get, \ + .add_links = acpi_fwnode_add_links, \ }; \EXPORT_SYMBOL_GPL (ops)
include/linux/acpi.h +9 -0
@@ -1463,12 +1463,21 @@ static inline int acpi_parse_spcr(bool enable_earlycon, bool enable_console)#if IS_ENABLED (CONFIG_ACPI_GENERIC_GSI )int acpi_irq_get (acpi_handle handle,unsigned int index,struct resource *res); +int acpi_get_gsi_parent_fwnode (acpi_handle handle,unsigned int index, +struct fwnode_handle **parent);#else static inline int acpi_irq_get (acpi_handle handle,unsigned int index,struct resource *res) {return -EINVAL ; } + +static inline +int acpi_get_gsi_parent_fwnode (acpi_handle handle,unsigned int index, +struct fwnode_handle **parent) +{ +return 0 ; +}#endif #ifdef CONFIG_ACPI_LPIT
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 5/17 ACPI: irq: Add support for deferred probe in acpi_register_gsi()
In reply to Sunil V LThe chip which provides the GSI support may not be initialized at the time of acpi_register_gsi(). Return -EPROBE_DEFER to support deferred probing similar to acpi_irq_get().
This is required to support ResourceSource as supported by ACPI spec for Interrupt resource.
--- drivers/acpi/irq.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/acpi/irq.c +4 -0
@@ -52,6 +52,7 @@ EXPORT_SYMBOL_GPL(acpi_gsi_to_irq);* * Returns: a valid linux IRQ number on success * -EINVAL on failure +* -EPROBE_DEFER if irqdomain not created yet */ int acpi_register_gsi (struct device *dev,u32 gsi,int trigger,int polarity)
@@ -65,6 +66,9 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,return -EINVAL ; } +if (!irq_find_matching_fwnode (fwspec.fwnode,DOMAIN_BUS_ANY )) +return -EPROBE_DEFER ; + fwspec.param[0 ] = gsi; fwspec.param[1 ] =acpi_dev_get_irq_type (trigger, polarity); fwspec.param_count =2 ;
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 6/17 pnp.h: Reconfigure IRQ in pnp_irq() to support deferred probe
In reply to Sunil V LPNP devices add the IRQ resources to PNP data structure early during boot from ACPI resource structure. As part of this, the Interrupt resource (GSI) are registered and appropriate linux IRQ is saved directly in PNP data structure while creating PNP devices. But at this time, the interrupt controller for the GSI (either via GSI vector mapping or via ResourceSource in Interrupt()) may not be probed and initialized. Hence, the IRQ number in PNP data structure may not be the linux IRQ number. When the actual driver for the PNP device get probed, it will get incorrect linux IRQ number.
Fix this issue similar to how platform devices handle this. Basically, while creating PNP devices, the hwirq number is saved in PNP device and marked as disabled since acpi_register_gsi() would have failed. When the actual driver calls pnp_irq(), get the linux IRQ number again if the IRQ is disabled.
--- drivers/pnp/pnpacpi/core.c | 7 +++++++ include/linux/pnp.h | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/pnp/pnpacpi/core.c +7 -0
@@ -326,3 +326,10 @@ static int __init pnpacpi_setup(char *str) }__setup ("pnpacpi=" , pnpacpi_setup); + +void pnpacpi_reconfigure_irq (struct pnp_dev *dev,unsigned int index,struct resource *res) +{ +if (has_acpi_companion (&dev->dev)) +acpi_irq_get (ACPI_HANDLE (&dev->dev), index, res); +} +EXPORT_SYMBOL (pnpacpi_reconfigure_irq);
include/linux/pnp.h +12 -2
@@ -26,6 +26,7 @@ struct pnp_dev;#ifdef CONFIG_PNP struct resource *pnp_get_resource (struct pnp_dev *dev,unsigned long type,unsigned int num); +#else static inline struct resource *pnp_get_resource (struct pnp_dev *dev,unsigned long type,unsigned int num)
@@ -146,13 +147,22 @@ static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,return 0 ; } +#ifdef CONFIG_PNPACPI +void pnpacpi_reconfigure_irq (struct pnp_dev *dev,unsigned int index,struct resource *res); +#endif -static inline resource_size_t pnp_irq (struct pnp_dev *dev,unsigned int bar) +static inline int pnp_irq (struct pnp_dev *dev,unsigned int bar) {struct resource *res =pnp_get_resource (dev,IORESOURCE_IRQ , bar); -if (pnp_resource_valid (res)) +if (pnp_resource_valid (res)) { +#ifdef CONFIG_PNPACPI +if (!pnp_resource_enabled (res)) +pnpacpi_reconfigure_irq (dev, bar, res); +#endif return res->start; + } +return -1 ; }
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 7/17 ACPI: scan.c: Add weak arch specific function to reorder the IRQCHIP probe
In reply to Sunil V LUnlike OF framework, the irqchip probe using IRQCHIP_ACPI_DECLARE has no order defined. Depending on the driver Makefile is not a good idea. So, usually it is worked around by mandating only root interrupt controller probed using IRQCHIP_ACPI_DECLARE and other interrupt controllers are probed via cascade mechanism.
However, this is also not a clean solution because if there are multiple root controllers (ex: RINTC in RISC-V which is per CPU) which need to be probed first, then the cascade will happen for every root controller. So, introduce a architecture specific weak function to order the probing of the interrupt controllers which can be implemented by different architectures as per their interrupt controller hierarchy.
--- drivers/acpi/scan.c | 3 +++ include/linux/acpi.h | 2 ++ 2 files changed, 5 insertions(+)
drivers/acpi/scan.c +3 -0
@@ -2685,6 +2685,8 @@ static int __init acpi_match_madt(union acpi_subtable_headers *header,return 0 ; } +void __weak arch_sort_irqchip_probe (struct acpi_probe_entry *ap_head,int nr) { } +int __init __acpi_probe_device_table (struct acpi_probe_entry *ap_head,int nr) {int count =0 ;
@@ -2693,6 +2695,7 @@ int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)return 0 ;mutex_lock (&acpi_probe_mutex); +arch_sort_irqchip_probe (ap_head, nr);for (ape = ap_head; nr; ape++, nr--) {if (ACPI_COMPARE_NAMESEG (ACPI_SIG_MADT , ape->id)) { acpi_probe_count =0 ;
include/linux/acpi.h +2 -0
@@ -1338,6 +1338,8 @@ struct acpi_probe_entry {kernel_ulong_t driver_data; }; +void arch_sort_irqchip_probe (struct acpi_probe_entry *ap_head,int nr); +#define ACPI_DECLARE_PROBE_ENTRY (table, name, table_id, subtable, \ valid, data, fn) \ static const struct acpi_probe_entry __acpi_probe_##name \
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 8/17 ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
In reply to Sunil V LACPI MADT entries for interrupt controllers don't have a way to describe the hierarchy. However, the hierarchy is known to the architecture and on RISC-V platforms, the MADT sub table types are ordered in the incremental order from the root controller which is RINTC. So, add architecture function for RISC-V to reorder the interrupt controller probing as per the hierarchy as below.
RINTC->IMSIC->APLIC->PLIC
--- drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/irq.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/irq.c
drivers/acpi/riscv/Makefile +1 -1
@@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o +obj-y += rhct.o irq.o
drivers/acpi/riscv/irq.c new file +32 -0
@@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023, Ventana Micro Systems Inc +* Author: Sunil V L <[email protected]> +* +*/ + +#include <linux/acpi.h> +#include <linux/sort.h> + +static int irqchip_cmp_func (const void *in0,const void *in1) +{ +struct acpi_probe_entry *elem0 = (struct acpi_probe_entry *)in0; +struct acpi_probe_entry *elem1 = (struct acpi_probe_entry *)in1; + +return (elem0->type > elem1->type) - (elem0->type < elem1->type); +} + +/* +* RISC-V irqchips in MADT of ACPI spec are defined in the same order how +* they should be probed. Since IRQCHIP_ACPI_DECLARE doesn't define any +* order, this arch function will reorder the probe functions as per the +* required order for the architecture. +*/ +void arch_sort_irqchip_probe (struct acpi_probe_entry *ap_head,int nr) +{ +struct acpi_probe_entry *ape = ap_head; + +if (nr ==1 || !ACPI_COMPARE_NAMESEG (ACPI_SIG_MADT , ape->id)) +return ; +sort (ape, nr,sizeof (*ape), irqchip_cmp_func,NULL ); +}
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 9/17 irqchip: riscv-intc: Add ACPI support for AIA
In reply to Sunil V LThe RINTC subtype structure in MADT also has information about other interrupt controllers. Save this information and provide interfaces to retrieve them when required by corresponding drivers.
--- arch/riscv/include/asm/irq.h | 45 +++++++++++++++ drivers/irqchip/irq-riscv-intc.c | 95 +++++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 1 deletion(-)
arch/riscv/include/asm/irq.h +45 -0
@@ -12,8 +12,53 @@#include <asm-generic/irq.h> +#ifdef CONFIG_ACPI + +/* +* The ext_intc_id format is as follows: +* Bits [31:24] APLIC/PLIC ID +* Bits [15:0] APLIC IDC ID / PLIC S-Mode Context ID for this hart +*/ +#define APLIC_PLIC_ID (x) ((x) >> 24) +#define IDC_CONTEXT_ID (x) ((x) & 0x0000ffff) + +int __init acpi_get_intc_index_hartid (u32 index,unsigned long *hartid); +int acpi_get_ext_intc_parent_hartid (u8 id,u32 idx,unsigned long *hartid); +void acpi_get_plic_nr_contexts (u8 id,int *nr_contexts); +int acpi_get_plic_context (u8 id,u32 idx,int *context_id); +int __init acpi_get_imsic_mmio_info (u32 index,struct resource *res); + +#else +static inline struct fwnode_handle *ext_entc_get_gsi_domain_id (u32 gsi) +{ +return NULL ; +} + +static inline int __init acpi_get_intc_index_hartid (u32 index,unsigned long *hartid) +{ +return -EINVAL ; +} + +static inline int acpi_get_ext_intc_parent_hartid (u8 id,u32 idx,unsigned long *hartid) +{ +return -EINVAL ; +} + +static inline void acpi_get_plic_nr_contexts (u8 id,int *nr_contexts) { } +static inline int acpi_get_plic_context (u8 id,u32 idx,int *context_id) +{ +return -EINVAL ; +} + +static inline int __init acpi_get_imsic_mmio_info (u32 index,struct resource *res) +{ +return -EINVAL ; +} +#endif +void riscv_set_intc_hwnode_fn (struct fwnode_handle *(*fn)(void ));struct fwnode_handle *riscv_get_intc_hwnode (void ); +int acpi_imsic_probe (struct fwnode_handle *parent);#endif /* _ASM_RISCV_IRQ_H */
drivers/irqchip/irq-riscv-intc.c +94 -1
114 lines not on this page · raw message
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 10/17 irqchip: riscv-imsic: Add ACPI support
In reply to Sunil V LRISC-V IMSIC interrupt controller provides IPI and MSI support. Currently, DT based drivers setup the IPI feature early during boot but defer setting up the MSI functionality. However, in ACPI systems, PCI scan happens early during boot and PCI subsystem expects MSI controller is already setup. Hence, in case of ACPI, both IPI and MSI features are initialized early itself.
--- drivers/irqchip/irq-riscv-imsic-early.c | 52 ++++++++- drivers/irqchip/irq-riscv-imsic-platform.c | 51 +++++--- drivers/irqchip/irq-riscv-imsic-state.c | 128 ++++++++++----------- drivers/irqchip/irq-riscv-imsic-state.h | 2 +- include/linux/irqchip/riscv-imsic.h | 10 ++ 5 files changed, 160 insertions(+), 83 deletions(-)
drivers/irqchip/irq-riscv-imsic-early.c +51 -1
@@ -5,13 +5,16 @@*/ #define pr_fmt (fmt) "riscv-imsic: " fmt +#include <linux/acpi.h> #include <linux/cpu.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/irq.h> #include <linux/irqchip.h> #include <linux/irqchip/chained_irq.h> +#include <linux/irqchip/riscv-imsic.h> #include <linux/module.h> +#include <linux/pci.h> #include <linux/spinlock.h> #include <linux/smp.h>
@@ -216,7 +219,7 @@ static int __init imsic_early_dt_init(struct device_node *node,struct fwnode_handle *fwnode = &node->fwnode;/* Setup IMSIC state */ - rc =imsic_setup_state (fwnode); + rc =imsic_setup_state (fwnode,NULL );if (rc) {pr_err ("%pfwP: failed to setup state (error %d)\n" , fwnode, rc);
@@ -233,3 +236,50 @@ static int __init imsic_early_dt_init(struct device_node *node,return 0 ; }IRQCHIP_DECLARE (riscv_imsic,"riscv,imsics" , imsic_early_dt_init); + +#ifdef CONFIG_ACPI + +static struct fwnode_handle *imsic_acpi_fwnode; + +struct fwnode_handle *imsic_acpi_get_fwnode (struct device *dev) +{ +return imsic_acpi_fwnode; +} + +static int __init imsic_early_acpi_init (union acpi_subtable_headers *header, +const unsigned long end) +{ +struct acpi_madt_imsic *imsic = (struct acpi_madt_imsic *)header; +int rc; + + imsic_acpi_fwnode =irq_domain_alloc_named_fwnode ("imsic" ); +if (!imsic_acpi_fwnode) { +pr_err ("unable to allocate IMSIC FW node\n" ); +return -ENOMEM ; + } + +/* Setup IMSIC state */ + rc =imsic_setup_state (imsic_acpi_fwnode, (void *)imsic); +if (rc) { +pr_err ("%pfwP: failed to setup state (error %d)\n" , imsic_acpi_fwnode, rc); +return rc; + } + +/* Do early setup of IMSIC state and IPIs */ + rc =imsic_early_probe (imsic_acpi_fwnode); +if (rc) +return rc; + + rc =imsic_platform_acpi_probe (imsic_acpi_fwnode); + +#ifdef CONFIG_PCI +if (!rc) +pci_msi_register_fwnode_provider (&imsic_acpi_get_fwnode); +#endif + +return rc; +} + +IRQCHIP_ACPI_DECLARE (riscv_imsic,ACPI_MADT_TYPE_IMSIC ,NULL , +1 , imsic_early_acpi_init); +#endif
drivers/irqchip/irq-riscv-imsic-platform.c +36 -15
91 lines not on this page · raw message
drivers/irqchip/irq-riscv-imsic-state.c +62 -66
184 lines not on this page · raw message
drivers/irqchip/irq-riscv-imsic-state.h +1 -1
@@ -105,6 +105,6 @@ void imsic_vector_debug_show_summary(struct seq_file *m, int ind);int imsic_hwirqs_alloc (unsigned int order);void imsic_hwirqs_free (unsigned int base_hwirq,unsigned int order); -int imsic_setup_state (struct fwnode_handle *fwnode); +int imsic_setup_state (struct fwnode_handle *fwnode,void *opaque);#endif
include/linux/irqchip/riscv-imsic.h +10 -0
@@ -84,4 +84,14 @@ static inline const struct imsic_global_config *imsic_get_global_config(void)#endif +#ifdef CONFIG_ACPI +int imsic_platform_acpi_probe (struct fwnode_handle *fwnode); +struct fwnode_handle *imsic_acpi_get_fwnode (struct device *dev); +#else +static inline struct fwnode_handle *imsic_acpi_get_fwnode (struct device *dev) +{ +return NULL ; +} +#endif +#endif
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 11/17 irqchip: riscv-aplic: Add ACPI support
In reply to Sunil V LAdd ACPI support in APLIC drivers. In ACPI, IO devices use Global System Interrupts (GSI) which is a flat space split across multiple APLICs.
--- arch/riscv/include/asm/irq.h | 6 +++ drivers/irqchip/irq-riscv-aplic-direct.c | 21 +++++--- drivers/irqchip/irq-riscv-aplic-main.c | 64 ++++++++++++++---------- drivers/irqchip/irq-riscv-aplic-main.h | 1 + drivers/irqchip/irq-riscv-aplic-msi.c | 9 +++- 5 files changed, 66 insertions(+), 35 deletions(-)
arch/riscv/include/asm/irq.h +6 -0
@@ -22,6 +22,12 @@#define APLIC_PLIC_ID (x) ((x) >> 24)#define IDC_CONTEXT_ID (x) ((x) & 0x0000ffff) +#ifdef CONFIG_RISCV_APLIC +struct fwnode_handle *aplic_get_gsi_domain_id (u32 gsi); +#else +static inline struct fwnode_handle *aplic_get_gsi_domain_id (u32 gsi) {return NULL ; } +#endif +int __init acpi_get_intc_index_hartid (u32 index,unsigned long *hartid);int acpi_get_ext_intc_parent_hartid (u8 id,u32 idx,unsigned long *hartid);void acpi_get_plic_nr_contexts (u8 id,int *nr_contexts);
drivers/irqchip/irq-riscv-aplic-direct.c +13 -8
@@ -4,6 +4,7 @@* Copyright (C) 2022 Ventana Micro Systems Inc. */ +#include <linux/acpi.h> #include <linux/bitops.h> #include <linux/cpu.h> #include <linux/interrupt.h>
@@ -14,6 +15,7 @@#include <linux/of_address.h> #include <linux/printk.h> #include <linux/smp.h> +#include <asm/acpi.h> #include "irq-riscv-aplic-main.h"
@@ -203,17 +205,20 @@ static int aplic_direct_starting_cpu(unsigned int cpu)static int aplic_direct_parse_parent_hwirq (struct device *dev,u32 index,u32 *parent_hwirq, -unsigned long *parent_hartid) +unsigned long *parent_hartid, +struct aplic_priv *priv) {struct of_phandle_args parent;int rc; -/* -* Currently, only OF fwnode is supported so extend this -* function for ACPI support. -*/ -if (!is_of_node (dev->fwnode)) -return -EINVAL ; +if (!is_of_node (dev->fwnode)) { + rc =acpi_get_ext_intc_parent_hartid (priv->id, index, parent_hartid); +if (rc) +return rc; + + *parent_hwirq =RV_IRQ_EXT ; +return 0 ; + } rc =of_irq_parse_one (to_of_node (dev->fwnode), index, &parent);if (rc)
@@ -251,7 +256,7 @@ int aplic_direct_setup(struct device *dev, void __iomem *regs)/* Setup per-CPU IDC and target CPU mask */ for (i =0 ; i < priv->nr_idcs; i++) { - rc =aplic_direct_parse_parent_hwirq (dev, i, &hwirq, &hartid); + rc =aplic_direct_parse_parent_hwirq (dev, i, &hwirq, &hartid, priv);if (rc) {dev_warn (dev,"parent irq for IDC%d not found\n" , i);continue ;
drivers/irqchip/irq-riscv-aplic-main.c +38 -26
94 lines not on this page · raw message
drivers/irqchip/irq-riscv-aplic-main.h +1 -0
@@ -28,6 +28,7 @@ struct aplic_priv {u32 gsi_base;u32 nr_irqs;u32 nr_idcs; +u32 id;void __iomem *regs;struct aplic_msicfg msicfg; };
drivers/irqchip/irq-riscv-aplic-msi.c +8 -1
@@ -178,6 +178,7 @@ static void aplic_msi_write_msg(struct msi_desc *desc, struct msi_msg *msg)int aplic_msi_setup (struct device *dev,void __iomem *regs) {const struct imsic_global_config *imsic_global; +struct irq_domain *msi_domain;struct irq_domain *irqdomain;struct aplic_priv *priv;struct aplic_msicfg *mc;
@@ -261,8 +262,14 @@ int aplic_msi_setup(struct device *dev, void __iomem *regs)* IMSIC and the IMSIC MSI domains are created later through * the platform driver probing so we set it explicitly here. */ -if (is_of_node (dev->fwnode)) +if (is_of_node (dev->fwnode)) {of_msi_configure (dev,to_of_node (dev->fwnode)); + }else { + msi_domain =irq_find_matching_fwnode (imsic_acpi_get_fwnode (dev), +DOMAIN_BUS_PLATFORM_MSI ); +if (msi_domain) +dev_set_msi_domain (dev, msi_domain); + } }/* Create irq domain instance for the APLIC MSI-mode */
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 12/17 irqchip: irq-sifive-plic: Add ACPI support
In reply to Sunil V LAdd ACPI support in PLIC driver. In ACPI, IO devices use Global System Interrupts (GSI) which is a flat space split across multiple PLICs.
--- arch/riscv/include/asm/irq.h | 6 +++ drivers/irqchip/irq-sifive-plic.c | 76 +++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 18 deletions(-)
arch/riscv/include/asm/irq.h +6 -0
@@ -28,6 +28,12 @@ struct fwnode_handle *aplic_get_gsi_domain_id(u32 gsi);static inline struct fwnode_handle *aplic_get_gsi_domain_id (u32 gsi) {return NULL ; }#endif +#ifdef CONFIG_SIFIVE_PLIC +struct fwnode_handle *plic_get_gsi_domain_id (u32 gsi); +#else +static inline struct fwnode_handle *plic_get_gsi_domain_id (u32 gsi) {return NULL ; } +#endif +int __init acpi_get_intc_index_hartid (u32 index,unsigned long *hartid);int acpi_get_ext_intc_parent_hartid (u8 id,u32 idx,unsigned long *hartid);void acpi_get_plic_nr_contexts (u8 id,int *nr_contexts);
drivers/irqchip/irq-sifive-plic.c +58 -18
155 lines not on this page · raw message
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 13/17 ACPI: bus: Add RINTC IRQ model for RISC-V
In reply to Sunil V LAdd the IRQ model for RISC-V INTC so that acpi_set_irq_model can use this for RISC-V.
--- drivers/acpi/bus.c | 3 +++ include/linux/acpi.h | 1 + 2 files changed, 4 insertions(+)
drivers/acpi/bus.c +3 -0
@@ -1158,6 +1158,9 @@ static int __init acpi_bus_init_irq(void)case ACPI_IRQ_MODEL_LPIC : message ="LPIC" ;break ; +case ACPI_IRQ_MODEL_RINTC : + message ="RINTC" ; +break ;default :pr_info ("Unknown interrupt routing model\n" );return -ENODEV ;
include/linux/acpi.h +1 -0
@@ -95,6 +95,7 @@ enum acpi_irq_model_id {ACPI_IRQ_MODEL_PLATFORM ,ACPI_IRQ_MODEL_GIC ,ACPI_IRQ_MODEL_LPIC , +ACPI_IRQ_MODEL_RINTC , ACPI_IRQ_MODEL_COUNT };
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 14/17 ACPI: bus: Add acpi_riscv_init function
In reply to Sunil V LAdd a new function for RISC-V to do any architecture specific initialization. This function will be used to create platform devices like APLIC, PLIC, RISC-V IOMMU etc. This is similar to acpi_arm_init().
--- drivers/acpi/bus.c | 1 + drivers/acpi/riscv/Makefile | 2 +- drivers/acpi/riscv/init.c | 12 ++++++++++++ include/linux/acpi.h | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 drivers/acpi/riscv/init.c
drivers/acpi/bus.c +1 -0
@@ -1417,6 +1417,7 @@ static int __init acpi_init(void)acpi_hest_init ();acpi_ghes_init ();acpi_arm_init (); +acpi_riscv_init ();acpi_scan_init ();acpi_ec_init ();acpi_debugfs_init ();
drivers/acpi/riscv/Makefile +1 -1
@@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-y += rhct.o irq.o +obj-y += rhct.o irq.o init.o
drivers/acpi/riscv/init.c new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2023, Ventana Micro Systems Inc +* Author: Sunil V L <[email protected]> +* +*/ + +#include <linux/acpi.h> + +void __init acpi_riscv_init (void ) +{ +}
include/linux/acpi.h +6 -0
@@ -1536,6 +1536,12 @@ void acpi_arm_init(void);static inline void acpi_arm_init (void ) { }#endif +#ifdef CONFIG_RISCV +void acpi_riscv_init (void ); +#else +static inline void acpi_riscv_init (void ) { } +#endif +#ifdef CONFIG_ACPI_PCC void acpi_init_pcc (void );#else
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 15/17 ACPI: RISC-V: Create APLIC platform device
In reply to Sunil V LSince APLIC needs to be a platform device, probe the MADT and create platform devices for each APLIC in the system.
--- drivers/acpi/riscv/init.c | 2 + drivers/acpi/riscv/init.h | 5 ++ drivers/acpi/riscv/irq.c | 118 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 drivers/acpi/riscv/init.h
drivers/acpi/riscv/init.c +2 -0
@@ -6,7 +6,9 @@*/ #include <linux/acpi.h> +#include "init.h" void __init acpi_riscv_init (void ) { +riscv_acpi_aplic_platform_init (); }
drivers/acpi/riscv/init.h new file +5 -0
@@ -0,0 +1,5 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include <linux/init.h> + +void __init riscv_acpi_imsic_platform_init (void ); +void __init riscv_acpi_aplic_platform_init (void );
drivers/acpi/riscv/irq.c +118 -0
128 lines not on this page · raw message
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 16/17 ACPI: RISC-V: Create PLIC platform device
In reply to Sunil V LSince PLIC needs to be a platform device, probe the MADT and create platform devices for each PLIC in the system.
--- drivers/acpi/riscv/init.c | 1 + drivers/acpi/riscv/init.h | 1 + drivers/acpi/riscv/irq.c | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+)
drivers/acpi/riscv/init.c +1 -0
@@ -11,4 +11,5 @@void __init acpi_riscv_init (void ) {riscv_acpi_aplic_platform_init (); +riscv_acpi_plic_platform_init (); }
drivers/acpi/riscv/init.h +1 -0
@@ -3,3 +3,4 @@void __init riscv_acpi_imsic_platform_init (void );void __init riscv_acpi_aplic_platform_init (void ); +void __init riscv_acpi_plic_platform_init (void );
drivers/acpi/riscv/irq.c +19 -0
@@ -148,3 +148,22 @@ void __init riscv_acpi_aplic_platform_init(void) {acpi_table_parse_madt (ACPI_MADT_TYPE_APLIC , aplic_parse_madt,0 ); } + +static int __init plic_parse_madt (union acpi_subtable_headers *header, +const unsigned long end) +{ +struct acpi_madt_plic *plic = (struct acpi_madt_plic *)header; + +return irqchip_add_platform_device ("riscv-plic" , + plic->id, + plic->base_addr, + plic->size, + plic->gsi_base, + plic->num_irqs, + header); +} + +void __init riscv_acpi_plic_platform_init (void ) +{ +acpi_table_parse_madt (ACPI_MADT_TYPE_PLIC , plic_parse_madt,0 ); +}
Signature · 1 line
2.39.2
Sunil V L
maintainerRFC PATCH v3 17/17 irqchip: riscv-intc: Set ACPI irqmodel
In reply to Sunil V LINTC being the root interrupt controller, set the ACPI irqmodel with callback function to get the GSI domain id.
--- arch/riscv/include/asm/irq.h | 13 +------------ drivers/irqchip/irq-riscv-intc.c | 1 + 2 files changed, 2 insertions(+), 12 deletions(-)
arch/riscv/include/asm/irq.h +1 -12
@@ -22,18 +22,7 @@#define APLIC_PLIC_ID (x) ((x) >> 24)#define IDC_CONTEXT_ID (x) ((x) & 0x0000ffff) -#ifdef CONFIG_RISCV_APLIC -struct fwnode_handle *aplic_get_gsi_domain_id (u32 gsi); -#else -static inline struct fwnode_handle *aplic_get_gsi_domain_id (u32 gsi) {return NULL ; } -#endif - -#ifdef CONFIG_SIFIVE_PLIC -struct fwnode_handle *plic_get_gsi_domain_id (u32 gsi); -#else -static inline struct fwnode_handle *plic_get_gsi_domain_id (u32 gsi) {return NULL ; } -#endif - +struct fwnode_handle *ext_entc_get_gsi_domain_id (u32 gsi);int __init acpi_get_intc_index_hartid (u32 index,unsigned long *hartid);int acpi_get_ext_intc_parent_hartid (u8 id,u32 idx,unsigned long *hartid);void acpi_get_plic_nr_contexts (u8 id,int *nr_contexts);
drivers/irqchip/irq-riscv-intc.c +1 -0
@@ -311,6 +311,7 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,return rc; } +acpi_set_irq_model (ACPI_IRQ_MODEL_RINTC , ext_entc_get_gsi_domain_id);return 0 ; }
Signature · 1 line
2.39.2
Rafael J. Wysocki
maintainerQuoted 90 lines · Sunil V L
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharingThe series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for
fw_devlinkfor ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.3) Modified
pnp_irq()to try registering the IRQ again if it sees it in disabled state. This solution is similar to howplatform_get_irq_optional()works for regular platform devices.4) Added support for re-ordering the probe of interrupt controllers when
IRQCHIP_ACPI_DECLAREis used.5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing
fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!Changes since RFC v2:
1) Introducedfw_devlinkfor ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due tofw_devlinksupport.
3) Droppedpci_set_msi()patch and added a patch inpci_create_root_bus().
4) Updatedpnp_irq()patch so that none of the actual PNP drivers need to change.Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe fromcore_initcall()toplatform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.To test the series,
1) Qemu should be built using the
riscv_acpi_b2_v8branch at
https://github.com/vlsunil/qemu.git2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernelarch/riscv/boot/Image\
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.This series is also available in
acpi_b2_v3_riscv_aia_v11branch at
https://github.com/vlsunil/linux.gitBased-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)Sunil V L (17):
arm64: PCI: Migrate ACPI related functions topci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Makepci_create_root_bus()declare its reliance on MSI domains
ACPI: Addfw_devlinksupport for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe inacpi_register_gsi()pnp.h: Reconfigure IRQ inpnp_irq()to support deferred probe
ACPI:scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIA
Quoted 8 lines
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Addacpi_riscv_initfunction
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodel
JFYI, I have no capacity to provide any feedback on this till 6.8-rc1 is out.
Thanks!
Sunil V L
maintainerQuoted 100 lines · Rafael J. Wysocki
Quoted 90 lines · Sunil V L
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharingThe series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for
fw_devlinkfor ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.3) Modified
pnp_irq()to try registering the IRQ again if it sees it in disabled state. This solution is similar to howplatform_get_irq_optional()works for regular platform devices.4) Added support for re-ordering the probe of interrupt controllers when
IRQCHIP_ACPI_DECLAREis used.5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing
fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!Changes since RFC v2:
1) Introducedfw_devlinkfor ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due tofw_devlinksupport.
3) Droppedpci_set_msi()patch and added a patch inpci_create_root_bus().
4) Updatedpnp_irq()patch so that none of the actual PNP drivers need to change.Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe fromcore_initcall()toplatform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.To test the series,
1) Qemu should be built using the
riscv_acpi_b2_v8branch at
https://github.com/vlsunil/qemu.git2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernelarch/riscv/boot/Image\
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.This series is also available in
acpi_b2_v3_riscv_aia_v11branch at
https://github.com/vlsunil/linux.gitBased-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)Sunil V L (17):
arm64: PCI: Migrate ACPI related functions topci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Makepci_create_root_bus()declare its reliance on MSI domains
ACPI: Addfw_devlinksupport for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe inacpi_register_gsi()pnp.h: Reconfigure IRQ inpnp_irq()to support deferred probe
ACPI:scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIAQuoted 8 lines
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Addacpi_riscv_initfunction
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodel
Quoted 2 lines
JFYI, I have no capacity to provide any feedback on this till 6.8-rc1 is out.
No worries!. I will wait for your feedback.
Thanks!
Sunil
Sunil V L
maintainerQuoted 100 lines · Rafael J. Wysocki
Quoted 90 lines · Sunil V L
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharingThe series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for
fw_devlinkfor ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.3) Modified
pnp_irq()to try registering the IRQ again if it sees it in disabled state. This solution is similar to howplatform_get_irq_optional()works for regular platform devices.4) Added support for re-ordering the probe of interrupt controllers when
IRQCHIP_ACPI_DECLAREis used.5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing
fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!Changes since RFC v2:
1) Introducedfw_devlinkfor ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due tofw_devlinksupport.
3) Droppedpci_set_msi()patch and added a patch inpci_create_root_bus().
4) Updatedpnp_irq()patch so that none of the actual PNP drivers need to change.Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe fromcore_initcall()toplatform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.To test the series,
1) Qemu should be built using the
riscv_acpi_b2_v8branch at
https://github.com/vlsunil/qemu.git2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernelarch/riscv/boot/Image\
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.This series is also available in
acpi_b2_v3_riscv_aia_v11branch at
https://github.com/vlsunil/linux.gitBased-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)Sunil V L (17):
arm64: PCI: Migrate ACPI related functions topci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Makepci_create_root_bus()declare its reliance on MSI domains
ACPI: Addfw_devlinksupport for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe inacpi_register_gsi()pnp.h: Reconfigure IRQ inpnp_irq()to support deferred probe
ACPI:scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIAQuoted 8 lines
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Addacpi_riscv_initfunction
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodel
Quoted 2 lines
JFYI, I have no capacity to provide any feedback on this till 6.8-rc1 is out.
Hi Rafael,
Gentle ping.
Could you please provide feedback on the series? Patches 4, 5, 6, 7 and 8 are bit critical IMO. So, I really look forward for your and other ACPI experts!.
Thanks!
Sunil
Rafael J. Wysocki
maintainerQuoted 104 lines · Sunil V L
Quoted 100 lines · Rafael J. Wysocki
Quoted 90 lines · Sunil V L
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharingThe series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for
fw_devlinkfor ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.3) Modified
pnp_irq()to try registering the IRQ again if it sees it in disabled state. This solution is similar to howplatform_get_irq_optional()works for regular platform devices.4) Added support for re-ordering the probe of interrupt controllers when
IRQCHIP_ACPI_DECLAREis used.5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing
fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!Changes since RFC v2:
1) Introducedfw_devlinkfor ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due tofw_devlinksupport.
3) Droppedpci_set_msi()patch and added a patch inpci_create_root_bus().
4) Updatedpnp_irq()patch so that none of the actual PNP drivers need to change.Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe fromcore_initcall()toplatform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.To test the series,
1) Qemu should be built using the
riscv_acpi_b2_v8branch at
https://github.com/vlsunil/qemu.git2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernelarch/riscv/boot/Image\
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.This series is also available in
acpi_b2_v3_riscv_aia_v11branch at
https://github.com/vlsunil/linux.gitBased-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)Sunil V L (17):
arm64: PCI: Migrate ACPI related functions topci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Makepci_create_root_bus()declare its reliance on MSI domains
ACPI: Addfw_devlinksupport for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe inacpi_register_gsi()pnp.h: Reconfigure IRQ inpnp_irq()to support deferred probe
ACPI:scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIAQuoted 8 lines
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Addacpi_riscv_initfunction
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodelQuoted 2 lines
JFYI, I have no capacity to provide any feedback on this till 6.8-rc1 is out.
Quoted 7 lines
Hi Rafael,
Gentle ping.
Could you please provide feedback on the series? Patches 4, 5, 6, 7 and 8 are bit critical IMO. So, I really look forward for your and other ACPI experts!.
There was quite a bit of discussion on patch [6/21] and it still seems relevant to me.
ACPI actually has a way to at least indicate what the probe ordering should be which is _DEP.
The current handling of _DEP in the kernel may not be covering this particular use case, but I would rather extend it (if necessary) instead of doing all of the -EPROBE_DEFER dance which seems fragile to me.
Thanks!
Sunil V L
maintainerQuoted 116 lines · Rafael J. Wysocki
Quoted 104 lines · Sunil V L
Quoted 100 lines · Rafael J. Wysocki
Quoted 90 lines · Sunil V L
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharingThe series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for
fw_devlinkfor ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.3) Modified
pnp_irq()to try registering the IRQ again if it sees it in disabled state. This solution is similar to howplatform_get_irq_optional()works for regular platform devices.4) Added support for re-ordering the probe of interrupt controllers when
IRQCHIP_ACPI_DECLAREis used.5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing
fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!Changes since RFC v2:
1) Introducedfw_devlinkfor ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due tofw_devlinksupport.
3) Droppedpci_set_msi()patch and added a patch inpci_create_root_bus().
4) Updatedpnp_irq()patch so that none of the actual PNP drivers need to change.Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe fromcore_initcall()toplatform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.To test the series,
1) Qemu should be built using the
riscv_acpi_b2_v8branch at
https://github.com/vlsunil/qemu.git2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernelarch/riscv/boot/Image\
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.This series is also available in
acpi_b2_v3_riscv_aia_v11branch at
https://github.com/vlsunil/linux.gitBased-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)Sunil V L (17):
arm64: PCI: Migrate ACPI related functions topci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Makepci_create_root_bus()declare its reliance on MSI domains
ACPI: Addfw_devlinksupport for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe inacpi_register_gsi()pnp.h: Reconfigure IRQ inpnp_irq()to support deferred probe
ACPI:scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIAQuoted 8 lines
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Addacpi_riscv_initfunction
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodelQuoted 2 lines
JFYI, I have no capacity to provide any feedback on this till 6.8-rc1 is out.
Quoted 7 lines
Hi Rafael,
Gentle ping.
Could you please provide feedback on the series? Patches 4, 5, 6, 7 and 8 are bit critical IMO. So, I really look forward for your and other ACPI experts!.
There was quite a bit of discussion on patch [6/21] and it still seems relevant to me.
Quoted 8 lines
ACPI actually has a way to at least indicate what the probe ordering should be which is
_DEP.The current handling of
_DEPin the kernel may not be covering this particular use case, but I would rather extend it (if necessary) instead of doing all of the -EPROBE_DEFER dance which seems fragile to me.
Hi Rafael,
Appreciate your help to look at the patches. Thank you very much!.
I am not very sure whether you looked into patches in the v3 of the series. Because, unlike in v2, v3 doesn't need changing all drivers to handle EPROBE_DEFER. In v3, it creates fw_devlink for the dependency as suggested by Marc. Please take a look at PATCH 4/17.
For the IRQ dependency, I think adding _DEP is not required. The "Extended Interrupt Descriptor" supports ResourceSource to indicate the dependency. Or GSI mapping can indicate the source. This is already handled in acpi_irq_parse_one_cb(). PATCH 4 uses this information to create links between producer and consumer so that DD framework probes the driver in the required order.
As you know, PNP devices are enumerated in a different way. I don't know why it was done like this. But pnpacpi_init() is called via fs_initcall() and acpi_dev_resource_interrupt() called from pnpacpi_allocated_resource() doesn't handle the ResourceSource dependency. It caches the information in PNP data structure and expects the IRQ mapping to be available. Even if we add support to handle extended interrupt descriptor, it is not going to help. Hence, I had to add PATCH 5/17 and PATCH 6/17. Again, the change is mainly in pnp_irq() now and hence it doesn't need changing all drivers.
Thanks,
Sunil
Sunil V L
maintainerQuoted 141 lines · Sunil V L
Quoted 116 lines · Rafael J. Wysocki
Quoted 104 lines · Sunil V L
Quoted 100 lines · Rafael J. Wysocki
Quoted 90 lines · Sunil V L
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharingThe series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for
fw_devlinkfor ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.3) Modified
pnp_irq()to try registering the IRQ again if it sees it in disabled state. This solution is similar to howplatform_get_irq_optional()works for regular platform devices.4) Added support for re-ordering the probe of interrupt controllers when
IRQCHIP_ACPI_DECLAREis used.5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing
fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!Changes since RFC v2:
1) Introducedfw_devlinkfor ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due tofw_devlinksupport.
3) Droppedpci_set_msi()patch and added a patch inpci_create_root_bus().
4) Updatedpnp_irq()patch so that none of the actual PNP drivers need to change.Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe fromcore_initcall()toplatform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.To test the series,
1) Qemu should be built using the
riscv_acpi_b2_v8branch at
https://github.com/vlsunil/qemu.git2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernelarch/riscv/boot/Image\
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.This series is also available in
acpi_b2_v3_riscv_aia_v11branch at
https://github.com/vlsunil/linux.gitBased-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)Sunil V L (17):
arm64: PCI: Migrate ACPI related functions topci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Makepci_create_root_bus()declare its reliance on MSI domains
ACPI: Addfw_devlinksupport for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe inacpi_register_gsi()pnp.h: Reconfigure IRQ inpnp_irq()to support deferred probe
ACPI:scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIAQuoted 8 lines
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Addacpi_riscv_initfunction
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodelQuoted 2 lines
JFYI, I have no capacity to provide any feedback on this till 6.8-rc1 is out.
Quoted 7 lines
Hi Rafael,
Gentle ping.
Could you please provide feedback on the series? Patches 4, 5, 6, 7 and 8 are bit critical IMO. So, I really look forward for your and other ACPI experts!.
There was quite a bit of discussion on patch [6/21] and it still seems relevant to me.
Quoted 8 lines
ACPI actually has a way to at least indicate what the probe ordering should be which is
_DEP.The current handling of
_DEPin the kernel may not be covering this particular use case, but I would rather extend it (if necessary) instead of doing all of the -EPROBE_DEFER dance which seems fragile to me.Hi Rafael,
Appreciate your help to look at the patches. Thank you very much!.
I am not very sure whether you looked into patches in the v3 of the series. Because, unlike in v2, v3 doesn't need changing all drivers to handle
EPROBE_DEFER. In v3, it createsfw_devlinkfor the dependency as suggested by Marc. Please take a look at PATCH 4/17.For the IRQ dependency, I think adding
_DEPis not required. The "Extended Interrupt Descriptor" supports ResourceSource to indicate the dependency. Or GSI mapping can indicate the source. This is already handled inacpi_irq_parse_one_cb(). PATCH 4 uses this information to create links between producer and consumer so that DD framework probes the driver in the required order.
Quoted 10 lines
As you know, PNP devices are enumerated in a different way. I don't know why it was done like this. But
pnpacpi_init()is called viafs_initcall()andacpi_dev_resource_interrupt()called frompnpacpi_allocated_resource()doesn't handle the ResourceSource dependency. It caches the information in PNP data structure and expects the IRQ mapping to be available. Even if we add support to handle extended interrupt descriptor, it is not going to help. Hence, I had to add PATCH 5/17 and PATCH 6/17. Again, the change is mainly inpnp_irq()now and hence it doesn't need changing all drivers.
Hi Rafael,
Any further feedback on this? Do you see any issues with fw_devlink and pnp_irq() changes for the interrupt controller dependency?
BTW, I explored the _DEP option you mentioned. But I think the current approach would probably be better with lesser impact than _DEP. Below are my findings.
1) When PNP device like PNP0501 (16550A UART) has _DEP, it does not get created in the first pass (as expected) but they won't get created even after the supplier clears the dependency. This is because acpi_pnp_attach() returns success without calling pnpacpi_add_device() when acpi_scan_clear_dep_fn() calls acpi_bus_attach(). Either acpi_pnp_attach() needs to be modified or pnpacpi_add_device() should be called as part of clearing the dependency. I may be wrong but I think modifying pnp_irq() would probably affect only RISC-V than any of the approaches above.
2) _DEP doesn't support PCI devices. When we have PCI link devices (PNP0C0F) in the _PRT, the PCI driver probe as part of PCI scan can happen prior to link device probe since link device will have dependency on the interrupt controller which may not be probed yet. This will cause issue to the PCI device driver init because _PRT says there is link device for legacy PCI interrupt routing but the link driver is not probed yet.
3) _DEP needs namespace interrupt controllers. We would like to avoid adding namespace devices also along with MADT.
Please let me know your thoughts.
Thanks,
Sunil
Sunil V L
maintainerQuoted 116 lines · Rafael J. Wysocki
Quoted 104 lines · Sunil V L
Quoted 100 lines · Rafael J. Wysocki
Quoted 90 lines · Sunil V L
This series adds support for the below ECR approved by ASWG.
1) MADT - https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/view?usp=sharingThe series primarily enables irqchip drivers for RISC-V ACPI based platforms.
The series can be broadly categorized like below.
1) PCI ACPI related functions are migrated from arm64 to common file so that we don't need to duplicate them for RISC-V.
2) Introduced support for
fw_devlinkfor ACPI nodes for IRQ dependency. This helps to support deferred probe of interrupt controller drivers.3) Modified
pnp_irq()to try registering the IRQ again if it sees it in disabled state. This solution is similar to howplatform_get_irq_optional()works for regular platform devices.4) Added support for re-ordering the probe of interrupt controllers when
IRQCHIP_ACPI_DECLAREis used.5) ACPI support added in RISC-V interrupt controller drivers.
This series is based on Anup's AIA v11 series. Since Anup's AIA v11 is not merged yet and first time introducing
fw_devlink, deferred probe and reordering support for IRQCHIP probe, this series is still kept as RFC. Looking forward for the feedback!Changes since RFC v2:
1) Introducedfw_devlinkfor ACPI nodes for IRQ dependency.
2) Dropped patches in drivers which are not required due tofw_devlinksupport.
3) Droppedpci_set_msi()patch and added a patch inpci_create_root_bus().
4) Updatedpnp_irq()patch so that none of the actual PNP drivers need to change.Changes since RFC v1:
1) Abandoned swnode approach as per Marc's feedback.
2) To cope up with AIA series changes which changed irqchip driver probe fromcore_initcall()toplatform_driver, added patches to support deferred probing.
3) Rebased on top of Anup's AIA v11 and added tags.To test the series,
1) Qemu should be built using the
riscv_acpi_b2_v8branch at
https://github.com/vlsunil/qemu.git2) EDK2 should be built using the instructions at:
https://github.com/tianocore/edk2/blob/master/OvmfPkg/RiscVVirt/README.md3) Build Linux using this series on top of Anup's AIA v11 series.
Run Qemu:
qemu-system-riscv64 \
-M virt,pflash0=pflash0,pflash1=pflash1,aia=aplic-imsic \
-m 2G -smp 8 \
-serial mon:stdio \
-device virtio-gpu-pci -full-screen \
-device qemu-xhci \
-device usb-kbd \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=RISCV_VIRT_CODE.fd \
-blockdev node-name=pflash1,driver=file,filename=RISCV_VIRT_VARS.fd \
-netdev user,id=net0 -device virtio-net-pci,netdev=net0 \
-kernelarch/riscv/boot/Image\
-initrd rootfs.cpio \
-append "root=/dev/ram ro console=ttyS0 rootwait earlycon=uart8250,mmio,0x10000000"To boot with APLIC only, use aia=aplic.
To boot with PLIC, remove aia= option.This series is also available in
acpi_b2_v3_riscv_aia_v11branch at
https://github.com/vlsunil/linux.gitBased-on: [email protected]
(https://lore.kernel.org/lkml/[email protected]/)Sunil V L (17):
arm64: PCI: Migrate ACPI related functions topci-acpi.c
RISC-V: ACPI: Implement PCI related functionality
PCI: Makepci_create_root_bus()declare its reliance on MSI domains
ACPI: Addfw_devlinksupport for ACPI fwnode for IRQ dependency
ACPI: irq: Add support for deferred probe inacpi_register_gsi()pnp.h: Reconfigure IRQ inpnp_irq()to support deferred probe
ACPI:scan.c: Add weak arch specific function to reorder the IRQCHIP
probe
ACPI: RISC-V: Implement arch function to reorder irqchip probe entries
irqchip: riscv-intc: Add ACPI support for AIAQuoted 8 lines
irqchip: riscv-imsic: Add ACPI support
irqchip: riscv-aplic: Add ACPI support
irqchip: irq-sifive-plic: Add ACPI support
ACPI: bus: Add RINTC IRQ model for RISC-V
ACPI: bus: Addacpi_riscv_initfunction
ACPI: RISC-V: Create APLIC platform device
ACPI: RISC-V: Create PLIC platform device
irqchip: riscv-intc: Set ACPI irqmodelQuoted 2 lines
JFYI, I have no capacity to provide any feedback on this till 6.8-rc1 is out.
Quoted 7 lines
Hi Rafael,
Gentle ping.
Could you please provide feedback on the series? Patches 4, 5, 6, 7 and 8 are bit critical IMO. So, I really look forward for your and other ACPI experts!.
There was quite a bit of discussion on patch [6/21] and it still seems relevant to me.
Quoted 8 lines
ACPI actually has a way to at least indicate what the probe ordering should be which is
_DEP.The current handling of
_DEPin the kernel may not be covering this particular use case, but I would rather extend it (if necessary) instead of doing all of the -EPROBE_DEFER dance which seems fragile to me.
Hi Rafael,
I found that _DEP is better than fw_devlink for ACPI since it works during scan itself. For ex: the way PCI host bridges are scanned in ACPI, PNP device handling. While some hacky solution could be done like I did in v3 (pnp_irq() changes), _DEP way seems much better.
So, we decided to go with your suggested approach and defined namespace devices for PLIC and APLIC required to create dependency mechanism. However, there are concerns that every device will have to add _DEP now and whether it is intended for this use case. Also, actually the dependency is already available in the form of GSI number mapping. Hence, instead of explicit dependency, we would like to create implicit dependency. So, I will send RFC v4 series with those changes. Please help us with feedback. If you could provide quick high level go/no-go, that will help us a lot since we need to finalize the spec whether to mandate _DEP or not.
I request you to provide some high level feedback in the RFC v4 I am going to send.
1) Creation of implicit dependency.
2) Handling PNP devices as part of clearing dependency
3) IRQCHIP probing reordering when there are multiple irqchips.
Thanks,
Sunil
Rafael J. Wysocki
maintainerHi,
[cut]
Quoted 19 lines
Quoted 1 line
Hi Rafael,
I found that
_DEPis better thanfw_devlinkfor ACPI since it works during scan itself. For ex: the way PCI host bridges are scanned in ACPI, PNP device handling. While some hacky solution could be done like I did in v3 (pnp_irq()changes),_DEPway seems much better.So, we decided to go with your suggested approach and defined namespace devices for PLIC and APLIC required to create dependency mechanism. However, there are concerns that every device will have to add
_DEPnow and whether it is intended for this use case. Also, actually the dependency is already available in the form of GSI number mapping. Hence, instead of explicit dependency, we would like to create implicit dependency. So, I will send RFC v4 series with those changes. Please help us with feedback. If you could provide quick high level go/no-go, that will help us a lot since we need to finalize the spec whether to mandate_DEPor not.
Quoted 2 lines
I request you to provide some high level feedback in the RFC v4 I am going to send.
I will, thank you!