Skip to content

Commit 07bb097

Browse files
tlendackyherbertx
authored andcommitted
crypto: ccp - Fix check for the primary ASP device
Currently, the ASP primary device check does not have support for PCI domains, and, as a result, when the system is configured with PCI domains (PCI segments) the wrong device can be selected as primary. This results in commands submitted to the device timing out and failing. The device check also relies on specific device and function assignments that may not hold in the future. Fix the primary ASP device check to include support for PCI domains and to perform proper checking of the Bus/Device/Function positions. Fixes: 2a6170d ("crypto: ccp: Add Platform Security Processor (PSP) device support") Cc: stable@vger.kernel.org Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 1fe244c commit 07bb097

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/crypto/ccp/sp-pci.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,17 @@ static bool sp_pci_is_master(struct sp_device *sp)
189189
pdev_new = to_pci_dev(dev_new);
190190
pdev_cur = to_pci_dev(dev_cur);
191191

192-
if (pdev_new->bus->number < pdev_cur->bus->number)
193-
return true;
192+
if (pci_domain_nr(pdev_new->bus) != pci_domain_nr(pdev_cur->bus))
193+
return pci_domain_nr(pdev_new->bus) < pci_domain_nr(pdev_cur->bus);
194194

195-
if (PCI_SLOT(pdev_new->devfn) < PCI_SLOT(pdev_cur->devfn))
196-
return true;
195+
if (pdev_new->bus->number != pdev_cur->bus->number)
196+
return pdev_new->bus->number < pdev_cur->bus->number;
197197

198-
if (PCI_FUNC(pdev_new->devfn) < PCI_FUNC(pdev_cur->devfn))
199-
return true;
198+
if (PCI_SLOT(pdev_new->devfn) != PCI_SLOT(pdev_cur->devfn))
199+
return PCI_SLOT(pdev_new->devfn) < PCI_SLOT(pdev_cur->devfn);
200+
201+
if (PCI_FUNC(pdev_new->devfn) != PCI_FUNC(pdev_cur->devfn))
202+
return PCI_FUNC(pdev_new->devfn) < PCI_FUNC(pdev_cur->devfn);
200203

201204
return false;
202205
}

0 commit comments

Comments
 (0)