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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18F94C433F5 for ; Mon, 27 Sep 2021 11:34:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE01D60F58 for ; Mon, 27 Sep 2021 11:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234102AbhI0Lf7 (ORCPT ); Mon, 27 Sep 2021 07:35:59 -0400 Received: from mga12.intel.com ([192.55.52.136]:7952 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234087AbhI0Lfy (ORCPT ); Mon, 27 Sep 2021 07:35:54 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10119"; a="203949077" X-IronPort-AV: E=Sophos;i="5.85,326,1624345200"; d="scan'208";a="203949077" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 04:34:16 -0700 X-IronPort-AV: E=Sophos;i="5.85,326,1624345200"; d="scan'208";a="561186742" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.212.183]) ([10.254.212.183]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 04:34:10 -0700 Cc: baolu.lu@linux.intel.com, "Liu, Yi L" , "alex.williamson@redhat.com" , "hch@lst.de" , "jasowang@redhat.com" , "joro@8bytes.org" , "jean-philippe@linaro.org" , "parav@mellanox.com" , "lkml@metux.net" , "pbonzini@redhat.com" , "lushenming@huawei.com" , "eric.auger@redhat.com" , "corbet@lwn.net" , "Raj, Ashok" , "yi.l.liu@linux.intel.com" , "Tian, Jun J" , "Wu, Hao" , "Jiang, Dave" , "jacob.jun.pan@linux.intel.com" , "kwankhede@nvidia.com" , "robin.murphy@arm.com" , "kvm@vger.kernel.org" , "iommu@lists.linux-foundation.org" , "dwmw2@infradead.org" , "linux-kernel@vger.kernel.org" , "david@gibson.dropbear.id.au" , "nicolinc@nvidia.com" To: "Tian, Kevin" , Jason Gunthorpe References: <20210919063848.1476776-1-yi.l.liu@intel.com> <20210919063848.1476776-7-yi.l.liu@intel.com> <20210921170943.GS327412@nvidia.com> <20210922123931.GI327412@nvidia.com> From: Lu Baolu Subject: Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces Message-ID: <4625393e-6203-2319-9c9f-9f35beb1c04a@linux.intel.com> Date: Mon, 27 Sep 2021 19:34:08 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/9/27 17:42, Tian, Kevin wrote: > +int iommu_device_set_dma_hint(struct device *dev, enum dma_hint hint) > +{ > + struct iommu_group *group; > + int ret; > + > + group = iommu_group_get(dev); > + /* not an iommu-probed device */ > + if (!group) > + return 0; > + > + mutex_lock(&group->mutex); > + ret = __iommu_group_viable(group, hint); > + mutex_unlock(&group->mutex); > + > + iommu_group_put(group); > + return ret; > +} Conceptually, we could also move iommu_deferred_attach() from iommu_dma_ops here to save unnecessary checks in the hot DMA API paths? Best regards, baolu