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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EB2AC433F5 for ; Mon, 28 Feb 2022 19:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229881AbiB1T5O (ORCPT ); Mon, 28 Feb 2022 14:57:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229864AbiB1T5M (ORCPT ); Mon, 28 Feb 2022 14:57:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 453A9140C4; Mon, 28 Feb 2022 11:56:31 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id D009D60A5B; Mon, 28 Feb 2022 19:56:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E835BC340F1; Mon, 28 Feb 2022 19:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646078190; bh=0OOU4ypDKyXvi1uajjSPnUmhPXeaSTp6ukVsSrlQHcA=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=RTXisNBZzA45iz5I1nD1Q49iYcdgMwiouYVpm5sJdmQu/9H3Ov4Fq04ogI46PGsIA oaBc37LVfwkKEZGCfFvr/j6nXxvPNIVuYPdJshypg2oWys6+aYhwo/oVHDZ0rhpKY+ +4mXh3fKy9RPjTyNheqYMVhvd9FlT6UZqMOgAL17c9ULCYs2cORvz/yNnrsPYMQQc0 UsPcu4z97fXmbKmf7hrkgc98uhwRfmsW9ncPZar9gWRTnnR+05/5gM/is7Mp1mvv7y 7xb/Zt2d7+4d+67ra8MyvoYhvG1UD37XJaFlwAMYuOJcjBzVy9IrI4UHnH5VWgi1+a HJ04Qzzd6J+DA== Date: Mon, 28 Feb 2022 13:56:28 -0600 From: Bjorn Helgaas To: Lu Baolu Cc: Greg Kroah-Hartman , Joerg Roedel , Alex Williamson , Bjorn Helgaas , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , kvm@vger.kernel.org, rafael@kernel.org, David Airlie , linux-pci@vger.kernel.org, Thierry Reding , Diana Craciun , Dmitry Osipenko , Will Deacon , Stuart Yoder , Jonathan Hunter , Chaitanya Kulkarni , Dan Williams , Cornelia Huck , linux-kernel@vger.kernel.org, Li Yang , iommu@lists.linux-foundation.org, Jacob jun Pan , Daniel Vetter , Robin Murphy Subject: Re: [PATCH v7 06/11] PCI: portdrv: Set driver_managed_dma Message-ID: <20220228195628.GA515785@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220228005056.599595-7-baolu.lu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Mon, Feb 28, 2022 at 08:50:51AM +0800, Lu Baolu wrote: > If a switch lacks ACS P2P Request Redirect, a device below the switch can > bypass the IOMMU and DMA directly to other devices below the switch, so > all the downstream devices must be in the same IOMMU group as the switch > itself. > > The existing VFIO framework allows the portdrv driver to be bound to the > bridge while its downstream devices are assigned to user space. The > pci_dma_configure() marks the IOMMU group as containing only devices > with kernel drivers that manage DMA. Avoid this default behavior for the > portdrv driver in order for compatibility with the current VFIO usage. It would be nice to explicitly say here how we can look at portdrv (and pci_stub) and conclude that ".driver_managed_dma = true" is safe. Otherwise I won't know what kind of future change to portdrv might make it unsafe. > Suggested-by: Jason Gunthorpe > Suggested-by: Kevin Tian > Signed-off-by: Lu Baolu > Reviewed-by: Jason Gunthorpe Acked-by: Bjorn Helgaas > --- > drivers/pci/pcie/portdrv_pci.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c > index 35eca6277a96..6b2adb678c21 100644 > --- a/drivers/pci/pcie/portdrv_pci.c > +++ b/drivers/pci/pcie/portdrv_pci.c > @@ -202,6 +202,8 @@ static struct pci_driver pcie_portdriver = { > > .err_handler = &pcie_portdrv_err_handler, > > + .driver_managed_dma = true, > + > .driver.pm = PCIE_PORTDRV_PM_OPS, > }; > > -- > 2.25.1 > > _______________________________________________ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu