Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7520375rwl; Thu, 23 Mar 2023 05:36:27 -0700 (PDT) X-Google-Smtp-Source: AK7set+COgCP+YMopKKUSAK8sRX72Q9SazHaHa3X+HEsftvKOv9Nw7qxYeoltHfKtmTe/mfUK9go X-Received: by 2002:a17:906:f217:b0:924:7f98:7c55 with SMTP id gt23-20020a170906f21700b009247f987c55mr10503517ejb.48.1679574987287; Thu, 23 Mar 2023 05:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679574987; cv=none; d=google.com; s=arc-20160816; b=RTHhMTML+52rUvTcAm6yWBki7+GGbeO3gqcxDrEOlYOo78V8lfvIkNjzjD2isK3/JZ LHDn4B0lSEeQmZbBrx0NOO7mj2EzsY1UpHiXxg5qKmeVHbqEvMRRiEquB6X8khv+oit3 styTIbHp2BXGT+lDzLDTE1NjWarF4TStPfdOU8bo1e4+/R69TVq9MyL+xqh3Ebm2kXyn yl+VnJEzd/mq2kUgIm3sZnetN7+DZya8SsRYXWzpMhgl8H/ktbAR+26NiXLJ02BQjoRw qX4DZv/JAX2k+EYMD+SUfDM9YmbwpkArYiT7Qj+VXtUCNEKA1E3Nw1u5xc+/I9xQOY/L D27A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=z9L3sQKpiNBTlFpQi2VTqA+Eb+vsGqlyH4MUNwwq/1I=; b=NweJU9VnKeq3Xf/a78fz95JrXZMvL9WCyramABzKF7lMZA0t+FmhCBMQDXUcWFmijf fAA5Rc5qS9oWXU7vZAC14liSmorP+hDB0lAJZzvkyoqlJK0CBBsrp327QmF/VHubjIAV syJaUwY8DiibCSVul50dJdkXlEoFV6TlqxkPTGCri04ZwiHXRcoElOaO5B0EUyKkLt8I ku2fsFHeXLDacTav7M/NEYum2Mn+UcClpn/b+HolY+pG6xm73izBKBjvzlV+bHDRogHE 3kMqMVhu7/GWs5oSaQlZyOfZ2wH5JNxaZhDM0t4XXY49sS/gn8TyysNWm2AWISh+5Hbh haaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a170906225500b0092554df06ffsi19808886ejr.286.2023.03.23.05.36.03; Thu, 23 Mar 2023 05:36:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231515AbjCWMf3 (ORCPT + 99 others); Thu, 23 Mar 2023 08:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbjCWMf2 (ORCPT ); Thu, 23 Mar 2023 08:35:28 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D0C1B2F8; Thu, 23 Mar 2023 05:35:27 -0700 (PDT) Received: from kwepemm600003.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Pj46f6NSwzKmj9; Thu, 23 Mar 2023 20:15:22 +0800 (CST) Received: from [10.174.179.79] (10.174.179.79) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 23 Mar 2023 20:15:44 +0800 Subject: Re: [PATCH v2] vhost/vdpa: Add MSI translation tables to iommu for software-managed MSI To: Jason Gunthorpe CC: "Michael S. Tsirkin" , Jason Wang , , , , , , , , , , Cindy Lu References: <20230207120843.1580403-1-sunnanyong@huawei.com> <20230217051158-mutt-send-email-mst@kernel.org> <20230310034101-mutt-send-email-mst@kernel.org> <20230310045100-mutt-send-email-mst@kernel.org> From: Nanyong Sun Message-ID: Date: Thu, 23 Mar 2023 20:15:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.79] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.3 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/3/23 19:31, Jason Gunthorpe wrote: > On Thu, Mar 23, 2023 at 05:22:36PM +0800, Nanyong Sun wrote: >>> A patch to export that function is alread posted: >>> >>> https://lore.kernel.org/linux-iommu/BN9PR11MB52760E9705F2985EACCD5C4A8CBA9@BN9PR11MB5276.namprd11.prod.outlook.com/T/#u >>> >>> But I do not want VDPA to mis-use it unless it also implements all the >>> ownership stuff properly. >>> >> I want to confirm if we need to introduce iommu group logic to vdpa, as "all >> the ownership stuff" ? > You have to call iommu_device_claim_dma_owner() > > But again, this is all pointless, iommufd takes are of all of this and > VDPA should switch to it instead of more hacking. > > Jason > . Yeah,  thanks for your suggestion,but as Michael and Jason Wang said, before iommufd is ready, we may need to make vDPA work well on software managed MSI platforms. To achieve that, basically we have two ways: 1. export iommu_get_resv_regions, and get regions device by device. 2. introduce iommu group, get regions by iommu_get_group_resv_regions, which already exported.