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 D0106C43334 for ; Sat, 23 Jul 2022 01:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236371AbiGWBJI (ORCPT ); Fri, 22 Jul 2022 21:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236406AbiGWBJH (ORCPT ); Fri, 22 Jul 2022 21:09: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 ESMTP id 1AAF98BABD for ; Fri, 22 Jul 2022 18:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658538546; 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=TtJITXeJe/HGejcmvCfgDWekHgAs+3zE0/89IdxKZLc=; b=AnRW15r6SqABdIHTcJw/b5bnbn8HaU4OO5yi5JK1+6XxL6x2Y1AAReAEKUBAbPh/7eITat fuI3AG4Hq4GsxSbgawWodSv8SNUMjBO76oJ58tMdDfLZFX0WMKC+BsT/BVkafLatQgdtbq q6pAG2x8Q+RP4gTP5zsYvAAGWWItJ2c= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-384-YXGrIBo3Ple5TRug0KORRg-1; Fri, 22 Jul 2022 21:09:04 -0400 X-MC-Unique: YXGrIBo3Ple5TRug0KORRg-1 Received: by mail-il1-f199.google.com with SMTP id g8-20020a92cda8000000b002dcbd57f808so3612891ild.4 for ; Fri, 22 Jul 2022 18:09:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=TtJITXeJe/HGejcmvCfgDWekHgAs+3zE0/89IdxKZLc=; b=Les5IRzcWzPqkI7fjZxse8bMhWEnH6JtaHfqbQgpIY6Ryj/TTHC0Omx3XZfa1gaIel qDeRKs9s4NkZSQpsAmEc34xidsy7B/GFFdDHSsCbpG8aXVu5cbvnAAG2I/aZbFi+TjW/ gBlQ5c7SYDMto251WYqNNVk8RDsQ2SWHczZYGS5z+XW9aQ9nAB8uBDzHQ5T5AdquKUAT QZiZZzq5/KGNOuCdJ6zECu//bbgIC5HCh7MiwgyXzhYxnz2ch3H6BLLzHxji7hr73AcI XDUgXCukZ5ABS8shHFjmNlCTck9z6yu22n0hhNs6VoFzomMVNl2U3PRgvARNvig1Phxh p1+Q== X-Gm-Message-State: AJIora/NPBFkgDiC6TLaol7zAWBTHOffFRefeTkz7cco7DqSWj61OP9p 9/mR/GQZGCiO77m0emaopctFv3EzCwsQU570xSpXwpY9fcufCnD5C68hfc6jtrvz0jj/VxBA0KO lYo692UoZzoHr+ccnxMjy X-Received: by 2002:a05:6e02:1b07:b0:2dc:767c:6607 with SMTP id i7-20020a056e021b0700b002dc767c6607mr962233ilv.178.1658538544163; Fri, 22 Jul 2022 18:09:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLeZy56sEhX34vmR/dm7wtpceD1ImpTzU8x3g21W4EturgnacF7y4YsmXib0rg5DdXzeXkiQ== X-Received: by 2002:a05:6e02:1b07:b0:2dc:767c:6607 with SMTP id i7-20020a056e021b0700b002dc767c6607mr962219ilv.178.1658538543921; Fri, 22 Jul 2022 18:09:03 -0700 (PDT) Received: from redhat.com ([38.15.36.239]) by smtp.gmail.com with ESMTPSA id g18-20020a05663810f200b0033f43a220a6sm2654122jae.11.2022.07.22.18.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 18:09:03 -0700 (PDT) Date: Fri, 22 Jul 2022 19:09:01 -0600 From: Alex Williamson To: Nicolin Chen Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v3 00/10] Update vfio_pin/unpin_pages API Message-ID: <20220722190901.262a1978.alex.williamson@redhat.com> In-Reply-To: References: <20220708224427.1245-1-nicolinc@nvidia.com> <20220722161129.21059262.alex.williamson@redhat.com> <20220722181800.56093444.alex.williamson@redhat.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Fri, 22 Jul 2022 17:38:25 -0700 Nicolin Chen wrote: > On Fri, Jul 22, 2022 at 06:18:00PM -0600, Alex Williamson wrote: > > External email: Use caution opening links or attachments > > > > > > On Fri, 22 Jul 2022 16:12:19 -0700 > > Nicolin Chen wrote: > > > > > On Fri, Jul 22, 2022 at 04:11:29PM -0600, Alex Williamson wrote: > > > > > > > GVT-g explodes for me with this series on my Broadwell test system, > > > > continuously spewing the following: > > > > > > Thank you for running additional tests. > > > > > > > [ 47.348778] WARNING: CPU: 3 PID: 501 at drivers/vfio/vfio_iommu_type1.c:978 vfio_iommu_type1_unpin_pages+0x7b/0x100 [vfio_iommu_type1] > > > > > > > Line 978 is the WARN_ON(i != npage) line. For the cases where we don't > > > > find a matching vfio_dma, I'm seeing addresses that look maybe like > > > > we're shifting a value that's already an iova by PAGE_SHIFT somewhere. > > > > > > Hmm..I don't understand the PAGE_SHIFT part. Do you mind clarifying? > > > > The iova was a very large address for a 4GB VM with a lot of zeros on > > the low order bits, ex. 0x162459000000. Thanks, > > Ah! Thanks for the hint. The following commit did a double shifting: > "vfio: Pass in starting IOVA to vfio_pin/unpin_pages AP" > > And the following change should fix: > ------------------- > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c > index 481dd2aeb40e..4790c7f35b88 100644 > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c > @@ -293,7 +293,7 @@ static int gvt_dma_map_page(struct intel_vgpu *vgpu, unsigned long gfn, > if (dma_mapping_error(dev, *dma_addr)) { > gvt_vgpu_err("DMA mapping failed for pfn 0x%lx, ret %d\n", > page_to_pfn(page), ret); > - gvt_unpin_guest_page(vgpu, gfn << PAGE_SHIFT, size); > + gvt_unpin_guest_page(vgpu, gfn, size); > return -ENOMEM; > } > > @@ -306,7 +306,7 @@ static void gvt_dma_unmap_page(struct intel_vgpu *vgpu, unsigned long gfn, > struct device *dev = vgpu->gvt->gt->i915->drm.dev; > > dma_unmap_page(dev, dma_addr, size, DMA_BIDIRECTIONAL); > - gvt_unpin_guest_page(vgpu, gfn << PAGE_SHIFT, size); > + gvt_unpin_guest_page(vgpu, gfn, size); > } > > static struct gvt_dma *__gvt_cache_find_dma_addr(struct intel_vgpu *vgpu, > ------------------- Looks likely. Not sure how Terrance was able to test this successfully though. > So, I think that I should send a v4, given that the patches aren't > officially applied? Yep, please rebase on current vfio next branch. Thanks, Alex