Skip to content

Commit a08df2f

Browse files
Lorenzo Pieralisirafaeljw
authored andcommitted
PCI/MSI: Make the pci_msi_map_rid_ctlr_node() interface firmware agnostic
To support booting with OF and ACPI seamlessly, GIC ITS parent code requires the PCI/MSI irqdomain layer to implement a function to retrieve an MSI controller fwnode and map an RID in a firmware agnostic way (ie pci_msi_map_rid_ctlr_node()). Convert pci_msi_map_rid_ctlr_node() to an OF agnostic interface (fwnode_handle based) and update the GIC ITS MSI parent code to reflect the pci_msi_map_rid_ctlr_node() change. Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260115-gicv5-host-acpi-v3-2-c13a9a150388@kernel.org Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 0323897 commit a08df2f

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

drivers/irqchip/irq-gic-its-msi-parent.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static int its_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
104104
static int its_v5_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
105105
int nvec, msi_alloc_info_t *info)
106106
{
107-
struct device_node *msi_node = NULL;
107+
struct fwnode_handle *msi_node = NULL;
108108
struct msi_domain_info *msi_info;
109109
struct pci_dev *pdev;
110110
phys_addr_t pa;
@@ -116,15 +116,15 @@ static int its_v5_pci_msi_prepare(struct irq_domain *domain, struct device *dev,
116116

117117
pdev = to_pci_dev(dev);
118118

119-
rid = pci_msi_map_rid_ctlr_node(pdev, &msi_node);
119+
rid = pci_msi_map_rid_ctlr_node(domain->parent, pdev, &msi_node);
120120
if (!msi_node)
121121
return -ENODEV;
122122

123-
ret = its_translate_frame_address(msi_node, &pa);
123+
ret = its_translate_frame_address(to_of_node(msi_node), &pa);
124124
if (ret)
125125
return -ENODEV;
126126

127-
of_node_put(msi_node);
127+
fwnode_handle_put(msi_node);
128128

129129
/* ITS specific DeviceID */
130130
info->scratchpad[0].ul = rid;

drivers/pci/msi/irqdomain.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,23 +376,34 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev)
376376
}
377377

378378
/**
379-
* pci_msi_map_rid_ctlr_node - Get the MSI controller node and MSI requester id (RID)
379+
* pci_msi_map_rid_ctlr_node - Get the MSI controller fwnode_handle and MSI requester id (RID)
380+
* @domain: The interrupt domain
380381
* @pdev: The PCI device
381-
* @node: Pointer to store the MSI controller device node
382+
* @node: Pointer to store the MSI controller fwnode_handle
382383
*
383-
* Use the firmware data to find the MSI controller node for @pdev.
384+
* Use the firmware data to find the MSI controller fwnode_handle for @pdev.
384385
* If found map the RID and initialize @node with it. @node value must
385386
* be set to NULL on entry.
386387
*
387388
* Returns: The RID.
388389
*/
389-
u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node)
390+
u32 pci_msi_map_rid_ctlr_node(struct irq_domain *domain, struct pci_dev *pdev,
391+
struct fwnode_handle **node)
390392
{
391393
u32 rid = pci_dev_id(pdev);
392394

393395
pci_for_each_dma_alias(pdev, get_msi_id_cb, &rid);
394396

395-
return of_msi_xlate(&pdev->dev, node, rid);
397+
/* Check whether the domain fwnode is an OF node */
398+
if (irq_domain_get_of_node(domain)) {
399+
struct device_node *msi_ctlr_node = NULL;
400+
401+
rid = of_msi_xlate(&pdev->dev, &msi_ctlr_node, rid);
402+
if (msi_ctlr_node)
403+
*node = of_fwnode_handle(msi_ctlr_node);
404+
}
405+
406+
return rid;
396407
}
397408

398409
/**

include/linux/msi.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,8 @@ void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
702702
void pci_msi_mask_irq(struct irq_data *data);
703703
void pci_msi_unmask_irq(struct irq_data *data);
704704
u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev);
705-
u32 pci_msi_map_rid_ctlr_node(struct pci_dev *pdev, struct device_node **node);
705+
u32 pci_msi_map_rid_ctlr_node(struct irq_domain *domain, struct pci_dev *pdev,
706+
struct fwnode_handle **node);
706707
struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev);
707708
void pci_msix_prepare_desc(struct irq_domain *domain, msi_alloc_info_t *arg,
708709
struct msi_desc *desc);

0 commit comments

Comments
 (0)