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 7EF3FC6FA99 for ; Fri, 10 Mar 2023 12:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230296AbjCJMgz (ORCPT ); Fri, 10 Mar 2023 07:36:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbjCJMgv (ORCPT ); Fri, 10 Mar 2023 07:36:51 -0500 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2077.outbound.protection.outlook.com [40.107.100.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6391C1135FF; Fri, 10 Mar 2023 04:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kvl5pxdLROcO3glkFiWiQR9xSAt+/zGFbJo/7IM79gYZWqdyTnvQAJNh0mGNzvzFrLCtpNnSXTDI/pkgd9kDfe/L4+8HR1oEh4wbqSpPE/2kEgph9DYjvuooJQaecZn97uoFERreKhJCKrpR4tLOCOjUsoC2stA0TUAryeqYEus1gYSfjX5u7GTtPHk+thnmOEwM+ucRmzgaQ7xmnlfANP+04g0WNzE8356IK2zIynJeoZ+sx/PqQmw2J/xF78rU1Pikh9Nm3cWTIzCHtNXAkPi2kjQIJHKPPBZAxi8t31hhTEyHaVKhVQHUo8TQHEjYj7C4dk7PHbk84rh+wRXJ9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qfAe0UXQ64SHpD0PnmTVJtHb/00llIsYoVOllzSpxXM=; b=Gicp/D5lhe9ELwoUdIPG3x/chmXNVzIgqJYUH6lkPOUW6DCqWC1F/Pm4379nXOT3uvtq1pfCu6jEwB4fpMwjKoZaghfkhLCgpS4BYHNjgeYeBuGN7KhRgzEPDyfKrez7KATgFJXsoDAAolPI7kdAk0xzzEaYtM3XVHjleBaYEaldtHmUOZPBc3PHbvNzPj2U5Svjl0q8kRCwFbnlVo4vMfU2+IJC7VMjJ8BMc+OVzrQ6K8do+wTOuRJ5c4DmjPRkWycLRsEFik6KNkLlBwlkXtMbdsLX9bBaWYNMqWEOS0rt81fDOpTSBN/ovcKKOfkgiEbxi+wTDvcAbsZGIHKJ3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qfAe0UXQ64SHpD0PnmTVJtHb/00llIsYoVOllzSpxXM=; b=tUVaTFtpStgyTy9TpvxCjWz6NUMY2HTKCSNul3BEMMmy+j5RsjFQjqXPTAMGU4uo9R1s/Ktf31GMIjhb2/Ec2127gb34hS2Lz7LGL19h17caoKJ3pngBjyjcsBfh3tW//XTfjtRV4ZytTtZ5PqRBAAkojj5ds8Jl0NrBD6RiqBmK9vgZQENeEtWHptGZdDxGomkpmF+i+o/lRd/p3LJK6xOTqNX7J3zs4O2qDt6PQrxaCn2tCUYgBIT3FcXkOtjHc7xrtjajqmICLWHK5KKY5/suqZlq4B1Qg8jMpD9w57PsNHHBU8T84WFZfbOqFBwqHLIWO2+jNLNTi4b0hgCnWA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by SJ2PR12MB7991.namprd12.prod.outlook.com (2603:10b6:a03:4c3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.20; Fri, 10 Mar 2023 12:36:09 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::ef6d:fdf6:352f:efd1]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::ef6d:fdf6:352f:efd1%3]) with mapi id 15.20.6178.017; Fri, 10 Mar 2023 12:36:09 +0000 Date: Fri, 10 Mar 2023 08:36:06 -0400 From: Jason Gunthorpe To: "Michael S. Tsirkin" Cc: Jason Wang , Nanyong Sun , joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, wangrong68@huawei.com, Cindy Lu Subject: Re: [PATCH v2] vhost/vdpa: Add MSI translation tables to iommu for software-managed MSI Message-ID: 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> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230310045100-mutt-send-email-mst@kernel.org> X-ClientProxiedBy: BYAPR06CA0014.namprd06.prod.outlook.com (2603:10b6:a03:d4::27) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ2PR12MB7991:EE_ X-MS-Office365-Filtering-Correlation-Id: 5db3b493-5067-4b24-49c4-08db21640656 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UEu595OGmb3P0NJ6OLpOa6x8ASMlu0l+HgPOixQ3MMD9AF4dsc9/Dw08lUOnB3aA65gkgYD/g5EqdRgEuquVoOCAJmZNoI5IMmaMFmPs++0jc/IHFF/xw0srFhMdwuDr/DUiocKn0SiNuJ+P8Ztza2UM6VPP7MySTteTbFna3vQHjflGAyUKB3QnZ6X9/0HK4ZNqK6VmHAIEt1000kyA8F81n/cqYAKLEqP2tjkwMNNBCvALgmountiG8SC5hcVzDZaeCZqIMU1aLnZ7zExnKaR5jMqmxGOekX0Egg1jEpWPlJfYIdbT0l5MiOTscSFLBv0OudKM+2wVBrvbWips1rabUXSZxJ14JgFbGClYhQT+a6Ke/OyruK0XlFx893glmqfoaSJkHZqI8sO7Zs8D3oAsSxauAnU1ra2C1M62I3sPJBg/GslzV4f5c9oZUf8K4AlCe10nIdfgFM1j523WRPI3G+KR8X89h3X+O9BkdRSRJMBtcMdRrK8ELrIx40jqNqx3nYcoO60LgypYhVifkoLV85GygbPxO5iIhWXONsvSEZ6pSTnP4Q/aSr4WYAwPsQ4h/LK9LPP4b7yF6k2HX27b9XRpA2QhMqCNtGKWSJSwl8zkDO1T+oTd9bGfxqkiF+gYGMUC/qdKPUUOA0mz3ZreQZoD2fEV5Qa4r8oLRTorO1Uk6s7M/mXR/lWGbiOe X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(396003)(39860400002)(136003)(346002)(366004)(451199018)(36756003)(86362001)(38100700002)(83380400001)(8936002)(478600001)(2906002)(966005)(6486002)(7416002)(45080400002)(5660300002)(6916009)(4326008)(66476007)(66556008)(8676002)(66946007)(316002)(54906003)(41300700001)(186003)(2616005)(6666004)(53546011)(6512007)(26005)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Ex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TViTVcwUW5kRE9MUWxSUFFkQ3oyWld6YnZyYndSUmU0Ry95U243T0Y3bHl3?= =?utf-8?B?c201S3dNaUpaQllpSnZEZGhxczFyb000S21XWG9tY3A2ZHpXOC8vaTY3QzhL?= =?utf-8?B?cFU5KzRiSGxBeG1xbkVXcndpWHR3TG1UTnNYcVpTaWRHWjRFemszZ2grZ2Nj?= =?utf-8?B?bTRvenkyejA3SERUOHFIeis2dk9KQjc1bktkWi9QbDc0bkJQQ29Gb1hvK25w?= =?utf-8?B?RGk4S1BBTnMwRlJqaC9qOVlnUkFaTHJUazludm9UdVJsQzhoakdBUXZrY3JP?= =?utf-8?B?b1drVEdjdUFOandqQmxQWERQaXBJaTQ2ektFT3lkeGhqM280RlNnbEpwM2J4?= =?utf-8?Q?ZShN+lj93cV82pvAzaS3Usk4G?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5db3b493-5067-4b24-49c4-08db21640656 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2023 12:36:09.1227 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dScoqvMjygHrF5uyqJJzIqEqbqsc/XL6LjVAAIqMguy8V1Fj78R+xUQKbGc6qkk8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7991 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 10, 2023 at 04:53:42AM -0500, Michael S. Tsirkin wrote: > On Fri, Mar 10, 2023 at 05:45:46PM +0800, Jason Wang wrote: > > On Fri, Mar 10, 2023 at 4:41 PM Michael S. Tsirkin wrote: > > > > > > On Mon, Feb 20, 2023 at 10:37:18AM +0800, Jason Wang wrote: > > > > On Fri, Feb 17, 2023 at 8:43 PM Jason Gunthorpe wrote: > > > > > > > > > > On Fri, Feb 17, 2023 at 05:12:29AM -0500, Michael S. Tsirkin wrote: > > > > > > On Thu, Feb 16, 2023 at 08:14:50PM -0400, Jason Gunthorpe wrote: > > > > > > > On Tue, Feb 07, 2023 at 08:08:43PM +0800, Nanyong Sun wrote: > > > > > > > > From: Rong Wang > > > > > > > > > > > > > > > > Once enable iommu domain for one device, the MSI > > > > > > > > translation tables have to be there for software-managed MSI. > > > > > > > > Otherwise, platform with software-managed MSI without an > > > > > > > > irq bypass function, can not get a correct memory write event > > > > > > > > from pcie, will not get irqs. > > > > > > > > The solution is to obtain the MSI phy base address from > > > > > > > > iommu reserved region, and set it to iommu MSI cookie, > > > > > > > > then translation tables will be created while request irq. > > > > > > > > > > > > > > Probably not what anyone wants to hear, but I would prefer we not add > > > > > > > more uses of this stuff. It looks like we have to get rid of > > > > > > > iommu_get_msi_cookie() :\ > > > > > > > > > > > > > > I'd like it if vdpa could move to iommufd not keep copying stuff from > > > > > > > it.. > > > > > > > > > > > > Absolutely but when is that happening? > > > > > > > > > > Don't know, I think it has to come from the VDPA maintainers, Nicolin > > > > > made some drafts but wasn't able to get it beyond that. > > > > > > > > Cindy (cced) will carry on the work. > > > > > > > > Thanks > > > > > > Hmm didn't see anything yet. Nanyong Sun maybe you can take a look? > > > > Just to clarify, Cindy will work on the iommufd conversion for > > vhost-vDPA, the changes are non-trivial and may take time. Before we > > are able to achieve that, I think we still need something like this > > patch to make vDPA work on software managed MSI platforms. > > > > Maybe Nanyong can post a new version that addresses the comment so far? > > > > Thanks > > Maybe but an ack from iommu maintainers will be needed anyway. Let's see > that version, maybe split the export to a patch by itself to make the > need for that ack clear. 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. Jason