crypto: ccp - Fix check for the primary ASP device
commit 07bb097b92b987db518e72525b515d77904e966e upstream.
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: 2a6170dfe7
("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ecc44297ac
commit
5baddc0806
@@ -243,14 +243,17 @@ static bool sp_pci_is_master(struct sp_device *sp)
|
|||||||
pdev_new = to_pci_dev(dev_new);
|
pdev_new = to_pci_dev(dev_new);
|
||||||
pdev_cur = to_pci_dev(dev_cur);
|
pdev_cur = to_pci_dev(dev_cur);
|
||||||
|
|
||||||
if (pdev_new->bus->number < pdev_cur->bus->number)
|
if (pci_domain_nr(pdev_new->bus) != pci_domain_nr(pdev_cur->bus))
|
||||||
return true;
|
return pci_domain_nr(pdev_new->bus) < pci_domain_nr(pdev_cur->bus);
|
||||||
|
|
||||||
if (PCI_SLOT(pdev_new->devfn) < PCI_SLOT(pdev_cur->devfn))
|
if (pdev_new->bus->number != pdev_cur->bus->number)
|
||||||
return true;
|
return pdev_new->bus->number < pdev_cur->bus->number;
|
||||||
|
|
||||||
if (PCI_FUNC(pdev_new->devfn) < PCI_FUNC(pdev_cur->devfn))
|
if (PCI_SLOT(pdev_new->devfn) != PCI_SLOT(pdev_cur->devfn))
|
||||||
return true;
|
return PCI_SLOT(pdev_new->devfn) < PCI_SLOT(pdev_cur->devfn);
|
||||||
|
|
||||||
|
if (PCI_FUNC(pdev_new->devfn) != PCI_FUNC(pdev_cur->devfn))
|
||||||
|
return PCI_FUNC(pdev_new->devfn) < PCI_FUNC(pdev_cur->devfn);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user