dt-bindings: soc: smem: Make indirection optional
v2 cover dt-bindings: soc: smem: Make indirection optional
In the modern Qualcomm platform there's no reason for having smem as a separate node, so let's change this.
Bjorn Andersson (4):
dt-bindings: sram: Document qcom,rpm-msg-ram
dt-bindings: soc: smem: Make indirection optional
soc: qcom: smem: Support reserved-memory description
arm64: dts: qcom: sdm845: Drop standalone smem node
.../bindings/soc/qcom/qcom,smem.yaml | 34 +++++++++-- .../devicetree/bindings/sram/sram.yaml | 5 +- arch/arm64/boot/dts/qcom/sdm845.dtsi | 10 +--- drivers/of/platform.c | 1 + drivers/soc/qcom/smem.c | 57 +++++++++++++------ 5 files changed, 77 insertions(+), 30 deletions(-)
Signature · 1 line
2.29.2
PATCH v2 1/4 dt-bindings: sram: Document qcom,rpm-msg-ram
The Qualcomm SMEM binding always depended on a reference to a SRAM node of compatible "qcom,rpm-msg-ram", document this as part of the SRAM binding.
The SRAM is consumed as a whole and not split up using subnodes, so properties related to this are not required.
---
Changes since v1:
- New patch, to resolve issue with the existing qcom,smem example
Documentation/devicetree/bindings/sram/sram.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/sram/sram.yaml +4 -1
@@ -31,6 +31,7 @@ properties: - amlogic,meson-gxbb-sram - arm,juno-sram-ns - atmel,sama5d2-securam + - qcom,rpm-msg-ram - rockchip,rk3288-pmu-sram reg:
@@ -135,7 +136,9 @@ if: properties: compatible: contains: - const: rockchip,rk3288-pmu-sram + enum: + - qcom,rpm-msg-ram + - rockchip,rk3288-pmu-sram else: required:
Signature · 1 line
2.29.2
Re: [PATCH v2 1/4] dt-bindings: sram: Document qcom,rpm-msg-ram
Quoted 7 lines · Bjorn Andersson
The Qualcomm SMEM binding always depended on a reference to a SRAM node of compatible "qcom,rpm-msg-ram", document this as part of the SRAM binding.
The SRAM is consumed as a whole and not split up using subnodes, so properties related to this are not required.
Quoted 9 lines
Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v1:
- New patch, to resolve issue with the existing qcom,smem exampleDocumentation/devicetree/bindings/sram/sram.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
PATCH v2 2/4 dt-bindings: soc: smem: Make indirection optional
In reply to Bjorn AnderssonIn the olden days the Qualcomm shared memory (SMEM) region consisted of multiple chunks of memory, so SMEM was described as a standalone node with references to its various memory regions.
But practically all modern Qualcomm platforms has a single reserved memory region used for SMEM. So rather than having to use two nodes to describe the one SMEM region, update the binding to allow the reserved-memory region alone to describe SMEM.
The olden format is preserved as valid, as this is widely used already.
---
Changes since v1:
- None
.../bindings/soc/qcom/qcom,smem.yaml | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/soc/qcom/qcom,smem.yaml +30 -4
@@ -10,14 +10,18 @@ maintainers: - Andy Gross <[email protected]> - Bjorn Andersson <[email protected]> -description: | - This binding describes the Qualcomm Shared Memory Manager, used to share data - between various subsystems and OSes in Qualcomm platforms. +description: + This binding describes the Qualcomm Shared Memory Manager, a region of + reserved-memory used to share data between various subsystems and OSes in + Qualcomm platforms. properties: compatible: const: qcom,smem + reg: + maxItems: 1 + memory-region: maxItems: 1 description: handle to memory reservation for main SMEM memory region.
@@ -29,11 +33,19 @@ properties: $ref: /schemas/types.yaml#/definitions/phandle description: handle to RPM message memory resource + no-map: true + required: - compatible - - memory-region - hwlocks +oneOf: + - required: + - reg + - no-map + - required: + - memory-region + additionalProperties: false examples:
@@ -43,6 +55,20 @@ examples: #size-cells = <1>; ranges; + smem@fa00000 { + compatible = "qcom,smem"; + reg = <0xfa00000 0x200000>; + no-map; + + hwlocks = <&tcsr_mutex 3>; + }; + }; + - | + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + smem_region: smem@fa00000 { reg = <0xfa00000 0x200000>; no-map;
Signature · 1 line
2.29.2
Quoted 11 lines · Bjorn Andersson
In the olden days the Qualcomm shared memory (SMEM) region consisted of multiple chunks of memory, so SMEM was described as a standalone node with references to its various memory regions.
But practically all modern Qualcomm platforms has a single reserved memory region used for SMEM. So rather than having to use two nodes to describe the one SMEM region, update the binding to allow the reserved-memory region alone to describe SMEM.
The olden format is preserved as valid, as this is widely used already.
Quoted 9 lines
Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v1:
- None.../bindings/soc/qcom/qcom,smem.yaml | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-)
PATCH v2 3/4 soc: qcom: smem: Support reserved-memory description
In reply to Bjorn AnderssonPractically all modern Qualcomm platforms has a single reserved-memory region for SMEM. So rather than having to describe SMEM in the form of a node with a reference to a reserved-memory node, allow the SMEM device to be instantiated directly from the reserved-memory node.
The current means of falling back to dereferencing the "memory-region" is kept as a fallback, if it's determined that the SMEM node is a reserved-memory node.
The "qcom,smem" compatible is added to the reserved_mem_matches list, to allow the reserved-memory device to be probed.
In order to retain the readability of the code, the resolution of resources is split from the actual ioremapping.
---
Changes since v1:
- None
drivers/of/platform.c | 1 + drivers/soc/qcom/smem.c | 57 ++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 18 deletions(-)
drivers/of/platform.c +1 -0
@@ -505,6 +505,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);static const struct of_device_id reserved_mem_matches[] = { { .compatible ="qcom,rmtfs-mem" }, { .compatible ="qcom,cmd-db" }, + { .compatible ="qcom,smem" }, { .compatible ="ramoops" }, { .compatible ="nvmem-rmem" }, {}
drivers/soc/qcom/smem.c +39 -18
116 lines not on this page · raw message
Signature · 1 line
2.29.2
Re: [PATCH v2 3/4] soc: qcom: smem: Support reserved-memory description
Hi Bjorn,
Quoted 110 lines · Bjorn Andersson
Practically all modern Qualcomm platforms has a single reserved-memory region for SMEM. So rather than having to describe SMEM in the form of a node with a reference to a reserved-memory node, allow the SMEM device to be instantiated directly from the reserved-memory node.
The current means of falling back to dereferencing the "memory-region" is kept as a fallback, if it's determined that the SMEM node is a reserved-memory node.
The "qcom,smem" compatible is added to the
reserved_mem_matcheslist, to allow the reserved-memory device to be probed.In order to retain the readability of the code, the resolution of resources is split from the actual ioremapping.
Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v1:
- Nonedrivers/of/platform.c | 1 + drivers/soc/qcom/smem.c | 57 ++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 18 deletions(-)drivers/of/platform.c +1
-0@@ -505,6 +505,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);static const struct of_device_id reserved_mem_matches[] = { { .compatible ="qcom,rmtfs-mem" }, { .compatible ="qcom,cmd-db" }, + { .compatible ="qcom,smem" }, { .compatible ="ramoops" }, { .compatible ="nvmem-rmem" }, {}drivers/soc/qcom/smem.c +9
-12@@ -9,6 +9,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/of_reserved_mem.h> #include <linux/platform_device.h> #include <linux/sizes.h> #include <linux/slab.h> @@ -240,7 +241,7 @@ static const u8 SMEM_INFO_MAGIC[] = { 0x53, 0x49, 0x49, 0x49 }; /* SIII */* @size: size of the memory region */ struct smem_region { -u32 aux_base; +phys_addr_t aux_base;void __iomem *virt_base;size_t size; };@@ -499,7 +500,7 @@ static void *qcom_smem_get_global(struct qcom_smem *smem,for (i =0 ; i < smem->num_regions; i++) { region = &smem->regions[i]; -if (region->aux_base == aux_base || !aux_base) { +if ((u32 )region->aux_base == aux_base || !aux_base) {if (size !=NULL ) *size =le32_to_cpu (entry->size);return region->virt_base +le32_to_cpu (entry->offset);@@ -664,7 +665,7 @@ phys_addr_t qcom_smem_virt_to_phys(void *p)if (p < region->virt_base + region->size) {u64 offset = p - region->virt_base; -return (phys_addr_t )region->aux_base + offset; +return region->aux_base + offset; } }@@ -863,12 +864,12 @@ qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host)return 0 ; } -static int qcom_smem_map_memory (struct qcom_smem *smem,struct device *dev, -const char *name,int i) +static int qcom_smem_resolve_mem (struct qcom_smem *smem,const char *name, +struct smem_region *region) { +struct device *dev = smem->dev;struct device_node *np;struct resource r; -resource_size_t size;int ret; np =of_parse_phandle (dev->of_node, name,0 );@@ -881,13 +882,9 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev,of_node_put (np);if (ret)return ret; - size =resource_size (&r); - smem->regions[i].virt_base =devm_ioremap_wc (dev, r.start, size); -if (!smem->regions[i].virt_base) -return -ENOMEM ; - smem->regions[i].aux_base = (u32 )r.start; - smem->regions[i].size = size; + region->aux_base = r.start; + region->size =resource_size (&r);return 0 ; }@@ -895,12 +892,14 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev,static int qcom_smem_probe (struct platform_device *pdev)
drivers/soc/qcom/smem.c static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, · line 902
Quoted 10 lines
drivers/soc/qcom/smem.c +2
-0{struct smem_header *header; +struct reserved_mem *rmem;struct qcom_smem *smem;size_t array_size;int num_regions;int hwlock_id;u32 version;int ret; +int i;
Just a nitpicking, the index can be unsigned.
Quoted 36 lines
drivers/soc/qcom/smem.c +21
-6num_regions =1 ;if (of_find_property (pdev->dev.of_node,"qcom,rpm-msg-ram" ,NULL ))@@ -914,13 +913,35 @@ static int qcom_smem_probe(struct platform_device *pdev) smem->dev = &pdev->dev; smem->num_regions = num_regions; - ret =qcom_smem_map_memory (smem, &pdev->dev,"memory-region" ,0 ); -if (ret) -return ret; + rmem =of_reserved_mem_lookup (pdev->dev.of_node); +if (rmem) { + smem->regions[0 ].aux_base = rmem->base; + smem->regions[0 ].size = rmem->size; + }else { +/* +* Fall back to the memory-region reference, if we're not a +* reserved-memory node. +*/ + ret =qcom_smem_resolve_mem (smem,"memory-region" , &smem->regions[0 ]); +if (ret) +return ret; + } -if (num_regions >1 && (ret =qcom_smem_map_memory (smem, &pdev->dev, -"qcom,rpm-msg-ram" ,1 ))) -return ret; +if (num_regions >1 ) { + ret =qcom_smem_resolve_mem (smem,"qcom,rpm-msg-ram" , &smem->regions[1 ]); +if (ret) +return ret; + } + +for (i =0 ; i < num_regions; i++) { + smem->regions[i].virt_base = devm_ioremap_wc(&pdev->dev,
drivers/soc/qcom/smem.c static int qcom_smem_probe(struct platform_device *pdev) · line 947
Quoted 10 lines
drivers/soc/qcom/smem.c +7
-0+ smem->regions[i].aux_base, + smem->regions[i].size); +if (!smem->regions[i].virt_base) { +dev_err (&pdev->dev,"failed to remap %pa\n" , &smem->regions[i].aux_base); +return -ENOMEM ; + } + } header = smem->regions[0 ].virt_base; if (le32_to_cpu(header->initialized) != 1 ||
--
Best wishes,
Vladimir
Re: [PATCH v2 3/4] soc: qcom: smem: Support reserved-memory description
Quoted 1 line · Vladimir Zapolskiy
On 9/30/21 9:21 PM, Bjorn Andersson wrote:
[..]
Quoted 1 line
Quoted 1 line
drivers/soc/qcom/smem.c +0
-0
[..]
Quoted 6 lines
Quoted 6 lines
drivers/soc/qcom/smem.c +1
-0@@ -895,12 +892,14 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev,static int qcom_smem_probe (struct platform_device *pdev) {struct smem_header *header; +struct reserved_mem *rmem;struct qcom_smem *smem;
Quoted 9 lines
drivers/soc/qcom/smem.c static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, · line 902
Quoted 6 lines
drivers/soc/qcom/smem.c +1
-0size_t array_size;int num_regions;int hwlock_id;u32 version;int ret; +int i;Just a nitpicking, the index can be unsigned.
It's compared against the "num_regions", which is also signed. So I think it should be signed.
[..]
Quoted 1 line
drivers/soc/qcom/smem.c static int qcom_smem_probe(struct platform_device *pdev) · line 936
Quoted 1 line
drivers/soc/qcom/smem.c +1
-0+for (i =0 ; i < num_regions; i++) {
Thanks for the review!
Regards,
Bjorn
Re: [PATCH v2 3/4] soc: qcom: smem: Support reserved-memory description
In reply to Bjorn AnderssonQuoted 15 lines · Bjorn Andersson
Practically all modern Qualcomm platforms has a single reserved-memory region for SMEM. So rather than having to describe SMEM in the form of a node with a reference to a reserved-memory node, allow the SMEM device to be instantiated directly from the reserved-memory node.
The current means of falling back to dereferencing the "memory-region" is kept as a fallback, if it's determined that the SMEM node is a reserved-memory node.
The "qcom,smem" compatible is added to the
reserved_mem_matcheslist, to allow the reserved-memory device to be probed.In order to retain the readability of the code, the resolution of resources is split from the actual ioremapping.
Quoted 7 lines
Signed-off-by Bjorn Andersson <[email protected]>---
Changes since v1:
- Nonedrivers/of/platform.c | 1 +
Quoted 2 lines
drivers/soc/qcom/smem.c | 57 ++++++++++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 18 deletions(-)
PATCH v2 4/4 arm64: dts: qcom: sdm845: Drop standalone smem node
In reply to Bjorn AnderssonNow that the SMEM binding and driver allows the SMEM node to be described in the reserved-memory region directly, move the compatible and hwlock properties to the reserved-memory node and drop the standadlone node.
---
Changes since v1:
- Node name is changed to "smem", as "memory" is reserved for memory nodes.
arch/arm64/boot/dts/qcom/sdm845.dtsi | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
arch/arm64/boot/dts/qcom/sdm845.dtsi +3 -7
@@ -99,9 +99,11 @@ aop_cmd_db_mem: memory@85fe0000 { no-map; }; - smem_mem: memory@86000000 { + smem@86000000 { + compatible = "qcom,smem"; reg = <0x0 0x86000000 0 0x200000>; no-map; + hwlocks = <&tcsr_mutex 3>; }; tz_mem: memory@86200000 {
@@ -941,12 +943,6 @@ tcsr_mutex: hwlock { #hwlock-cells = <1>; }; - smem { - compatible = "qcom,smem"; - memory-region = <&smem_mem>; - hwlocks = <&tcsr_mutex 3>; - }; - smp2p-cdsp { compatible = "qcom,smp2p"; qcom,smem = <94>, <432>;
Signature · 1 line
2.29.2
Bjorn Andersson
AppliedRe: (subset) [PATCH v2 4/4] arm64: dts: qcom: sdm845: Drop standalone smem node
Quoted 6 lines · Bjorn Andersson
Now that the SMEM binding and driver allows the SMEM node to be described in the reserved-memory region directly, move the compatible and hwlock properties to the reserved-memory node and drop the standadlone node.
Applied, thanks!
[4/4] arm64: dts: qcom: sdm845: Drop standalone smem node
commit: 622adb84b3e7c48a888c3df26fbf28679ded660b
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>
Hi Bjorn,
Quoted 9 lines · Bjorn Andersson
In the modern Qualcomm platform there's no reason for having smem as a separate node, so let's change this.
Bjorn Andersson (4):
dt-bindings: sram: Document qcom,rpm-msg-ram
dt-bindings: soc: smem: Make indirection optional
soc: qcom: smem: Support reserved-memory description
arm64: dts: qcom: sdm845: Drop standalone smem node
Quoted 7 lines
.../bindings/soc/qcom/qcom,smem.yaml | 34 +++++++++-- .../devicetree/bindings/sram/sram.yaml | 5 +- arch/arm64/boot/dts/qcom/sdm845.dtsi | 10 +--- drivers/of/platform.c | 1 + drivers/soc/qcom/smem.c | 57 +++++++++++++------ 5 files changed, 77 insertions(+), 30 deletions(-)
the patch series looks good.
--
Best wishes,
Vladimir
This series was applied to qcom/linux.git (for-next) by Bjorn Andersson <[email protected]>:
Hello:
This series was applied to qcom/linux.git (for-next) by Bjorn Andersson <[email protected]>:
Quoted 10 lines · On Thu, 30 Sep 2021 11:21:07 -0700 you wrote:
In the modern Qualcomm platform there's no reason for having smem as a separate node, so let's change this.
Bjorn Andersson (4):
dt-bindings: sram: Document qcom,rpm-msg-ram
dt-bindings: soc: smem: Make indirection optional
soc: qcom: smem: Support reserved-memory description
arm64: dts: qcom: sdm845: Drop standalone smem node[...]
Here is the summary with links:
- [v2,1/4] dt-bindings: sram: Document qcom,rpm-msg-ram
https://git.kernel.org/qcom/c/d0fe6491ddd2 - [v2,2/4] dt-bindings: soc: smem: Make indirection optional https://git.kernel.org/qcom/c/7a99e87e2e6b - [v2,3/4] soc: qcom: smem: Support reserved-memory description https://git.kernel.org/qcom/c/b5af64fceb04 - [v2,4/4] arm64: dts: qcom: sdm845: Drop standalone smem node https://git.kernel.org/qcom/c/622adb84b3e7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Bjorn Andersson
AppliedRe: (subset) [PATCH v2 0/4] dt-bindings: soc: smem: Make indirection optional
In reply to Bjorn AnderssonQuoted 10 lines · Bjorn Andersson
In the modern Qualcomm platform there's no reason for having smem as a separate node, so let's change this.
Bjorn Andersson (4):
dt-bindings: sram: Document qcom,rpm-msg-ram
dt-bindings: soc: smem: Make indirection optional
soc: qcom: smem: Support reserved-memory description
arm64: dts: qcom: sdm845: Drop standalone smem node[...]
Applied, thanks!
[4/4] arm64: dts: qcom: sdm845: Drop standalone smem node
commit: 622adb84b3e7c48a888c3df26fbf28679ded660b
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>