Skip to content

Commit 749aaf3

Browse files
johnkeepingbjorn-helgaas
authored andcommitted
PCI: endpoint: Use correct "end of test" interrupt
pci_epf_test_raise_irq() reads the interrupt to use for the response from reg->command, but this has been cleared at the beginning of the command handler so the value is always zero at this point. Instead, extract the interrupt index before handling the command and then pass the requested interrupt into pci_epf_test_raise_irq(). This allows us to remove the specific code to extract the interrupt for COMMAND_RAISE_MSI_IRQ since it is now handled in common code. Fixes: 3ecf323 ("PCI: endpoint: Do not reset *command* inadvertently") Signed-off-by: John Keeping <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Acked-by: Kishon Vijay Abraham I <[email protected]>
1 parent 19a8d6b commit 749aaf3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,8 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
251251
return ret;
252252
}
253253

254-
static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test)
254+
static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, u8 irq)
255255
{
256-
u8 irq;
257256
u8 msi_count;
258257
struct pci_epf *epf = epf_test->epf;
259258
struct pci_epc *epc = epf->epc;
@@ -262,7 +261,6 @@ static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test)
262261

263262
reg->status |= STATUS_IRQ_RAISED;
264263
msi_count = pci_epc_get_msi(epc);
265-
irq = (reg->command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT;
266264
if (irq > msi_count || msi_count <= 0)
267265
pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0);
268266
else
@@ -289,6 +287,8 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
289287
reg->command = 0;
290288
reg->status = 0;
291289

290+
irq = (command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT;
291+
292292
if (command & COMMAND_RAISE_LEGACY_IRQ) {
293293
reg->status = STATUS_IRQ_RAISED;
294294
pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0);
@@ -301,7 +301,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
301301
reg->status |= STATUS_WRITE_FAIL;
302302
else
303303
reg->status |= STATUS_WRITE_SUCCESS;
304-
pci_epf_test_raise_irq(epf_test);
304+
pci_epf_test_raise_irq(epf_test, irq);
305305
goto reset_handler;
306306
}
307307

@@ -311,7 +311,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
311311
reg->status |= STATUS_READ_SUCCESS;
312312
else
313313
reg->status |= STATUS_READ_FAIL;
314-
pci_epf_test_raise_irq(epf_test);
314+
pci_epf_test_raise_irq(epf_test, irq);
315315
goto reset_handler;
316316
}
317317

@@ -321,13 +321,12 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
321321
reg->status |= STATUS_COPY_SUCCESS;
322322
else
323323
reg->status |= STATUS_COPY_FAIL;
324-
pci_epf_test_raise_irq(epf_test);
324+
pci_epf_test_raise_irq(epf_test, irq);
325325
goto reset_handler;
326326
}
327327

328328
if (command & COMMAND_RAISE_MSI_IRQ) {
329329
msi_count = pci_epc_get_msi(epc);
330-
irq = (command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT;
331330
if (irq > msi_count || msi_count <= 0)
332331
goto reset_handler;
333332
reg->status = STATUS_IRQ_RAISED;

0 commit comments

Comments
 (0)