Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp370630imm; Thu, 12 Jul 2018 21:57:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeLlJr4Oo0aZp7s7D1TMq9Cgk8RoP3RJW3ByxoaNnMhqWVGdoseGtrWsyt7+u81Ym2kK+F/ X-Received: by 2002:a65:4d05:: with SMTP id i5-v6mr4600122pgt.58.1531457842724; Thu, 12 Jul 2018 21:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531457842; cv=none; d=google.com; s=arc-20160816; b=dYBsCmSZQ/k3oi4nS/196G4m28B6YeJ8jXhbvAOWABkV2EfZSJ/tgJxfJjoY3ss2K2 s8W98YDQyKwn9BPYTOj4H3GCYpwD8ClB0kBt1OmD0PzKY60OiawO8qZG7T6GE1SlgCJe uXZ/FIJz/F6oSJ8+sOke1Dy6GDihOTu25FBYS+ToZqx9+4uuf6SmdYYEPYvKouq4R/Cw m7k5JFoDjAtFAZtgFgwBcX4P3WtZ8Y9Jkc2OwH4au3oFdJjz+JBefaSgFrWfAU8OYAma RH0lcKeMZPnyGvnzMgLyRF31IZXX9L7xg1UXnjbrOt3wzOxtrKZDrJXhAR5N0Pt9utxj YTpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=GZ7pbph9RA5T64mYEULW8PTxgiFXpzZJDFXv+4YEJTs=; b=ipXJHBG/8IH0y0mirCKrCA4mwGo+sMEuCRCxqG+q05L+i0PW6pOnA7d8D9Wm+pVlim tltnQ2qKmg+0AXsg575HQyEf13uvu2dd2xe9KawnU8p8b257Yot1Bc0SOwX+jAV5zomp 3NUS+UpH0Vs846xIOznSm17eo0w4j7UKpYWrdNslVGfPcphiZjzz/YDTExbJ6Usf+v2N wmL0e3w/D4OUVOuNxuxOLpJrsP8ga8QYDPu/t4wr9rZooGufS/3lVBDqx/plGXv6M/lu NnhJoXqHtAkJx1JZFmCkhi7MLSAWd+WVddw791MjZn2mKWN0UBc+aZuWEzYCHxIt2QCG tR2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="EIZr/01/"; 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 6-v6si23785347plb.409.2018.07.12.21.57.05; Thu, 12 Jul 2018 21:57:22 -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="EIZr/01/"; 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 S1727188AbeGMFJX (ORCPT + 99 others); Fri, 13 Jul 2018 01:09:23 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:46856 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726389AbeGMFJX (ORCPT ); Fri, 13 Jul 2018 01:09:23 -0400 Received: by mail-qt0-f196.google.com with SMTP id d4-v6so10630174qtn.13 for ; Thu, 12 Jul 2018 21:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=GZ7pbph9RA5T64mYEULW8PTxgiFXpzZJDFXv+4YEJTs=; b=EIZr/01/kxIkfl+OywpLODL4nibHyCtSMf6F2V0J716AEXd5GVSdwyfscdZVDEQLs6 CDqEia1MxlM43hunCTy4iOSwOi1qnVpyLMDhPZI3djYAUbwHrH7/CZl+E86wtUzoZ5yw kMnfy1gfOUrCXCMkxSciqp+ah+whMSaHLcoQc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GZ7pbph9RA5T64mYEULW8PTxgiFXpzZJDFXv+4YEJTs=; b=Dp2uk4BzsfJhgMbbdqgPTbFSAzyzEtfARZsZmtW0yNHi+aeJMiECK2ledlnrqrmH69 oJDlCC4GAltBFOVMuwt43OVE0C+6CZMQsm1QPA63s4ilBrewrbavtMV74ZrHSZRrpgRA U+H2uUaZ7CnMEVzyDD2ABVrILBaY5Yl2wQBPIOIoL6Hocg/NY+vqLbJGpSJKQrININ5J GkZ5tRnTR+tUCUrpFdWcbUIHyeFpiNGYiJ6691p65vhStyObh/9RUktdh3IdI8RnPrIX j8m/+Xl6ORoUVBsCbuzfLHiGWdm6EiSnsPtUn7WEAHTF3yqSzCLU2+gWkzXWuDYYSKfZ tp6w== X-Gm-Message-State: AOUpUlG3SX0NJfG6R+15JY0uJRb9WdTgyR3JuUpOafRpUpsYeO9j+t3A 4OVOkGbkSjoxLO+oyZIHFZIwDg== X-Received: by 2002:aed:2a33:: with SMTP id c48-v6mr4484932qtd.147.1531457791261; Thu, 12 Jul 2018 21:56:31 -0700 (PDT) Received: from mannams-OptiPlex-7010.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id w43-v6sm15830537qth.58.2018.07.12.21.56.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jul 2018 21:56:30 -0700 (PDT) From: Srinath Mannam To: Alex Williamson 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, Srinath Mannam Subject: [RFC PATCH] vfio/pci: map prefetchble bars as writecombine Date: Fri, 13 Jul 2018 10:26:17 +0530 Message-Id: <1531457777-11825-1-git-send-email-srinath.mannam@broadcom.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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, -- 2.7.4