Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12442927rwd; Fri, 23 Jun 2023 06:17:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4e+SvLM8Xyo+Gkp889xzOVlud0wJypcVk9WyfdueVKQaGwebfEwo+6RoaTr/LX62QtM4Ne X-Received: by 2002:a05:6a21:1510:b0:114:f112:d8f0 with SMTP id nq16-20020a056a21151000b00114f112d8f0mr17580094pzb.35.1687526224654; Fri, 23 Jun 2023 06:17:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1687526224; cv=pass; d=google.com; s=arc-20160816; b=FbUJeuidjc+T2brA9fHhUg4t+lUjhMJYpzm79+F9qX/qfTfyT6i0Ft3m2y9B/UXKj9 x5E+ly7Q1/DwDlRhK6k/aa7C6icxPRD/B6LLnbzax7k/Gm10QOBY6EqVB60R0dnBY1V6 J6VK3kivVRIKL3j+CfsZ+vXKDj8q+YPUmWD95c5rFDg3ZKGMgjjGppbUB6dFcLN7rTQq gLL/o5k6jQqm1r1zGbeZTDv5xK3l4cXHi949X+1itGm85LnQ932taX+tMcK1a/kgc+8f zTN38NPsKaqnPNTbH9DXEI5WYitsIq6R2pdBU1XS5jX2GJ9bV4cl55PCkLjJnxOE9oPR guiw== 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=m1T4XFi+Blae8gHWJLFXceGHyPipylcPB/eKg+BLnyc=; b=U2OEAG7QwurIAf6mh9Qx2UWd9r7/+S8u7aA0og6zfLwW9Zn8DksNvMkNUo1WD7S4UA w2rLUS7XSer85hcAQ/VmfXFB6R84UNC76cvJ4pPY/njJYtiZV3QlHTtKYL8uSKPwp21J boPmIGVoZ4KVD3Ft0RlohBquxvp9q0huTSFYTUGJRMFXA1AQ4G+rhayMmpwb8yZyC2wu YT6bbSexd5VdS2LELaplbnMK+GMc/3ktdtn/rKCTDpoPNmHiYGHHWMJkW1LDxQ0XvVSt 8r9zLSM8Z4zKz8pP+apRFwVkGC7n4iFYqHhU3+x5SSJI3P2+tLGPp3LkavFpujB8cdV7 R1hQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=WqVSyGXt; 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 h65-20020a625344000000b0065e445224e5si3046889pfb.332.2023.06.23.06.16.47; Fri, 23 Jun 2023 06:17:04 -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=WqVSyGXt; 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 S231424AbjFWNHX (ORCPT + 99 others); Fri, 23 Jun 2023 09:07:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231278AbjFWNHW (ORCPT ); Fri, 23 Jun 2023 09:07:22 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C0012129; Fri, 23 Jun 2023 06:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jRIQMfjSq6m7q7+nlkT2MUvcHQIY2c4yPchDmx8yXzrlVIWo1nTQeYr0+F1K1q0kzkPTD889z8TBpKKiGrTqx9FG72lDCoQNk/Of3ihd3ckgd9M+kn3VrFv3RoND7paAMPFXWX+XnqQfPZ0qfUYbtQbLGlNcLc+AC+4mnOVhsbFnPOFgKBMboBhRghEORodJcZH5nYTeBdswEefisCbticoHVYLZe7uhixRiL/+yCe44CiMRhPBFBjBKxQjaxMm2RjKmKNG+TOE09t7o6eqROclnaWfsa1NHqLgIzHlSt5d9h4ASOZOv+kt9JL5oKfq6bts88lUg1rbkKaZohmVbbg== 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=m1T4XFi+Blae8gHWJLFXceGHyPipylcPB/eKg+BLnyc=; b=YVRcVS/bcAc7fZwW2zVZgQhOYK6hKJ+TW1OyTnxe6WnMAPwt+rfvJQYYusnzmf8Db2Iea1F4rypkq1IZSTxPCGLHqIV/8S7Cj86eyGP9hL88OFMun5tDso42SRskxLnqeD7D0BPZLYjtHRSdR2PeWFNFcXmK+0dxS/tGe8LN+latYAWbpqoXwP0Sd+NtNqkN4SNGrdayvRBAcvzWmKaj/5gsEU7o2pBZBdLD6iPig10jtOf4S9geitpEZkNuMBS1zpKJYRai2trtfdAR4IJKaV+AGtIVv1RTgV4+b0vmve9sBXnafUzJRVaocmBrijX8eAqS4oBPtq2pklF2TLYr3w== 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=m1T4XFi+Blae8gHWJLFXceGHyPipylcPB/eKg+BLnyc=; b=WqVSyGXtLvnL8hNhHoHeqhJdiVjF4uo67jPfUHSNSALSKK3KmB68/WxDdDs3vWB9yYXYBWUtvr8grMXmuc/vHBekNB0SDP+1DMn/fIm55N3k+USZrtXWqOMAsamPAVPTMysS16gacmxmzOIoZSJZcgW96LmKRDZjWAd6B06cwlzpP97r4ARFFloM1vTYpmZGuZ0AxMfnezFZGiXFdGGKWdwd6Xv5xIrohz84hMpnngeN19MpQr2EPKMhUgd69RN37wesj6nB2HxB8uA7sVpZ3ouAPaSrGW1XKjERY76o+MopZyv0+yoqv2myTYHjS809dMZSZIFXfMYb7dMCqR1uQw== 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 SJ0PR12MB6966.namprd12.prod.outlook.com (2603:10b6:a03:449::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21; Fri, 23 Jun 2023 13:07:18 +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 13:07:18 +0000 Date: Fri, 23 Jun 2023 10:07:15 -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> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <62dcff6b-852d-4a85-dfd4-0ce1f324602e@redhat.com> X-ClientProxiedBy: CH2PR19CA0020.namprd19.prod.outlook.com (2603:10b6:610:4d::30) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|SJ0PR12MB6966:EE_ X-MS-Office365-Filtering-Correlation-Id: 22c1f7a4-c776-4041-c3bd-08db73eac569 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: otydpx0l2F4M46elcJifBZWCK5VZoJBwPNhs04rkHGhZDY/y/W5rbig4SDKk+1isZVkCvnxoTtt376AccyiJ3K/x8/B1j1TbXaUF6tWcove8599HFuyymBYJK4w43fzoYUWJjnhd5m9KFadz+ykk+XOmq8W5GEyZb4K2AqdoRIHN3waLqf9oIPOsLn2/L0mcywxbA3Z72Y6wGhyqTGt9CnApK6JwIFEWyoXah+w+YlG+n65Od1OTGqiWGtXMW/1s1F9MqPrXuJr4Bw581lkd1KU6+vmlBQnMUTDPwZunhDD6p7zEU3CtlJq1+dj08TusQJeMFvhuagBT5nytzJBmbOEsv+vaSiCBMZaaQRjAtZpiKpPRe7CoUG1hpDMwWJnZFoyTjaSB4bo5jsyfNhDON512814I79LQaXTnsQONaIYG5Y08VPqZ7Mol8uhh9ju/R1Ewj85KweL9gniR3TegqgGbkjp3GNkAXat6QMjsQPBOMYEF7Ujdw+4GrBQXlv5zOGLhZMKja0JvowQb2ufQ4N8+ZGCtfHNSWS+KRXoEZywy59jtp+sGETpcB8qkV6DU 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)(366004)(396003)(346002)(376002)(136003)(451199021)(36756003)(478600001)(26005)(4744005)(2616005)(6486002)(8676002)(6666004)(83380400001)(53546011)(2906002)(6512007)(5660300002)(66574015)(66476007)(316002)(66946007)(66556008)(6916009)(41300700001)(8936002)(86362001)(38100700002)(4326008)(6506007)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N3NOSmpjR0k0QjNQK291SEVrMDRMVlBsckEzMTUyVWRmK0p3UU9QWXIwNGo5?= =?utf-8?B?MlVWN0xXZmVwMFN1YXpVMC9ZSk1KL1d6ak5HZ2ZqUFoyWVZYM0RwQUxSUkc0?= =?utf-8?B?R3lqYm5HSjNXTnBmM0hDOXpyZkVWYjdjSGZaS0tIWXJEYzJhR3VkeXE3S1Nx?= =?utf-8?B?YStNWmVJSXRocEc5Z2pZYnVZbm1Dai9Fd1Zvd3pqYTZQSUEveVFaTUdIK0Yv?= =?utf-8?B?T2d0UmFHK25kTXh3Tno5MDd4TWttRDF6NWZzQUc1WFFKTHgzSmgvSEZHdTd0?= =?utf-8?B?MHZySTgvTWhHV2RRY21CTU1YWkRZVzBlWitHK3pscHJXL3F2TDdMdkZ4NEdT?= =?utf-8?B?M1RVTElCOTZIWDhSeGdPUXU4bVdIbTZQWk9hWDN4WndOelJqNlBnTHRzRWxC?= =?utf-8?B?VXRUUUp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12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2023 13:07:17.7740 (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: KdooQB7f7ppTDj6ytcvvUG+dxNBP1bGa5vebNsDxMZSZDqu6y1Om8J1upFWyXgzY X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6966 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 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. Jason