Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2599711rda; Wed, 25 Oct 2023 07:21:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmc5kXd0+Wie/QyiNn4s5d3TV4pKH7SPMxodjvD5YsM/X6BALzJxf1qR1lonGhfE5eyieW X-Received: by 2002:a05:6870:15cf:b0:1ea:8645:6352 with SMTP id k15-20020a05687015cf00b001ea86456352mr13382220oad.11.1698243687388; Wed, 25 Oct 2023 07:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698243687; cv=none; d=google.com; s=arc-20160816; b=U5N1bN/yWgNVaANhLBZa1yHmCFAXzeoSRnE4y+ihp66z1G8ApegBN3s9EyIfD7/Agr 9TskO0Y0Q1pBv6JMKRpKoelghGM69JJ1JwMhhoFwEx5UCzis7PNp4WRcXZrcT3zoef7H w1OULjcmoOXCEWs0hJY/vlVAFiad2lSIWT3XBgQoROfkpKRTfULF4FDX9x9frq3y7itL AzcrsPorf0UXIEyP3q8r15m4cOHACoiWvbbh0ccpDzQ5PHJxIVG07j1JeJkkqJLKIUHE QWkqXuZ9JdI29ELtzpdQFun/egPuo0IRxo1FunVz03siyDKw9VsSkjSlXK0Vsaxg/Dwi h+og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=S1yh9aFBXnB/uUDqIchESZqamQpwZAPHQV0zqqMljjg=; fh=WEhjSPOGt86iHwkpa9j+O5eGA66lyFhXSoI1bfofyEA=; b=K9T9iYtECVtslaBLeGfdFMnbtK5oAYfjQ38b4YcsLoOIjriliJlr9+r+K+3o6pzxNd CRtFHAO2C1eVd4JjNIYuMu20zOxfbFPhBNXemTXsGRI65ecKjTx3I3tqyozQCeHvWKRg IVNekKp1LUNS5Unxfk1L1MkuRA6RubbOabHBEvaRr96f5dJ/+xon7De+5hO5E2t0tfdL g6X3Y7sCgytDaUaw+vgR103NGPdY9bnU297rxAvkbREHoIELBXTJR26yWAIKyG10TOg4 jqq5HF0qlyHJxttOQF9cUfIovjZbaeSVIZdbF00X37M2VZlmeytcIbHq0HIvzlb94Xp/ 7Rhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KPW6x6rV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id s186-20020a815ec3000000b00592462f74e0si11971828ywb.341.2023.10.25.07.21.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 07:21:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KPW6x6rV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 42014807FD59; Wed, 25 Oct 2023 07:21:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234893AbjJYOVJ (ORCPT + 99 others); Wed, 25 Oct 2023 10:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232846AbjJYOVH (ORCPT ); Wed, 25 Oct 2023 10:21:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7671B9 for ; Wed, 25 Oct 2023 07:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698243623; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S1yh9aFBXnB/uUDqIchESZqamQpwZAPHQV0zqqMljjg=; b=KPW6x6rVg7rgOsqO8KUx/BD1X22FUcAV5tt2tTyWxHS7nXLrBOXmMFy/lNu4jxc2dhIVaB xFFUmi93uYgWoazqOB7ku5Qgfr3WnPTLxjCv2owQ18RKI5WMQY8wEqBhR5ugKurqwlno1U RFXPd7bG6f+sgl3IQU6xn07xEprsWas= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-JUp5NiC9M6yxak6uV_XpCw-1; Wed, 25 Oct 2023 10:20:22 -0400 X-MC-Unique: JUp5NiC9M6yxak6uV_XpCw-1 Received: by mail-io1-f70.google.com with SMTP id ca18e2360f4ac-7a9985d56a8so70346139f.2 for ; Wed, 25 Oct 2023 07:20:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698243621; x=1698848421; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S1yh9aFBXnB/uUDqIchESZqamQpwZAPHQV0zqqMljjg=; b=eSr1j86pAUpQHBTSf7EiGwUEBDLDhE83chdX0jPqT1CWsa8aRhJ/svJ4LNvfb/RKAc z9pmDIpdXnMEsgUP5kw5U3hpPcSa19fTQm+TXjEak38Cl97nDvIfjLs+e8sUwK3t6YUD b5LFDcNN4Dc8yFGN3kEFskYpPnlnJvRH1665Yz44QlsxrzWRvNSOnNu8bZ8lANNeaJwr W2EEuqlSP0J6mH+sc/iy9ZS0n2nZ51pxUdKi3lm2HmF9DbzTjsKvreU8i41AyNmoM/Sx x5Ptwyim1kUjaBIjshRaxkEweouGA74cQISaexLLSpKib8816g6lgjNouITSqC/zeMRG 8GGQ== X-Gm-Message-State: AOJu0YyNlhhGeOCMSY6zmUei+j6p1CeUaogeIfxjiYnPdImo+Y2G1Unc b1uG+ruf4SjSreEkP3BVUdgY+UbwPGwTIRpsfXBLGm/Arb7W8prPLuCRe7Zosu10BUPPs9Pw0P0 M3klgjoA98Zqx6/99e6QCqyZI X-Received: by 2002:a05:6e02:12c6:b0:357:a04c:31d2 with SMTP id i6-20020a056e0212c600b00357a04c31d2mr20557624ilm.16.1698243621710; Wed, 25 Oct 2023 07:20:21 -0700 (PDT) X-Received: by 2002:a05:6e02:12c6:b0:357:a04c:31d2 with SMTP id i6-20020a056e0212c600b00357a04c31d2mr20557588ilm.16.1698243621425; Wed, 25 Oct 2023 07:20:21 -0700 (PDT) Received: from redhat.com ([38.15.60.12]) by smtp.gmail.com with ESMTPSA id a18-20020a92d352000000b0035742971dd3sm3769998ilh.16.2023.10.25.07.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 07:20:20 -0700 (PDT) Date: Wed, 25 Oct 2023 08:20:19 -0600 From: Alex Williamson To: Ankit Agrawal Cc: "Tian, Kevin" , Jason Gunthorpe , Yishai Hadas , "shameerali.kolothum.thodi@huawei.com" , Aniket Agashe , Neo Jia , Kirti Wankhede , "Tarun Gupta (SW-GPU)" , Vikram Sethi , Andy Currid , Alistair Popple , John Hubbard , Dan Williams , "Anuj Aggarwal (SW-GPU)" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v12 1/1] vfio/nvgpu: Add vfio pci variant module for grace hopper Message-ID: <20231025082019.14575863.alex.williamson@redhat.com> In-Reply-To: References: <20231015163047.20391-1-ankita@nvidia.com> <20231017165437.69a84f0c.alex.williamson@redhat.com> <20231023084312.15b8e37e.alex.williamson@redhat.com> <20231024082854.0b767d74.alex.williamson@redhat.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.35; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 25 Oct 2023 07:21:24 -0700 (PDT) On Wed, 25 Oct 2023 12:43:24 +0000 Ankit Agrawal wrote: > While the physical BAR is present on the device, it is not being used on = the host > system. The access to the device memory region on the host occur through = the > C2C interconnect link (not the PCIe) and is present for access as a separ= ate memory > region in the physical address space on the host. The variant driver quer= ies this range > from the host ACPI DSD tables. BTW, it's still never been answered why the latest QEMU series dropped the _DSD support. > Now, this device memory region on the host is exposed as a device BAR in = the VM. > So the device BAR in the VM is actually mapped to the device memory regio= n in the > physical address space (and not to the physical BAR) on the host. The con= fig space > accesses to the device however, are still going to the physical BAR on th= e host. >=20 > > Does this BAR2 size match the size we're reporting for the region?=C2= =A0 Now > > I'm confused why we need to intercept the BAR2 region info if there's > > physically a real BAR behind it.=C2=A0 Thanks, =20 >=20 > Yes, it does match the size being reported through region info. But the r= egion > info ioctl is still intercepted to provide additional cap to establish th= e sparse > mapping. Why we do sparse mapping? The actual device memory size is not > power-of-2 aligned (a requirement for a BAR). So we roundup to the next > power-of-2 value and report the size as such. Then we utilize sparse mapp= ing > to show only the actual size of the device memory as mappable. Yes, it's clear to me why we need the sparse mapping and why we intercept the accesses, but the fact that there's an underlying physical BAR of the same size in config space has been completely absent in any previous discussions. In light of that, I don't think we should be independently calculating the BAR2 region size using roundup_pow_of_two(nvdev->memlength). Instead we should be using pci_resource_len() of the physical BAR2 to make it evident that this relationship exists. The comments throughout should also be updated to reflect this as currently they're written as if there is no physical BAR2 and we're making a completely independent decision relative to BAR2 sizing. A comment should also be added to nvgrace_gpu_vfio_pci_read/write() explaining that the physical BAR2 provides the correct behavior relative to config space accesses. The probe function should also fail if pci_resource_len() for BAR2 is not sufficient for the coherent memory region. Thanks, Alex