Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3867621pxb; Mon, 27 Sep 2021 04:36:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZZ6DApuCT2vGPSte9JEgH0UOiJb2j+akfXNZOd8Dmtl/U8oDbFmhRXhGupm0kCqGL4G11 X-Received: by 2002:a17:906:2505:: with SMTP id i5mr26379411ejb.450.1632742560767; Mon, 27 Sep 2021 04:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632742560; cv=none; d=google.com; s=arc-20160816; b=k5atIaXahVn20o8ryCoQNrsC3rYb4NQ8aBwENS+TfSK2FWUGMa4rK4vmzqDjAEBKWe ZSx0NlsqQ4Yz65yjmKH+R9I9+VwaKhOL49SgqCeo0xet4emQcUBfZrTV5GVFn20qSDKS N0ZwMIPxFQniZpnxTAnYsjOes2N87rIfQfdFvhz4kyN3WXX7tzkfEHBL3T8jowW5Fapt ET0FjYZ4guBdTIPmtTpzyf9OaSZFcmSv/Ppvhe/bVoM98BCmUE8OABlmrmHGjPdG9qeE SCS5WmqjYwqiXloSNPbNm9i5IzRB8yyGX2U+muFI3bBKsb4XEDBqXtGL1X9j+hgCat1f MeZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:to:cc; bh=PYPY5S5YpNi9GqYZV5f3SQHgHqNL6eZ2RDvLhNx5+3c=; b=NjI2n0ANRcWgQkjuB7e5/AQNjZNGvd2gpXo51wc4KZNJbRv0f5FdMr3CuMapQjgKn3 3llaovWTV9mDQDzr6fxgibQ4EBfRLZbXUYg5mAmXCxhKJdZ5WFutS7zZgTz58r1AnKME P2IUMSCzHOi2Tvcl4OYPAzpzUbCoh1k5rNVTtYEcEGhkxYzjCwUjZTeBoiihb8FvB7mS aBBjDXSqyhxFaP/MXfNT5Ztb3V8TAW2+8Vvy6Vo9owIF94hA3kwbRzPFCcqzJ4DvotNH JO/soEyNU00ck0P3eEvMc5OLX/5rXjduGLtfMQFwnTtiPDNcsXR3juwxNBX21BgN1iPg F51g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si17191292edh.145.2021.09.27.04.35.36; Mon, 27 Sep 2021 04:36:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233948AbhI0Lf5 (ORCPT + 99 others); Mon, 27 Sep 2021 07:35:57 -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