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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6CDB5C6FD19 for ; Mon, 13 Mar 2023 22:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=t1E93JNCK+DoAlrw5lU6ZwBdxxamLsVa9BjLBBp0668=; b=BVwhGnUAk3z9nG Q1xu//Fr8Jw1WluADzvlO0t8tdcH/2BepSrUSs+E72orujDcFdU3ndF4k8EGsGByNnvjQhyWzGnKa ioHYqahq4t3UTgwBXvwKJPq/MJwiE2ZTnt7kB+jcQ7v6ZWMYburN/cfIgrMYgDMBwpL0lRH7qVaRx PfN3pu9NeKj41TBU3KR+kelNEzRB0Rh/QVJA3XIrIzWUFCVvXojveE2MdiMvxLGqkQVj61g0lj/x4 sy2H7aCxFXSrQ2rnaqj99au0QYE4T0xhBZXmFQyVe/VKv+ek0wRrAyLFK3XYo5h0qLyAqBPPfrLK5 ihKEEWbOEehYwmmxfZOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqsC-00869s-Vl; Mon, 13 Mar 2023 22:42:33 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pbqs9-00869A-GP for linux-arm-kernel@lists.infradead.org; Mon, 13 Mar 2023 22:42:30 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2B98FB815E5; Mon, 13 Mar 2023 22:42:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFE65C433EF; Mon, 13 Mar 2023 22:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678747347; bh=o+9RRoemqsFvnAj1RdtpzpNry1V+R+AF/d0DKvHxRVU=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=oYt1JyFXtYjnJLkP9+hKdSrG6aUZ6SK954FAI7xoRfVcWNPyTeZ2JjVfA9sQ0cYlY 1ELGa60BQRmFKaPHp+nxEOR6YaRagRmIOkTK8oJ6N5SELBVIGPZP/E8+aoLCJlhSZ6 QI76mUZvTegkdb/paHdVZhYq0glRqHOZ+1BPipnTLeuT0Ji/NXoGSlJkCupO5B18QS qfLR8A4E8q9stazbYOxUAm8svbdkprcKjtSubavOGUjdjMJh4lmmXj/pNzd2mahFQu /Ey0tsbpEuBXoO41Q2tonuBl+otxVUlAjxZVs1OuCES/uTuxUJAiaGUYTqe7yuUHa/ 6C0FHq7EafXVQ== Date: Mon, 13 Mar 2023 17:42:25 -0500 From: Bjorn Helgaas To: Sathyanarayanan Kuppuswamy Cc: Ganapatrao Kulkarni , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, joro@8bytes.org, bhelgaas@google.com, robin.murphy@arm.com, will@kernel.org, jean-philippe@linaro.org, darren@os.amperecomputing.com, scott@os.amperecomputing.com Subject: Re: [PATCH v2 1/2] PCI/ATS: Add a helper function to configure ATS STU of a PF Message-ID: <20230313224225.GA1551878@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6339c50a-8dfe-f3a2-63d7-504abd4e62f0@linux.intel.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230313_154229_710588_6266348C X-CRM114-Status: GOOD ( 22.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Mar 13, 2023 at 03:30:30PM -0700, Sathyanarayanan Kuppuswamy wrote: > On 3/13/23 2:12 PM, Bjorn Helgaas wrote: > > On Mon, Feb 27, 2023 at 08:21:36PM -0800, Ganapatrao Kulkarni wrote: > >> As per PCI specification (PCI Express Base Specification Revision > >> 6.0, Section 10.5) both PF and VFs of a PCI EP are permitted to be enabled > >> independently for ATS capability, however the STU(Smallest Translation > >> Unit) is shared between PF and VFs. For VFs, it is hardwired to Zero and > >> the associated PF's value applies to VFs. > >> > >> In the current code, the STU is being configured while enabling the PF ATS. > >> Hence, it is not able to enable ATS for VFs, if it is not enabled on the > >> associated PF already. > >> > >> Adding a function pci_ats_stu_configure(), which can be called to > >> configure the STU during PF enumeration. > >> Latter enumerations of VFs can successfully enable ATS independently. > >> + * pci_ats_stu_configure - Configure STU of a PF. > >> + * @dev: the PCI device > >> + * @ps: the IOMMU page shift > >> + * > >> + * Returns 0 on success, or negative on failure. > >> + */ > >> +int pci_ats_stu_configure(struct pci_dev *dev, int ps) > >> +{ > >> + u16 ctrl; > >> + > >> + if (dev->ats_enabled || dev->is_virtfn) > >> + return 0; > > We don't have any checks for the PF case here. That means you can > re-configure the STU as many times as you want until ATS is enabled > in PF. So, if there are active VFs which uses this STU, can PF > re-configure the STU at will? Really good question! I withdraw my ack until this is resolved. I don't think we want PFs changing STU behind the back of VFs. Bjorn _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel