[PATCH 1/2] [v3] powerpc/44x: Fix PCI MSI support for Maui APM821xx SoC and Bluestone board

Josh Boyer jwboyer at gmail.com
Fri Mar 16 23:41:07 EST 2012


On Mon, Mar 12, 2012 at 4:07 AM, Mai La <mla at apm.com> wrote:
> diff --git a/arch/powerpc/sysdev/ppc4xx_msi.c b/arch/powerpc/sysdev/ppc4xx_msi.c
> index 1c2d7af..63989d0 100644
> --- a/arch/powerpc/sysdev/ppc4xx_msi.c
> +++ b/arch/powerpc/sysdev/ppc4xx_msi.c
> @@ -28,10 +28,11 @@
>  #include <linux/of_platform.h>
>  #include <linux/interrupt.h>
>  #include <linux/export.h>
> +#include <linux/kernel.h>
>  #include <asm/prom.h>
>  #include <asm/hw_irq.h>
>  #include <asm/ppc-pci.h>
> -#include <boot/dcr.h>
> +#include <asm/dcr.h>
>  #include <asm/dcr-regs.h>
>  #include <asm/msi_bitmap.h>
>
> @@ -43,13 +44,14 @@
>  #define PEIH_FLUSH0    0x30
>  #define PEIH_FLUSH1    0x38
>  #define PEIH_CNTRST    0x48
> -#define NR_MSI_IRQS    4
> +
> +int msi_irqs;

This should be static.

>  struct ppc4xx_msi {
>        u32 msi_addr_lo;
>        u32 msi_addr_hi;
>        void __iomem *msi_regs;
> -       int msi_virqs[NR_MSI_IRQS];
> +       int *msi_virqs;
>        struct msi_bitmap bitmap;
>        struct device_node *msi_dev;
>  };
> @@ -61,7 +63,7 @@ static int ppc4xx_msi_init_allocator(struct platform_device *dev,
>  {
>        int err;
>
> -       err = msi_bitmap_alloc(&msi_data->bitmap, NR_MSI_IRQS,
> +       err = msi_bitmap_alloc(&msi_data->bitmap, msi_irqs,
>                              dev->dev.of_node);
>        if (err)
>                return err;
> @@ -83,6 +85,9 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
>        struct msi_desc *entry;
>        struct ppc4xx_msi *msi_data = &ppc4xx_msi;
>
> +       msi_data->msi_virqs = kmalloc((msi_irqs) * sizeof(int),
> +                                           GFP_KERNEL);
> +

What happens if this allocation fails?  Unlikely perhaps, but we should still
probably try and handle the error.

>        list_for_each_entry(entry, &dev->msi_list, list) {
>                int_no = msi_bitmap_alloc_hwirqs(&msi_data->bitmap, 1);
>                if (int_no >= 0)

<snip>

> @@ -234,6 +241,10 @@ static int __devinit ppc4xx_msi_probe(struct platform_device *dev)
>                goto error_out;
>        }
>
> +       msi_irqs = of_irq_count(dev->dev.of_node);
> +       if (!msi_irqs)
> +               return -1;
> +

Maybe return -ENODEV here instead of -1?  It probably doesn't matter at the
moment, but if anything actually checked why the probe function failed, that
would be more descriptive.

josh


More information about the Linuxppc-dev mailing list