On 2025/1/15 16:11, Tian, Kevin wrote:
From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
Sent: Thursday, December 19, 2024 9:36 PM
+ * if it's enabled.
+ */
+ if (idev->dev->iommu->max_pasids) {
+ cmd->out_max_pasid_log2 = ilog2(idev->dev->iommu-
max_pasids);
+
+ if (dev_is_pci(idev->dev)) {
+ struct pci_dev *pdev = to_pci_dev(idev->dev);
+ int ctrl;
+
+ ctrl = pci_pasid_ctrl_status(pdev);
+
+ WARN_ON_ONCE(!(ctrl & PCI_PASID_CTRL_ENABLE));
If not enabled then also clear cmd->out_max_pasid_log2?
btw pci_pasid_ctrl_status() could return a errno but the check above
treat it as an unsigned value.
ctrl should never be errno when idev->dev->iommu->max_pasids is non-zero.
Perhaps this warn should check ctrl as well. Like the below:
WARN_ON_ONCE(ctrl < 0 || !(ctrl & PCI_PASID_CTRL_ENABLE));
Regards,
Yi Liu