Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4904404pxb; Tue, 28 Sep 2021 06:39:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ5pljRPitD25pB4vTFQRBeVjeiYVKzbIcehHXZ87mRzATSkvyDwPZflSXLIguP6/bRJg9 X-Received: by 2002:a17:906:2ed1:: with SMTP id s17mr6971554eji.261.1632836366406; Tue, 28 Sep 2021 06:39:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632836366; cv=none; d=google.com; s=arc-20160816; b=Ut/1o5J50SL+cQ+VCRE5E9re9It/OLsxNLfmV1ASFMFGHrEcUM8WLnDUUX14B2bTNX gH+R+Ax6Qf9NQMi0mYBIk7VbRSulivAhuc1FsNgjhquc876CZfPOupvPG7YPjv1f8wge rWlMiiyxWhM4Qs92eKvg3Ap+MKgJjMxedMc7cVE4eBWHAud0KO/IVO7qg8TziOMDXI7I LYSLdo7O3ODVMXYvmAo1ZH6yXjsa7dqecjVtB+DiGvK88wefI6/5KaEsKaHT2YhC5q8g 5ho3ACmHR5ZmQJ2/jAu3zXhWjjB3/omPpn9MLznRrlh4Un223gK+MPk8dbI7wSqIIy0+ +4IQ== 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=Tw0t6Xb/UgIsLKlSl6IBPFl1zhKeyF8ne6fcFOvtM5o=; b=ICzDWBgq8lXnoscbbcX29OuQRpf0OEJwJEbDK9PmR+6xShRYu8fK7TT6GsMl4oNjWw I3mR+A9+q+h5+CNazQwLEyb2zlX0vMhKw+arPmmF6vo/dYSq8l4TPv1Y2Kma7iBiL4I9 P+6S6cubXMjh2+KkihZ2Bo3gR25n+K8pDe+7PiQUIh/bBSSvM/ArX3zDKODrwndA6FXJ +NQHBpxm6lvNnibyAhKgoFxcoDanYTu6Bb4IEzvZVYAbB2Yazca/YXbAIBI5EDD0xsME IPqT7K/9kCmSP7SjWs+sZlBx7LPG+6sthjso7pQzeDXLY13TEs6XTqsu5O46NSgcFpCu OM0g== 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 q9si22096494edj.505.2021.09.28.06.38.59; Tue, 28 Sep 2021 06:39:26 -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 S240906AbhI1Nhb (ORCPT + 99 others); Tue, 28 Sep 2021 09:37:31 -0400 Received: from mga04.intel.com ([192.55.52.120]:37605 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240971AbhI1NhW (ORCPT ); Tue, 28 Sep 2021 09:37:22 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10120"; a="222803124" X-IronPort-AV: E=Sophos;i="5.85,329,1624345200"; d="scan'208";a="222803124" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2021 06:35:14 -0700 X-IronPort-AV: E=Sophos;i="5.85,329,1624345200"; d="scan'208";a="553993941" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.212.203]) ([10.254.212.203]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2021 06:35:08 -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: Jason Gunthorpe , "Tian, Kevin" 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> <20210927150928.GA1517957@nvidia.com> <20210928115751.GK964074@nvidia.com> From: Lu Baolu Subject: Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces Message-ID: <9a314095-3db9-30fc-2ed9-4e46d385036d@linux.intel.com> Date: Tue, 28 Sep 2021 21:35:05 +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: <20210928115751.GK964074@nvidia.com> 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 Hi Jason, On 2021/9/28 19:57, Jason Gunthorpe wrote: > On Tue, Sep 28, 2021 at 07:30:41AM +0000, Tian, Kevin wrote: > >>> Also, don't call it "hint", there is nothing hinty about this, it has >>> definitive functional impacts. >> >> possibly dma_mode (too broad?) or dma_usage > > You just need a flag to specify if the driver manages DMA ownership > itself, or if it requires the driver core to setup kernel ownership > > DMA_OWNER_KERNEL > DMA_OWNER_DRIVER_CONTROLLED > > ? > > There is a bool 'suprress_bind_attrs' already so it could be done like > this: > > bool suppress_bind_attrs:1; > > /* If set the driver must call iommu_XX as the first action in probe() */ > bool suppress_dma_owner:1; > > Which is pretty low cost. Yes. Pretty low cost to fix the BUG_ON() issue. Any kernel-DMA driver binding is blocked if the device's iommu group has been put into user- dma mode. Another issue is, when putting a device into user-dma mode, all devices belonging to the same iommu group shouldn't be bound with a kernel-dma driver. Kevin's prototype checks this by READ_ONCE(dev->driver). This is not lock safe as discussed below, https://lore.kernel.org/linux-iommu/20210927130935.GZ964074@nvidia.com/ Any guidance on this? Best regards, baolu