From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 942DBC433E0 for ; Thu, 23 Jul 2020 23:54:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A32422BF5 for ; Thu, 23 Jul 2020 23:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595548489; bh=UzX/AGYoCB8T78QYmOdcDcKyRy2jrBvxTcltmnDIzdA=; h=Date:From:To:Cc:Subject:In-Reply-To:List-ID:From; b=YCz2wrNvPb7Wz6Xds2gUpOgmIyWZCpTco+Cgg7PvD2OLMVs5ba5qoYkc9WKGP0GKh nmoqr2DVl3I6Dvn9iSTvUNZNtmh67HVhk00Px0U0FBRHIh0pPo938pJ6x+YxeW+t6H wAioLjhDWLTR/STls8fFbGeDngzP4YPvSYyegDoE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbgGWXys (ORCPT ); Thu, 23 Jul 2020 19:54:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:44686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727778AbgGWXys (ORCPT ); Thu, 23 Jul 2020 19:54:48 -0400 Received: from localhost (mobile-166-175-191-139.mycingular.net [166.175.191.139]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 08097207C4; Thu, 23 Jul 2020 23:54:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595548487; bh=UzX/AGYoCB8T78QYmOdcDcKyRy2jrBvxTcltmnDIzdA=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=uslZaGUqify8pCiomAUIjTdXLyABjbNbCxTVEOTFmwx0PLP0IqN+Qa6V3cKr4XYfz BEvEgH18gnL2l4F0YWejix7P32QEZQk8AXvqCwAMGL5MwPNk+SLeTAPOwgpsSFX1od UxtN8lqUXA2GaU5toItGBuijaTpWKO6LXOfIOE38= Date: Thu, 23 Jul 2020 18:54:45 -0500 From: Bjorn Helgaas To: Ashok Raj Cc: linux-pci@vger.kernel.org, Bjorn Helgaas , Joerg Roedel , Lu Baolu , stable@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org Subject: Re: [PATCH v3 1/1] PCI/ATS: Check PRI supported on the PF device when SRIOV is enabled Message-ID: <20200723235445.GA1471911@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1595543849-19692-1-git-send-email-ashok.raj@intel.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Jul 23, 2020 at 03:37:29PM -0700, Ashok Raj wrote: > PASID and PRI capabilities are only enumerated in PF devices. VF devices > do not enumerate these capabilites. IOMMU drivers also need to enumerate > them before enabling features in the IOMMU. Extending the same support as > PASID feature discovery (pci_pasid_features) for PRI. > > Fixes: b16d0cb9e2fc ("iommu/vt-d: Always enable PASID/PRI PCI capabilities before ATS") > Signed-off-by: Ashok Raj This looks right to me, but I would like Joerg's ack before applying it. > To: Bjorn Helgaas > To: Joerg Roedel > To: Lu Baolu > Cc: stable@vger.kernel.org > Cc: linux-pci@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: Ashok Raj > Cc: iommu@lists.linux-foundation.org > --- > v3: Added Fixes tag > v2: Fixed build failure reported from lkp when CONFIG_PRI=n > > drivers/iommu/intel/iommu.c | 2 +- > drivers/pci/ats.c | 13 +++++++++++++ > include/linux/pci-ats.h | 4 ++++ > 3 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index d759e7234e98..276452f5e6a7 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -2560,7 +2560,7 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu, > } > > if (info->ats_supported && ecap_prs(iommu->ecap) && > - pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_PRI)) > + pci_pri_supported(pdev)) > info->pri_supported = 1; > } > } > diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c > index b761c1f72f67..2e6cf0c700f7 100644 > --- a/drivers/pci/ats.c > +++ b/drivers/pci/ats.c > @@ -325,6 +325,19 @@ int pci_prg_resp_pasid_required(struct pci_dev *pdev) > > return pdev->pasid_required; > } > + > +/** > + * pci_pri_supported - Check if PRI is supported. > + * @pdev: PCI device structure > + * > + * Returns true if PRI capability is present, false otherwise. > + */ > +bool pci_pri_supported(struct pci_dev *pdev) > +{ > + /* VFs share the PF PRI configuration */ > + return !!(pci_physfn(pdev)->pri_cap); > +} > +EXPORT_SYMBOL_GPL(pci_pri_supported); > #endif /* CONFIG_PCI_PRI */ > > #ifdef CONFIG_PCI_PASID > diff --git a/include/linux/pci-ats.h b/include/linux/pci-ats.h > index f75c307f346d..df54cd5b15db 100644 > --- a/include/linux/pci-ats.h > +++ b/include/linux/pci-ats.h > @@ -28,6 +28,10 @@ int pci_enable_pri(struct pci_dev *pdev, u32 reqs); > void pci_disable_pri(struct pci_dev *pdev); > int pci_reset_pri(struct pci_dev *pdev); > int pci_prg_resp_pasid_required(struct pci_dev *pdev); > +bool pci_pri_supported(struct pci_dev *pdev); > +#else > +static inline bool pci_pri_supported(struct pci_dev *pdev) > +{ return false; } > #endif /* CONFIG_PCI_PRI */ > > #ifdef CONFIG_PCI_PASID > -- > 2.7.4 >