~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/sysdev/mpic_msi.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * Copyright 2006-2007, Michael Ellerman, IBM Corporation.
  4  */
  5 
  6 #include <linux/irq.h>
  7 #include <linux/irqdomain.h>
  8 #include <linux/of_irq.h>
  9 #include <linux/bitmap.h>
 10 #include <linux/msi.h>
 11 #include <asm/mpic.h>
 12 #include <asm/hw_irq.h>
 13 #include <asm/ppc-pci.h>
 14 #include <asm/msi_bitmap.h>
 15 
 16 #include <sysdev/mpic.h>
 17 
 18 void mpic_msi_reserve_hwirq(struct mpic *mpic, irq_hw_number_t hwirq)
 19 {
 20         /* The mpic calls this even when there is no allocator setup */
 21         if (!mpic->msi_bitmap.bitmap)
 22                 return;
 23 
 24         msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, hwirq);
 25 }
 26 
 27 #ifdef CONFIG_MPIC_U3_HT_IRQS
 28 static int __init mpic_msi_reserve_u3_hwirqs(struct mpic *mpic)
 29 {
 30         irq_hw_number_t hwirq;
 31         const struct irq_domain_ops *ops = mpic->irqhost->ops;
 32         struct device_node *np;
 33         int flags, index, i;
 34         struct of_phandle_args oirq;
 35 
 36         pr_debug("mpic: found U3, guessing msi allocator setup\n");
 37 
 38         /* Reserve source numbers we know are reserved in the HW.
 39          *
 40          * This is a bit of a mix of U3 and U4 reserves but that's going
 41          * to work fine, we have plenty enough numbers left so let's just
 42          * mark anything we don't like reserved.
 43          */
 44         for (i = 0;   i < 8;   i++)
 45                 msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);
 46 
 47         for (i = 42;  i < 46;  i++)
 48                 msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);
 49 
 50         for (i = 100; i < 105; i++)
 51                 msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);
 52 
 53         for (i = 124; i < mpic->num_sources; i++)
 54                 msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, i);
 55 
 56 
 57         np = NULL;
 58         while ((np = of_find_all_nodes(np))) {
 59                 pr_debug("mpic: mapping hwirqs for %pOF\n", np);
 60 
 61                 index = 0;
 62                 while (of_irq_parse_one(np, index++, &oirq) == 0) {
 63                         ops->xlate(mpic->irqhost, NULL, oirq.args,
 64                                                 oirq.args_count, &hwirq, &flags);
 65                         msi_bitmap_reserve_hwirq(&mpic->msi_bitmap, hwirq);
 66                 }
 67         }
 68 
 69         return 0;
 70 }
 71 #else
 72 static int __init mpic_msi_reserve_u3_hwirqs(struct mpic *mpic)
 73 {
 74         return -1;
 75 }
 76 #endif
 77 
 78 int __init mpic_msi_init_allocator(struct mpic *mpic)
 79 {
 80         int rc;
 81 
 82         rc = msi_bitmap_alloc(&mpic->msi_bitmap, mpic->num_sources,
 83                               irq_domain_get_of_node(mpic->irqhost));
 84         if (rc)
 85                 return rc;
 86 
 87         rc = msi_bitmap_reserve_dt_hwirqs(&mpic->msi_bitmap);
 88         if (rc > 0) {
 89                 if (mpic->flags & MPIC_U3_HT_IRQS)
 90                         rc = mpic_msi_reserve_u3_hwirqs(mpic);
 91 
 92                 if (rc) {
 93                         msi_bitmap_free(&mpic->msi_bitmap);
 94                         return rc;
 95                 }
 96         }
 97 
 98         return 0;
 99 }
100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php