Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp841363imm; Wed, 18 Jul 2018 11:36:11 -0700 (PDT) X-Google-Smtp-Source: AAOMgpegIboUPg1UIDnvRAmNdv+9iLUmh7fFMWiHLdKTMan5gJ4Efsmf7ZrgDMV2lzcP+FGCrWeA X-Received: by 2002:a62:d8c:: with SMTP id 12-v6mr6358505pfn.202.1531938971630; Wed, 18 Jul 2018 11:36:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531938971; cv=none; d=google.com; s=arc-20160816; b=jpgxEqRkm3U7unA4Pic0yOt6HzB8n5YsSuv8yb4fS3eROGFwyKLcFBpfTvwa0tiTUx b/1u+UWP9f6+rq0qoWIe5onUEtr6lhj/Du405WPjjyDYzXnVpv0qPPR23kqgRjAhrzTG WXT9yJH7ieTvR4J6HHGPf13lXICNMq/IrvVYRXgSQRsQilZcHlHwCyNn8I0zXl/jyFla hq3bLqC8Gyk8EoiUnQaHxPNc1dZI6PQjOWeYuP7gUvOrB7VsAvyxzGRG3CLiQ2QrMrrB DsRn5PV/F7tqTAeaHsoy8/Qdf0AeZyEIFcE31pBiaCZ/f+15lYDFRGtX/2Vz/c/a5igx aiCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=lZY8QMuT7Vbq3sfluO9YRRPcacvm2T6ysDJmWYWu9vM=; b=maQ5w+uw9qxrLR/CjX4+QWh0DGukvp6u2M+6MuK0P8AsSdeOFcD5X2iCadAKgRu1iC b4+j+AHPEmD0BeU7j5VORUcZUCr+WfOlid3o7Uw4drBGLphgXoJbTt5Zq0AhjnY2jnFB D5h2rWIt+szvIDqKhvT8C6JTxO9P+bEdQrN08EczeHZplU/hhOLq0Fz/vBWwLnYp9vES e6V9N6/gA6zwc5LSmYArigDLa1rJ1k1coC6waCs01HxHqiE1wa54GvhoBcL+RFOIt3XW odepU5buZEfm4HOAjHZTT6JkaVccWnH8avYDxTVOeklYjfmKJoLfTUtIeTlCa4qM7LpG opUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=YQauBU5m; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c16-v6si1105312pfn.212.2018.07.18.11.35.56; Wed, 18 Jul 2018 11:36:11 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=YQauBU5m; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728626AbeGRTO3 (ORCPT + 99 others); Wed, 18 Jul 2018 15:14:29 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34027 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbeGRTO3 (ORCPT ); Wed, 18 Jul 2018 15:14:29 -0400 Received: by mail-oi0-f65.google.com with SMTP id 13-v6so10699861ois.1 for ; Wed, 18 Jul 2018 11:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lZY8QMuT7Vbq3sfluO9YRRPcacvm2T6ysDJmWYWu9vM=; b=YQauBU5mI6eUMYr+FjliNb6O+N8Mx3Ssnho3SI2YC4E/3eZeAt+379V0wC9iTmvMFy ouA+hzgQ1qxoqXkDjeuA5qZGQAIulIzy32Rb2YqnNUmrN/b8ulSKVN2F4JdcxfdbgFrb FuRnUZ5x8CzWzNG7Sg/i0KriVlW8IqHmeYpBI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lZY8QMuT7Vbq3sfluO9YRRPcacvm2T6ysDJmWYWu9vM=; b=SgOBN0gr6eNR9BRCgehn6SZpvrFzncax5aVa8KDw0GMRWnxgqv8WJFVhjTWCR/N5wQ p/JYPJDFVL6p1bAudSPfd8aGq2ZuMhYBSrpAVTeHdWQahP3JjJx7VmIt/6b/L0LukZ9V D7AGo+Tx64Wg00KYS1P1tJr6UoJErobCV9HmH18XHPdRz3qHsGcOWP44Z50xXclKsuOG /Fah0wCRydK6GdyiDMJYJMgWurIXO6jOnQX6eu/LNdbsR6GyhEVHulcBf4bm/opBuHQ0 /vAtd6Sc98/HDHmtk037cbIFZoA0j1/70XitlrHE5LtMbkpMjc5ius8ZUVn9Gy1OM+ff 84ew== X-Gm-Message-State: AOUpUlFyEC8IEfwY5CixAiP9DkOmUOvxwKF9eO9TpA08jwRTRxKMB93g ZANofqvAxkdEzyYs/scPj6pjntNyahFAjMnC6y2uYA== X-Received: by 2002:aca:d986:: with SMTP id q128-v6mr7159605oig.349.1531938919362; Wed, 18 Jul 2018 11:35:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:6043:0:0:0:0:0 with HTTP; Wed, 18 Jul 2018 11:35:18 -0700 (PDT) In-Reply-To: <20180717092207.775e381c@t450s.home> References: <1531457777-11825-1-git-send-email-srinath.mannam@broadcom.com> <20180717092207.775e381c@t450s.home> From: Srinath Mannam Date: Thu, 19 Jul 2018 00:05:18 +0530 Message-ID: Subject: Re: [RFC PATCH] vfio/pci: map prefetchble bars as writecombine To: Alex Williamson Cc: Ray Jui , Vikram Prakash , Scott Branden , kvm@vger.kernel.org, BCM Kernel Feedback , Linux Kernel Mailing List , aik@ozlabs.ru, David Gibson , benh@kernel.crashing.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alex, On Tue, Jul 17, 2018 at 8:52 PM, Alex Williamson wrote: > 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 Thank you for inputs.. I have gone through the long list of mail chain discussion. > > 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, > To implement with user specified WC flags, many changes need to be done. Suppose In DPDK, prefetcable BARs map using WC flag, then also same question comes that WC may be different for different CPUs. As per functionality, both WC and PREFETCHABLE are same, like merging writes and typically WC is uncached. So, based on prefetchable BARs behavior and usage we need to map bar memory. Is it right to map prefetchable BARs as strongly ordered, aligned access and uncached? Please correct me if my understanding is wrong. Regards, Srinath. > 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, >