From patchwork Tue May 14 20:40:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 1099705 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RnM/VQ6m"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 453V2p038Zz9sPD for ; Wed, 15 May 2019 06:41:22 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbfENUlU (ORCPT ); Tue, 14 May 2019 16:41:20 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:40544 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726338AbfENUk4 (ORCPT ); Tue, 14 May 2019 16:40:56 -0400 Received: by mail-pg1-f195.google.com with SMTP id d31so142696pgl.7 for ; Tue, 14 May 2019 13:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TNtuY5Z+cYvoyqselos2LWUUlqGVhq3oEuLlC6NFZj4=; b=RnM/VQ6mE0T6Xe8fFsgAvxrMJCHhOpkmsjc03a2XttI/CGU4if1QQOm7wM771FpRhO 0XooNeg9dFS5j+n21e4CEPdUNxw/VK/0lFAwv6bG1z2ez2tVm1+QMK640BiCq4PbsinQ vj4kU2bBm7sydIOtsDcnzq3V25Kt/Ep4RXiTA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TNtuY5Z+cYvoyqselos2LWUUlqGVhq3oEuLlC6NFZj4=; b=Ucewaly9Lud5Tn6LWNCKYVQ8myIcF/8/7CtB+whhRlPqJ8rPEjKWtB7zfUub6fpy87 DmHz3BNbxsKRCkUqe+xj3Dyfq+W8qIm/vCqshCFdQq+2Bwp2FLC0yuyw+BeTFq4ftoaT EMxaAJBoXR9SQFdLho6Xv66JIC79y6kebZtblyy1UOVte4yEUBB86TooLFChbmKwFw8+ AL30Y5GTNCOjwvvJsVUv3CbsPGL9ENTdJQXyEo+LUecuJZdJA3P8DxYAxtjbin/z9WHw /5RqeVOfKV57sPUkP1RCalyiu/LysuVxIEOeDr3nAp7mnxPmyRcn/1W4tiXs8u5MJkEt Hysw== X-Gm-Message-State: APjAAAXfGw1/KH+6pDtv7exg6WI7z5wyM4CYa+I0eKIrlIgSpZrnPfOi VKiVryIL3F8vo5kLbUfRp/IhTA== X-Google-Smtp-Source: APXvYqz9c4Fas9ZYbM03192T2GnA0wnnUJXeGMcnMrr0nbuGVkx1q0hKUyWdEvtj5DHHEeXpQZ4s4g== X-Received: by 2002:a63:314a:: with SMTP id x71mr40085284pgx.385.1557866455694; Tue, 14 May 2019 13:40:55 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id p2sm2137pfi.73.2019.05.14.13.40.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 13:40:55 -0700 (PDT) From: Stephen Boyd To: Rob Herring , Frank Rowand Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Hsin-Yi Wang Subject: [PATCH v2 1/3] dt-bindings: Remove Linuxisms from common-properties binding Date: Tue, 14 May 2019 13:40:51 -0700 Message-Id: <20190514204053.124122-2-swboyd@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190514204053.124122-1-swboyd@chromium.org> References: <20190514204053.124122-1-swboyd@chromium.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org We shouldn't reference Linux kernel functions or Linux itself in proper bindings. It's OK to reference functions in the kernel when explaining examples, but otherwise we shouldn't reference functions to describe what the binding means. Cc: Hsin-Yi Wang Signed-off-by: Stephen Boyd --- .../devicetree/bindings/common-properties.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/common-properties.txt b/Documentation/devicetree/bindings/common-properties.txt index a3448bfa1c82..98a28130e100 100644 --- a/Documentation/devicetree/bindings/common-properties.txt +++ b/Documentation/devicetree/bindings/common-properties.txt @@ -5,30 +5,29 @@ Endianness ---------- The Devicetree Specification does not define any properties related to hardware -byteswapping, but endianness issues show up frequently in porting Linux to +byte swapping, but endianness issues show up frequently in porting drivers to different machine types. This document attempts to provide a consistent -way of handling byteswapping across drivers. +way of handling byte swapping across drivers. Optional properties: - big-endian: Boolean; force big endian register accesses unconditionally (e.g. ioread32be/iowrite32be). Use this if you - know the peripheral always needs to be accessed in BE mode. + know the peripheral always needs to be accessed in big endian (BE) mode. - little-endian: Boolean; force little endian register accesses unconditionally (e.g. readl/writel). Use this if you know the - peripheral always needs to be accessed in LE mode. + peripheral always needs to be accessed in little endian (LE) mode. - native-endian: Boolean; always use register accesses matched to the endianness of the kernel binary (e.g. LE vmlinux -> readl/writel, - BE vmlinux -> ioread32be/iowrite32be). In this case no byteswaps + BE vmlinux -> ioread32be/iowrite32be). In this case no byte swaps will ever be performed. Use this if the hardware "self-adjusts" register endianness based on the CPU's configured endianness. If a binding supports these properties, then the binding should also specify the default behavior if none of these properties are present. In such cases, little-endian is the preferred default, but it is not -a requirement. The of_device_is_big_endian() and of_fdt_is_big_endian() -helper functions do assume that little-endian is the default, because -most existing (PCI-based) drivers implicitly default to LE by using -readl/writel for MMIO accesses. +a requirement. Some implementations assume that little-endian is +the default, because most existing (PCI-based) drivers implicitly +default to LE for their MMIO accesses. Examples: Scenario 1 : CPU in LE mode & device in LE mode. From patchwork Tue May 14 20:40:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 1099704 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YPL3r83l"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 453V2m6whxz9sP8 for ; Wed, 15 May 2019 06:41:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbfENUlO (ORCPT ); Tue, 14 May 2019 16:41:14 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41190 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbfENUk5 (ORCPT ); Tue, 14 May 2019 16:40:57 -0400 Received: by mail-pf1-f193.google.com with SMTP id q17so102323pfq.8 for ; Tue, 14 May 2019 13:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n9za352hE3ZueleWfuyo9coMAwkfOt9GXkoYlh/EHlI=; b=YPL3r83lJDb9POCxfAD0R3L1iJgVZzCq8cQDPGYrM+xL4wiqdO6E0a+NZlWi+nmaZj uEkbnErpKUymJYufx3GoEdqcv66yhyjorgmlLhT0C3h7Qky9Z5Srivu0odXj37LnROig XD776Jy1V+YNOfYUsQ2gkVFPZZPDcVVDgwmLU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n9za352hE3ZueleWfuyo9coMAwkfOt9GXkoYlh/EHlI=; b=k/hobyuq7IJNXCO0ZENbOSEGSAuBHskZMtzngT6r0fJ7itMh9mTrQqHFfMnOkQlD6W qAWgbwz8KtGZtOZMW5XrqtsFL+sy+IxWd7Iyp37vzMYUf+FQDHVyULqv2j0XXKdgjeC9 nbEOg8t8xFdiH3bJXm0ryIHCgI94SSGrpR7Eu1JmWb7k3J9qeg99/2iQJTCb7AuPqm9v M9SeBU4iP9cbXnCn21cHufLGu56/i7lGv/IF7txHHtkWRdv/WzgrueevErjYIHDcXErU RFj0DCcHA+YAsHdzow+dSdXbfqyJ8MpngrpQNvzg+56jq+HmYvFbklL+w7RO37AS+wsg qDng== X-Gm-Message-State: APjAAAUlBhifJwDX8xArrgz1vkFaZkK+mw+XmhfE1RTqt8xTXfct5NpN XZR8RP9DHqdjcQ566cYj8sRC2g== X-Google-Smtp-Source: APXvYqyxCNQQitAxoK0bdUz/KVX/Lk/IeO2hikQeSb141VYl1QmP0Fo3zaFarsibbAsyIwBY2xE9hQ== X-Received: by 2002:a63:d949:: with SMTP id e9mr39677144pgj.437.1557866456510; Tue, 14 May 2019 13:40:56 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id p2sm2137pfi.73.2019.05.14.13.40.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 13:40:55 -0700 (PDT) From: Stephen Boyd To: Rob Herring , Frank Rowand Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Hsin-Yi Wang Subject: [PATCH v2 2/3] of/fdt: Remove dead code and mark functions with __init Date: Tue, 14 May 2019 13:40:52 -0700 Message-Id: <20190514204053.124122-3-swboyd@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190514204053.124122-1-swboyd@chromium.org> References: <20190514204053.124122-1-swboyd@chromium.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Some functions in here are never called, and others are only called during __init. Remove the dead code and some dead exports for functions that don't exist (I'm looking at you of_fdt_get_string!). Mark some functions with __init so we can throw them away after we boot up and poke at the FDT blob too. Cc: Hsin-Yi Wang Signed-off-by: Stephen Boyd --- drivers/of/fdt.c | 37 +++++-------------------------------- include/linux/of_fdt.h | 11 ----------- 2 files changed, 5 insertions(+), 43 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 4734223ab702..93414b89735f 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -38,7 +38,7 @@ * memory entries in the /memory node. This function may be called * any time after initial_boot_param is set. */ -void of_fdt_limit_memory(int limit) +void __init of_fdt_limit_memory(int limit) { int memory; int len; @@ -110,25 +110,6 @@ static int of_fdt_is_compatible(const void *blob, return 0; } -/** - * of_fdt_is_big_endian - Return true if given node needs BE MMIO accesses - * @blob: A device tree blob - * @node: node to test - * - * Returns true if the node has a "big-endian" property, or if the kernel - * was compiled for BE *and* the node has a "native-endian" property. - * Returns false otherwise. - */ -bool of_fdt_is_big_endian(const void *blob, unsigned long node) -{ - if (fdt_getprop(blob, node, "big-endian", NULL)) - return true; - if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && - fdt_getprop(blob, node, "native-endian", NULL)) - return true; - return false; -} - static bool of_fdt_device_is_available(const void *blob, unsigned long node) { const char *status = fdt_getprop(blob, node, "status", NULL); @@ -145,8 +126,8 @@ static bool of_fdt_device_is_available(const void *blob, unsigned long node) /** * of_fdt_match - Return true if node matches a list of compatible values */ -int of_fdt_match(const void *blob, unsigned long node, - const char *const *compat) +static int __init of_fdt_match(const void *blob, unsigned long node, + const char *const *compat) { unsigned int tmp, score = 0; @@ -758,7 +739,7 @@ int __init of_scan_flat_dt_subnodes(unsigned long parent, * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none */ -int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname) +int __init of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname) { return fdt_subnode_offset(initial_boot_params, node, uname); } @@ -771,14 +752,6 @@ unsigned long __init of_get_flat_dt_root(void) return 0; } -/** - * of_get_flat_dt_size - Return the total size of the FDT - */ -int __init of_get_flat_dt_size(void) -{ - return fdt_totalsize(initial_boot_params); -} - /** * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr * @@ -804,7 +777,7 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat) /** * of_flat_dt_match - Return true if node matches a list of compatible values */ -int __init of_flat_dt_match(unsigned long node, const char *const *compat) +static int __init of_flat_dt_match(unsigned long node, const char *const *compat) { return of_fdt_match(initial_boot_params, node, compat); } diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index a713e5d156d8..acf820e88952 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -23,15 +23,6 @@ struct device_node; /* For scanning an arbitrary device-tree at any time */ -extern char *of_fdt_get_string(const void *blob, u32 offset); -extern void *of_fdt_get_property(const void *blob, - unsigned long node, - const char *name, - int *size); -extern bool of_fdt_is_big_endian(const void *blob, - unsigned long node); -extern int of_fdt_match(const void *blob, unsigned long node, - const char *const *compat); extern void *of_fdt_unflatten_tree(const unsigned long *blob, struct device_node *dad, struct device_node **mynodes); @@ -64,9 +55,7 @@ extern int of_get_flat_dt_subnode_by_name(unsigned long node, extern const void *of_get_flat_dt_prop(unsigned long node, const char *name, int *size); extern int of_flat_dt_is_compatible(unsigned long node, const char *name); -extern int of_flat_dt_match(unsigned long node, const char *const *matches); extern unsigned long of_get_flat_dt_root(void); -extern int of_get_flat_dt_size(void); extern uint32_t of_get_flat_dt_phandle(unsigned long node); extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, From patchwork Tue May 14 20:40:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 1099703 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=devicetree-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="aoywBB6x"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 453V2g0lMHz9sP8 for ; Wed, 15 May 2019 06:41:15 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbfENUk7 (ORCPT ); Tue, 14 May 2019 16:40:59 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42959 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbfENUk5 (ORCPT ); Tue, 14 May 2019 16:40:57 -0400 Received: by mail-pf1-f193.google.com with SMTP id 13so100040pfw.9 for ; Tue, 14 May 2019 13:40:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZOSFwWR6X/LU0mbE+B8y1nxNZ62szs9hXxH/kMhQXpA=; b=aoywBB6xhd+TEBFb11h+NDf8gP2RwoXM/+RGmp2MQvrX60QVIW9ZQhwvi/GaaBIGlw 1nceIjiuGWGD/r7uWcZZeKIQEC4CtIbBD0N/NTiO75PwRgQjtX5bg08om2TWjLdA72ze Wz2mH1m3xdWEN1Lbe3bPVQnp9zQXOgDS2B0wU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZOSFwWR6X/LU0mbE+B8y1nxNZ62szs9hXxH/kMhQXpA=; b=Cfyjhb2XbLtmiGKWQX6R6NCW+/RlpcS/qIl7Hass+RLRnD7JxdyDYtAFP7sGIZqqhy ZCgV9YsJ0oVjxouzz95xxlE719XgeQz8i0iYH4zZC/p83MDDCR4PM+MDZMh32xe6vkiT eWYjcf2Phe7bpDYYsuwY2akyAMl3ZvZyoeAK5qV6twSu7Vvg9ivhVRl4d6kpiTgd0qJF bCyljQwcguhE8tguKxEQB93TRCVhyl6yD88QQ6pryKRe1iGjVG9fyOAEitf4aJSc/2eO FMxXYJhuoHoUAY6HfMCYz/XWDetFTt8Vg65HJTEcI02TSHqijo0XSWptSPkrKRN+be0T T0MA== X-Gm-Message-State: APjAAAVP65BG7Twx+C0U+SpCQYl59YFpSEHc0W+1P6OM/6bxTh0i7mQw hsDzNlAmtbWFLNtfo8Hp3Y76Dg== X-Google-Smtp-Source: APXvYqykohH7nNYtYXxpXQh6fvYURqf0hwvpGbFY1xMuuDEjZn5yie249qDHWz/KB5Zp3rAJCwnVfA== X-Received: by 2002:a62:2fc6:: with SMTP id v189mr5247034pfv.136.1557866457316; Tue, 14 May 2019 13:40:57 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id p2sm2137pfi.73.2019.05.14.13.40.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 13:40:56 -0700 (PDT) From: Stephen Boyd To: Rob Herring , Frank Rowand Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Hsin-Yi Wang Subject: [PATCH v2 3/3] of/fdt: Mark initial_boot_params as __ro_after_init Date: Tue, 14 May 2019 13:40:53 -0700 Message-Id: <20190514204053.124122-4-swboyd@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190514204053.124122-1-swboyd@chromium.org> References: <20190514204053.124122-1-swboyd@chromium.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The FDT pointer, i.e. initial_boot_params, shouldn't be changed after init. It's only set by boot code and then the only user of the FDT is the raw sysfs reading API. Mark this pointer with __ro_after_init so that the pointer can't be changed after init. Cc: Hsin-Yi Wang Signed-off-by: Stephen Boyd --- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 93414b89735f..f131a1b8588b 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -516,7 +516,7 @@ EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree); int __initdata dt_root_addr_cells; int __initdata dt_root_size_cells; -void *initial_boot_params; +void *initial_boot_params __ro_after_init; #ifdef CONFIG_OF_EARLY_FLATTREE