Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp318491pxb; Thu, 30 Sep 2021 06:47:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyOaPgmVSYe6O65gCQfkZHuFe/kxkwFRnzNJjY9lC8boRFufzvgoI3b5quaK0Qsxfzq65C X-Received: by 2002:a50:9d44:: with SMTP id j4mr7305926edk.173.1633009640780; Thu, 30 Sep 2021 06:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633009640; cv=none; d=google.com; s=arc-20160816; b=XPzHX5XypgP5hNmkI753SK3+BO7RIgDjL6+gZeYC6FYpCnI7z5ZYCIA7UHUGc6/XiP vRdlKL1lzdF+iNzsLVBFxIhQIvieqGz+Jr6jbedQktmyH9bHLSuIShOnrV/Nh6R8S5WT 1Rl96NPkmrlMnUDFxgyjhbL8coxan087eGxNUavnlpTMiqbUBJuPSmdBcNG6bse52DSC 3q1Qtp17yT+kaZxcT9+yKDHTX5O3Cq7bief5dJ+dPWcccaPA7QwWM2qiMbodILu1+B5V uXc0XU+cXa0Gb77goD6ef0AWcOQwDwCx5X6Rrc6/sX5ECd21LAYyRPGD82/qPedRANlX vi4A== 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=EWf/6pDS1Yj9WOInE9gr8yqR5YLkArAK5yqDKOEmudc=; b=J03vTBWF1of2YWWiTfopqd0pAWQXNMpQ5R8vcXrtsHgyxx0ZZv859wPcwgMgG+FAr9 aG2Imhu6YD7o3TeYq0hGc9JIuXIJIlC7c6cdnbGU3wfuvtw0DRKr32d32u3J01hCUZcF hB4vOBDzClww06yblEZ3r9xUktOCpxFqsw2SnK4UUjvTwl48knRV5hqHA2K8VpgHc3BP Tj19QxutrAb2/SuH9zrP8JWB2xN5Jg2wnnKgLjZrhGkHbmduTSGprQffDlQpXRsUgt6I q6R/l6nDGerujAwg8mdCoRmOT7wNLysoPtFhvxFNCkmonXCPWi+X+cPTvQXHx6EYHR4g A4fQ== 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 y6si4488295edc.477.2021.09.30.06.46.46; Thu, 30 Sep 2021 06:47:20 -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 S1351690AbhI3Npu (ORCPT + 99 others); Thu, 30 Sep 2021 09:45:50 -0400 Received: from mga12.intel.com ([192.55.52.136]:39054 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351414AbhI3Npu (ORCPT ); Thu, 30 Sep 2021 09:45:50 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10122"; a="204671574" X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="204671574" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 06:44:07 -0700 X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="564177724" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.254.214.141]) ([10.254.214.141]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 06:44:00 -0700 Cc: baolu.lu@linux.intel.com, Jean-Philippe Brucker , Alex Williamson , "Liu, Yi L" , "hch@lst.de" , "jasowang@redhat.com" , "joro@8bytes.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 , "Lu, Baolu" References: <20210919063848.1476776-1-yi.l.liu@intel.com> <20210919063848.1476776-11-yi.l.liu@intel.com> <20210922152407.1bfa6ff7.alex.williamson@redhat.com> <20210922234954.GB964074@nvidia.com> <20210923112716.GE964074@nvidia.com> <20210923122220.GL964074@nvidia.com> From: Lu Baolu Subject: Re: [RFC 10/20] iommu/iommufd: Add IOMMU_DEVICE_GET_INFO Message-ID: <9a04c421-4a25-f1de-a896-321026b3f0ce@linux.intel.com> Date: Thu, 30 Sep 2021 21:43:58 +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/30 16:49, Tian, Kevin wrote: >> From: Jason Gunthorpe >> Sent: Thursday, September 23, 2021 8:22 PM >> >>>> These are different things and need different bits. Since the ARM path >>>> has a lot more code supporting it, I'd suggest Intel should change >>>> their code to use IOMMU_BLOCK_NO_SNOOP and abandon >> IOMMU_CACHE. >>> >>> I didn't fully get this point. The end result is same, i.e. making the DMA >>> cache-coherent when IOMMU_CACHE is set. Or if you help define the >>> behavior of IOMMU_CACHE, what will you define now? >> >> It is clearly specifying how the kernel API works: >> >> !IOMMU_CACHE >> must call arch cache flushers >> IOMMU_CACHE - >> do not call arch cache flushers >> IOMMU_CACHE|IOMMU_BLOCK_NO_SNOOP - >> dot not arch cache flushers, and ignore the no snoop bit. > > Who will set IOMMU_BLOCK_NO_SNOOP? I feel this is arch specific > knowledge about how cache coherency is implemented, i.e. > when IOMMU_CACHE is set intel-iommu driver just maps it to > blocking no-snoop. It's not necessarily to be an attribute in > the same level as IOMMU_CACHE? > >> >> On Intel it should refuse to create a !IOMMU_CACHE since the HW can't >> do that. > > Agree. In reality I guess this is not hit because all devices are marked > coherent on Intel platforms... > > Baolu, any insight here? I am trying to follow the discussion here. Please guide me if I didn't get the right context. Here, we are discussing arch_sync_dma_for_cpu() and arch_sync_dma_for_device(). The x86 arch has clflush to sync dma buffer for device, but I can't see any instruction to sync dma buffer for cpu if the device is not cache coherent. Is that the reason why x86 can't have an implementation for arch_sync_dma_for_cpu(), hence all devices are marked coherent? > Thanks > Kevin > Best regards, baolu