From patchwork Sat Sep 19 06:49:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Baker X-Patchwork-Id: 53951 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id B179322A0D for ; Sat, 19 Sep 2015 06:49:17 +0000 (UTC) Received: by wicmn1 with SMTP id mn1sf15922383wic.1 for ; Fri, 18 Sep 2015 23:49:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=/A5FScK4pEWdf6lcpxzvwXNlApAKg1iODVXB6BhtQxo=; b=iS4d+e8kfMWu1d4iFYV7okq9Qykl9CXd/NFyx1xfhbHM82pp0IClsFczViscjMIvuw yjh4kJ3vYUhxRD5zvEacdadZSbWi+JKoBKTHWl3PaJa5hVhYePloV2rYhD/lkubYVIiI cF+g4+rqB8fU4AcYCnIbZm0TaCqu/QRfboP74nIc4d7ZuJy7IDp/1CN44rMgne5aDfb3 XbEtf9elgvu8WA2fuohmG6vvjapSzHA7ObC7N+zyf1NHjetO24X27Tvh8zxi6rAwvALE XtUJKTp2diTuDdhTeTA3dciENmLHHDF9J2zGxrEehu8tztGD1h0hJjQM1IHKGi9IoqBA vuvg== X-Gm-Message-State: ALoCoQmWiW1QrgZwFmMg2+5+uljhh1EubKndz0nvjWBnKEBbGyvXP5xHnSILlGNr3WhKjKecoFEN X-Received: by 10.112.202.165 with SMTP id kj5mr1539196lbc.5.1442645357023; Fri, 18 Sep 2015 23:49:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.201 with SMTP id je9ls319812lac.5.gmail; Fri, 18 Sep 2015 23:49:16 -0700 (PDT) X-Received: by 10.112.132.1 with SMTP id oq1mr4509548lbb.108.1442645356716; Fri, 18 Sep 2015 23:49:16 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id lj3si8892084lab.155.2015.09.18.23.49.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 23:49:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lahg1 with SMTP id g1so42320189lah.1 for ; Fri, 18 Sep 2015 23:49:16 -0700 (PDT) X-Received: by 10.152.5.133 with SMTP id s5mr4483800las.19.1442645356555; Fri, 18 Sep 2015 23:49:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp676193lbq; Fri, 18 Sep 2015 23:49:15 -0700 (PDT) X-Received: by 10.66.124.198 with SMTP id mk6mr11509712pab.114.1442645355260; Fri, 18 Sep 2015 23:49:15 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si19755663pas.197.2015.09.18.23.49.14; Fri, 18 Sep 2015 23:49:15 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753953AbbISGtM (ORCPT + 30 others); Sat, 19 Sep 2015 02:49:12 -0400 Received: from mail-qg0-f50.google.com ([209.85.192.50]:34467 "EHLO mail-qg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751218AbbISGtL (ORCPT ); Sat, 19 Sep 2015 02:49:11 -0400 Received: by qgez77 with SMTP id z77so55719715qge.1 for ; Fri, 18 Sep 2015 23:49:10 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.99.49 with SMTP id p46mr10613706qge.76.1442645349865; Fri, 18 Sep 2015 23:49:09 -0700 (PDT) Received: by 10.55.3.21 with HTTP; Fri, 18 Sep 2015 23:49:09 -0700 (PDT) In-Reply-To: References: <20150826010220.8851.18077.stgit@dwillia2-desk3.amr.corp.intel.com> <20150826012735.8851.49787.stgit@dwillia2-desk3.amr.corp.intel.com> Date: Fri, 18 Sep 2015 23:49:09 -0700 Message-ID: Subject: Re: [PATCH v2 2/9] mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h From: Tyler Baker To: Dan Williams Cc: "linux-nvdimm@lists.01.org" , Boaz Harrosh , david , "linux-kernel@vger.kernel.org" , Christoph Hellwig , Linux MM , "H. Peter Anvin" , Ross Zwisler , Ingo Molnar , "Kevin's boot bot" Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tyler.baker@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 18 September 2015 at 16:59, Dan Williams wrote: > On Fri, Sep 18, 2015 at 4:42 PM, Tyler Baker wrote: >> Hi, >> >> On 25 August 2015 at 18:27, Dan Williams wrote: >>> From: Christoph Hellwig >>> >>> Three architectures already define these, and we'll need them genericly >>> soon. >>> >>> Signed-off-by: Christoph Hellwig >>> Signed-off-by: Dan Williams >>> --- >>> arch/arm/include/asm/memory.h | 6 ------ >>> arch/arm64/include/asm/memory.h | 6 ------ >>> arch/unicore32/include/asm/memory.h | 6 ------ >>> include/asm-generic/memory_model.h | 6 ++++++ >>> 4 files changed, 6 insertions(+), 18 deletions(-) >>> >>> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h >>> index b7f6fb462ea0..98d58bb04ac5 100644 >>> --- a/arch/arm/include/asm/memory.h >>> +++ b/arch/arm/include/asm/memory.h >>> @@ -119,12 +119,6 @@ >>> #endif >>> >>> /* >>> - * Convert a physical address to a Page Frame Number and back >>> - */ >>> -#define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT)) >>> -#define __pfn_to_phys(pfn) ((phys_addr_t)(pfn) << PAGE_SHIFT) >>> - >>> -/* >>> * Convert a page to/from a physical address >>> */ >>> #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) >>> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h >>> index f800d45ea226..d808bb688751 100644 >>> --- a/arch/arm64/include/asm/memory.h >>> +++ b/arch/arm64/include/asm/memory.h >>> @@ -81,12 +81,6 @@ >>> #define __phys_to_virt(x) ((unsigned long)((x) - PHYS_OFFSET + PAGE_OFFSET)) >>> >>> /* >>> - * Convert a physical address to a Page Frame Number and back >>> - */ >>> -#define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT)) >>> -#define __pfn_to_phys(pfn) ((phys_addr_t)(pfn) << PAGE_SHIFT) >>> - >>> -/* >>> * Convert a page to/from a physical address >>> */ >>> #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) >>> diff --git a/arch/unicore32/include/asm/memory.h b/arch/unicore32/include/asm/memory.h >>> index debafc40200a..3bb0a29fd2d7 100644 >>> --- a/arch/unicore32/include/asm/memory.h >>> +++ b/arch/unicore32/include/asm/memory.h >>> @@ -61,12 +61,6 @@ >>> #endif >>> >>> /* >>> - * Convert a physical address to a Page Frame Number and back >>> - */ >>> -#define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) >>> -#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) >>> - >>> -/* >>> * Convert a page to/from a physical address >>> */ >>> #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) >>> diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h >>> index 14909b0b9cae..f20f407ce45d 100644 >>> --- a/include/asm-generic/memory_model.h >>> +++ b/include/asm-generic/memory_model.h >>> @@ -69,6 +69,12 @@ >>> }) >>> #endif /* CONFIG_FLATMEM/DISCONTIGMEM/SPARSEMEM */ >>> >>> +/* >>> + * Convert a physical address to a Page Frame Number and back >>> + */ >>> +#define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT)) >>> +#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) >> >> The kernelci.org bot has been reporting complete boot failures[1] on >> ARM platforms with more than 4GB of memory and LPAE enabled. I've >> bisected[2] the failures down to this commit, and reverting it on top >> of the latest mainline resolves the boot issue. I took a closer look >> at this patch and noticed the cast to phys_addr_t was dropped in the >> generic function. Adding this to the new generic function solves the >> boot issue I'm reporting. >> >> diff --git a/include/asm-generic/memory_model.h >> b/include/asm-generic/memory_model.h >> index f20f407..db9f5c7 100644 >> --- a/include/asm-generic/memory_model.h >> +++ b/include/asm-generic/memory_model.h >> @@ -73,7 +73,7 @@ >> * Convert a physical address to a Page Frame Number and back >> */ >> #define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT)) >> -#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) >> +#define __pfn_to_phys(pfn) ((phys_addr_t)(pfn) << PAGE_SHIFT) >> >> #define page_to_pfn __page_to_pfn >> #define pfn_to_page __pfn_to_page >> >> If this fix is valid, I can send a formal patch or it can be squashed >> into the original commit. > > This fix is valid, but I wonder if it should just use the existing > PFN_PHYS() definition in include/linux/pfn.h? Good suggestion, seems like the rational thing to do. FWIW, I gave the patch below a spin through the kernelci.org build/boot ci loop[1]. All went well, no new regressions were detected. From: Tyler Baker Date: Fri, 18 Sep 2015 17:56:26 -0700 Subject: [PATCH] mm: fix type cast in __pfn_to_phys() The various definitions of __pfn_to_phys() have been consolidated to use a generic macro in include/asm-generic/memory_model.h. This hit mainline in the form of 012dcef3f058 "mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h". When the generic macro was implemented the type cast to phys_addr_t was dropped which caused boot regressions on ARM platforms with more than 4GB of memory and LPAE enabled. It was suggested to use PFN_PHYS() defined in include/linux/pfn.h as provides the correct logic and avoids further duplication. Reported-by: kernelci.org bot Suggested-by: Dan Williams Signed-off-by: Tyler Baker --- include/asm-generic/memory_model.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/memory_model.h b/include/asm-generic/memory_model.h index f20f407..4b4b056 100644 --- a/include/asm-generic/memory_model.h +++ b/include/asm-generic/memory_model.h @@ -73,7 +73,7 @@ * Convert a physical address to a Page Frame Number and back */ #define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT)) -#define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) +#define __pfn_to_phys(pfn) PFN_PHYS(pfn) #define page_to_pfn __page_to_pfn #define pfn_to_page __pfn_to_page