Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12734059rwd; Fri, 23 Jun 2023 09:55:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4W453/CtzHzrDAvxDnrPjYG2OkrUmznwhxvhmCs94PR8pp8Ja33QLmsM97X6KCc+u57rzt X-Received: by 2002:a05:6a00:230d:b0:666:81ae:fec0 with SMTP id h13-20020a056a00230d00b0066681aefec0mr20918521pfh.25.1687539355017; Fri, 23 Jun 2023 09:55:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687539354; cv=pass; d=google.com; s=arc-20160816; b=F2NLurhRlQqEU2pz9JvmU3sJflw4YYFKnA3w31lcSmi3wIp2AvnwZu8NKYG2AHXMKR RBdEdfdjU+RVn8vJJWRicZftByDoOZn3o//A/76RuSBr5oPmqlgSbvwmT3Yd6PYjd67N 8y9Or2QeSrrkPcu9weLn6q5C0g4hOlSdVMwedj4vU3qaxAp4iy42KaAn42q5bRajLwHk pjNJN7FxJSzxFpgkeeij9xuQNK70sO9kRVHwLBFRZo1TzjwRYWgzqCTjH91S5WI9jtLF Z4v0Z2ytQI5XUt8qKkCzPmHzhw7Ftj6trUsvBfyftV3zYsZ8FEGiSrlXLoOe83yVI0JR belg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to :content-transfer-encoding:content-disposition:references:message-id :subject:cc:to:from:date:dkim-signature; bh=qcRjeimoUKtZns525pG8mVV3zrCHtdr82RhFAM+9zEI=; b=nQX7l84EOuv8Af05yTxuHnCklxE/ZrO/0Kdt76e/vlPOIP8IRr+GssnEX81D4pGGpT OM8q9yBirz4CaF2RbBlvpmiuup4WjGwvGhwUqRcpd9euVY6ISRIvGvbj0VHsxnK4FHOC ulVd03tGO3qiDqivX1Nc/ltbEzDhyY7SR1a52mHKHhYpeCkruOpkhe+8Fcw5Fp79GY4s LXjOeQugFUWa9QqANXgYGEjpdNjZMUj9RBZrtA88A4NDf8HKn3TjSF49HS4Bt0qNYtEG 0j4oVCosRQLVz+zgD3Xb/YWrFsp9VtV62DCGpvpe4mZBO/2h5mV9kR/qaVHPb4G1qsP5 Dq7A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Y7wGCQIr; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z14-20020aa7958e000000b0065300b42889si3306750pfj.363.2023.06.23.09.55.41; Fri, 23 Jun 2023 09:55:54 -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; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Y7wGCQIr; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231978AbjFWQit (ORCPT + 99 others); Fri, 23 Jun 2023 12:38:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbjFWQis (ORCPT ); Fri, 23 Jun 2023 12:38:48 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 684BB9B; Fri, 23 Jun 2023 09:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ELbt0lwPC6D2M4LmVVVdCa1s3za+n8f2Jw79Q9TvwBms62znBx0AUEcITKbdEaCJkd12pqKwgGuSt0BaQmRkYD1aPsb3aQaEHGr1oAo7DpGZFMdZQGL2fwRZ37gLXIN2flgNS0mfwngR1PrZdoVKT2MXOHVUD6oI6kAJhMDAl9UiPqqiDyMd4EgO51qWaWbpD15XuYqUDUedaLSDq19HZtJU84svflsBe/a/pbPp5YgjgXfdXnLb+ymHzqxDPsMY/npDc1qrU6lEPiNSBgkxxzKlhMlVY8pRFXFjPWyquHO8qv9PDwrHPzijScbXm2Y8/pwNJBfrrVARC+P/wUCFOg== 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=qcRjeimoUKtZns525pG8mVV3zrCHtdr82RhFAM+9zEI=; b=CZ7Ly2evq6LZLQooAfHUFYJ8eTwkSdYorjpnZv6a188GEueo/8e4XlJI0nsQqrxwaAPuTcmx1RmH/1F8AC7dcEhpD3kpwEHnvLjsrm43q7B0AU5I9jiDbe2nwBf4XqYSfFBYzHWmieMacnq0bjqH6h6znygDdIs2LvTTnFZIz9GwCkPsfcAVa4krwgfzrPEPWRCfsOTGu638dK0lnPtfIj/ZxK6sPKKw9q6g4vwfUkpOzrOjAbdFy6AwHSypXGuw05g+uQW+vBOuQuvXZ5ksDmoivigcdXk4qOi/+9d5UijtFsOcf9b/GhN5RUdH4iA+Jb3ALBExq6rHItDZNCrGJw== 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=qcRjeimoUKtZns525pG8mVV3zrCHtdr82RhFAM+9zEI=; b=Y7wGCQIruZrLbaBqcjLibYSUZ9/KgMzAe51wqVbeywqAEq4nZoXir5bmeOl8iijmpES3lVSWaau+fyFk1WQ9z/qNScUdGTqtOStAt2BcgCaLtNN7Se1jCULe5fLIXWGyrAnd3ml5WwWbGPWoVAFCzQ8mQs/fqajO43Ae/P++LUIhu2ZWsvtmNlkEIfLtucPTFKTD475uBu5PFFRcbGuFIxa0u3PH0O0znBG679ry1ok4R4DbqptDgsb4WmMkQP4U4aK7HAskEXEldCLC9SDWjg3bJc2P8oSrxQsrcB3tBpsT/akRmGviZoeG3LHEHAwx6BrbuDAilYlJhdvhmE/a8g== 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 IA1PR12MB8333.namprd12.prod.outlook.com (2603:10b6:208:3fe::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Fri, 23 Jun 2023 16:38:45 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%7]) with mapi id 15.20.6521.024; Fri, 23 Jun 2023 16:38:45 +0000 Date: Fri, 23 Jun 2023 13:38:43 -0300 From: Jason Gunthorpe To: =?utf-8?Q?C=C3=A9dric?= Le Goater Cc: ankita@nvidia.com, alex.williamson@redhat.com, aniketa@nvidia.com, cjia@nvidia.com, kwankhede@nvidia.com, targupta@nvidia.com, vsethi@nvidia.com, acurrid@nvidia.com, apopple@nvidia.com, jhubbard@nvidia.com, danw@nvidia.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/1] vfio/nvgpu: Add vfio pci variant module for grace hopper Message-ID: References: <20230622030720.19652-1-ankita@nvidia.com> <46a79333-12f6-229f-86f9-1e79bdba7d11@redhat.com> <62dcff6b-852d-4a85-dfd4-0ce1f324602e@redhat.com> <4b0f4def-e2bd-b7b2-7c70-1df741780e1c@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4b0f4def-e2bd-b7b2-7c70-1df741780e1c@redhat.com> X-ClientProxiedBy: YT4PR01CA0410.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:10b::16) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|IA1PR12MB8333:EE_ X-MS-Office365-Filtering-Correlation-Id: c3b5a676-aecf-45e4-7e53-08db7408502d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x0o3FaQP3HQdkvqHKyYaJEUszA73X0MIjDMlhJ0fg53FFklpYoShkhVSDytuH0PrLIEr1yrC2aX82WHW58gvjEbUVu1vIdHW7yNCQjN/9DdHT9Vn6kC39VR7UI+B5ujy2PJ2xp6SqmddO+DaHyt1RygVL1PouhQ7jg/MmTzTfmkdst7ilG6H/46CdWYzvMHf5VMRPukps4O1jY/AvvoVvZ16MIp/AEwBnxXPq/eR9cY3D/wpxHo7EjIcQ6+TLEbRwmJekTm9yqpFq2NruwNDFHLqqNNhXjCEGmePcTpH239B83Mw4bEnFZlGefMKrVNYh19Z5noLnGYNDqNQITdld6hTnv+XRjAZNfFOg2rqT3ekMPRps99IW75Hm2ELr3ObAnFgAOwDdi8zVCjWj8xu+9i6GzYRfxoQWHEu1KcgAYaZKooyb+BQ7yllCxDwWjjH4XgeVcTL7rUn2CQgClhq/FpnxEiwYGhQZtOrxqwIxp4+0sxTsot+q4olObHbWHiqUcb5PXtdW4EziCVst6WZLNigFtRz3ram7MJbG/SjLKcdK6a2M6W0Y5oXhe5I1HxV 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:(13230028)(4636009)(39860400002)(376002)(366004)(346002)(136003)(396003)(451199021)(478600001)(36756003)(6916009)(66946007)(66476007)(83380400001)(66556008)(4326008)(316002)(86362001)(6512007)(26005)(6506007)(66574015)(2616005)(6486002)(38100700002)(53546011)(186003)(8936002)(5660300002)(8676002)(41300700001)(2906002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?em53V0hyTitNUG1Ta2xPL1RTbkJRVXR2UU05azVPSmVRVC9VY3FOZmVpaXpz?= =?utf-8?B?OWZOUEVPZTRTYkpUQjhKcGxhYzd1N0JkSFBhTWd3NmZLaHNXRUdxQ1AyUHpT?= =?utf-8?B?dUhmTEZrcDUyQXlhRWtiUGxTenpHaFAyNUFSUjRMRTNZT1hCNk9BaEVwNDd1?= =?utf-8?B?WGFFTWJ6bWhXSDViY3hoWGlkN0g5aXNaMS9uZ0RxMm1iVjk4YXliZTc5eU91?= =?utf-8?B?a0VGZXQ2RjRzY1ovNUZ6L01NM0JqWllSaWJSVWtQOUsxRWhZbFpxb1N4Skp4?= =?utf-8?B?OEwyWGlpMzJmMkZBdHhrZXduZUNXalMwN0MvY2hGbEMrVWs2TzRESlhPampW?= =?utf-8?B?blR0TkwxZzRxZ3NIczdWQ01SRHYvMkVVTU01YTZ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id: c3b5a676-aecf-45e4-7e53-08db7408502d X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2023 16:38:45.8014 (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: kwxavs5ew2e901TGyxCBWRP9EwTh+SGV4FITEZKrdzGdhMIEmhL/HZp/b1iXwqAk X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8333 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 Fri, Jun 23, 2023 at 05:07:37PM +0200, Cédric Le Goater wrote: > On 6/23/23 15:07, Jason Gunthorpe wrote: > > On Fri, Jun 23, 2023 at 03:04:17PM +0200, Cédric Le Goater wrote: > > > On 6/23/23 13:47, Jason Gunthorpe wrote: > > > > On Fri, Jun 23, 2023 at 08:27:17AM +0200, Cédric Le Goater wrote: > > > > > > + req_len = vma->vm_end - vma->vm_start; > > > > > > + pgoff = vma->vm_pgoff & > > > > > > + ((1U << (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT)) - 1); > > > > > > + if (pgoff >= (nvdev->mem_prop.mem_length >> PAGE_SHIFT)) > > > > > > + return -EINVAL; > > > > > > > > > > you cound introduce accessor macros for nvdev->mem_prop.mem_length and > > > > > nvdev->mem_prop.hpa > > > > > > > > Accessors are not the usual style.. > > > > > > I meant something like > > > > > > #define nvgpu_mem_size(nvdev) (nvdev)->mem_prop.mem_length > > > #define nvgpu_mem_pa_base(nvdev) (nvdev)->mem_prop.hpa > > > > > > This is minor. > > > > Yeah, this is what I thought you ment, I'm against this kind of > > obfuscation in the kernel without a very strong purpose, and if you do > > something like this it should be a static inline function. > > OK. We could drop the intermediate struct attribute instead then. Yah, if the struct isn't needed for some other reason Jason