Commit e58f2259 authored by Thomas Gleixner's avatar Thomas Gleixner

genirq/msi, treewide: Use a named struct for PCI/MSI attributes

The unnamed struct sucks and is in the way of further cleanups. Stick the
PCI related MSI data into a real data structure and cleanup all users.

No functional change.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarJuergen Gross <jgross@suse.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: default avatarKalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20211206210224.374863119@linutronix.de
parent bec61847
...@@ -212,7 +212,7 @@ static int setup_msi_msg_address(struct pci_dev *dev, struct msi_msg *msg) ...@@ -212,7 +212,7 @@ static int setup_msi_msg_address(struct pci_dev *dev, struct msi_msg *msg)
entry = first_pci_msi_entry(dev); entry = first_pci_msi_entry(dev);
for (; dn; dn = of_get_next_parent(dn)) { for (; dn; dn = of_get_next_parent(dn)) {
if (entry->msi_attrib.is_64) { if (entry->pci.msi_attrib.is_64) {
prop = of_get_property(dn, "msi-address-64", &len); prop = of_get_property(dn, "msi-address-64", &len);
if (prop) if (prop)
break; break;
......
...@@ -2154,10 +2154,10 @@ static void pnv_msi_compose_msg(struct irq_data *d, struct msi_msg *msg) ...@@ -2154,10 +2154,10 @@ static void pnv_msi_compose_msg(struct irq_data *d, struct msi_msg *msg)
int rc; int rc;
rc = __pnv_pci_ioda_msi_setup(phb, pdev, d->hwirq, rc = __pnv_pci_ioda_msi_setup(phb, pdev, d->hwirq,
entry->msi_attrib.is_64, msg); entry->pci.msi_attrib.is_64, msg);
if (rc) if (rc)
dev_err(&pdev->dev, "Failed to setup %s-bit MSI #%ld : %d\n", dev_err(&pdev->dev, "Failed to setup %s-bit MSI #%ld : %d\n",
entry->msi_attrib.is_64 ? "64" : "32", d->hwirq, rc); entry->pci.msi_attrib.is_64 ? "64" : "32", d->hwirq, rc);
} }
/* /*
......
...@@ -332,7 +332,7 @@ static int check_msix_entries(struct pci_dev *pdev) ...@@ -332,7 +332,7 @@ static int check_msix_entries(struct pci_dev *pdev)
expected = 0; expected = 0;
for_each_pci_msi_entry(entry, pdev) { for_each_pci_msi_entry(entry, pdev) {
if (entry->msi_attrib.entry_nr != expected) { if (entry->pci.msi_attrib.entry_nr != expected) {
pr_debug("rtas_msi: bad MSI-X entries.\n"); pr_debug("rtas_msi: bad MSI-X entries.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -449,7 +449,7 @@ static int pseries_msi_ops_prepare(struct irq_domain *domain, struct device *dev ...@@ -449,7 +449,7 @@ static int pseries_msi_ops_prepare(struct irq_domain *domain, struct device *dev
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct pci_dev *pdev = to_pci_dev(dev);
struct msi_desc *desc = first_pci_msi_entry(pdev); struct msi_desc *desc = first_pci_msi_entry(pdev);
int type = desc->msi_attrib.is_msix ? PCI_CAP_ID_MSIX : PCI_CAP_ID_MSI; int type = desc->pci.msi_attrib.is_msix ? PCI_CAP_ID_MSIX : PCI_CAP_ID_MSI;
return rtas_prepare_msi_irqs(pdev, nvec, type, arg); return rtas_prepare_msi_irqs(pdev, nvec, type, arg);
} }
...@@ -580,7 +580,7 @@ static int pseries_irq_domain_alloc(struct irq_domain *domain, unsigned int virq ...@@ -580,7 +580,7 @@ static int pseries_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
int hwirq; int hwirq;
int i, ret; int i, ret;
hwirq = rtas_query_irq_number(pci_get_pdn(pdev), desc->msi_attrib.entry_nr); hwirq = rtas_query_irq_number(pci_get_pdn(pdev), desc->pci.msi_attrib.entry_nr);
if (hwirq < 0) { if (hwirq < 0) {
dev_err(&pdev->dev, "Failed to query HW IRQ: %d\n", hwirq); dev_err(&pdev->dev, "Failed to query HW IRQ: %d\n", hwirq);
return hwirq; return hwirq;
......
...@@ -146,13 +146,13 @@ static int sparc64_setup_msi_irq(unsigned int *irq_p, ...@@ -146,13 +146,13 @@ static int sparc64_setup_msi_irq(unsigned int *irq_p,
msiqid = pick_msiq(pbm); msiqid = pick_msiq(pbm);
err = ops->msi_setup(pbm, msiqid, msi, err = ops->msi_setup(pbm, msiqid, msi,
(entry->msi_attrib.is_64 ? 1 : 0)); (entry->pci.msi_attrib.is_64 ? 1 : 0));
if (err) if (err)
goto out_msi_free; goto out_msi_free;
pbm->msi_irq_table[msi - pbm->msi_first] = *irq_p; pbm->msi_irq_table[msi - pbm->msi_first] = *irq_p;
if (entry->msi_attrib.is_64) { if (entry->pci.msi_attrib.is_64) {
msg.address_hi = pbm->msi64_start >> 32; msg.address_hi = pbm->msi64_start >> 32;
msg.address_lo = pbm->msi64_start & 0xffffffff; msg.address_lo = pbm->msi64_start & 0xffffffff;
} else { } else {
......
...@@ -163,7 +163,7 @@ int pci_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec, ...@@ -163,7 +163,7 @@ int pci_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec,
struct msi_desc *desc = first_pci_msi_entry(pdev); struct msi_desc *desc = first_pci_msi_entry(pdev);
init_irq_alloc_info(arg, NULL); init_irq_alloc_info(arg, NULL);
if (desc->msi_attrib.is_msix) { if (desc->pci.msi_attrib.is_msix) {
arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSIX; arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSIX;
} else { } else {
arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSI; arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSI;
......
...@@ -306,7 +306,7 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -306,7 +306,7 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
return -EINVAL; return -EINVAL;
map_irq.table_base = pci_resource_start(dev, bir); map_irq.table_base = pci_resource_start(dev, bir);
map_irq.entry_nr = msidesc->msi_attrib.entry_nr; map_irq.entry_nr = msidesc->pci.msi_attrib.entry_nr;
} }
ret = -EINVAL; ret = -EINVAL;
...@@ -398,7 +398,7 @@ static void xen_pv_teardown_msi_irqs(struct pci_dev *dev) ...@@ -398,7 +398,7 @@ static void xen_pv_teardown_msi_irqs(struct pci_dev *dev)
{ {
struct msi_desc *msidesc = first_pci_msi_entry(dev); struct msi_desc *msidesc = first_pci_msi_entry(dev);
if (msidesc->msi_attrib.is_msix) if (msidesc->pci.msi_attrib.is_msix)
xen_pci_frontend_disable_msix(dev); xen_pci_frontend_disable_msix(dev);
else else
xen_pci_frontend_disable_msi(dev); xen_pci_frontend_disable_msi(dev);
...@@ -414,7 +414,7 @@ static int xen_msi_domain_alloc_irqs(struct irq_domain *domain, ...@@ -414,7 +414,7 @@ static int xen_msi_domain_alloc_irqs(struct irq_domain *domain,
if (WARN_ON_ONCE(!dev_is_pci(dev))) if (WARN_ON_ONCE(!dev_is_pci(dev)))
return -EINVAL; return -EINVAL;
if (first_msi_entry(dev)->msi_attrib.is_msix) if (first_msi_entry(dev)->pci.msi_attrib.is_msix)
type = PCI_CAP_ID_MSIX; type = PCI_CAP_ID_MSIX;
else else
type = PCI_CAP_ID_MSI; type = PCI_CAP_ID_MSI;
......
...@@ -911,7 +911,7 @@ static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci) ...@@ -911,7 +911,7 @@ static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci)
} }
ab_pci->msi_ep_base_data = msi_desc->msg.data; ab_pci->msi_ep_base_data = msi_desc->msg.data;
if (msi_desc->msi_attrib.is_64) if (msi_desc->pci.msi_attrib.is_64)
set_bit(ATH11K_PCI_FLAG_IS_MSI_64, &ab_pci->flags); set_bit(ATH11K_PCI_FLAG_IS_MSI_64, &ab_pci->flags);
ath11k_dbg(ab, ATH11K_DBG_PCI, "msi base data is %d\n", ab_pci->msi_ep_base_data); ath11k_dbg(ab, ATH11K_DBG_PCI, "msi base data is %d\n", ab_pci->msi_ep_base_data);
......
This diff is collapsed.
...@@ -263,7 +263,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev, ...@@ -263,7 +263,7 @@ static int pci_frontend_enable_msix(struct pci_dev *dev,
i = 0; i = 0;
for_each_pci_msi_entry(entry, dev) { for_each_pci_msi_entry(entry, dev) {
op.msix_entries[i].entry = entry->msi_attrib.entry_nr; op.msix_entries[i].entry = entry->pci.msi_attrib.entry_nr;
/* Vector is useless at this point. */ /* Vector is useless at this point. */
op.msix_entries[i].vector = -1; op.msix_entries[i].vector = -1;
i++; i++;
......
...@@ -68,6 +68,42 @@ static inline void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) ...@@ -68,6 +68,42 @@ static inline void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg)
typedef void (*irq_write_msi_msg_t)(struct msi_desc *desc, typedef void (*irq_write_msi_msg_t)(struct msi_desc *desc,
struct msi_msg *msg); struct msi_msg *msg);
/**
* pci_msi_desc - PCI/MSI specific MSI descriptor data
*
* @msi_mask: [PCI MSI] MSI cached mask bits
* @msix_ctrl: [PCI MSI-X] MSI-X cached per vector control bits
* @is_msix: [PCI MSI/X] True if MSI-X
* @multiple: [PCI MSI/X] log2 num of messages allocated
* @multi_cap: [PCI MSI/X] log2 num of messages supported
* @can_mask: [PCI MSI/X] Masking supported?
* @is_64: [PCI MSI/X] Address size: 0=32bit 1=64bit
* @entry_nr: [PCI MSI/X] Entry which is described by this descriptor
* @default_irq:[PCI MSI/X] The default pre-assigned non-MSI irq
* @mask_pos: [PCI MSI] Mask register position
* @mask_base: [PCI MSI-X] Mask register base address
*/
struct pci_msi_desc {
union {
u32 msi_mask;
u32 msix_ctrl;
};
struct {
u8 is_msix : 1;
u8 multiple : 3;
u8 multi_cap : 3;
u8 can_mask : 1;
u8 is_64 : 1;
u8 is_virtual : 1;
u16 entry_nr;
unsigned default_irq;
} msi_attrib;
union {
u8 mask_pos;
void __iomem *mask_base;
};
};
/** /**
* platform_msi_desc - Platform device specific msi descriptor data * platform_msi_desc - Platform device specific msi descriptor data
* @msi_priv_data: Pointer to platform private data * @msi_priv_data: Pointer to platform private data
...@@ -107,17 +143,7 @@ struct ti_sci_inta_msi_desc { ...@@ -107,17 +143,7 @@ struct ti_sci_inta_msi_desc {
* address or data changes * address or data changes
* @write_msi_msg_data: Data parameter for the callback. * @write_msi_msg_data: Data parameter for the callback.
* *
* @msi_mask: [PCI MSI] MSI cached mask bits * @pci: [PCI] PCI speficic msi descriptor data
* @msix_ctrl: [PCI MSI-X] MSI-X cached per vector control bits
* @is_msix: [PCI MSI/X] True if MSI-X
* @multiple: [PCI MSI/X] log2 num of messages allocated
* @multi_cap: [PCI MSI/X] log2 num of messages supported
* @maskbit: [PCI MSI/X] Mask-Pending bit supported?
* @is_64: [PCI MSI/X] Address size: 0=32bit 1=64bit
* @entry_nr: [PCI MSI/X] Entry which is described by this descriptor
* @default_irq:[PCI MSI/X] The default pre-assigned non-MSI irq
* @mask_pos: [PCI MSI] Mask register position
* @mask_base: [PCI MSI-X] Mask register base address
* @platform: [platform] Platform device specific msi descriptor data * @platform: [platform] Platform device specific msi descriptor data
* @fsl_mc: [fsl-mc] FSL MC device specific msi descriptor data * @fsl_mc: [fsl-mc] FSL MC device specific msi descriptor data
* @inta: [INTA] TISCI based INTA specific msi descriptor data * @inta: [INTA] TISCI based INTA specific msi descriptor data
...@@ -138,38 +164,10 @@ struct msi_desc { ...@@ -138,38 +164,10 @@ struct msi_desc {
void *write_msi_msg_data; void *write_msi_msg_data;
union { union {
/* PCI MSI/X specific data */ struct pci_msi_desc pci;
struct { struct platform_msi_desc platform;
union { struct fsl_mc_msi_desc fsl_mc;
u32 msi_mask; struct ti_sci_inta_msi_desc inta;
u32 msix_ctrl;
};
struct {
u8 is_msix : 1;
u8 multiple : 3;
u8 multi_cap : 3;
u8 can_mask : 1;
u8 is_64 : 1;
u8 is_virtual : 1;
u16 entry_nr;
unsigned default_irq;
} msi_attrib;
union {
u8 mask_pos;
void __iomem *mask_base;
};
};
/*
* Non PCI variants add their data structure here. New
* entries need to use a named structure. We want
* proper name spaces for this. The PCI part is
* anonymous for now as it would require an immediate
* tree wide cleanup.
*/
struct platform_msi_desc platform;
struct fsl_mc_msi_desc fsl_mc;
struct ti_sci_inta_msi_desc inta;
}; };
}; };
......
...@@ -91,7 +91,7 @@ static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr, ...@@ -91,7 +91,7 @@ static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr,
return -ENODEV; return -ENODEV;
if (dev_is_pci(dev)) if (dev_is_pci(dev))
is_msix = entry->msi_attrib.is_msix; is_msix = entry->pci.msi_attrib.is_msix;
return sysfs_emit(buf, "%s\n", is_msix ? "msix" : "msi"); return sysfs_emit(buf, "%s\n", is_msix ? "msix" : "msi");
} }
...@@ -535,7 +535,7 @@ static bool msi_check_reservation_mode(struct irq_domain *domain, ...@@ -535,7 +535,7 @@ static bool msi_check_reservation_mode(struct irq_domain *domain,
* masking and MSI does so when the can_mask attribute is set. * masking and MSI does so when the can_mask attribute is set.
*/ */
desc = first_msi_entry(dev); desc = first_msi_entry(dev);
return desc->msi_attrib.is_msix || desc->msi_attrib.can_mask; return desc->pci.msi_attrib.is_msix || desc->pci.msi_attrib.can_mask;
} }
int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment