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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D27AC433DB for ; Sat, 16 Jan 2021 01:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1BAC239E4 for ; Sat, 16 Jan 2021 01:22:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728207AbhAPBWR (ORCPT ); Fri, 15 Jan 2021 20:22:17 -0500 Received: from mga09.intel.com ([134.134.136.24]:55631 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbhAPBWR (ORCPT ); Fri, 15 Jan 2021 20:22:17 -0500 IronPort-SDR: h43Gi4tTtPS8Qt9K0xdP2ne5XhRI31Vg0ejPlIr6vNion1y8TLLObYRoZj7Ri81+ogRPJ8TQLv TOMESzq7hIag== X-IronPort-AV: E=McAfee;i="6000,8403,9865"; a="178778399" X-IronPort-AV: E=Sophos;i="5.79,351,1602572400"; d="scan'208";a="178778399" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 17:20:28 -0800 IronPort-SDR: DznnGYuwJ/UxxQrmQGJd5b9g6Om3RrfpkvoMPBs122KxptEO3Brz/fbs5840Umw7sUzZLqkujt GGgy0p/jLtsg== X-IronPort-AV: E=Sophos;i="5.79,351,1602572400"; d="scan'208";a="382861945" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.249.175.94]) ([10.249.175.94]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 17:20:18 -0800 Cc: baolu.lu@linux.intel.com, tglx@linutronix.de, ashok.raj@intel.com, kevin.tian@intel.com, dave.jiang@intel.com, megha.dey@intel.com, dwmw2@infradead.org, alex.williamson@redhat.com, bhelgaas@google.com, dan.j.williams@intel.com, will@kernel.org, joro@8bytes.org, dmaengine@vger.kernel.org, eric.auger@redhat.com, jacob.jun.pan@intel.com, jgg@mellanox.com, kvm@vger.kernel.org, kwankhede@nvidia.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, iommu@lists.linux-foundation.org, maz@kernel.org, mona.hossain@intel.com, netanelg@mellanox.com, parav@mellanox.com, pbonzini@redhat.com, rafael@kernel.org, samuel.ortiz@intel.com, sanjay.k.kumar@intel.com, shahafs@mellanox.com, tony.luck@intel.com, vkoul@kernel.org, yan.y.zhao@linux.intel.com, yi.l.liu@intel.com Subject: Re: [RFC PATCH v3 1/2] iommu: Add capability IOMMU_CAP_VIOMMU To: Leon Romanovsky References: <20210114013003.297050-1-baolu.lu@linux.intel.com> <20210114013003.297050-2-baolu.lu@linux.intel.com> <20210114132627.GA944463@unreal> <20210115063108.GI944463@unreal> From: Lu Baolu Message-ID: Date: Sat, 16 Jan 2021 09:20:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210115063108.GI944463@unreal> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org Hi, On 2021/1/15 14:31, Leon Romanovsky wrote: > On Fri, Jan 15, 2021 at 07:49:47AM +0800, Lu Baolu wrote: >> Hi Leon, >> >> On 1/14/21 9:26 PM, Leon Romanovsky wrote: >>> On Thu, Jan 14, 2021 at 09:30:02AM +0800, Lu Baolu wrote: >>>> Some vendor IOMMU drivers are able to declare that it is running in a VM >>>> context. This is very valuable for the features that only want to be >>>> supported on bare metal. Add a capability bit so that it could be used. >>> >>> And how is it used? Who and how will set it? >> >> Use the existing iommu_capable(). I should add more descriptions about >> who and how to use it. > > I want to see the code that sets this capability. Currently we have Intel VT-d and the virt-iommu setting this capability. static bool intel_iommu_capable(enum iommu_cap cap) { if (cap == IOMMU_CAP_CACHE_COHERENCY) return domain_update_iommu_snooping(NULL) == 1; if (cap == IOMMU_CAP_INTR_REMAP) return irq_remapping_enabled == 1; + if (cap == IOMMU_CAP_VIOMMU) + return caching_mode_enabled(); return false; } And, +static bool viommu_capable(enum iommu_cap cap) +{ + if (cap == IOMMU_CAP_VIOMMU) + return true; + + return false; +} Best regards, baolu 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 X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E69BBC433E0 for ; Sat, 16 Jan 2021 01:20:35 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5928123A3C for ; Sat, 16 Jan 2021 01:20:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5928123A3C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id D9F4E2E186; Sat, 16 Jan 2021 01:20:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vJJLBT1+61Ry; Sat, 16 Jan 2021 01:20:33 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 9B2B52E194; Sat, 16 Jan 2021 01:20:33 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 79D60C088B; Sat, 16 Jan 2021 01:20:33 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id D966EC013A for ; Sat, 16 Jan 2021 01:20:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CFB1486341 for ; Sat, 16 Jan 2021 01:20:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UnsKCaIkeMqQ for ; Sat, 16 Jan 2021 01:20:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 3511386227 for ; Sat, 16 Jan 2021 01:20:32 +0000 (UTC) IronPort-SDR: OM+FCdov7f4wqJ6DpycTPkHgWDSY8sMoUqKHMaZHG2J3p5PpvomRed3jwgrE7hV/B2v8Z8dkDw 0KWT3c1ut75g== X-IronPort-AV: E=McAfee;i="6000,8403,9865"; a="165718216" X-IronPort-AV: E=Sophos;i="5.79,351,1602572400"; d="scan'208";a="165718216" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 17:20:28 -0800 IronPort-SDR: DznnGYuwJ/UxxQrmQGJd5b9g6Om3RrfpkvoMPBs122KxptEO3Brz/fbs5840Umw7sUzZLqkujt GGgy0p/jLtsg== X-IronPort-AV: E=Sophos;i="5.79,351,1602572400"; d="scan'208";a="382861945" Received: from blu2-mobl3.ccr.corp.intel.com (HELO [10.249.175.94]) ([10.249.175.94]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 17:20:18 -0800 Subject: Re: [RFC PATCH v3 1/2] iommu: Add capability IOMMU_CAP_VIOMMU To: Leon Romanovsky References: <20210114013003.297050-1-baolu.lu@linux.intel.com> <20210114013003.297050-2-baolu.lu@linux.intel.com> <20210114132627.GA944463@unreal> <20210115063108.GI944463@unreal> From: Lu Baolu Message-ID: Date: Sat, 16 Jan 2021 09:20:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210115063108.GI944463@unreal> Content-Language: en-US Cc: kvm@vger.kernel.org, rafael@kernel.org, linux-pci@vger.kernel.org, sanjay.k.kumar@intel.com, mona.hossain@intel.com, samuel.ortiz@intel.com, kwankhede@nvidia.com, will@kernel.org, dan.j.williams@intel.com, dave.jiang@intel.com, ashok.raj@intel.com, netanelg@mellanox.com, maz@kernel.org, vkoul@kernel.org, jgg@mellanox.com, yan.y.zhao@linux.intel.com, shahafs@mellanox.com, kevin.tian@intel.com, parav@mellanox.com, alex.williamson@redhat.com, bhelgaas@google.com, tglx@linutronix.de, megha.dey@intel.com, tony.luck@intel.com, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, jacob.jun.pan@intel.com, dmaengine@vger.kernel.org, pbonzini@redhat.com, dwmw2@infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" Hi, On 2021/1/15 14:31, Leon Romanovsky wrote: > On Fri, Jan 15, 2021 at 07:49:47AM +0800, Lu Baolu wrote: >> Hi Leon, >> >> On 1/14/21 9:26 PM, Leon Romanovsky wrote: >>> On Thu, Jan 14, 2021 at 09:30:02AM +0800, Lu Baolu wrote: >>>> Some vendor IOMMU drivers are able to declare that it is running in a VM >>>> context. This is very valuable for the features that only want to be >>>> supported on bare metal. Add a capability bit so that it could be used. >>> >>> And how is it used? Who and how will set it? >> >> Use the existing iommu_capable(). I should add more descriptions about >> who and how to use it. > > I want to see the code that sets this capability. Currently we have Intel VT-d and the virt-iommu setting this capability. static bool intel_iommu_capable(enum iommu_cap cap) { if (cap == IOMMU_CAP_CACHE_COHERENCY) return domain_update_iommu_snooping(NULL) == 1; if (cap == IOMMU_CAP_INTR_REMAP) return irq_remapping_enabled == 1; + if (cap == IOMMU_CAP_VIOMMU) + return caching_mode_enabled(); return false; } And, +static bool viommu_capable(enum iommu_cap cap) +{ + if (cap == IOMMU_CAP_VIOMMU) + return true; + + return false; +} Best regards, baolu _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu