Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3665888imm; Tue, 17 Jul 2018 08:23:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfCnSkakV0kdFqnw2e4XZVVyGDe8+cyC0rYG755D4A6VUFP9vxxKG2hBrrC5sogmSS9kpxN X-Received: by 2002:a63:c252:: with SMTP id l18-v6mr2045227pgg.76.1531841018594; Tue, 17 Jul 2018 08:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531841018; cv=none; d=google.com; s=arc-20160816; b=ls9sMgefMFcLpd1bQtbhnk8qkmJ2SyUUh50CDefbCo3TpX4PMJCF789Udk6DdCO/78 UYjLAtpFEdyvZKpVpW/fDSYU/Bhk5rDyNz1qpqJaCVsBhAfIR5KrJfITubA71Vnoa2SI 5cGyMtFqkBSaAU+Z/qZup1g/xcunxGTHwjnGS8MktwQO4OVrXgRGBy7a5aBrVB6CQNqr CkAXaslK89niG0XxfBricXRlNfxfKuQoTKytA2x+zZ53NijK68N81aEMPwabAENN7T0x OlvOJPAh4LxT8A+MDARXddJMcx7gobUnq6z4epm3PoUDpMb9iN4/Gi2H6gOSDPC4vNqN 04SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=eSOTl/tMIIqJgwBBVaasBbLdygWvHh25T8BiGaJzV+s=; b=KNr+YJ/mpu9ZlrIdKO4CkAGa0yw3bB48m/bBo+n6bN6UzOZJGrkF/DRdOjhPGalYtw PhJwwumt/ThwB82TuaTN20sDluHKmPAm28jDYn2d5Sv0p8BFZ38hdJSIHdcqdu9vYnND m2hdk4Umwxr4glPjF4taZw8IkVnWdI9h8ue+qknjMpXKpU5LwcvNLrkfmx2N+WcCUvPQ raU6bTcF36TnVb+sML2K6AihEMlx5hD9uCXrfuDux5WZqDtLVqpBDB4gnA5QJhFNWD/9 VTeBkI4KkS2q4V7yL7gUNqQIE2I481QQQMIbVA4H7mH3hLNjXX2rawdiuDNGs7ead8ig a3tw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a36-v6si1110652pla.207.2018.07.17.08.23.23; Tue, 17 Jul 2018 08:23:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729686AbeGQPzR (ORCPT + 99 others); Tue, 17 Jul 2018 11:55:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33478 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbeGQPzR (ORCPT ); Tue, 17 Jul 2018 11:55:17 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0A73356CB; Tue, 17 Jul 2018 15:22:08 +0000 (UTC) Received: from t450s.home (ovpn-116-29.phx2.redhat.com [10.3.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id A78471949D; Tue, 17 Jul 2018 15:22:07 +0000 (UTC) Date: Tue, 17 Jul 2018 09:22:07 -0600 From: Alex Williamson To: Srinath Mannam Cc: ray.jui@broadcom.com, vikram.prakash@broadcom.com, scott.branden@broadcom.com, kvm@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, , David Gibson , Subject: Re: [RFC PATCH] vfio/pci: map prefetchble bars as writecombine Message-ID: <20180717092207.775e381c@t450s.home> In-Reply-To: <1531457777-11825-1-git-send-email-srinath.mannam@broadcom.com> References: <1531457777-11825-1-git-send-email-srinath.mannam@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 17 Jul 2018 15:22:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Jul 2018 10:26:17 +0530 Srinath Mannam wrote: > By default all BARs map with VMA access permissions > as pgprot_noncached. > > In ARM64 pgprot_noncached is MT_DEVICE_nGnRnE which > is strongly ordered and allows aligned access. > This type of mapping works for NON-PREFETCHABLE bars > containing EP controller registers. > But it restricts PREFETCHABLE bars from doing > unaligned access. > > In CMB NVMe drives PREFETCHABLE bars are required to > map as MT_NORMAL_NC to do unaligned access. > > Signed-off-by: Srinath Mannam > Reviewed-by: Ray Jui > Reviewed-by: Vikram Prakash > --- This has been discussed before: https://www.spinics.net/lists/kvm/msg156548.html CC'ing the usual suspects from the previous thread. I'm not convinced that the patch here has considered anything other than the ARM64 implications and it's not clear that it considers compatibility with existing users or devices at all. Can we guarantee for all devices and use cases that WC is semantically equivalent and preferable to UC? If not then we need to device an extension to the interface that allows the user to specify WC. Thanks, Alex > drivers/vfio/pci/vfio_pci.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index b423a30..eff6b65 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -1142,7 +1142,10 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma) > } > > vma->vm_private_data = vdev; > - vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); > + if (pci_resource_flags(pdev, index) & IORESOURCE_PREFETCH) > + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); > + else > + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); > vma->vm_pgoff = (pci_resource_start(pdev, index) >> PAGE_SHIFT) + pgoff; > > return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,