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 9F02BC433EF for ; Mon, 14 Feb 2022 10:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348850AbiBNKtv (ORCPT ); Mon, 14 Feb 2022 05:49:51 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:38544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349297AbiBNKtS (ORCPT ); Mon, 14 Feb 2022 05:49:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC44BBF968; Mon, 14 Feb 2022 02:12:30 -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 87D9B61073; Mon, 14 Feb 2022 10:12:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66EBAC340E9; Mon, 14 Feb 2022 10:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644833550; bh=7NYDUafZDceGQPElb2hl+Hd5rp37LJZRhhfQjS2vSeY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KIA94p4J7BkmTeN192s/A8IemcJzGjBWor/XAvftRUl2OnKHj1JcdIwkXM4WhhTxP eoyys+e7YJRpTBpF2UCcoDVWqVl1VgB1QoSg6p9zpK4lEQhSYTPSD0yqpnvZlZC4Fh YvBMlrTmTr8m62V/aKo0ZVrsFC30ht5DbB/euNWo= Date: Mon, 14 Feb 2022 11:03:42 +0100 From: Greg Kroah-Hartman To: Lu Baolu Cc: Joerg Roedel , Alex Williamson , Bjorn Helgaas , Jason Gunthorpe , Christoph Hellwig , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Dan Williams , rafael@kernel.org, Diana Craciun , Cornelia Huck , Eric Auger , Liu Yi L , Jacob jun Pan , Chaitanya Kulkarni , Stuart Yoder , Laurentiu Tudor , Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , Li Yang , Dmitry Osipenko , iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 07/14] PCI: Add driver dma ownership management Message-ID: References: <20220104015644.2294354-1-baolu.lu@linux.intel.com> <20220104015644.2294354-8-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220104015644.2294354-8-baolu.lu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Tue, Jan 04, 2022 at 09:56:37AM +0800, Lu Baolu wrote: > Multiple PCI devices may be placed in the same IOMMU group because > they cannot be isolated from each other. These devices must either be > entirely under kernel control or userspace control, never a mixture. This > checks and sets DMA ownership during driver binding, and release the > ownership during driver unbinding. > > The device driver may set a new flag (no_kernel_api_dma) to skip calling > iommu_device_use_dma_api() during the binding process. For instance, the > userspace framework drivers (vfio etc.) which need to manually claim > their own dma ownership when assigning the device to userspace. > > Signed-off-by: Lu Baolu > --- > include/linux/pci.h | 5 +++++ > drivers/pci/pci-driver.c | 21 +++++++++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/include/linux/pci.h b/include/linux/pci.h > index 18a75c8e615c..d29a990e3f02 100644 > --- a/include/linux/pci.h > +++ b/include/linux/pci.h > @@ -882,6 +882,10 @@ struct module; > * created once it is bound to the driver. > * @driver: Driver model structure. > * @dynids: List of dynamically added device IDs. > + * @no_kernel_api_dma: Device driver doesn't use kernel DMA API for DMA. > + * Drivers which don't require DMA or want to manually claim the > + * owner type (e.g. userspace driver frameworks) could set this > + * flag. Again with the bikeshedding, but this name is a bit odd. Of course it's in the kernel, this is all kernel code, so you can drop that. And again, "negative" flags are rough. So maybe just "prevent_dma"? thanks, greg k-h