Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2181366ybv; Fri, 21 Feb 2020 10:26:00 -0800 (PST) X-Google-Smtp-Source: APXvYqzl9IoBRNS6lyaM6nbiveCoT9xVz4N7u6IAjUPb+p/va5KFizYOFjakx39gFr07kiwCuL25 X-Received: by 2002:aca:c507:: with SMTP id v7mr3088221oif.157.1582309560315; Fri, 21 Feb 2020 10:26:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582309560; cv=none; d=google.com; s=arc-20160816; b=BYCdU1z5cimYu+CEiB//d40pdAZNWOTce4Hid7n7H7GP9APtO1ioQYLmVJG0zZ4hub aoKun1MVRPX0Sn5Bh0wewj3r0QUYaOf9JNoOmUq7gbRghoot3+4xk4AjfDPnV/NNNFHZ O0ObdyQa5TaM/8XM3O+95qlwO8Q3jS+yjaEaqAu4W/Y9qcYHhS0sawmMYztvVxV4s48s hhYJcQKg1AHNcT/jlCBGxdk6KrZOFt7CrjCYextC+GPN4WyuZ5C1hehVE/Qm8+ddPNrB QNMf840OdbC+OWRMM8Zs7lGObFXO9R4YtlpCg9kSqE5n7TFedTYLoRwcth/xXrdUML94 3DjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=xJkGlQfYKtk/Ele7Es+p24/DodM0zmBM9IJYH2/L4fI=; b=0tYmZ0niN7Ylj08y5eEbFEgDgWzlHiwsPLbCokIUzQtPhi9Vx62Xx90sE7laPTQGTk vYYigh51DzaCqfjdxRmVUJO4ecxwGGjypRsO8UVbHwJ6pvJ0Qi/zzJ2Thkytpt1FKZUA w3NKVSfLTbvO9DoE92XYChZnVdTYBV55mr5tn3CXaYD5uy8P99Ozr8PQpX2qxkvpGltC 4HH3iAqa6BITabIFMv5k/JMuuO5FQ3zw/E1Vv1zRlrcPjm7MAido3pQbcU34Cjy5AyIQ WBm6dxHDmcELstKb49ac2iG5VjQvIgOJZJjq5X5wTQIui2a2uag26WaOc7CSkU/KDkp6 h7SA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si1822615otq.148.2020.02.21.10.25.48; Fri, 21 Feb 2020 10:26:00 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729712AbgBUSZc (ORCPT + 99 others); Fri, 21 Feb 2020 13:25:32 -0500 Received: from ale.deltatee.com ([207.54.116.67]:59190 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729438AbgBUSZa (ORCPT ); Fri, 21 Feb 2020 13:25:30 -0500 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j5CzA-00057s-B6; Fri, 21 Feb 2020 11:25:25 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1j5Cz3-0007Nt-Mw; Fri, 21 Feb 2020 11:25:05 -0700 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, Dan Williams , Michal Hocko , David Hildenbrand , Andrew Morton Cc: Christoph Hellwig , Catalin Marinas , Will Deacon , Benjamin Herrenschmidt , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Eric Badger , Logan Gunthorpe , Jason Gunthorpe Date: Fri, 21 Feb 2020 11:25:03 -0700 Message-Id: <20200221182503.28317-8-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200221182503.28317-1-logang@deltatee.com> References: <20200221182503.28317-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org, dan.j.williams@intel.com, akpm@linux-foundation.org, hch@lst.de, catalin.marinas@arm.com, benh@kernel.crashing.org, tglx@linutronix.de, david@redhat.com, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, mhocko@kernel.org, will@kernel.org, luto@kernel.org, peterz@infradead.org, ebadger@gigaio.com, logang@deltatee.com, jgg@ziepe.ca X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT,SURBL_BLOCKED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH v3 7/7] mm/memremap: Set caching mode for PCI P2PDMA memory to WC X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PCI BAR IO memory should never be mapped as WB, however prior to this the PAT bits were set WB and it was typically overridden by MTRR registers set by the firmware. Set PCI P2PDMA memory to be WC (writecombining) as the only current user (the NVMe CMB) was originally mapped WC before the P2PDMA code replaced the mapping with devm_memremap_pages(). Future use-cases may need to generalize this by adding flags to select the caching type, as some P2PDMA cases will not want WC. However, those use-cases are not upstream yet and this can be changed when they arrive. Cc: Dan Williams Cc: Christoph Hellwig Cc: Jason Gunthorpe Signed-off-by: Logan Gunthorpe --- mm/memremap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memremap.c b/mm/memremap.c index 06742372a203..8d141c3e3364 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -190,7 +190,10 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid) } break; case MEMORY_DEVICE_DEVDAX: + need_devmap_managed = false; + break; case MEMORY_DEVICE_PCI_P2PDMA: + params.pgprot = pgprot_writecombine(params.pgprot); need_devmap_managed = false; break; default: -- 2.20.1