Skip to content

Commit

Permalink
s390/pci: clarify interrupt vector usage
Browse files Browse the repository at this point in the history
Rename and clarify the usage of the interrupt bit vectors. Also change
the array of the per-function bit vectors to be dynamically allocated.

Signed-off-by: Sebastian Ott <sebott@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Sebastian Ott authored and Martin Schwidefsky committed Apr 29, 2019
1 parent 30e63ef commit b1f5486
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions arch/s390/pci/pci_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
#define SIC_IRQ_MODE_ALL 0
#define SIC_IRQ_MODE_SINGLE 1

static struct airq_iv *zpci_aisb_iv;
static struct airq_iv *zpci_aibv[ZPCI_NR_DEVICES];
/*
* summary bit vector - one summary bit per function
*/
static struct airq_iv *zpci_sbv;

/*
* interrupt bit vectors - one vector per function
*/
static struct airq_iv **zpci_ibv;

/* Modify PCI: Register adapter interruptions */
static int zpci_set_airq(struct zpci_dev *zdev)
Expand All @@ -29,7 +36,7 @@ static int zpci_set_airq(struct zpci_dev *zdev)
fib.noi = airq_iv_end(zdev->aibv);
fib.aibv = (unsigned long) zdev->aibv->vector;
fib.aibvo = 0; /* each zdev has its own interrupt vector */
fib.aisb = (unsigned long) zpci_aisb_iv->vector + (zdev->aisb/64)*8;
fib.aisb = (unsigned long) zpci_sbv->vector + (zdev->aisb/64)*8;
fib.aisbo = zdev->aisb & 63;

return zpci_mod_fc(req, &fib, &status) ? -EIO : 0;
Expand Down Expand Up @@ -65,7 +72,7 @@ static void zpci_irq_handler(struct airq_struct *airq, bool floating)
inc_irq_stat(IRQIO_PCI);
for (si = 0;;) {
/* Scan adapter summary indicator bit vector */
si = airq_iv_scan(zpci_aisb_iv, si, airq_iv_end(zpci_aisb_iv));
si = airq_iv_scan(zpci_sbv, si, airq_iv_end(zpci_sbv));
if (si == -1UL) {
if (irqs_on++)
/* End of second scan with interrupts on. */
Expand All @@ -78,7 +85,7 @@ static void zpci_irq_handler(struct airq_struct *airq, bool floating)
}

/* Scan the adapter interrupt vector for this device. */
aibv = zpci_aibv[si];
aibv = zpci_ibv[si];
for (ai = 0;;) {
ai = airq_iv_scan(aibv, ai, airq_iv_end(aibv));
if (ai == -1UL)
Expand Down Expand Up @@ -106,7 +113,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
msi_vecs = min_t(unsigned int, nvec, zdev->max_msi);

/* Allocate adapter summary indicator bit */
aisb = airq_iv_alloc_bit(zpci_aisb_iv);
aisb = airq_iv_alloc_bit(zpci_sbv);
if (aisb == -1UL)
return -EIO;
zdev->aisb = aisb;
Expand All @@ -117,7 +124,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
return -ENOMEM;

/* Wire up shortcut pointer */
zpci_aibv[aisb] = zdev->aibv;
zpci_ibv[aisb] = zdev->aibv;

/* Request MSI interrupts */
hwirq = 0;
Expand Down Expand Up @@ -176,8 +183,8 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
}

if (zdev->aisb != -1UL) {
zpci_aibv[zdev->aisb] = NULL;
airq_iv_free_bit(zpci_aisb_iv, zdev->aisb);
zpci_ibv[zdev->aisb] = NULL;
airq_iv_free_bit(zpci_sbv, zdev->aisb);
zdev->aisb = -1UL;
}
if (zdev->aibv) {
Expand All @@ -202,13 +209,19 @@ int __init zpci_irq_init(void)
*zpci_airq.lsi_ptr = 1;

rc = -ENOMEM;
zpci_aisb_iv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC);
if (!zpci_aisb_iv)
zpci_ibv = kcalloc(ZPCI_NR_DEVICES, sizeof(*zpci_ibv), GFP_KERNEL);
if (!zpci_ibv)
goto out_airq;

zpci_sbv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC);
if (!zpci_sbv)
goto out_free;

zpci_set_irq_ctrl(SIC_IRQ_MODE_SINGLE, NULL, PCI_ISC);
return 0;

out_free:
kfree(zpci_ibv);
out_airq:
unregister_adapter_interrupt(&zpci_airq);
out:
Expand All @@ -217,6 +230,7 @@ int __init zpci_irq_init(void)

void __init zpci_irq_exit(void)
{
airq_iv_release(zpci_aisb_iv);
airq_iv_release(zpci_sbv);
kfree(zpci_ibv);
unregister_adapter_interrupt(&zpci_airq);
}

0 comments on commit b1f5486

Please sign in to comment.