Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp29216ybl; Tue, 7 Jan 2020 13:27:27 -0800 (PST) X-Google-Smtp-Source: APXvYqwyry9eeC2iDAd9weFPd6Nd4/huB5SLlnUrsCZhtU3lAIlSnQ8Ek53Ztv/4wM6bBLba8hJ8 X-Received: by 2002:aca:d544:: with SMTP id m65mr379732oig.177.1578432447129; Tue, 07 Jan 2020 13:27:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578432447; cv=none; d=google.com; s=arc-20160816; b=BAp5kbyqynPncpl13OObEyxsqQ6blD2TDTBFMPVH4EqWiI/bGqvOM6O7bShYbcXUOp HL/fGKDDqokDB29GwHOwaLq79qHDpmIPAZxHs1LOoGQOczAlo7o+UocKTRdh7QWb0Ljf wbJlUUrewHwUbQ2Bm0Ahz0HsdGL825MQCiDr1KhcJpyI2j9DnlXz3dtO6+fkQMIITUul tTeB+Y29txnPKGHjmc3U9DhtThkLOCN1yqLeFdcYQESW354xfaQ/e8htPjPromkBMKIQ hGgqQosm3z79OUsn4P0/dqMyr3gqKSxqDNlwNu6/ehCni090CTjwKSLxP81TiXUj1FA5 IMdQ== 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=t9+jZ67FLayVangz80/4w8U9Y3AWdBtg6bofj6T30vg=; b=ZIwdAY2Jm9oH3TSccxh63ZkDsOOyyYDsZ4YVWIC6DlkRP/sedptaYXd50+e2fjmSFQ oy6980vMl4V+BUoT/rtd3J+N0/WsEXE8m7pZ3eStLKbpEmrgOffheqDHw4AHXyQr4E2O m9P8ZATs0qWCpIvMzDA6zWoYY1kx6yHiHCoamf3KzCuzCW76v5U8xB3OvR7xGPWotpdb ylG8ebXOjz3EEc6WgmCrft+QCgWCG7tRh8AUa2RwA7eJb++iR3gS3DHSQb5ENdygmZOy eNle47BNpyhEbSYC/DJJtsmzkiell3DX+91j/iKTvVD8S0Y8fOSp0eHLHGqi0YvzMofy /LPA== 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 p20si572631otk.73.2020.01.07.13.27.14; Tue, 07 Jan 2020 13:27:27 -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 S1728666AbgAGVZF (ORCPT + 99 others); Tue, 7 Jan 2020 16:25:05 -0500 Received: from ale.deltatee.com ([207.54.116.67]:51280 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727257AbgAGVAQ (ORCPT ); Tue, 7 Jan 2020 16:00:16 -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 1iovxO-0007vy-Fh; Tue, 07 Jan 2020 14:00:09 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1iovxJ-0001zP-94; Tue, 07 Jan 2020 14:00:01 -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: Tue, 7 Jan 2020 13:59:59 -0700 Message-Id: <20200107205959.7575-9-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200107205959.7575-1-logang@deltatee.com> References: <20200107205959.7575-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 autolearn=ham autolearn_force=no version=3.4.2 Subject: [PATCH v2 8/8] 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 45ab4ef0643d..d36ff688b768 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -187,7 +187,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: + modifiers.pgprot = pgprot_writecombine(modifiers.pgprot); need_devmap_managed = false; break; default: -- 2.20.1