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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECC18C6FD1D for ; Thu, 23 Mar 2023 12:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231681AbjCWMfa (ORCPT ); Thu, 23 Mar 2023 08:35:30 -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 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.