Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1111431pxk; Fri, 18 Sep 2020 04:12:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFqH4rMRRLR40RwULl+xGia2b0nbz45q8jn0s6nJGVi3KQKBXQbIDYM9wSOSghxML0xtnr X-Received: by 2002:a05:6402:1717:: with SMTP id y23mr39611448edu.112.1600427530105; Fri, 18 Sep 2020 04:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600427530; cv=none; d=google.com; s=arc-20160816; b=hs0SxZyrxgj8XCf6y8K0XevE1mhNrGlcGwUkcmDxZ9GvSRndM+f2jQMxJ1iMcqfZb1 mbM6nlnMF0fJMQeR0/DDZYTI0gNs/kljBHrCWHM57lTLHtHhJyBwFTNgIlZgF+WGWYrV RHWzSH8DyAbt2wkwns4dvSK2SBylskjTnUtr3bCzAglBXmQ/bJzYoWwccYPfx9NuRnJ8 XruUz41+JeF+GcVWFswp+FySWhQk016dylHz4HHURP5JUmVFIgphsz8bkE1GYX3A8YXV fbx6yXUsc50/hee9+zXeSmHG8m0HqKi7v2ZoQXurWmcdOv11AWpYfVjz7+X14xYlblqT uxQA== 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=3NUYTcIczGrDiuKjJy9KPQXv6gr1x1WkjU0wN/IhknM=; b=jSPglYHsN3GkvG1jk4EWsPiAvfgXUQyVjP1L6zu4li6XitueQUi8QPPCzzfKBpoCJo draGgW+CPTO3yTmapgunThiP/S4qRXA1UMCaM3Zq/PSsDD3q4Ri+XpPRj/m4R1mnaZFO AcefdNW7VsQ9a4DH9WhcMvW/YpK/CDhxWB0ZxkE5D3LVk9vXS2uOrMoye2iRA7L17YCB ymUkExmQOqgw1bwVCWIA2loIxVAo4OrId2PfQRMbXHD7e6+DUEZnXaezPP0ZRg8NqD1G 3ogmeFhOhe7otmu+px5ijx+y2ebPd+cxlpfK9YjBGPDzVQlBeMlirTJWK563apa8dvgs AmIg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si1777619ejk.113.2020.09.18.04.11.46; Fri, 18 Sep 2020 04:12:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726139AbgIRLHu (ORCPT + 99 others); Fri, 18 Sep 2020 07:07:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:46250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725955AbgIRLHu (ORCPT ); Fri, 18 Sep 2020 07:07:50 -0400 Received: from gaia (unknown [31.124.44.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D3B3220874; Fri, 18 Sep 2020 11:07:48 +0000 (UTC) Date: Fri, 18 Sep 2020 12:07:46 +0100 From: Catalin Marinas To: Clint Sbisa Cc: Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Bjorn Helgaas , Jason Gunthorpe , Lorenzo Pieralisi Subject: Re: [PATCH v2] arm64: Enable PCI write-combine resources under sysfs Message-ID: <20200918110745.GD6335@gaia> References: <20200918033312.ddfpibgfylfjpex2@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918033312.ddfpibgfylfjpex2@amazon.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 18, 2020 at 03:33:12AM +0000, Clint Sbisa wrote: > This change exposes write-combine mappings under sysfs for > prefetchable PCI resources on arm64. > > Originally, the usage of "write combine" here was driven by the x86 > definition of write combine. This definition is specific to x86 and > does not generalize to other architectures. However, the usage of WC > has mutated to "write combine" semantics, which is implemented > differently on each arch. > > Generally, prefetchable BARs are accepted to allow speculative > accesses, write combining, and re-ordering-- from the PCI perspective, > this means there are no read side effects. (This contradicts the PCI > spec which allows prefetchable BARs to have read side effects, but > this definition is ill-advised as it is impossible to meet.) On x86, > prefetchable BARs are mapped as WC as originally defined (with some > conditionals on arch features). On arm64, WC is taken to mean normal > non-cacheable memory. > > In practice, write combine semantics are used to minimize write > operations. A common usage of this is minimizing PCI TLPs which can > significantly improve performance with PCI devices. In order to > provide the same benefits to userspace, we need to allow userspace to > map prefetchable BARs with write combine semantics. The resourceX_wc > mapping is used today by userspace programs and libraries. > > While this model is flawed as "write combine" is very ill-defined, it > is already used by multiple non-x86 archs to expose write combine > semantics to user space. We enable this on arm64 to give userspace on > arm64 an equivalent mechanism for utilizing write combining with PCI > devices. > > Cc: Benjamin Herrenschmidt > Cc: Bjorn Helgaas > Cc: Catalin Marinas > Cc: Jason Gunthorpe > Cc: Lorenzo Pieralisi > Cc: Will Deacon > Signed-off-by: Clint Sbisa Acked-by: Catalin Marinas