Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/pci: move everything irq related to pci_irq.c

Move everything interrupt related from pci.c to pci_irq.c.
No functional change.

Signed-off-by: Sebastian Ott <sebott@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
c840927c 066ee72a

+229 -217
+6
arch/s390/include/asm/pci.h
··· 26 26 #define ZPCI_BUS_NR 0 /* default bus number */ 27 27 #define ZPCI_DEVFN 0 /* default device number */ 28 28 29 + #define ZPCI_NR_DMA_SPACES 1 30 + #define ZPCI_NR_DEVICES CONFIG_PCI_NR_FUNCTIONS 31 + 29 32 /* PCI Function Controls */ 30 33 #define ZPCI_FC_FN_ENABLED 0x80 31 34 #define ZPCI_FC_ERROR 0x40 ··· 221 218 /* DMA */ 222 219 int zpci_dma_init(void); 223 220 void zpci_dma_exit(void); 221 + 222 + int __init zpci_irq_init(void); 223 + void __init zpci_irq_exit(void); 224 224 225 225 /* FMB */ 226 226 int zpci_fmb_enable_device(struct zpci_dev *);
+1 -1
arch/s390/pci/Makefile
··· 3 3 # Makefile for the s390 PCI subsystem. 4 4 # 5 5 6 - obj-$(CONFIG_PCI) += pci.o pci_dma.o pci_clp.o pci_sysfs.o \ 6 + obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_dma.o pci_clp.o pci_sysfs.o \ 7 7 pci_event.o pci_debug.o pci_insn.o pci_mmio.o
-216
arch/s390/pci/pci.c
··· 24 24 #include <linux/err.h> 25 25 #include <linux/export.h> 26 26 #include <linux/delay.h> 27 - #include <linux/irq.h> 28 - #include <linux/kernel_stat.h> 29 27 #include <linux/seq_file.h> 30 28 #include <linux/pci.h> 31 - #include <linux/msi.h> 32 29 33 30 #include <asm/isc.h> 34 31 #include <asm/airq.h> ··· 34 37 #include <asm/pci_clp.h> 35 38 #include <asm/pci_dma.h> 36 39 37 - #define SIC_IRQ_MODE_ALL 0 38 - #define SIC_IRQ_MODE_SINGLE 1 39 - 40 - #define ZPCI_NR_DMA_SPACES 1 41 - #define ZPCI_NR_DEVICES CONFIG_PCI_NR_FUNCTIONS 42 - 43 40 /* list of all detected zpci devices */ 44 41 static LIST_HEAD(zpci_list); 45 42 static DEFINE_SPINLOCK(zpci_list_lock); 46 43 47 - static struct irq_chip zpci_irq_chip = { 48 - .name = "zPCI", 49 - .irq_unmask = pci_msi_unmask_irq, 50 - .irq_mask = pci_msi_mask_irq, 51 - }; 52 - 53 44 static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES); 54 45 static DEFINE_SPINLOCK(zpci_domain_lock); 55 - 56 - static struct airq_iv *zpci_aisb_iv; 57 - static struct airq_iv *zpci_aibv[ZPCI_NR_DEVICES]; 58 46 59 47 #define ZPCI_IOMAP_ENTRIES \ 60 48 min(((unsigned long) ZPCI_NR_DEVICES * PCI_BAR_COUNT / 2), \ ··· 102 120 return pci_domain_nr(bus); 103 121 } 104 122 EXPORT_SYMBOL_GPL(pci_proc_domain); 105 - 106 - /* Modify PCI: Register adapter interruptions */ 107 - static int zpci_set_airq(struct zpci_dev *zdev) 108 - { 109 - u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT); 110 - struct zpci_fib fib = {0}; 111 - u8 status; 112 - 113 - fib.isc = PCI_ISC; 114 - fib.sum = 1; /* enable summary notifications */ 115 - fib.noi = airq_iv_end(zdev->aibv); 116 - fib.aibv = (unsigned long) zdev->aibv->vector; 117 - fib.aibvo = 0; /* each zdev has its own interrupt vector */ 118 - fib.aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8; 119 - fib.aisbo = zdev->aisb & 63; 120 - 121 - return zpci_mod_fc(req, &fib, &status) ? -EIO : 0; 122 - } 123 - 124 - /* Modify PCI: Unregister adapter interruptions */ 125 - static int zpci_clear_airq(struct zpci_dev *zdev) 126 - { 127 - u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_DEREG_INT); 128 - struct zpci_fib fib = {0}; 129 - u8 cc, status; 130 - 131 - cc = zpci_mod_fc(req, &fib, &status); 132 - if (cc == 3 || (cc == 1 && status == 24)) 133 - /* Function already gone or IRQs already deregistered. */ 134 - cc = 0; 135 - 136 - return cc ? -EIO : 0; 137 - } 138 123 139 124 /* Modify PCI: Register I/O address translation parameters */ 140 125 int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaas, ··· 301 352 .write = pci_write, 302 353 }; 303 354 304 - static void zpci_irq_handler(struct airq_struct *airq) 305 - { 306 - unsigned long si, ai; 307 - struct airq_iv *aibv; 308 - int irqs_on = 0; 309 - 310 - inc_irq_stat(IRQIO_PCI); 311 - for (si = 0;;) { 312 - /* Scan adapter summary indicator bit vector */ 313 - si = airq_iv_scan(zpci_aisb_iv, si, airq_iv_end(zpci_aisb_iv)); 314 - if (si == -1UL) { 315 - if (irqs_on++) 316 - /* End of second scan with interrupts on. */ 317 - break; 318 - /* First scan complete, reenable interrupts. */ 319 - if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC)) 320 - break; 321 - si = 0; 322 - continue; 323 - } 324 - 325 - /* Scan the adapter interrupt vector for this device. */ 326 - aibv = zpci_aibv[si]; 327 - for (ai = 0;;) { 328 - ai = airq_iv_scan(aibv, ai, airq_iv_end(aibv)); 329 - if (ai == -1UL) 330 - break; 331 - inc_irq_stat(IRQIO_MSI); 332 - airq_iv_lock(aibv, ai); 333 - generic_handle_irq(airq_iv_get_data(aibv, ai)); 334 - airq_iv_unlock(aibv, ai); 335 - } 336 - } 337 - } 338 - 339 - int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) 340 - { 341 - struct zpci_dev *zdev = to_zpci(pdev); 342 - unsigned int hwirq, msi_vecs; 343 - unsigned long aisb; 344 - struct msi_desc *msi; 345 - struct msi_msg msg; 346 - int rc, irq; 347 - 348 - zdev->aisb = -1UL; 349 - if (type == PCI_CAP_ID_MSI && nvec > 1) 350 - return 1; 351 - msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); 352 - 353 - /* Allocate adapter summary indicator bit */ 354 - aisb = airq_iv_alloc_bit(zpci_aisb_iv); 355 - if (aisb == -1UL) 356 - return -EIO; 357 - zdev->aisb = aisb; 358 - 359 - /* Create adapter interrupt vector */ 360 - zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK); 361 - if (!zdev->aibv) 362 - return -ENOMEM; 363 - 364 - /* Wire up shortcut pointer */ 365 - zpci_aibv[aisb] = zdev->aibv; 366 - 367 - /* Request MSI interrupts */ 368 - hwirq = 0; 369 - for_each_pci_msi_entry(msi, pdev) { 370 - if (hwirq >= msi_vecs) 371 - break; 372 - irq = irq_alloc_desc(0); /* Alloc irq on node 0 */ 373 - if (irq < 0) 374 - return -ENOMEM; 375 - rc = irq_set_msi_desc(irq, msi); 376 - if (rc) 377 - return rc; 378 - irq_set_chip_and_handler(irq, &zpci_irq_chip, 379 - handle_simple_irq); 380 - msg.data = hwirq; 381 - msg.address_lo = zdev->msi_addr & 0xffffffff; 382 - msg.address_hi = zdev->msi_addr >> 32; 383 - pci_write_msi_msg(irq, &msg); 384 - airq_iv_set_data(zdev->aibv, hwirq, irq); 385 - hwirq++; 386 - } 387 - 388 - /* Enable adapter interrupts */ 389 - rc = zpci_set_airq(zdev); 390 - if (rc) 391 - return rc; 392 - 393 - return (msi_vecs == nvec) ? 0 : msi_vecs; 394 - } 395 - 396 - void arch_teardown_msi_irqs(struct pci_dev *pdev) 397 - { 398 - struct zpci_dev *zdev = to_zpci(pdev); 399 - struct msi_desc *msi; 400 - int rc; 401 - 402 - /* Disable adapter interrupts */ 403 - rc = zpci_clear_airq(zdev); 404 - if (rc) 405 - return; 406 - 407 - /* Release MSI interrupts */ 408 - for_each_pci_msi_entry(msi, pdev) { 409 - if (!msi->irq) 410 - continue; 411 - if (msi->msi_attrib.is_msix) 412 - __pci_msix_desc_mask_irq(msi, 1); 413 - else 414 - __pci_msi_desc_mask_irq(msi, 1, 1); 415 - irq_set_msi_desc(msi->irq, NULL); 416 - irq_free_desc(msi->irq); 417 - msi->msg.address_lo = 0; 418 - msi->msg.address_hi = 0; 419 - msi->msg.data = 0; 420 - msi->irq = 0; 421 - } 422 - 423 - if (zdev->aisb != -1UL) { 424 - zpci_aibv[zdev->aisb] = NULL; 425 - airq_iv_free_bit(zpci_aisb_iv, zdev->aisb); 426 - zdev->aisb = -1UL; 427 - } 428 - if (zdev->aibv) { 429 - airq_iv_release(zdev->aibv); 430 - zdev->aibv = NULL; 431 - } 432 - } 433 - 434 355 #ifdef CONFIG_PCI_IOV 435 356 static struct resource iov_res = { 436 357 .name = "PCI IOV res", ··· 348 529 pci_iounmap(pdev, (void __iomem __force *) 349 530 pdev->resource[i].start); 350 531 } 351 - } 352 - 353 - static struct airq_struct zpci_airq = { 354 - .handler = zpci_irq_handler, 355 - .isc = PCI_ISC, 356 - }; 357 - 358 - static int __init zpci_irq_init(void) 359 - { 360 - int rc; 361 - 362 - rc = register_adapter_interrupt(&zpci_airq); 363 - if (rc) 364 - goto out; 365 - /* Set summary to 1 to be called every time for the ISC. */ 366 - *zpci_airq.lsi_ptr = 1; 367 - 368 - rc = -ENOMEM; 369 - zpci_aisb_iv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC); 370 - if (!zpci_aisb_iv) 371 - goto out_airq; 372 - 373 - zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC); 374 - return 0; 375 - 376 - out_airq: 377 - unregister_adapter_interrupt(&zpci_airq); 378 - out: 379 - return rc; 380 - } 381 - 382 - static void zpci_irq_exit(void) 383 - { 384 - airq_iv_release(zpci_aisb_iv); 385 - unregister_adapter_interrupt(&zpci_airq); 386 532 } 387 533 388 534 static int zpci_alloc_iomap(struct zpci_dev *zdev)
+222
arch/s390/pci/pci_irq.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #define KMSG_COMPONENT "zpci" 3 + #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 4 + 5 + #include <linux/kernel.h> 6 + #include <linux/irq.h> 7 + #include <linux/kernel_stat.h> 8 + #include <linux/pci.h> 9 + #include <linux/msi.h> 10 + 11 + #include <asm/isc.h> 12 + #include <asm/airq.h> 13 + 14 + #define SIC_IRQ_MODE_ALL 0 15 + #define SIC_IRQ_MODE_SINGLE 1 16 + 17 + static struct airq_iv *zpci_aisb_iv; 18 + static struct airq_iv *zpci_aibv[ZPCI_NR_DEVICES]; 19 + 20 + /* Modify PCI: Register adapter interruptions */ 21 + static int zpci_set_airq(struct zpci_dev *zdev) 22 + { 23 + u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_REG_INT); 24 + struct zpci_fib fib = {0}; 25 + u8 status; 26 + 27 + fib.isc = PCI_ISC; 28 + fib.sum = 1; /* enable summary notifications */ 29 + fib.noi = airq_iv_end(zdev->aibv); 30 + fib.aibv = (unsigned long) zdev->aibv->vector; 31 + fib.aibvo = 0; /* each zdev has its own interrupt vector */ 32 + fib.aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8; 33 + fib.aisbo = zdev->aisb & 63; 34 + 35 + return zpci_mod_fc(req, &fib, &status) ? -EIO : 0; 36 + } 37 + 38 + /* Modify PCI: Unregister adapter interruptions */ 39 + static int zpci_clear_airq(struct zpci_dev *zdev) 40 + { 41 + u64 req = ZPCI_CREATE_REQ(zdev->fh, 0, ZPCI_MOD_FC_DEREG_INT); 42 + struct zpci_fib fib = {0}; 43 + u8 cc, status; 44 + 45 + cc = zpci_mod_fc(req, &fib, &status); 46 + if (cc == 3 || (cc == 1 && status == 24)) 47 + /* Function already gone or IRQs already deregistered. */ 48 + cc = 0; 49 + 50 + return cc ? -EIO : 0; 51 + } 52 + 53 + static struct irq_chip zpci_irq_chip = { 54 + .name = "zPCI", 55 + .irq_unmask = pci_msi_unmask_irq, 56 + .irq_mask = pci_msi_mask_irq, 57 + }; 58 + 59 + static void zpci_irq_handler(struct airq_struct *airq) 60 + { 61 + unsigned long si, ai; 62 + struct airq_iv *aibv; 63 + int irqs_on = 0; 64 + 65 + inc_irq_stat(IRQIO_PCI); 66 + for (si = 0;;) { 67 + /* Scan adapter summary indicator bit vector */ 68 + si = airq_iv_scan(zpci_aisb_iv, si, airq_iv_end(zpci_aisb_iv)); 69 + if (si == -1UL) { 70 + if (irqs_on++) 71 + /* End of second scan with interrupts on. */ 72 + break; 73 + /* First scan complete, reenable interrupts. */ 74 + if (zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC)) 75 + break; 76 + si = 0; 77 + continue; 78 + } 79 + 80 + /* Scan the adapter interrupt vector for this device. */ 81 + aibv = zpci_aibv[si]; 82 + for (ai = 0;;) { 83 + ai = airq_iv_scan(aibv, ai, airq_iv_end(aibv)); 84 + if (ai == -1UL) 85 + break; 86 + inc_irq_stat(IRQIO_MSI); 87 + airq_iv_lock(aibv, ai); 88 + generic_handle_irq(airq_iv_get_data(aibv, ai)); 89 + airq_iv_unlock(aibv, ai); 90 + } 91 + } 92 + } 93 + 94 + int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) 95 + { 96 + struct zpci_dev *zdev = to_zpci(pdev); 97 + unsigned int hwirq, msi_vecs; 98 + unsigned long aisb; 99 + struct msi_desc *msi; 100 + struct msi_msg msg; 101 + int rc, irq; 102 + 103 + zdev->aisb = -1UL; 104 + if (type == PCI_CAP_ID_MSI && nvec > 1) 105 + return 1; 106 + msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); 107 + 108 + /* Allocate adapter summary indicator bit */ 109 + aisb = airq_iv_alloc_bit(zpci_aisb_iv); 110 + if (aisb == -1UL) 111 + return -EIO; 112 + zdev->aisb = aisb; 113 + 114 + /* Create adapter interrupt vector */ 115 + zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK); 116 + if (!zdev->aibv) 117 + return -ENOMEM; 118 + 119 + /* Wire up shortcut pointer */ 120 + zpci_aibv[aisb] = zdev->aibv; 121 + 122 + /* Request MSI interrupts */ 123 + hwirq = 0; 124 + for_each_pci_msi_entry(msi, pdev) { 125 + if (hwirq >= msi_vecs) 126 + break; 127 + irq = irq_alloc_desc(0); /* Alloc irq on node 0 */ 128 + if (irq < 0) 129 + return -ENOMEM; 130 + rc = irq_set_msi_desc(irq, msi); 131 + if (rc) 132 + return rc; 133 + irq_set_chip_and_handler(irq, &zpci_irq_chip, 134 + handle_simple_irq); 135 + msg.data = hwirq; 136 + msg.address_lo = zdev->msi_addr & 0xffffffff; 137 + msg.address_hi = zdev->msi_addr >> 32; 138 + pci_write_msi_msg(irq, &msg); 139 + airq_iv_set_data(zdev->aibv, hwirq, irq); 140 + hwirq++; 141 + } 142 + 143 + /* Enable adapter interrupts */ 144 + rc = zpci_set_airq(zdev); 145 + if (rc) 146 + return rc; 147 + 148 + return (msi_vecs == nvec) ? 0 : msi_vecs; 149 + } 150 + 151 + void arch_teardown_msi_irqs(struct pci_dev *pdev) 152 + { 153 + struct zpci_dev *zdev = to_zpci(pdev); 154 + struct msi_desc *msi; 155 + int rc; 156 + 157 + /* Disable adapter interrupts */ 158 + rc = zpci_clear_airq(zdev); 159 + if (rc) 160 + return; 161 + 162 + /* Release MSI interrupts */ 163 + for_each_pci_msi_entry(msi, pdev) { 164 + if (!msi->irq) 165 + continue; 166 + if (msi->msi_attrib.is_msix) 167 + __pci_msix_desc_mask_irq(msi, 1); 168 + else 169 + __pci_msi_desc_mask_irq(msi, 1, 1); 170 + irq_set_msi_desc(msi->irq, NULL); 171 + irq_free_desc(msi->irq); 172 + msi->msg.address_lo = 0; 173 + msi->msg.address_hi = 0; 174 + msi->msg.data = 0; 175 + msi->irq = 0; 176 + } 177 + 178 + if (zdev->aisb != -1UL) { 179 + zpci_aibv[zdev->aisb] = NULL; 180 + airq_iv_free_bit(zpci_aisb_iv, zdev->aisb); 181 + zdev->aisb = -1UL; 182 + } 183 + if (zdev->aibv) { 184 + airq_iv_release(zdev->aibv); 185 + zdev->aibv = NULL; 186 + } 187 + } 188 + 189 + static struct airq_struct zpci_airq = { 190 + .handler = zpci_irq_handler, 191 + .isc = PCI_ISC, 192 + }; 193 + 194 + int __init zpci_irq_init(void) 195 + { 196 + int rc; 197 + 198 + rc = register_adapter_interrupt(&zpci_airq); 199 + if (rc) 200 + goto out; 201 + /* Set summary to 1 to be called every time for the ISC. */ 202 + *zpci_airq.lsi_ptr = 1; 203 + 204 + rc = -ENOMEM; 205 + zpci_aisb_iv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC); 206 + if (!zpci_aisb_iv) 207 + goto out_airq; 208 + 209 + zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC); 210 + return 0; 211 + 212 + out_airq: 213 + unregister_adapter_interrupt(&zpci_airq); 214 + out: 215 + return rc; 216 + } 217 + 218 + void __init zpci_irq_exit(void) 219 + { 220 + airq_iv_release(zpci_aisb_iv); 221 + unregister_adapter_interrupt(&zpci_airq); 222 + }