powerpc/fsl_msi: clean up and document calculation of MSIIR address
PATCH 1/1 powerpc/fsl_msi: clean up and document calculation of MSIIR address
Commit 3da34aae (powerpc/fsl: Support unique MSI addresses per PCIe Root Complex) redefined the meanings of msi->msi_addr_hi and msi->msi_addr_lo to be an offset rather than an address. To help clarify the code, we make the following changes:
1) Get rid of msi_addr_hi, which is always zero anyway.
2) Rename msi_addr_lo to ccsr_msiir_offset, to indicate that it's an offset relative to the beginning of CCSR.
3) Calculate 64-bit addresses using actual 64-bit math.
4) Document some of the code and assumptions we make.
--- arch/powerpc/sysdev/fsl_msi.c | 26 ++++++++++++++++++-------- arch/powerpc/sysdev/fsl_msi.h | 3 +-- 2 files changed, 19 insertions(+), 10 deletions(-)
arch/powerpc/sysdev/fsl_msi.c +18 -8
@@ -30,7 +30,7 @@ LIST_HEAD(msi_head);struct fsl_msi_feature {u32 fsl_pic_ip; -u32 msiir_offset; +u32 msiir_offset;/* offset of MSIIR, relative to start of MSI regs */ };struct fsl_msi_cascade_data {
@@ -120,16 +120,23 @@ static void fsl_teardown_msi_irqs(struct pci_dev *pdev)return ; } +/* +* Initialize the address and data fields of an MSI message object +*/ static void fsl_compose_msi_msg (struct pci_dev *pdev,int hwirq,struct msi_msg *msg, -struct fsl_msi *fsl_msi_data) +struct fsl_msi *msi_data) { -struct fsl_msi *msi_data = fsl_msi_data;struct pci_controller *hose =pci_bus_to_host (pdev->bus); -u64 base =fsl_pci_immrbar_base (hose); - msg->address_lo = msi_data->msi_addr_lo +lower_32_bits (base); - msg->address_hi = msi_data->msi_addr_hi +upper_32_bits (base); +/* +* The PCI address of MSIIR is equal to the PCI base address of CCSR +* plus the offset of MSIIR. +*/ +u64 addr =fsl_pci_immrbar_base (hose) + msi_data->ccsr_msiir_offset; + + msg->address_hi =upper_32_bits (addr); + msg->address_lo =lower_32_bits (addr); msg->data = hwirq;
@@ -359,8 +366,11 @@ static int __devinit fsl_of_msi_probe(struct platform_device *dev) msi->irqhost->host_data = msi; - msi->msi_addr_hi =0x0 ; - msi->msi_addr_lo = features->msiir_offset + (res.start &0xfffff ); +/* +* We assume that the 'reg' property of the MSI node contains an +* offset that has five (or fewer) digits, hence the 0xfffff. +*/ + msi->ccsr_msiir_offset = features->msiir_offset + (res.start &0xfffff ); rc =fsl_msi_init_allocator (msi);if (rc) {
arch/powerpc/sysdev/fsl_msi.h +1 -2
@@ -28,8 +28,7 @@ struct fsl_msi {unsigned long cascade_irq; -u32 msi_addr_lo; -u32 msi_addr_hi; +u32 ccsr_msiir_offset;/* offset of MSIIR, relative to start of CCSR */ void __iomem *msi_regs;u32 feature;int msi_virqs[NR_MSI_REG ];
Signature · 1 line
1.7.3.4
Quoted 2 lines · Timur Tabi
Commit
3da34aae(powerpc/fsl: Support unique MSI addresses per PCIe Root Complex) redefined the meanings ofmsi->msi_addr_hiandmsi->msi_addr_lo=
to be
Quoted 2 lines
an offset rather than an address. To help clarify the code, we make the following changes:
Kumar, I'm going to merge this patch into a bigger patch that makes a=20 bunch of other fixes.=