From patchwork Wed Oct 11 05:08:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 115494 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp339359qgn; Tue, 10 Oct 2017 22:10:02 -0700 (PDT) X-Received: by 10.101.65.11 with SMTP id w11mr6948565pgp.207.1507698602220; Tue, 10 Oct 2017 22:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507698602; cv=none; d=google.com; s=arc-20160816; b=BDdJfzgB+leZdQxK3+SgHR5cDR0xmKddLKNOyn8CSXlHW0znBduit5VcCk3B9sb5Ui IRWazJAixokpLC5fwXNHkg7YdXXBdXWtKhasMIzkrh+PD2SHbssKXUnL0AzOMJCQJgQ/ N3pfUmJM7Ze8pC6Bna7dontkvDJaypkEAubVFK/UKid18ba9ygvwSTgUE39HJUFNRuin lwVC9QTbTByBRYMoALdxYgRIaJHiUoruAmhd/RcXPz/mAlE72EJeekump6LdYjP05/iT IxhrOH+/++A1yQqrA901JrDef1O28kmbx2lDsyJCcFOGa/5Kofq3e63j/WftSq5bdNs2 Mg9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3HkPyj2Sf2NndRDkteoEYLrqkOYFD28lTS5yEyGB6qU=; b=JAaNOw1qbzdDLdIRUnwsBs/lK1QXBXHFqRqS4G07mVa2VMi+lswuGTZqfyJ3VXtD0q Q6DgMjPy/ijRtHMD9se+d/Sm/EUywTgvP5GFgsTMbSznc8lZfIrumdAllp7vUa9NFYok BKkKrYCNbZr4ID8U+WjCUUluSFiws4wQbedbsP/4805i+g2sQDmJDG0lkGsqCiUS6IyX bBV/HiVd18YVsaeEMA8bVkT16+LcvHEWb9BIqGn5Q5hgemSAO6fXFIeOjtZM6DZFoe5Z 36CfaHrX09Ygbk5Chx/gA5Y6ixkwEvxCUA5sjOxzbhbNMSbIY9ZD5Dxz5dHvnNPZ+cpO P9xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AKjVAU9V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8si497184plo.439.2017.10.10.22.10.01; Tue, 10 Oct 2017 22:10:02 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AKjVAU9V; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757204AbdJKFKA (ORCPT + 26 others); Wed, 11 Oct 2017 01:10:00 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:56780 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932286AbdJKFJG (ORCPT ); Wed, 11 Oct 2017 01:09:06 -0400 Received: by mail-pf0-f170.google.com with SMTP id b85so528531pfj.13 for ; Tue, 10 Oct 2017 22:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3HkPyj2Sf2NndRDkteoEYLrqkOYFD28lTS5yEyGB6qU=; b=AKjVAU9VYZe0EToTCDcZoBLdKV+SpBkWwoxz6/Eb8+WEvBFbLMgWSdEI51etUmEeFT Jyk7OAI0E55HqzMpSiHxquJxipWHnX1k2fm/0h4uw3I40ihTAwcB2mIchGqSNnk66JvC q3+peEuj6O9bcpu2ioXKxgkVu85etN94yDw9Q= 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; bh=3HkPyj2Sf2NndRDkteoEYLrqkOYFD28lTS5yEyGB6qU=; b=CIlDQ0qEgHpP90uUeNGWd6r2wl1Tw2BsqTGTfdMgfXWaCJuvRjaOtefu/0ZDlfhqdQ S0bOjLBSS/6EPoepVjXt27nXTUcBwGKY9uOvq0HOpDHLiqrghNUWveoI4A40uKB8rCyo RsVkw2IZAsuHpovmXDoQDNCwVmech26U5S9w7v2SuEBF8tdG0tCAdzNdaPj4BJqw/Chs PAA0nObb4y8EVMSRCPZsf3wQqL0dvxytYnIqXonLsa/DW8Xhibz5GvSluSafYyf1OAGi 1WfDGvTYfYM8CDUAMRxGGzqxJxMzu/bSAQPYWrGOtjVomwlGE30xU5vv9frjPJge9ghB IFBg== X-Gm-Message-State: AMCzsaWOhjO7ZPG3a/a4LH/n+OHlMl8NN0ayYO3MdP3X/b/OjrkcY8DV NCTqRh+WqkSJzYyRMNOHCgGc7A== X-Google-Smtp-Source: AOwi7QA1HzRW6MqU1GZHSOz4f6hvgMolWmTP82YhMGPGC3hJbBfAeI3Uexnx9y9LoybaKdzuVNRqlQ== X-Received: by 10.84.235.129 with SMTP id p1mr13979037plk.153.1507698545288; Tue, 10 Oct 2017 22:09:05 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id n29sm28336361pgd.74.2017.10.10.22.09.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 22:09:04 -0700 (PDT) From: Bjorn Andersson To: Andy Gross , Frank Rowand , Rob Herring Cc: Anton Vorontsov , Colin Cross , David Brown , Kees Cook , Tony Luck , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-soc@vger.kernel.org Subject: [PATCH v4 2/5] of: reserved_mem: Accessor for acquiring reserved_mem Date: Tue, 10 Oct 2017 22:08:54 -0700 Message-Id: <20171011050857.7588-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171011050857.7588-1-bjorn.andersson@linaro.org> References: <20171011050857.7588-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some cases drivers referencing a reserved-memory region might want to remap the entire region, but when defining the reserved-memory by "size" the client driver has no means to know the associated base address of the reserved memory region. This patch adds an accessor for such drivers to acquire a handle to their associated reserved-memory for this purpose. A complicating factor for the implementation is that the reserved_mem objects are created from the flattened DeviceTree, as such we can't use the device_node address for comparison. Fortunately the name of the node will be used as "name" of the reserved_mem and will be used when building the full_name, so we can compare the "name" with the basename of the full_name to find the match. Reviewed-by: Rob Herring Signed-off-by: Bjorn Andersson --- Changes since v3: - Renamed function from _get() to _lookup() - Picked up Rob's R-b Changes since v2: - None Changes since v1: - Previous patch provided interface to resolve memory-region reference, instead of direct lookup by device_node drivers/of/of_reserved_mem.c | 26 ++++++++++++++++++++++++++ include/linux/of_reserved_mem.h | 5 +++++ 2 files changed, 31 insertions(+) -- 2.12.0 diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index d507c3569a88..b108c7a1f74c 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -397,3 +397,29 @@ void of_reserved_mem_device_release(struct device *dev) rmem->ops->device_release(rmem, dev); } EXPORT_SYMBOL_GPL(of_reserved_mem_device_release); + +/** + * of_reserved_mem_lookup() - acquire reserved_mem from a device node + * @np: node pointer of the desired reserved-memory region + * + * This function allows drivers to acquire a reference to the reserved_mem + * struct based on a device node handle. + * + * Returns a reserved_mem reference, or NULL on error. + */ +struct reserved_mem *of_reserved_mem_lookup(struct device_node *np) +{ + const char *name; + int i; + + if (!np->full_name) + return NULL; + + name = kbasename(np->full_name); + for (i = 0; i < reserved_mem_count; i++) + if (!strcmp(reserved_mem[i].name, name)) + return &reserved_mem[i]; + + return NULL; +} +EXPORT_SYMBOL_GPL(of_reserved_mem_lookup); diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index f8e1992d6423..c58f780104f9 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h @@ -44,6 +44,7 @@ int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, void fdt_init_reserved_mem(void); void fdt_reserved_mem_save_node(unsigned long node, const char *uname, phys_addr_t base, phys_addr_t size); +struct reserved_mem *of_reserved_mem_lookup(struct device_node *np); #else static inline int of_reserved_mem_device_init_by_idx(struct device *dev, struct device_node *np, int idx) @@ -55,6 +56,10 @@ static inline void of_reserved_mem_device_release(struct device *pdev) { } static inline void fdt_init_reserved_mem(void) { } static inline void fdt_reserved_mem_save_node(unsigned long node, const char *uname, phys_addr_t base, phys_addr_t size) { } +static inline struct reserved_mem *of_reserved_mem_lookup(struct device_node *np) +{ + return NULL; +} #endif /** From patchwork Wed Oct 11 05:08:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 115492 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp338840qgn; Tue, 10 Oct 2017 22:09:16 -0700 (PDT) X-Received: by 10.99.132.198 with SMTP id k189mr14586440pgd.25.1507698556676; Tue, 10 Oct 2017 22:09:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507698556; cv=none; d=google.com; s=arc-20160816; b=Og6jsVxIqWlFDHOZO78JTf9cj1G+hrC1M2aKMn+rrje5MwUtKiMpMkeqDKySF6ohZg grskDC7Zmk/WX3KAgc+3hoWAaOGjFv1ytxoLkdWGj25mfpu6wl+XdQ1HnpowcYRYAQf0 z0G1bOZsURy6aoSFpQgs50KR95sC505ZPje0+V/84lSKyE/Ia1YJyU/ysUo1Bc1Atdvs w6EPHV4Pc0k2/B1fjPyVCpfgwFj8qBQ1gRcOefnZnYYz92USPXSFIThtkG0EE+8kYyBQ lr/L5vVEA0rDtumrf2XBCz4pUIexS3mzTu+lrI07KB+n5hEbTQaWAesT4ttZCRsyjwnz MZPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=0Jlqb9y6+kJzMWt7nfCr8lCfDPwqsQ1aSqmhAIlqXb4=; b=f0rgIj1dawFXW+92O61OsYXEotVMDfZLg+zC+iV7ZRWfxGqXq0a1MthNoHE2UTpkt0 coeNaa53J8cDmAX6XGiWfargr969AF5sW4VEpFIfOKx5t40DmDeqK647S8PytaBESFRz l7xIG2aXRNE5RQARYNFOuMSiZg1gxB9L9bnPVWmORp4NNpPv4BnChZR6lUAZRHSiBp4t rjtrp+XWASrWCkL9fL6QY3TffW3EmAzFNKKi6lYKydRN/S3l34UDwYi0JiTMRdxyWigU 4r2oHx4fQBwyrEBAFrTnk1AfMVQ9hlEJuEgCn4HBpvDi2b3lu7buhaf4LurctG8VvnM8 6FiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SJrHzEEA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si9772616pln.353.2017.10.10.22.09.16; Tue, 10 Oct 2017 22:09:16 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SJrHzEEA; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757028AbdJKFJO (ORCPT + 26 others); Wed, 11 Oct 2017 01:09:14 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:54583 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932580AbdJKFJH (ORCPT ); Wed, 11 Oct 2017 01:09:07 -0400 Received: by mail-pf0-f171.google.com with SMTP id m28so534577pfi.11 for ; Tue, 10 Oct 2017 22:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Jlqb9y6+kJzMWt7nfCr8lCfDPwqsQ1aSqmhAIlqXb4=; b=SJrHzEEAmUaLH275ZSyeCaayNRULeRN+JhCeTBgt1nZDtrVisRhxYdmKou3O91X5Hk GnRIdObchQ2trSuuBCwOpzWSTvKZzADix5t2m9Y8EOuyQbEECG86UkJFuyV6+9MzgbCE s6GEzJccjUnArDdRDZ64eMGRzz3+sbFOMMfgQ= 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; bh=0Jlqb9y6+kJzMWt7nfCr8lCfDPwqsQ1aSqmhAIlqXb4=; b=VDcj0I2pKvJn5yxgxZjB1qWU5ujwdLr1u91oM8HpjEMQb6QQyjQkVKm8emqSrAd3x2 5xE3+SCcrc30YhykalC5nVg0fXJEh2bW9CkcPtiQXPlwy5vNHOoOHFRM4W3P7JbiAgzI AMy9ghYdOuILnR8FOJZZF332JIRewhPp5B9PGfsgrVc1ikyOae/OHQkExRuSitBt+zSd 1+CSRzgmquNiUDt79sQL4jehrG714mlUe9xq6MbxPWoTqwQN1PaHNj0XSsUREYgwmjKL E4Sohz1DI1rg390x4xF8afY7YdYqVTzeWFpF2U1CS7fV131CP6/FSOsIrr+MiMNl8I9R 5Z6g== X-Gm-Message-State: AMCzsaUbxVUaCD9J9r6z8B61d92LBcWpffGpiezosHzj5kbbnZapXcWy BumpsI4swX/Lw41Ca9UznFxf3A== X-Google-Smtp-Source: AOwi7QADrZiqVOayJMTwltGJYD8IXDPtm0vSqR6j8gwfGS0hThs9dFjsjJbilmmGPOAQL5TDzdH9oQ== X-Received: by 10.99.178.15 with SMTP id x15mr8668282pge.243.1507698546802; Tue, 10 Oct 2017 22:09:06 -0700 (PDT) Received: from localhost.localdomain (ip68-111-217-79.sd.sd.cox.net. [68.111.217.79]) by smtp.gmail.com with ESMTPSA id n29sm28336361pgd.74.2017.10.10.22.09.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 22:09:06 -0700 (PDT) From: Bjorn Andersson To: Andy Gross Cc: Anton Vorontsov , Colin Cross , David Brown , Frank Rowand , Kees Cook , Rob Herring , Tony Luck , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-soc@vger.kernel.org Subject: [PATCH v4 3/5] dt-binding: soc: qcom: Add binding for rmtfs memory Date: Tue, 10 Oct 2017 22:08:55 -0700 Message-Id: <20171011050857.7588-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20171011050857.7588-1-bjorn.andersson@linaro.org> References: <20171011050857.7588-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds the binding for describing shared memory used to exchange file system blocks between the RMTFS client and service. A client for this is generally found in the modem firmware and is used for accessing persistent storage for things such as radio calibration. Acked-by: Rob Herring Signed-off-by: Bjorn Andersson --- Changes since v3: - None Changes since v2: - Renamed compatible to "rmtfs-mem" in attempt to clarify that this is not a file system, but some chunk of memory. Changed since v1: - Memory described in a single reserved-memory node, rather than by reference from a "dummy" node - qcom,vmdid added .../bindings/reserved-memory/qcom,rmtfs-mem.txt | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt -- 2.12.0 diff --git a/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt new file mode 100644 index 000000000000..8562ba1dce69 --- /dev/null +++ b/Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.txt @@ -0,0 +1,51 @@ +Qualcomm Remote File System Memory binding + +This binding describes the Qualcomm remote filesystem memory, which serves the +purpose of describing the shared memory region used for remote processors to +access block device data using the Remote Filesystem protocol. + +- compatible: + Usage: required + Value type: + Definition: must be: + "qcom,rmtfs-mem" + +- reg: + Usage: required for static allocation + Value type: + Definition: must specify base address and size of the memory region, + as described in reserved-memory.txt + +- size: + Usage: required for dynamic allocation + Value type: + Definition: must specify a size of the memory region, as described in + reserved-memory.txt + +- qcom,client-id: + Usage: required + Value type: + Definition: identifier of the client to use this region for buffers. + +- qcom,vmid: + Usage: optional + Value type: + Definition: vmid of the remote processor, to set up memory protection. + += EXAMPLE +The following example shows the remote filesystem memory setup for APQ8016, +with the rmtfs region for the Hexagon DSP (id #1) located at 0x86700000. + + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + rmtfs@86700000 { + compatible = "qcom,rmtfs-mem"; + reg = <0x0 0x86700000 0x0 0xe0000>; + no-map; + + qcom,client-id = <1>; + }; + };