Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp169190pxy; Fri, 30 Apr 2021 02:55:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxawn71z05fvMUCU6HH0y0AZl52Gk+3RSmKlyXlaXTEmqXptjAqk4Q4pA+UEnHG3oNbZhKg X-Received: by 2002:a17:902:e745:b029:ee:9dd5:f289 with SMTP id p5-20020a170902e745b02900ee9dd5f289mr1905617plf.64.1619776517827; Fri, 30 Apr 2021 02:55:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619776517; cv=none; d=google.com; s=arc-20160816; b=ZZahOCQdVeXTWRhuQ1szsU5CO1Mq+fjV36f4aGL9nNjzENgiKiFgqX6drbennVye1y m156giDd+Q1qNbN7wGAgwB2/l476IsyWxhsLRYjVQHk4u62N+FVivtAFOBS3acuRi8Qp hNEMtpPifNKUIoF/6J52TcQY+JhSvS1R7TVg7CNGYo6lherL6DAkPSDctge4GTK7gTGw FHcpTDaIIhApv+5DdzGouNu6c3w0wrh1gVnZ+ws90JhLr4kU0ZhOkBwsKwRlJ+Tqo1Li Nyz0M4JrvWZSneWI4sgNdcFC9Z8RBkq7LFWRPcTDfnIuvxlgjAMKeViuMk3Gy3MvwrR+ hnCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ZCLefKEPm58WBTZ9GkSsI2vjw03KLy8XRsHcnDr//zo=; b=duiV6sLvsAjkljoXNx2ZLfLDgz+80gjcdT0mGzbvepzGWl3IACeJ5WiUkiz9u5sSj3 AFesNEKVkARTZ4Z2kNHOpuBYWDKJrqHUTMxXevuYlU4eUuaTMtlZI7YGrMoK6axXhvxC gRU38jagnm2EdgCp8JBS0nm9W6UTsVakDLtOtmA+4CBtWivkaYc1J1QDS4FsnYrm8h1j J12vm71jh5uvnHRMlbPIYLui/quBlPqC8I+I6g2dpYld9PXvl+DQfBbKOHdVTO0q76JS RMOq8tm1D5HpC4m71BePMOWtESfCPacOLqGOmccteSSneYx92KLsXT965UgRdu2BEMnH UWRg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s6si1848865pjg.29.2021.04.30.02.55.05; Fri, 30 Apr 2021 02:55:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231476AbhD3JzN (ORCPT + 99 others); Fri, 30 Apr 2021 05:55:13 -0400 Received: from foss.arm.com ([217.140.110.172]:44722 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbhD3JzM (ORCPT ); Fri, 30 Apr 2021 05:55:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C087031B; Fri, 30 Apr 2021 02:54:24 -0700 (PDT) Received: from lpieralisi (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 01C143F73B; Fri, 30 Apr 2021 02:54:22 -0700 (PDT) Date: Fri, 30 Apr 2021 10:54:17 +0100 From: Lorenzo Pieralisi To: Shanker Donthineni Cc: Marc Zyngier , Alex Williamson , Will Deacon , Catalin Marinas , Christoffer Dall , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Vikram Sethi , Jason Sequeira , jgg@nvidia.com, benh@kernel.crashing.org Subject: Re: [RFC 1/2] vfio/pci: keep the prefetchable attribute of a BAR region in VMA Message-ID: <20210430095417.GA13686@lpieralisi> References: <20210429162906.32742-1-sdonthineni@nvidia.com> <20210429162906.32742-2-sdonthineni@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210429162906.32742-2-sdonthineni@nvidia.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+Jason, Ben] On Thu, Apr 29, 2021 at 11:29:05AM -0500, Shanker Donthineni wrote: > For pass-through device assignment, the ARM64 KVM hypervisor retrieves > the memory region properties physical address, size, and whether a > region backed with struct page or not from VMA. The prefetchable > attribute of a BAR region isn't visible to KVM to make an optimal > decision for stage2 attributes. > > This patch updates vma->vm_page_prot and maps with write-combine > attribute if the associated BAR is prefetchable. For ARM64 > pgprot_writecombine() is mapped to memory-type MT_NORMAL_NC which > has no side effects on reads and multiple writes can be combined. > > Signed-off-by: Shanker Donthineni > --- > drivers/vfio/pci/vfio_pci.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) A bit of background information that may be useful: https://lore.kernel.org/linux-pci/2b539df4c9ec703458e46da2fc879ee3b310b31c.camel@kernel.crashing.org Lorenzo > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > index 5023e23db3bc..1b734fe1dd51 100644 > --- a/drivers/vfio/pci/vfio_pci.c > +++ b/drivers/vfio/pci/vfio_pci.c > @@ -1703,7 +1703,11 @@ 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 (IS_ENABLED(CONFIG_ARM64) && > + (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; > > /* > -- > 2.17.1 >