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

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: 3ecf3232c54c ("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>

authored by

John Keeping and committed by
Bjorn Helgaas
749aaf33 19a8d6b7

+6 -7
+6 -7
drivers/pci/endpoint/functions/pci-epf-test.c
··· 251 251 return ret; 252 252 } 253 253 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) 255 255 { 256 - u8 irq; 257 256 u8 msi_count; 258 257 struct pci_epf *epf = epf_test->epf; 259 258 struct pci_epc *epc = epf->epc; ··· 261 262 262 263 reg->status |= STATUS_IRQ_RAISED; 263 264 msi_count = pci_epc_get_msi(epc); 264 - irq = (reg->command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT; 265 265 if (irq > msi_count || msi_count <= 0) 266 266 pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); 267 267 else ··· 287 289 reg->command = 0; 288 290 reg->status = 0; 289 291 292 + irq = (command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT; 293 + 290 294 if (command & COMMAND_RAISE_LEGACY_IRQ) { 291 295 reg->status = STATUS_IRQ_RAISED; 292 296 pci_epc_raise_irq(epc, PCI_EPC_IRQ_LEGACY, 0); ··· 301 301 reg->status |= STATUS_WRITE_FAIL; 302 302 else 303 303 reg->status |= STATUS_WRITE_SUCCESS; 304 - pci_epf_test_raise_irq(epf_test); 304 + pci_epf_test_raise_irq(epf_test, irq); 305 305 goto reset_handler; 306 306 } 307 307 ··· 311 311 reg->status |= STATUS_READ_SUCCESS; 312 312 else 313 313 reg->status |= STATUS_READ_FAIL; 314 - pci_epf_test_raise_irq(epf_test); 314 + pci_epf_test_raise_irq(epf_test, irq); 315 315 goto reset_handler; 316 316 } 317 317 ··· 321 321 reg->status |= STATUS_COPY_SUCCESS; 322 322 else 323 323 reg->status |= STATUS_COPY_FAIL; 324 - pci_epf_test_raise_irq(epf_test); 324 + pci_epf_test_raise_irq(epf_test, irq); 325 325 goto reset_handler; 326 326 } 327 327 328 328 if (command & COMMAND_RAISE_MSI_IRQ) { 329 329 msi_count = pci_epc_get_msi(epc); 330 - irq = (command & MSI_NUMBER_MASK) >> MSI_NUMBER_SHIFT; 331 330 if (irq > msi_count || msi_count <= 0) 332 331 goto reset_handler; 333 332 reg->status = STATUS_IRQ_RAISED;