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: 3ecf3232c5 ("PCI: endpoint: Do not reset *command* inadvertently")
Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
This commit is contained in:
John Keeping 2017-09-20 13:56:06 -05:00 committed by Bjorn Helgaas
parent 19a8d6b760
commit 749aaf3372
1 changed files with 6 additions and 7 deletions

View File

@ -251,9 +251,8 @@ err:
return ret; return ret;
} }
static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test) static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, u8 irq)
{ {
u8 irq;
u8 msi_count; u8 msi_count;
struct pci_epf *epf = epf_test->epf; struct pci_epf *epf = epf_test->epf;
struct pci_epc *epc = epf->epc; struct pci_epc *epc = epf->epc;
@ -262,7 +261,6 @@ static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test)
reg->status |= STATUS_IRQ_RAISED; reg->status |= STATUS_IRQ_RAISED;
msi_count = pci_epc_get_msi(epc); msi_count = pci_epc_get_msi(epc);
irq = (reg->command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT;
if (irq > msi_count || msi_count <= 0) if (irq > msi_count || msi_count <= 0)
pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0);
else else
@ -289,6 +287,8 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
reg->command = 0; reg->command = 0;
reg->status = 0; reg->status = 0;
irq = (command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT;
if (command & COMMAND_RAISE_LEGACY_IRQ) { if (command & COMMAND_RAISE_LEGACY_IRQ) {
reg->status = STATUS_IRQ_RAISED; reg->status = STATUS_IRQ_RAISED;
pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); 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)
reg->status |= STATUS_WRITE_FAIL; reg->status |= STATUS_WRITE_FAIL;
else else
reg->status |= STATUS_WRITE_SUCCESS; reg->status |= STATUS_WRITE_SUCCESS;
pci_epf_test_raise_irq(epf_test); pci_epf_test_raise_irq(epf_test, irq);
goto reset_handler; goto reset_handler;
} }
@ -311,7 +311,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
reg->status |= STATUS_READ_SUCCESS; reg->status |= STATUS_READ_SUCCESS;
else else
reg->status |= STATUS_READ_FAIL; reg->status |= STATUS_READ_FAIL;
pci_epf_test_raise_irq(epf_test); pci_epf_test_raise_irq(epf_test, irq);
goto reset_handler; goto reset_handler;
} }
@ -321,13 +321,12 @@ static void pci_epf_test_cmd_handler(struct work_struct *work)
reg->status |= STATUS_COPY_SUCCESS; reg->status |= STATUS_COPY_SUCCESS;
else else
reg->status |= STATUS_COPY_FAIL; reg->status |= STATUS_COPY_FAIL;
pci_epf_test_raise_irq(epf_test); pci_epf_test_raise_irq(epf_test, irq);
goto reset_handler; goto reset_handler;
} }
if (command & COMMAND_RAISE_MSI_IRQ) { if (command & COMMAND_RAISE_MSI_IRQ) {
msi_count = pci_epc_get_msi(epc); msi_count = pci_epc_get_msi(epc);
irq = (command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT;
if (irq > msi_count || msi_count <= 0) if (irq > msi_count || msi_count <= 0)
goto reset_handler; goto reset_handler;
reg->status = STATUS_IRQ_RAISED; reg->status = STATUS_IRQ_RAISED;