.../bindings/firmware/arm,scmi.yaml | 69 +++++ drivers/firmware/arm_scmi/Kconfig | 13 + drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/common.h | 3 + drivers/firmware/arm_scmi/driver.c | 4 + drivers/firmware/arm_scmi/qcom_hvc.c | 241 ++++++++++++++++++ 6 files changed, 331 insertions(+) create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c
This change introduce a new transport channel for Qualcomm virtual platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC. The difference between the two transports is that a parameter is passed in the hypervisor call to identify which doorbell to assert. This parameter is dynamically generated at runtime on the device and insuitable to pass via the devicetree. The function ID and parameter are stored by firmware in the shmem region. This has been tested on ARM64 virtual Qualcomm platform. Nikunj Kela (2): dt-bindings: arm: Add qcom specific hvc transport for SCMI firmware: arm_scmi: Add qcom hvc/shmem transport .../bindings/firmware/arm,scmi.yaml | 69 +++++ drivers/firmware/arm_scmi/Kconfig | 13 + drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/common.h | 3 + drivers/firmware/arm_scmi/driver.c | 4 + drivers/firmware/arm_scmi/qcom_hvc.c | 241 ++++++++++++++++++ 6 files changed, 331 insertions(+) create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c -- 2.17.1
This change augments smc transport to include support for Qualcomm virtual
platforms by passing a parameter(capability-id) in the hypervisor call to
identify which doorbell to assert. This parameter is dynamically generated
at runtime on the device and insuitable to pass via the devicetree.
The capability-id is stored by firmware in the shmem region.
This has been tested on ARM64 virtual Qualcomm platform.
---
v6 -> use unsigned long for cap-id
v5 -> changed compatible, removed polling support patch,
make use of smc-id binding for function-id
v4 -> port the changes into smc.c
v3 -> fix the compilation error reported by the test bot,
add support for polling based instances
v2 -> use allOf construct in dtb schema,
remove wrappers from mutexes,
use architecture independent channel layout
v1 -> original patches
Nikunj Kela (2):
dt-bindings: arm: Add new compatible for smc/hvc transport for SCMI
firmware: arm_scmi: Add qcom smc/hvc transport support
.../bindings/firmware/arm,scmi.yaml | 4 +++
drivers/firmware/arm_scmi/driver.c | 1 +
drivers/firmware/arm_scmi/smc.c | 27 +++++++++++++++++--
3 files changed, 30 insertions(+), 2 deletions(-)
--
2.17.1
On Mon, 09 Oct 2023 12:14:35 -0700, Nikunj Kela wrote:
> This change augments smc transport to include support for Qualcomm virtual
> platforms by passing a parameter(capability-id) in the hypervisor call to
> identify which doorbell to assert. This parameter is dynamically generated
> at runtime on the device and insuitable to pass via the devicetree.
>
> The capability-id is stored by firmware in the shmem region.
>
> [...]
Applied to sudeep.holla/linux (for-next/scmi/updates), thanks!
[1/2] dt-bindings: arm: Add new compatible for smc/hvc transport for SCMI
https://git.kernel.org/sudeep.holla/c/6979f88f5a8e
[2/2] firmware: arm_scmi: Add qcom smc/hvc transport support
https://git.kernel.org/sudeep.holla/c/da405477e767
--
Regards,
Sudeep
Introduce compatible "qcom,scmi-smc" for SCMI smc/hvc transport channel for
Qualcomm virtual platforms.
This compatible mandates populating an additional parameter 'capability-id'
from the last 8 bytes of the shmem channel.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
Reviewed-by: Brian Masney <bmasney@redhat.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
Documentation/devicetree/bindings/firmware/arm,scmi.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index 563a87dfb31a..4591523b51a0 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -38,6 +38,9 @@ properties:
with shmem address(4KB-page, offset) as parameters
items:
- const: arm,scmi-smc-param
+ - description: SCMI compliant firmware with Qualcomm SMC/HVC transport
+ items:
+ - const: qcom,scmi-smc
- description: SCMI compliant firmware with SCMI Virtio transport.
The virtio transport only supports a single device.
items:
@@ -313,6 +316,7 @@ else:
enum:
- arm,scmi-smc
- arm,scmi-smc-param
+ - qcom,scmi-smc
then:
required:
- arm,smc-id
--
2.17.1
This change adds the support for SCMI message exchange on Qualcomm
virtual platforms.
The hypervisor associates an object-id also known as capability-id
with each smc/hvc doorbell object. The capability-id is used to
identify the doorbell from the VM's capability namespace, similar
to a file-descriptor.
The hypervisor, in addition to the function-id, expects the capability-id
to be passed in x1 register when SMC/HVC call is invoked.
The capability-id is allocated by the hypervisor on bootup and is stored in
the shmem region by the firmware before starting Linux.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
Reviewed-by: Brian Masney <bmasney@redhat.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
drivers/firmware/arm_scmi/smc.c | 27 +++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 87383c05424b..09371f40d61f 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
{ .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
+ { .compatible = "qcom,scmi-smc", .data = &scmi_smc_desc},
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index 8eba60a41975..7611e9665038 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -15,6 +15,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
+#include <linux/limits.h>
#include <linux/processor.h>
#include <linux/slab.h>
@@ -50,6 +51,8 @@
* @func_id: smc/hvc call function id
* @param_page: 4K page number of the shmem channel
* @param_offset: Offset within the 4K page of the shmem channel
+ * @cap_id: smc/hvc doorbell's capability id to be used on Qualcomm virtual
+ * platforms
*/
struct scmi_smc {
@@ -63,6 +66,7 @@ struct scmi_smc {
unsigned long func_id;
unsigned long param_page;
unsigned long param_offset;
+ unsigned long cap_id;
};
static irqreturn_t smc_msg_done_isr(int irq, void *data)
@@ -124,6 +128,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
bool tx)
{
struct device *cdev = cinfo->dev;
+ unsigned long cap_id = ULONG_MAX;
struct scmi_smc *scmi_info;
resource_size_t size;
struct resource res;
@@ -162,6 +167,18 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
if (ret < 0)
return ret;
+ if (of_device_is_compatible(dev->of_node, "qcom,scmi-smc")) {
+ void __iomem *ptr = (void __iomem *)scmi_info->shmem + size - 8;
+ /* The capability-id is kept in last 8 bytes of shmem.
+ * +-------+ <-- 0
+ * | shmem |
+ * +-------+ <-- size - 8
+ * | capId |
+ * +-------+ <-- size
+ */
+ memcpy_fromio(&cap_id, ptr, sizeof(cap_id));
+ }
+
if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
scmi_info->param_page = SHMEM_PAGE(res.start);
scmi_info->param_offset = SHMEM_OFFSET(res.start);
@@ -184,6 +201,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
}
scmi_info->func_id = func_id;
+ scmi_info->cap_id = cap_id;
scmi_info->cinfo = cinfo;
smc_channel_lock_init(scmi_info);
cinfo->transport_info = scmi_info;
@@ -220,8 +238,13 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
- arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->param_page,
- scmi_info->param_offset, 0, 0, 0, 0, 0, &res);
+ if (scmi_info->cap_id != ULONG_MAX)
+ arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->cap_id, 0,
+ 0, 0, 0, 0, 0, &res);
+ else
+ arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->param_page,
+ scmi_info->param_offset, 0, 0, 0, 0, 0,
+ &res);
/* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
if (res.a0) {
--
2.17.1
On Mon, Oct 09, 2023 at 12:14:37PM -0700, Nikunj Kela wrote:
> This change adds the support for SCMI message exchange on Qualcomm
> virtual platforms.
>
> The hypervisor associates an object-id also known as capability-id
> with each smc/hvc doorbell object. The capability-id is used to
> identify the doorbell from the VM's capability namespace, similar
> to a file-descriptor.
>
> The hypervisor, in addition to the function-id, expects the capability-id
> to be passed in x1 register when SMC/HVC call is invoked.
>
> The capability-id is allocated by the hypervisor on bootup and is stored in
> the shmem region by the firmware before starting Linux.
>
> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
> Reviewed-by: Brian Masney <bmasney@redhat.com>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
FYI for the next time. When posting on the list, the senders sign-off must
be the last. The only reason I signed off is because it is needed as part
of committer in the git repo. You should have ideally dropped it in this case.
If there was some other author/co-developer of the patch, then your signoff
will be always at the end as you are sending the patch.
Refer "Sign your work - the Developer's Certificate of Origin" section
in Documentation/process/submitting-patches.rst
> ---
> drivers/firmware/arm_scmi/driver.c | 1 +
> drivers/firmware/arm_scmi/smc.c | 27 +++++++++++++++++++++++++--
> 2 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 87383c05424b..09371f40d61f 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
> #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
> { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
> { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
> + { .compatible = "qcom,scmi-smc", .data = &scmi_smc_desc},
> #endif
> #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
> { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> index 8eba60a41975..7611e9665038 100644
> --- a/drivers/firmware/arm_scmi/smc.c
> +++ b/drivers/firmware/arm_scmi/smc.c
> @@ -15,6 +15,7 @@
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/of_irq.h>
> +#include <linux/limits.h>
> #include <linux/processor.h>
> #include <linux/slab.h>
>
> @@ -50,6 +51,8 @@
> * @func_id: smc/hvc call function id
> * @param_page: 4K page number of the shmem channel
> * @param_offset: Offset within the 4K page of the shmem channel
> + * @cap_id: smc/hvc doorbell's capability id to be used on Qualcomm virtual
> + * platforms
> */
>
> struct scmi_smc {
> @@ -63,6 +66,7 @@ struct scmi_smc {
> unsigned long func_id;
> unsigned long param_page;
> unsigned long param_offset;
> + unsigned long cap_id;
> };
>
> static irqreturn_t smc_msg_done_isr(int irq, void *data)
> @@ -124,6 +128,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> bool tx)
> {
> struct device *cdev = cinfo->dev;
> + unsigned long cap_id = ULONG_MAX;
> struct scmi_smc *scmi_info;
> resource_size_t size;
> struct resource res;
> @@ -162,6 +167,18 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> if (ret < 0)
> return ret;
>
> + if (of_device_is_compatible(dev->of_node, "qcom,scmi-smc")) {
> + void __iomem *ptr = (void __iomem *)scmi_info->shmem + size - 8;
> + /* The capability-id is kept in last 8 bytes of shmem.
> + * +-------+ <-- 0
> + * | shmem |
> + * +-------+ <-- size - 8
> + * | capId |
> + * +-------+ <-- size
> + */
> + memcpy_fromio(&cap_id, ptr, sizeof(cap_id));
> + }
> +
> if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
> scmi_info->param_page = SHMEM_PAGE(res.start);
> scmi_info->param_offset = SHMEM_OFFSET(res.start);
> @@ -184,6 +201,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> }
>
> scmi_info->func_id = func_id;
> + scmi_info->cap_id = cap_id;
> scmi_info->cinfo = cinfo;
> smc_channel_lock_init(scmi_info);
> cinfo->transport_info = scmi_info;
> @@ -220,8 +238,13 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>
> shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
>
> - arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->param_page,
> - scmi_info->param_offset, 0, 0, 0, 0, 0, &res);
> + if (scmi_info->cap_id != ULONG_MAX)
> + arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->cap_id, 0,
> + 0, 0, 0, 0, 0, &res);
> + else
> + arm_smccc_1_1_invoke(scmi_info->func_id, scmi_info->param_page,
> + scmi_info->param_offset, 0, 0, 0, 0, 0,
> + &res);
>
> /* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
> if (res.a0) {
> --
> 2.17.1
>
--
Regards,
Sudeep
This change augments smc transport to include support for Qualcomm virtual
platforms by passing a parameter(capability-id) in the hypervisor call to
identify which doorbell to assert. This parameter is dynamically generated
at runtime on the device and insuitable to pass via the devicetree.
The capability-id is stored by firmware in the shmem region.
This has been tested on ARM64 virtual Qualcomm platform.
---
v5 -> changed compatible, removed polling support patch,
make use of smc-id binding for function-id
v4 -> port the changes into smc.c
v3 -> fix the compilation error reported by the test bot,
add support for polling based instances
v2 -> use allOf construct in dtb schema,
remove wrappers from mutexes,
use architecture independent channel layout
v1 -> original patches
Nikunj Kela (2):
dt-bindings: arm: Add new compatible for smc/hvc transport for SCMI
firmware: arm_scmi: Add qcom smc/hvc transport support
.../bindings/firmware/arm,scmi.yaml | 4 +++
drivers/firmware/arm_scmi/driver.c | 1 +
drivers/firmware/arm_scmi/smc.c | 33 +++++++++++++++++--
3 files changed, 36 insertions(+), 2 deletions(-)
--
2.17.1
Introduce compatible "qcom,scmi-smc" for SCMI smc/hvc transport channel for
Qualcomm virtual platforms.
This compatible mandates populating an additional parameter 'capability-id'
from the last 8 bytes of the shmem channel.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
Documentation/devicetree/bindings/firmware/arm,scmi.yaml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index 563a87dfb31a..4591523b51a0 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -38,6 +38,9 @@ properties:
with shmem address(4KB-page, offset) as parameters
items:
- const: arm,scmi-smc-param
+ - description: SCMI compliant firmware with Qualcomm SMC/HVC transport
+ items:
+ - const: qcom,scmi-smc
- description: SCMI compliant firmware with SCMI Virtio transport.
The virtio transport only supports a single device.
items:
@@ -313,6 +316,7 @@ else:
enum:
- arm,scmi-smc
- arm,scmi-smc-param
+ - qcom,scmi-smc
then:
required:
- arm,smc-id
--
2.17.1
On Fri, Oct 06, 2023 at 09:42:05AM -0700, Nikunj Kela wrote: > Introduce compatible "qcom,scmi-smc" for SCMI smc/hvc transport channel for > Qualcomm virtual platforms. > > This compatible mandates populating an additional parameter 'capability-id' > from the last 8 bytes of the shmem channel. > While I am happy with the simplification here, I am also bit nervous how long before Qualcomm abandons this. I hope this is adopted as is in all internal and downstream code without any modifications and this is not just a push for upstreaming some change to minimise delta with internal/ downstream code. -- Regards, Sudeep
On 10/9/2023 7:41 AM, Sudeep Holla wrote: > On Fri, Oct 06, 2023 at 09:42:05AM -0700, Nikunj Kela wrote: >> Introduce compatible "qcom,scmi-smc" for SCMI smc/hvc transport channel for >> Qualcomm virtual platforms. >> >> This compatible mandates populating an additional parameter 'capability-id' >> from the last 8 bytes of the shmem channel. >> > While I am happy with the simplification here, I am also bit nervous how > long before Qualcomm abandons this. I hope this is adopted as is in all > internal and downstream code without any modifications and this is not > just a push for upstreaming some change to minimise delta with internal/ > downstream code. > > -- > Regards, > Sudeep Qualcomm is using patch on all the virtual auto platforms using shmem/doorbell as scmi channel. This is already being used without any modifications in our downstream code. No delta for this patch series. Thanks!
On 10/9/23 16:52, Nikunj Kela wrote: > > On 10/9/2023 7:41 AM, Sudeep Holla wrote: >> On Fri, Oct 06, 2023 at 09:42:05AM -0700, Nikunj Kela wrote: >>> Introduce compatible "qcom,scmi-smc" for SCMI smc/hvc transport >>> channel for >>> Qualcomm virtual platforms. >>> >>> This compatible mandates populating an additional parameter >>> 'capability-id' >>> from the last 8 bytes of the shmem channel. >>> >> While I am happy with the simplification here, I am also bit nervous how >> long before Qualcomm abandons this. I hope this is adopted as is in all >> internal and downstream code without any modifications and this is not >> just a push for upstreaming some change to minimise delta with internal/ >> downstream code. >> >> -- >> Regards, >> Sudeep > > Qualcomm is using patch on all the virtual auto platforms using > shmem/doorbell as scmi channel. This is already being used without any > modifications in our downstream code. No delta for this patch series. > Thanks! AFAICT Sudeep is looking for a solid guarantee that it will continue to be used as-is, on more than one platform and on more than one BSP version. There have been cases where such firmware interfaces had silent ABI breaks (or were replaced altogether) between qc downstream branches and this would be unacceptable. Understandably, having a unified means of communication for *all* Qualcomm chips (i.e. not only auto) going forward would likely be expected.. Konrad
On Fri, Oct 06, 2023 at 09:42:05AM -0700, Nikunj Kela wrote: > Introduce compatible "qcom,scmi-smc" for SCMI smc/hvc transport channel for > Qualcomm virtual platforms. > > This compatible mandates populating an additional parameter 'capability-id' > from the last 8 bytes of the shmem channel. > > Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> Reviewed-by: Brian Masney <bmasney@redhat.com>
This change adds the support for SCMI message exchange on Qualcomm
virtual platforms.
The hypervisor associates an object-id also known as capability-id
with each smc/hvc doorbell object. The capability-id is used to
identify the doorbell from the VM's capability namespace, similar
to a file-descriptor.
The hypervisor, in addition to the function-id, expects the capability-id
to be passed in x1 register when SMC/HVC call is invoked.
The capability-id is allocated by the hypervisor on bootup and is stored in
the shmem region by the firmware before starting Linux.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
drivers/firmware/arm_scmi/smc.c | 33 ++++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 87383c05424b..09371f40d61f 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
{ .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
+ { .compatible = "qcom,scmi-smc", .data = &scmi_smc_desc},
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index c193516a254d..3d594d65ab14 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -50,6 +50,8 @@
* @func_id: smc/hvc call function id
* @param_page: 4K page number of the shmem channel
* @param_offset: Offset within the 4K page of the shmem channel
+ * @cap_id: smc/hvc doorbell's capability id to be used on Qualcomm virtual
+ * platforms
*/
struct scmi_smc {
@@ -63,6 +65,7 @@ struct scmi_smc {
u32 func_id;
u32 param_page;
u32 param_offset;
+ s64 cap_id;
};
static irqreturn_t smc_msg_done_isr(int irq, void *data)
@@ -128,6 +131,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
resource_size_t size;
struct resource res;
struct device_node *np;
+ s64 cap_id = -EINVAL;
u32 func_id;
int ret;
@@ -162,6 +166,25 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
if (ret < 0)
return ret;
+ if (of_device_is_compatible(dev->of_node, "qcom,scmi-smc")) {
+ /* The capability-id is kept in last 8 bytes of shmem.
+ * +-------+
+ * | |
+ * | shmem |
+ * | |
+ * | |
+ * +-------+ <-- (size - 8)
+ * | capId |
+ * +-------+ <-- size
+ */
+
+#ifdef CONFIG_64BIT
+ cap_id = ioread64((void *)scmi_info->shmem + size - 8);
+#else
+ cap_id = ioread32((void *)scmi_info->shmem + size - 8);
+#endif
+ }
+
if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
scmi_info->param_page = SHMEM_PAGE(res.start);
scmi_info->param_offset = SHMEM_OFFSET(res.start);
@@ -184,6 +207,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
}
scmi_info->func_id = func_id;
+ scmi_info->cap_id = cap_id;
scmi_info->cinfo = cinfo;
smc_channel_lock_init(scmi_info);
cinfo->transport_info = scmi_info;
@@ -213,6 +237,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
struct arm_smccc_res res;
unsigned long page = scmi_info->param_page;
unsigned long offset = scmi_info->param_offset;
+ long cap_id = (long)scmi_info->cap_id;
/*
* Channel will be released only once response has been
@@ -222,8 +247,12 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
- arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
- &res);
+ if (cap_id >= 0)
+ arm_smccc_1_1_invoke(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0,
+ 0, &res);
+ else
+ arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0,
+ 0, 0, &res);
/* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
if (res.a0) {
--
2.17.1
On Fri, Oct 06, 2023 at 09:42:06AM -0700, Nikunj Kela wrote:
> This change adds the support for SCMI message exchange on Qualcomm
> virtual platforms.
>
> The hypervisor associates an object-id also known as capability-id
> with each smc/hvc doorbell object. The capability-id is used to
> identify the doorbell from the VM's capability namespace, similar
> to a file-descriptor.
>
> The hypervisor, in addition to the function-id, expects the capability-id
> to be passed in x1 register when SMC/HVC call is invoked.
>
> The capability-id is allocated by the hypervisor on bootup and is stored in
> the shmem region by the firmware before starting Linux.
>
Since you are happy to move to signed value, I assume you are happy to loose
upper half of the range values ?
Anyways after Bjorn pointed out inconsistency, I am thinking of moving
all the values to unsigned long to work with both 32bit and 64bit.
Does the below delta on top of this patch works for you and makes sense?
--
Regards,
Sudeep
-->8
diff --git c/drivers/firmware/arm_scmi/smc.c i/drivers/firmware/arm_scmi/smc.c
index bf0b7769c7b2..e00c5e81c8d9 100644
--- c/drivers/firmware/arm_scmi/smc.c
+++ i/drivers/firmware/arm_scmi/smc.c
@@ -15,6 +15,7 @@
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
+#include <linux/limits.h>
#include <linux/processor.h>
#include <linux/slab.h>
@@ -65,7 +66,7 @@ struct scmi_smc {
unsigned long func_id;
unsigned long param_page;
unsigned long param_offset;
- s64 cap_id;
+ unsigned long cap_id;
};
static irqreturn_t smc_msg_done_isr(int irq, void *data)
@@ -127,11 +128,11 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
bool tx)
{
struct device *cdev = cinfo->dev;
+ unsigned long cap_id = ULONG_MAX;
struct scmi_smc *scmi_info;
resource_size_t size;
struct resource res;
struct device_node *np;
- s64 cap_id = -EINVAL;
u32 func_id;
int ret;
@@ -167,6 +168,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
return ret;
if (of_device_is_compatible(dev->of_node, "qcom,scmi-smc")) {
+ void __iomem *ptr = (void __iomem *)scmi_info->shmem + size - 8;
/* The capability-id is kept in last 8 bytes of shmem.
* +-------+
* | |
@@ -177,12 +179,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
* | capId |
* +-------+ <-- size
*/
-
-#ifdef CONFIG_64BIT
- cap_id = ioread64((void *)scmi_info->shmem + size - 8);
-#else
- cap_id = ioread32((void *)scmi_info->shmem + size - 8);
-#endif
+ memcpy_fromio(&cap_id, ptr, sizeof(cap_id));
}
if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
@@ -247,7 +244,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
- if (cap_id >= 0)
+ if (cap_id != ULONG_MAX)
arm_smccc_1_1_invoke(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0,
0, &res);
else
On 10/9/2023 7:47 AM, Sudeep Holla wrote:
> On Fri, Oct 06, 2023 at 09:42:06AM -0700, Nikunj Kela wrote:
>> This change adds the support for SCMI message exchange on Qualcomm
>> virtual platforms.
>>
>> The hypervisor associates an object-id also known as capability-id
>> with each smc/hvc doorbell object. The capability-id is used to
>> identify the doorbell from the VM's capability namespace, similar
>> to a file-descriptor.
>>
>> The hypervisor, in addition to the function-id, expects the capability-id
>> to be passed in x1 register when SMC/HVC call is invoked.
>>
>> The capability-id is allocated by the hypervisor on bootup and is stored in
>> the shmem region by the firmware before starting Linux.
>>
> Since you are happy to move to signed value, I assume you are happy to loose
> upper half of the range values ?
>
> Anyways after Bjorn pointed out inconsistency, I am thinking of moving
> all the values to unsigned long to work with both 32bit and 64bit.
>
> Does the below delta on top of this patch works for you and makes sense?
This looks good to me. Will do some testing and float v6 with the
changes you suggested below. Thanks
>
> --
> Regards,
> Sudeep
>
> -->8
> diff --git c/drivers/firmware/arm_scmi/smc.c i/drivers/firmware/arm_scmi/smc.c
> index bf0b7769c7b2..e00c5e81c8d9 100644
> --- c/drivers/firmware/arm_scmi/smc.c
> +++ i/drivers/firmware/arm_scmi/smc.c
> @@ -15,6 +15,7 @@
> #include <linux/of.h>
> #include <linux/of_address.h>
> #include <linux/of_irq.h>
> +#include <linux/limits.h>
> #include <linux/processor.h>
> #include <linux/slab.h>
>
> @@ -65,7 +66,7 @@ struct scmi_smc {
> unsigned long func_id;
> unsigned long param_page;
> unsigned long param_offset;
> - s64 cap_id;
> + unsigned long cap_id;
> };
>
> static irqreturn_t smc_msg_done_isr(int irq, void *data)
> @@ -127,11 +128,11 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> bool tx)
> {
> struct device *cdev = cinfo->dev;
> + unsigned long cap_id = ULONG_MAX;
> struct scmi_smc *scmi_info;
> resource_size_t size;
> struct resource res;
> struct device_node *np;
> - s64 cap_id = -EINVAL;
> u32 func_id;
> int ret;
>
> @@ -167,6 +168,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> return ret;
>
> if (of_device_is_compatible(dev->of_node, "qcom,scmi-smc")) {
> + void __iomem *ptr = (void __iomem *)scmi_info->shmem + size - 8;
> /* The capability-id is kept in last 8 bytes of shmem.
> * +-------+
> * | |
> @@ -177,12 +179,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> * | capId |
> * +-------+ <-- size
> */
> -
> -#ifdef CONFIG_64BIT
> - cap_id = ioread64((void *)scmi_info->shmem + size - 8);
> -#else
> - cap_id = ioread32((void *)scmi_info->shmem + size - 8);
> -#endif
> + memcpy_fromio(&cap_id, ptr, sizeof(cap_id));
> }
>
> if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
> @@ -247,7 +244,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>
> shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
>
> - if (cap_id >= 0)
> + if (cap_id != ULONG_MAX)
> arm_smccc_1_1_invoke(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0,
> 0, &res);
> else
>
On Mon, Oct 09, 2023 at 07:59:08AM -0700, Nikunj Kela wrote: > > On 10/9/2023 7:47 AM, Sudeep Holla wrote: > > On Fri, Oct 06, 2023 at 09:42:06AM -0700, Nikunj Kela wrote: > > > This change adds the support for SCMI message exchange on Qualcomm > > > virtual platforms. > > > > > > The hypervisor associates an object-id also known as capability-id > > > with each smc/hvc doorbell object. The capability-id is used to > > > identify the doorbell from the VM's capability namespace, similar > > > to a file-descriptor. > > > > > > The hypervisor, in addition to the function-id, expects the capability-id > > > to be passed in x1 register when SMC/HVC call is invoked. > > > > > > The capability-id is allocated by the hypervisor on bootup and is stored in > > > the shmem region by the firmware before starting Linux. > > > > > Since you are happy to move to signed value, I assume you are happy to loose > > upper half of the range values ? > > > > Anyways after Bjorn pointed out inconsistency, I am thinking of moving > > all the values to unsigned long to work with both 32bit and 64bit. > > > > Does the below delta on top of this patch works for you and makes sense? > > This looks good to me. Will do some testing and float v6 with the changes > you suggested below. Thanks > Please refer or use the patch from [1] when reposting. I rebased on my patch[2] that I posted few minutes back. I am trying to finalise the branch and send PR in next couple of days, so please test and post sooner. Sorry for the rush. -- Regards, Sudeep [1] https://git.kernel.org/sudeep.holla/h/for-next/scmi/updates [2] https://lore.kernel.org/r/20231009152049.1428872-1-sudeep.holla@arm.com
On 10/9/2023 8:29 AM, Sudeep Holla wrote: > On Mon, Oct 09, 2023 at 07:59:08AM -0700, Nikunj Kela wrote: >> On 10/9/2023 7:47 AM, Sudeep Holla wrote: >>> On Fri, Oct 06, 2023 at 09:42:06AM -0700, Nikunj Kela wrote: >>>> This change adds the support for SCMI message exchange on Qualcomm >>>> virtual platforms. >>>> >>>> The hypervisor associates an object-id also known as capability-id >>>> with each smc/hvc doorbell object. The capability-id is used to >>>> identify the doorbell from the VM's capability namespace, similar >>>> to a file-descriptor. >>>> >>>> The hypervisor, in addition to the function-id, expects the capability-id >>>> to be passed in x1 register when SMC/HVC call is invoked. >>>> >>>> The capability-id is allocated by the hypervisor on bootup and is stored in >>>> the shmem region by the firmware before starting Linux. >>>> >>> Since you are happy to move to signed value, I assume you are happy to loose >>> upper half of the range values ? >>> >>> Anyways after Bjorn pointed out inconsistency, I am thinking of moving >>> all the values to unsigned long to work with both 32bit and 64bit. >>> >>> Does the below delta on top of this patch works for you and makes sense? >> This looks good to me. Will do some testing and float v6 with the changes >> you suggested below. Thanks >> > Please refer or use the patch from [1] when reposting. I rebased on my > patch[2] that I posted few minutes back. I am trying to finalise the branch > and send PR in next couple of days, so please test and post sooner. Sorry > for the rush. Validated the patch from [1] below on Qualcomm ARM64 virtual platform using SMC64 convention. Thanks! > > -- > Regards, > Sudeep > [1] https://git.kernel.org/sudeep.holla/h/for-next/scmi/updates > [2] https://lore.kernel.org/r/20231009152049.1428872-1-sudeep.holla@arm.com
On Mon, Oct 09, 2023 at 10:49:44AM -0700, Nikunj Kela wrote: > > On 10/9/2023 8:29 AM, Sudeep Holla wrote: > > On Mon, Oct 09, 2023 at 07:59:08AM -0700, Nikunj Kela wrote: > > > On 10/9/2023 7:47 AM, Sudeep Holla wrote: > > > > On Fri, Oct 06, 2023 at 09:42:06AM -0700, Nikunj Kela wrote: > > > > > This change adds the support for SCMI message exchange on Qualcomm > > > > > virtual platforms. > > > > > > > > > > The hypervisor associates an object-id also known as capability-id > > > > > with each smc/hvc doorbell object. The capability-id is used to > > > > > identify the doorbell from the VM's capability namespace, similar > > > > > to a file-descriptor. > > > > > > > > > > The hypervisor, in addition to the function-id, expects the capability-id > > > > > to be passed in x1 register when SMC/HVC call is invoked. > > > > > > > > > > The capability-id is allocated by the hypervisor on bootup and is stored in > > > > > the shmem region by the firmware before starting Linux. > > > > > > > > > Since you are happy to move to signed value, I assume you are happy to loose > > > > upper half of the range values ? > > > > > > > > Anyways after Bjorn pointed out inconsistency, I am thinking of moving > > > > all the values to unsigned long to work with both 32bit and 64bit. > > > > > > > > Does the below delta on top of this patch works for you and makes sense? > > > This looks good to me. Will do some testing and float v6 with the changes > > > you suggested below. Thanks > > > > > Please refer or use the patch from [1] when reposting. I rebased on my > > patch[2] that I posted few minutes back. I am trying to finalise the branch > > and send PR in next couple of days, so please test and post sooner. Sorry > > for the rush. > > Validated the patch from [1] below on Qualcomm ARM64 virtual platform using > SMC64 convention. Thanks! > Thanks, since I have patched a bit, it is better if you post them so that we have a link for the exact patch on the list. Just pick up the patches from the branch[1] and post them as v6 with a change log so that all the details are captured for reference purposes. -- Regards, Sudeep [1] https://git.kernel.org/sudeep.holla/h/for-next/scmi/updates [2] https://lore.kernel.org/r/20231009152049.1428872-1-sudeep.holla@arm.com
On 10/9/2023 12:08 PM, Sudeep Holla wrote: > On Mon, Oct 09, 2023 at 10:49:44AM -0700, Nikunj Kela wrote: >> On 10/9/2023 8:29 AM, Sudeep Holla wrote: >>> On Mon, Oct 09, 2023 at 07:59:08AM -0700, Nikunj Kela wrote: >>>> On 10/9/2023 7:47 AM, Sudeep Holla wrote: >>>>> On Fri, Oct 06, 2023 at 09:42:06AM -0700, Nikunj Kela wrote: >>>>>> This change adds the support for SCMI message exchange on Qualcomm >>>>>> virtual platforms. >>>>>> >>>>>> The hypervisor associates an object-id also known as capability-id >>>>>> with each smc/hvc doorbell object. The capability-id is used to >>>>>> identify the doorbell from the VM's capability namespace, similar >>>>>> to a file-descriptor. >>>>>> >>>>>> The hypervisor, in addition to the function-id, expects the capability-id >>>>>> to be passed in x1 register when SMC/HVC call is invoked. >>>>>> >>>>>> The capability-id is allocated by the hypervisor on bootup and is stored in >>>>>> the shmem region by the firmware before starting Linux. >>>>>> >>>>> Since you are happy to move to signed value, I assume you are happy to loose >>>>> upper half of the range values ? >>>>> >>>>> Anyways after Bjorn pointed out inconsistency, I am thinking of moving >>>>> all the values to unsigned long to work with both 32bit and 64bit. >>>>> >>>>> Does the below delta on top of this patch works for you and makes sense? >>>> This looks good to me. Will do some testing and float v6 with the changes >>>> you suggested below. Thanks >>>> >>> Please refer or use the patch from [1] when reposting. I rebased on my >>> patch[2] that I posted few minutes back. I am trying to finalise the branch >>> and send PR in next couple of days, so please test and post sooner. Sorry >>> for the rush. >> Validated the patch from [1] below on Qualcomm ARM64 virtual platform using >> SMC64 convention. Thanks! >> > Thanks, since I have patched a bit, it is better if you post them so that > we have a link for the exact patch on the list. Just pick up the patches > from the branch[1] and post them as v6 with a change log so that all the > details are captured for reference purposes. v6 on its way, thanks! >
On Fri, Oct 06, 2023 at 09:42:06AM -0700, Nikunj Kela wrote: > This change adds the support for SCMI message exchange on Qualcomm > virtual platforms. > > The hypervisor associates an object-id also known as capability-id > with each smc/hvc doorbell object. The capability-id is used to > identify the doorbell from the VM's capability namespace, similar > to a file-descriptor. > > The hypervisor, in addition to the function-id, expects the capability-id > to be passed in x1 register when SMC/HVC call is invoked. > > The capability-id is allocated by the hypervisor on bootup and is stored in > the shmem region by the firmware before starting Linux. > > Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> Reviewed-by: Brian Masney <bmasney@redhat.com>
This change augments smc transport to include support for Qualcomm virtual
platforms by passing a parameter(capability-id) in the hypervisor call to
identify which doorbell to assert. This parameter is dynamically generated
at runtime on the device and insuitable to pass via the devicetree.
The function ID and parameter are stored by firmware in the shmem region.
This has been tested on ARM64 virtual Qualcomm platform.
---
v4 -> port the changes into smc.c
v3 -> fix the compilation error reported by the test bot,
add support for polling based instances
v2 -> use allOf construct in dtb schema,
remove wrappers from mutexes,
use architecture independent channel layout
v1 -> original patches
Nikunj Kela (4):
firmware: arm_scmi: Add polling support for completion in smc
dt-bindings: arm: convert nested if-else construct to allOf
dt-bindings: arm: Add new compatible for smc/hvc transport for SCMI
firmware: arm_scmi: Add qcom hvc/shmem transport support
.../bindings/firmware/arm,scmi.yaml | 67 +++++++++++--------
drivers/firmware/arm_scmi/Kconfig | 14 ++++
drivers/firmware/arm_scmi/driver.c | 1 +
drivers/firmware/arm_scmi/smc.c | 62 +++++++++++++++--
4 files changed, 110 insertions(+), 34 deletions(-)
--
2.17.1
Gentle Ping! On 9/11/2023 12:43 PM, Nikunj Kela wrote: > This change augments smc transport to include support for Qualcomm virtual > platforms by passing a parameter(capability-id) in the hypervisor call to > identify which doorbell to assert. This parameter is dynamically generated > at runtime on the device and insuitable to pass via the devicetree. > > The function ID and parameter are stored by firmware in the shmem region. > > This has been tested on ARM64 virtual Qualcomm platform. > > --- > v4 -> port the changes into smc.c > > v3 -> fix the compilation error reported by the test bot, > add support for polling based instances > > v2 -> use allOf construct in dtb schema, > remove wrappers from mutexes, > use architecture independent channel layout > > v1 -> original patches > > Nikunj Kela (4): > firmware: arm_scmi: Add polling support for completion in smc > dt-bindings: arm: convert nested if-else construct to allOf > dt-bindings: arm: Add new compatible for smc/hvc transport for SCMI > firmware: arm_scmi: Add qcom hvc/shmem transport support > > .../bindings/firmware/arm,scmi.yaml | 67 +++++++++++-------- > drivers/firmware/arm_scmi/Kconfig | 14 ++++ > drivers/firmware/arm_scmi/driver.c | 1 + > drivers/firmware/arm_scmi/smc.c | 62 +++++++++++++++-- > 4 files changed, 110 insertions(+), 34 deletions(-) >
On 18/09/2023 17:01, Nikunj Kela wrote: > Gentle Ping! Whatever is written with exclamation mark is not really gentle. Especially for second time... and 7 days after posting. 7 days and you ping. Please relax, and help out by reviewing other patches on the mailing lists in order to relieve the burden of maintainers and move your patches higher up the list. Best regards, Krzysztof
On Mon, Sep 18, 2023 at 08:01:26AM -0700, Nikunj Kela wrote: > Gentle Ping! > I will take a look at this later this week. That said, I am unable be gauge the urgency based on you ping here. You have shown the same urgency last time for a feature that I queued promptly just to know that it was abandon within couple of days. So I don't want to rush here simply based on the number of pings here. I need to understand that it is really that important. For now, I am thinking of skipping even v6.7 just to allow some time for Qcom to make up its mind and be absolutely sure this is what they *really* want this time. -- Regards, Sudeep
On Mon, Sep 18, 2023 at 04:15:52PM +0100, Sudeep Holla wrote: > On Mon, Sep 18, 2023 at 08:01:26AM -0700, Nikunj Kela wrote: > > Gentle Ping! > > > > I will take a look at this later this week. That said, I am unable be > gauge the urgency based on you ping here. You have shown the same urgency > last time for a feature that I queued promptly just to know that it was > abandon within couple of days. So I don't want to rush here simply based > on the number of pings here. I need to understand that it is really that > important. For now, I am thinking of skipping even v6.7 just to allow > some time for Qcom to make up its mind and be absolutely sure this is what > they *really* want this time. Hi Sudeep, Red Hat is interested in this patch set. Qualcomm is moving one of their automotive platforms over to use SCMI and this will appear in that product. Brian
On Mon, Sep 18, 2023 at 11:54:25AM -0400, Brian Masney wrote: > On Mon, Sep 18, 2023 at 04:15:52PM +0100, Sudeep Holla wrote: > > On Mon, Sep 18, 2023 at 08:01:26AM -0700, Nikunj Kela wrote: > > > Gentle Ping! > > > > > > > I will take a look at this later this week. That said, I am unable be > > gauge the urgency based on you ping here. You have shown the same urgency > > last time for a feature that I queued promptly just to know that it was > > abandon within couple of days. So I don't want to rush here simply based > > on the number of pings here. I need to understand that it is really that > > important. For now, I am thinking of skipping even v6.7 just to allow > > some time for Qcom to make up its mind and be absolutely sure this is what > > they *really* want this time. > > Hi Sudeep, > > Red Hat is interested in this patch set. Qualcomm is moving one of their > automotive platforms over to use SCMI and this will appear in that > product. > Thanks Brian, I trust Redhat over Qcom 😄. I will try to review and enable progress later this week. We can try to target next merge window. -- Regards, Sudeep
On 9/19/2023 1:56 AM, Sudeep Holla wrote: > On Mon, Sep 18, 2023 at 11:54:25AM -0400, Brian Masney wrote: >> On Mon, Sep 18, 2023 at 04:15:52PM +0100, Sudeep Holla wrote: >>> On Mon, Sep 18, 2023 at 08:01:26AM -0700, Nikunj Kela wrote: >>>> Gentle Ping! >>>> >>> I will take a look at this later this week. That said, I am unable be >>> gauge the urgency based on you ping here. You have shown the same urgency >>> last time for a feature that I queued promptly just to know that it was >>> abandon within couple of days. So I don't want to rush here simply based >>> on the number of pings here. I need to understand that it is really that >>> important. For now, I am thinking of skipping even v6.7 just to allow >>> some time for Qcom to make up its mind and be absolutely sure this is what >>> they *really* want this time. >> Hi Sudeep, >> >> Red Hat is interested in this patch set. Qualcomm is moving one of their >> automotive platforms over to use SCMI and this will appear in that >> product. >> > Thanks Brian, I trust Redhat over Qcom 😄. I will try to review and enable > progress later this week. We can try to target next merge window. > > -- > Regards, > Sudeep Gentle Ping...
On Mon, Oct 02, 2023 at 10:31:27AM -0700, Nikunj Kela wrote: > > On 9/19/2023 1:56 AM, Sudeep Holla wrote: > > On Mon, Sep 18, 2023 at 11:54:25AM -0400, Brian Masney wrote: > > > On Mon, Sep 18, 2023 at 04:15:52PM +0100, Sudeep Holla wrote: > > > > On Mon, Sep 18, 2023 at 08:01:26AM -0700, Nikunj Kela wrote: > > > > > Gentle Ping! > > > > > > > > > I will take a look at this later this week. That said, I am unable be > > > > gauge the urgency based on you ping here. You have shown the same urgency > > > > last time for a feature that I queued promptly just to know that it was > > > > abandon within couple of days. So I don't want to rush here simply based > > > > on the number of pings here. I need to understand that it is really that > > > > important. For now, I am thinking of skipping even v6.7 just to allow > > > > some time for Qcom to make up its mind and be absolutely sure this is what > > > > they *really* want this time. > > > Hi Sudeep, > > > > > > Red Hat is interested in this patch set. Qualcomm is moving one of their > > > automotive platforms over to use SCMI and this will appear in that > > > product. > > > > > Thanks Brian, I trust Redhat over Qcom 😄. I will try to review and enable > > progress later this week. We can try to target next merge window. > > > > -- > > Regards, > > Sudeep > Gentle Ping... Sorry for the delay, both me and Cristian looking at this now. -- Regards, Sudeep
On Mon, Oct 02, 2023 at 10:31:27AM -0700, Nikunj Kela wrote: > > On 9/19/2023 1:56 AM, Sudeep Holla wrote: > > On Mon, Sep 18, 2023 at 11:54:25AM -0400, Brian Masney wrote: > > > On Mon, Sep 18, 2023 at 04:15:52PM +0100, Sudeep Holla wrote: > > > > On Mon, Sep 18, 2023 at 08:01:26AM -0700, Nikunj Kela wrote: > > > > > Gentle Ping! > > > > > > > > > I will take a look at this later this week. That said, I am unable be > > > > gauge the urgency based on you ping here. You have shown the same urgency > > > > last time for a feature that I queued promptly just to know that it was > > > > abandon within couple of days. So I don't want to rush here simply based > > > > on the number of pings here. I need to understand that it is really that > > > > important. For now, I am thinking of skipping even v6.7 just to allow > > > > some time for Qcom to make up its mind and be absolutely sure this is what > > > > they *really* want this time. > > > Hi Sudeep, > > > > > > Red Hat is interested in this patch set. Qualcomm is moving one of their > > > automotive platforms over to use SCMI and this will appear in that > > > product. > > > > > Thanks Brian, I trust Redhat over Qcom 😄. I will try to review and enable > > progress later this week. We can try to target next merge window. > > > > -- > > Regards, > > Sudeep > Gentle Ping... Looking at this tomorrow. Thanks, Cristian
Currently, the return from the smc call assumes the completion of
the scmi request. However this may not be true in virtual platforms
that are using hvc doorbell.
This change adds a Kconfig to enable the polling for the request
completion.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
drivers/firmware/arm_scmi/Kconfig | 14 ++++++++++++++
drivers/firmware/arm_scmi/smc.c | 15 ++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
index ea0f5083ac47..771d60f8319f 100644
--- a/drivers/firmware/arm_scmi/Kconfig
+++ b/drivers/firmware/arm_scmi/Kconfig
@@ -125,6 +125,20 @@ config ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE
in atomic context too, at the price of using a number of busy-waiting
primitives all over instead. If unsure say N.
+config ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
+ bool "Enable polling support for SCMI SMC transport"
+ depends on ARM_SCMI_TRANSPORT_SMC
+ help
+ Enable completion polling support for SCMI SMC based transport.
+
+ If you want the SCMI SMC based transport to poll for the completion,
+ answer Y.
+ Enabling completion polling might be desired in the absence of the a2p
+ irq when the return from smc/hvc call doesn't indicate the completion
+ of the SCMI requests. This might be useful for instances used in
+ virtual platforms.
+ If unsure say N.
+
config ARM_SCMI_TRANSPORT_VIRTIO
bool "SCMI transport based on VirtIO"
depends on VIRTIO=y || VIRTIO=ARM_SCMI_PROTOCOL
diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index c193516a254d..0a0b7e401159 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -250,6 +250,16 @@ static void smc_mark_txdone(struct scmi_chan_info *cinfo, int ret,
smc_channel_lock_release(scmi_info);
}
+#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
+static bool
+smc_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)
+{
+ struct scmi_smc *scmi_info = cinfo->transport_info;
+
+ return shmem_poll_done(scmi_info->shmem, xfer);
+}
+#endif
+
static const struct scmi_transport_ops scmi_smc_ops = {
.chan_available = smc_chan_available,
.chan_setup = smc_chan_setup,
@@ -257,6 +267,9 @@ static const struct scmi_transport_ops scmi_smc_ops = {
.send_message = smc_send_message,
.mark_txdone = smc_mark_txdone,
.fetch_response = smc_fetch_response,
+#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
+ .poll_done = smc_poll_done,
+#endif
};
const struct scmi_desc scmi_smc_desc = {
@@ -272,6 +285,6 @@ const struct scmi_desc scmi_smc_desc = {
* for the issued command will be immmediately ready to be fetched
* from the shared memory area.
*/
- .sync_cmds_completed_on_ret = true,
+ .sync_cmds_completed_on_ret = !IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION),
.atomic_enabled = IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE),
};
--
2.17.1
On Mon, Sep 11, 2023 at 12:43:56PM -0700, Nikunj Kela wrote: > Currently, the return from the smc call assumes the completion of > the scmi request. However this may not be true in virtual platforms > that are using hvc doorbell. > Hmm, it is expectation from SMCCC for the fast calls. Is you HVC FID not a fast call. AFAIK, only TOS use yielding calls. Are you using them here ? If not, this must complete when the SMC/HVC returns. We added support for platforms indicating the same via interrupt. I would like to avoid adding this build config. Why does it require polling ? Broken firmware ? I would add a compatible for that. Or if the qcom always wants to do this way, just make it specific to the qcom compatible. I would avoid a config flag as it needs to be always enabled for single image and affects other platforms as well. So please drop this change. If this is absolutely needed, just add additional property which DT maintainers may not like as it is more like a policy or just make it compatible specific. -- Regards, Sudeep
On 10/3/2023 3:33 AM, Sudeep Holla wrote: > On Mon, Sep 11, 2023 at 12:43:56PM -0700, Nikunj Kela wrote: >> Currently, the return from the smc call assumes the completion of >> the scmi request. However this may not be true in virtual platforms >> that are using hvc doorbell. >> > Hmm, it is expectation from SMCCC for the fast calls. Is you HVC FID > not a fast call. AFAIK, only TOS use yielding calls. Are you using them > here ? If not, this must complete when the SMC/HVC returns. We added > support for platforms indicating the same via interrupt. > > I would like to avoid adding this build config. Why does it require polling ? > Broken firmware ? I would add a compatible for that. Or if the qcom always > wants to do this way, just make it specific to the qcom compatible. > > I would avoid a config flag as it needs to be always enabled for single > image and affects other platforms as well. So please drop this change. > If this is absolutely needed, just add additional property which DT > maintainers may not like as it is more like a policy or just make it > compatible specific. > > -- > Regards, > Sudeep We are using Fast call FID. We are using completion IRQ for all the scmi instances except one where we need to communicate with the server when GIC is in suspended state in HLOS. We will need to poll the channel for completion in that use case. I am open to suggestions.
On Tue, Oct 03, 2023 at 08:53:20AM -0700, Nikunj Kela wrote: > > On 10/3/2023 3:33 AM, Sudeep Holla wrote: > > On Mon, Sep 11, 2023 at 12:43:56PM -0700, Nikunj Kela wrote: > > > Currently, the return from the smc call assumes the completion of > > > the scmi request. However this may not be true in virtual platforms > > > that are using hvc doorbell. > > > > > Hmm, it is expectation from SMCCC for the fast calls. Is you HVC FID > > not a fast call. AFAIK, only TOS use yielding calls. Are you using them > > here ? If not, this must complete when the SMC/HVC returns. We added > > support for platforms indicating the same via interrupt. > > > > I would like to avoid adding this build config. Why does it require polling ? > > Broken firmware ? I would add a compatible for that. Or if the qcom always > > wants to do this way, just make it specific to the qcom compatible. > > > > I would avoid a config flag as it needs to be always enabled for single > > image and affects other platforms as well. So please drop this change. > > If this is absolutely needed, just add additional property which DT > > maintainers may not like as it is more like a policy or just make it > > compatible specific. > > > > -- > > Regards, > > Sudeep > We are using Fast call FID. We are using completion IRQ for all the scmi > instances except one where we need to communicate with the server when GIC > is in suspended state in HLOS. We will need to poll the channel for > completion in that use case. I am open to suggestions. IIUC, for the sake of that one corner case, you have added the polling Kconfig and will be enabled for all the case and even on other platforms in a single Image. I think we could be something better, no ? Please share details on that one corner case. Is it in the scmi drivers already ? If so, specifics please. If no, again provide details on how you plan to use. We do have ways to make a polling call, but haven't mixed it with interrupt based calls for a reason, but we can revisit if it makes sense. -- Regards, Sudeep
On 10/4/2023 9:11 AM, Sudeep Holla wrote: > On Tue, Oct 03, 2023 at 08:53:20AM -0700, Nikunj Kela wrote: >> On 10/3/2023 3:33 AM, Sudeep Holla wrote: >>> On Mon, Sep 11, 2023 at 12:43:56PM -0700, Nikunj Kela wrote: >>>> Currently, the return from the smc call assumes the completion of >>>> the scmi request. However this may not be true in virtual platforms >>>> that are using hvc doorbell. >>>> >>> Hmm, it is expectation from SMCCC for the fast calls. Is you HVC FID >>> not a fast call. AFAIK, only TOS use yielding calls. Are you using them >>> here ? If not, this must complete when the SMC/HVC returns. We added >>> support for platforms indicating the same via interrupt. >>> >>> I would like to avoid adding this build config. Why does it require polling ? >>> Broken firmware ? I would add a compatible for that. Or if the qcom always >>> wants to do this way, just make it specific to the qcom compatible. >>> >>> I would avoid a config flag as it needs to be always enabled for single >>> image and affects other platforms as well. So please drop this change. >>> If this is absolutely needed, just add additional property which DT >>> maintainers may not like as it is more like a policy or just make it >>> compatible specific. >>> >>> -- >>> Regards, >>> Sudeep >> We are using Fast call FID. We are using completion IRQ for all the scmi >> instances except one where we need to communicate with the server when GIC >> is in suspended state in HLOS. We will need to poll the channel for >> completion in that use case. I am open to suggestions. > IIUC, for the sake of that one corner case, you have added the polling > Kconfig and will be enabled for all the case and even on other platforms > in a single Image. I think we could be something better, no ? > > Please share details on that one corner case. > Is it in the scmi drivers already ? If so, specifics please. > If no, again provide details on how you plan to use. We do have ways > to make a polling call, but haven't mixed it with interrupt based calls > for a reason, but we can revisit if it makes sense. > > -- > Regards, > Sudeep Ok. I will discard this patch for now from this series and will explore alternative ways instead of polling that might work in our usecase. If required, will provide you with more details in a separate patch. Thanks!
On Tue, Oct 03, 2023 at 11:33:17AM +0100, Sudeep Holla wrote: > On Mon, Sep 11, 2023 at 12:43:56PM -0700, Nikunj Kela wrote: > > Currently, the return from the smc call assumes the completion of > > the scmi request. However this may not be true in virtual platforms > > that are using hvc doorbell. > > > > Hmm, it is expectation from SMCCC for the fast calls. Is you HVC FID > not a fast call. AFAIK, only TOS use yielding calls. Are you using them > here ? If not, this must complete when the SMC/HVC returns. We added > support for platforms indicating the same via interrupt. > > I would like to avoid adding this build config. Why does it require polling ? > Broken firmware ? I would add a compatible for that. Or if the qcom always > wants to do this way, just make it specific to the qcom compatible. > > I would avoid a config flag as it needs to be always enabled for single > image and affects other platforms as well. So please drop this change. > If this is absolutely needed, just add additional property which DT > maintainers may not like as it is more like a policy or just make it > compatible specific. > Not sure if it could be acceptable or controversial, BUT if there is the need somehow to support polling for yielding calls (depending on the location of the SCMI server), should not we think about doing this by just looking up dynamically the fast-call bits in the provided FID ? Why we need another binding, given that the FID is currently already statically provided by the DT itself (via smc-id) or dynamically by the hypervisor at setup by the changes in this series and the SMCCC spec clearly defines how the IDs are supposed to be formed for fast-atomic-calls ? This way we could enforce the compliance with the SMCCC spec tooo... ...for sure it would require a bit of work in the core, though, given the const nature of some of this structures. Thanks, Cristian
On Mon, Sep 11, 2023 at 12:43:56PM -0700, Nikunj Kela wrote:
> Currently, the return from the smc call assumes the completion of
> the scmi request. However this may not be true in virtual platforms
> that are using hvc doorbell.
>
> This change adds a Kconfig to enable the polling for the request
> completion.
>
> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
> ---
> drivers/firmware/arm_scmi/Kconfig | 14 ++++++++++++++
> drivers/firmware/arm_scmi/smc.c | 15 ++++++++++++++-
> 2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
> index ea0f5083ac47..771d60f8319f 100644
> --- a/drivers/firmware/arm_scmi/Kconfig
> +++ b/drivers/firmware/arm_scmi/Kconfig
> @@ -125,6 +125,20 @@ config ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE
> in atomic context too, at the price of using a number of busy-waiting
> primitives all over instead. If unsure say N.
>
> +config ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
> + bool "Enable polling support for SCMI SMC transport"
> + depends on ARM_SCMI_TRANSPORT_SMC
> + help
> + Enable completion polling support for SCMI SMC based transport.
> +
> + If you want the SCMI SMC based transport to poll for the completion,
> + answer Y.
> + Enabling completion polling might be desired in the absence of the a2p
> + irq when the return from smc/hvc call doesn't indicate the completion
> + of the SCMI requests. This might be useful for instances used in
> + virtual platforms.
> + If unsure say N.
> +
> config ARM_SCMI_TRANSPORT_VIRTIO
> bool "SCMI transport based on VirtIO"
> depends on VIRTIO=y || VIRTIO=ARM_SCMI_PROTOCOL
> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> index c193516a254d..0a0b7e401159 100644
> --- a/drivers/firmware/arm_scmi/smc.c
> +++ b/drivers/firmware/arm_scmi/smc.c
> @@ -250,6 +250,16 @@ static void smc_mark_txdone(struct scmi_chan_info *cinfo, int ret,
> smc_channel_lock_release(scmi_info);
> }
>
> +#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
> +static bool
> +smc_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)
> +{
> + struct scmi_smc *scmi_info = cinfo->transport_info;
> +
> + return shmem_poll_done(scmi_info->shmem, xfer);
> +}
> +#endif
> +
> static const struct scmi_transport_ops scmi_smc_ops = {
> .chan_available = smc_chan_available,
> .chan_setup = smc_chan_setup,
> @@ -257,6 +267,9 @@ static const struct scmi_transport_ops scmi_smc_ops = {
> .send_message = smc_send_message,
> .mark_txdone = smc_mark_txdone,
> .fetch_response = smc_fetch_response,
> +#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
> + .poll_done = smc_poll_done,
> +#endif
> };
>
> const struct scmi_desc scmi_smc_desc = {
> @@ -272,6 +285,6 @@ const struct scmi_desc scmi_smc_desc = {
> * for the issued command will be immmediately ready to be fetched
> * from the shared memory area.
> */
> - .sync_cmds_completed_on_ret = true,
> + .sync_cmds_completed_on_ret = !IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION),
> .atomic_enabled = IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE),
From a Linux distributor viewpoint, it would be nice if this was
determined at runtime, rather than at compile time. We generate a single
kernel binary that's used on systems from multiple hardware
manufacturers. We'd run into an issue if one company required this, but
another one didn't. We may potentially run into this same type of issue
with the upstream arm64 defconfig.
Brian
On 10/2/2023 11:18 AM, Brian Masney wrote:
> On Mon, Sep 11, 2023 at 12:43:56PM -0700, Nikunj Kela wrote:
>> Currently, the return from the smc call assumes the completion of
>> the scmi request. However this may not be true in virtual platforms
>> that are using hvc doorbell.
>>
>> This change adds a Kconfig to enable the polling for the request
>> completion.
>>
>> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
>> ---
>> drivers/firmware/arm_scmi/Kconfig | 14 ++++++++++++++
>> drivers/firmware/arm_scmi/smc.c | 15 ++++++++++++++-
>> 2 files changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
>> index ea0f5083ac47..771d60f8319f 100644
>> --- a/drivers/firmware/arm_scmi/Kconfig
>> +++ b/drivers/firmware/arm_scmi/Kconfig
>> @@ -125,6 +125,20 @@ config ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE
>> in atomic context too, at the price of using a number of busy-waiting
>> primitives all over instead. If unsure say N.
>>
>> +config ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
>> + bool "Enable polling support for SCMI SMC transport"
>> + depends on ARM_SCMI_TRANSPORT_SMC
>> + help
>> + Enable completion polling support for SCMI SMC based transport.
>> +
>> + If you want the SCMI SMC based transport to poll for the completion,
>> + answer Y.
>> + Enabling completion polling might be desired in the absence of the a2p
>> + irq when the return from smc/hvc call doesn't indicate the completion
>> + of the SCMI requests. This might be useful for instances used in
>> + virtual platforms.
>> + If unsure say N.
>> +
>> config ARM_SCMI_TRANSPORT_VIRTIO
>> bool "SCMI transport based on VirtIO"
>> depends on VIRTIO=y || VIRTIO=ARM_SCMI_PROTOCOL
>> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
>> index c193516a254d..0a0b7e401159 100644
>> --- a/drivers/firmware/arm_scmi/smc.c
>> +++ b/drivers/firmware/arm_scmi/smc.c
>> @@ -250,6 +250,16 @@ static void smc_mark_txdone(struct scmi_chan_info *cinfo, int ret,
>> smc_channel_lock_release(scmi_info);
>> }
>>
>> +#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
>> +static bool
>> +smc_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)
>> +{
>> + struct scmi_smc *scmi_info = cinfo->transport_info;
>> +
>> + return shmem_poll_done(scmi_info->shmem, xfer);
>> +}
>> +#endif
>> +
>> static const struct scmi_transport_ops scmi_smc_ops = {
>> .chan_available = smc_chan_available,
>> .chan_setup = smc_chan_setup,
>> @@ -257,6 +267,9 @@ static const struct scmi_transport_ops scmi_smc_ops = {
>> .send_message = smc_send_message,
>> .mark_txdone = smc_mark_txdone,
>> .fetch_response = smc_fetch_response,
>> +#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION
>> + .poll_done = smc_poll_done,
>> +#endif
>> };
>>
>> const struct scmi_desc scmi_smc_desc = {
>> @@ -272,6 +285,6 @@ const struct scmi_desc scmi_smc_desc = {
>> * for the issued command will be immmediately ready to be fetched
>> * from the shared memory area.
>> */
>> - .sync_cmds_completed_on_ret = true,
>> + .sync_cmds_completed_on_ret = !IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_POLL_COMPLETION),
>> .atomic_enabled = IS_ENABLED(CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE),
> From a Linux distributor viewpoint, it would be nice if this was
> determined at runtime, rather than at compile time. We generate a single
> kernel binary that's used on systems from multiple hardware
> manufacturers. We'd run into an issue if one company required this, but
> another one didn't. We may potentially run into this same type of issue
> with the upstream arm64 defconfig.
>
> Brian
This is a transport dependent property. Either the transport supports
"completion on return of the smc call" or not. For a given platform,
this will be fixed for all channels. This is similar to
CONFIG_ARM_SCMI_TRANSPORT_SMC_ATOMIC_ENABLE which is also a Kconfig.
Nested if-else construct is not scalable therefore, convert
it to allOf:if-else.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
.../bindings/firmware/arm,scmi.yaml | 55 +++++++++----------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index b138f3d23df8..8d54ea768d38 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -284,35 +284,34 @@ $defs:
required:
- compatible
-if:
- properties:
- compatible:
- contains:
- const: arm,scmi
-then:
- properties:
- interrupts: false
- interrupt-names: false
-
- required:
- - mboxes
- - shmem
-
-else:
- if:
- properties:
- compatible:
- contains:
- enum:
- - arm,scmi-smc
- - arm,scmi-smc-param
- then:
- required:
- - arm,smc-id
- - shmem
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: arm,scmi
+ then:
+ properties:
+ interrupts: false
+ interrupt-names: false
+
+ required:
+ - mboxes
+ - shmem
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - arm,scmi-smc
+ - arm,scmi-smc-param
+ then:
+ required:
+ - arm,smc-id
+ - shmem
- else:
- if:
+ - if:
properties:
compatible:
contains:
--
2.17.1
Introduce compatible "qcom,scmi-hvc-shmem" for SCMI smc/hvc
transport channel for Qualcomm virtual platforms.
The compatible mandates a shared memory channel.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
.../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index 8d54ea768d38..4090240f45b1 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -45,6 +45,9 @@ properties:
- description: SCMI compliant firmware with OP-TEE transport
items:
- const: linaro,scmi-optee
+ - description: SCMI compliant firmware with Qualcomm hvc/shmem transport
+ items:
+ - const: qcom,scmi-hvc-shmem
interrupts:
description:
@@ -320,6 +323,15 @@ allOf:
required:
- linaro,optee-channel-id
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: qcom,scmi-hvc-shmem
+ then:
+ required:
+ - shmem
+
examples:
- |
firmware {
--
2.17.1
On Mon, Sep 11, 2023 at 12:43:58PM -0700, Nikunj Kela wrote:
> Introduce compatible "qcom,scmi-hvc-shmem" for SCMI smc/hvc
> transport channel for Qualcomm virtual platforms.
> The compatible mandates a shared memory channel.
>
> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
> .../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
> index 8d54ea768d38..4090240f45b1 100644
> --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
> +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
> @@ -45,6 +45,9 @@ properties:
> - description: SCMI compliant firmware with OP-TEE transport
> items:
> - const: linaro,scmi-optee
> + - description: SCMI compliant firmware with Qualcomm hvc/shmem transport
> + items:
> + - const: qcom,scmi-hvc-shmem
Can it be simply "qcom,scmi-smc" for 2 reasons ?
1. We don't support SMC/HVC without shmem, so what is your argument to add
'-shmem' in the compatible here ?
2. The exact conduit(SMC/HVC) used is detected runtime, so I prefer to keep
'-smc' instead of '-hvc' in the compatible just to avoid giving an illusion
that HVC is the conduit chosen here based on the compatible. It can be true
for other reason but I don't want to mislead here by using HVC.
>
> interrupts:
> description:
> @@ -320,6 +323,15 @@ allOf:
> required:
> - linaro,optee-channel-id
>
> + - if:
> + properties:
> + compatible:
> + contains:
> + const: qcom,scmi-hvc-shmem
> + then:
> + required:
> + - shmem
> +
> examples:
> - |
> firmware {
> --
> 2.17.1
>
--
Regards,
Sudeep
On 10/3/2023 3:44 AM, Sudeep Holla wrote:
> On Mon, Sep 11, 2023 at 12:43:58PM -0700, Nikunj Kela wrote:
>> Introduce compatible "qcom,scmi-hvc-shmem" for SCMI smc/hvc
>> transport channel for Qualcomm virtual platforms.
>> The compatible mandates a shared memory channel.
>>
>> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
>> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>> ---
>> .../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
>> index 8d54ea768d38..4090240f45b1 100644
>> --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
>> +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
>> @@ -45,6 +45,9 @@ properties:
>> - description: SCMI compliant firmware with OP-TEE transport
>> items:
>> - const: linaro,scmi-optee
>> + - description: SCMI compliant firmware with Qualcomm hvc/shmem transport
>> + items:
>> + - const: qcom,scmi-hvc-shmem
> Can it be simply "qcom,scmi-smc" for 2 reasons ?
> 1. We don't support SMC/HVC without shmem, so what is your argument to add
> '-shmem' in the compatible here ?
In our platforms, there are multiple ways to allocate memory. One is
preallocated shmem as used here, another is dynamically by hypervisor
APIs. shmem was to just to indicate it is preallocated.
> 2. The exact conduit(SMC/HVC) used is detected runtime, so I prefer to keep
> '-smc' instead of '-hvc' in the compatible just to avoid giving an illusion
> that HVC is the conduit chosen here based on the compatible. It can be true
> for other reason but I don't want to mislead here by using HVC.
IUUC, currently, conduit comes from PSCI dt node. We have been using smc
for PSCI but want to use hvc here. That being said, I am fine to explore
if we can change PSCI to use hvc too.
>> interrupts:
>> description:
>> @@ -320,6 +323,15 @@ allOf:
>> required:
>> - linaro,optee-channel-id
>>
>> + - if:
>> + properties:
>> + compatible:
>> + contains:
>> + const: qcom,scmi-hvc-shmem
>> + then:
>> + required:
>> + - shmem
>> +
>> examples:
>> - |
>> firmware {
>> --
>> 2.17.1
>>
On Tue, Oct 03, 2023 at 08:59:45AM -0700, Nikunj Kela wrote: > > On 10/3/2023 3:44 AM, Sudeep Holla wrote: > > On Mon, Sep 11, 2023 at 12:43:58PM -0700, Nikunj Kela wrote: > > > Introduce compatible "qcom,scmi-hvc-shmem" for SCMI smc/hvc > > > transport channel for Qualcomm virtual platforms. > > > The compatible mandates a shared memory channel. > > > > > > Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> > > > Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> > > > --- > > > .../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++ > > > 1 file changed, 12 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml > > > index 8d54ea768d38..4090240f45b1 100644 > > > --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml > > > +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml > > > @@ -45,6 +45,9 @@ properties: > > > - description: SCMI compliant firmware with OP-TEE transport > > > items: > > > - const: linaro,scmi-optee > > > + - description: SCMI compliant firmware with Qualcomm hvc/shmem transport > > > + items: > > > + - const: qcom,scmi-hvc-shmem > > Can it be simply "qcom,scmi-smc" for 2 reasons ? > > 1. We don't support SMC/HVC without shmem, so what is your argument to add > > '-shmem' in the compatible here ? > > In our platforms, there are multiple ways to allocate memory. One is > preallocated shmem as used here, another is dynamically by hypervisor APIs. > shmem was to just to indicate it is preallocated. > Let us keep it without shmem. If it is dynamically allocated, you must not need another compatible as you can check it at the runtime. > > > 2. The exact conduit(SMC/HVC) used is detected runtime, so I prefer to keep > > '-smc' instead of '-hvc' in the compatible just to avoid giving an illusion > > that HVC is the conduit chosen here based on the compatible. It can be true > > for other reason but I don't want to mislead here by using HVC. > > IUUC, currently, conduit comes from PSCI dt node. We have been using smc for > PSCI but want to use hvc here. That being said, I am fine to explore if we > can change PSCI to use hvc too. > I think only OPTEE has explicit conduit other than PSCI and it is continued for legacy/compatibility reasons IIUC and IIRC. Anything else depends on the conduit used by PSCI to be consistent. So yes you need to use what the PSCI conduit is and you don't need the extra information from the DT either as new property or in the compatible. -- Regards, Sudeep
On 10/4/2023 8:53 AM, Sudeep Holla wrote: > On Tue, Oct 03, 2023 at 08:59:45AM -0700, Nikunj Kela wrote: >> On 10/3/2023 3:44 AM, Sudeep Holla wrote: >>> On Mon, Sep 11, 2023 at 12:43:58PM -0700, Nikunj Kela wrote: >>>> Introduce compatible "qcom,scmi-hvc-shmem" for SCMI smc/hvc >>>> transport channel for Qualcomm virtual platforms. >>>> The compatible mandates a shared memory channel. >>>> >>>> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> >>>> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> >>>> --- >>>> .../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++ >>>> 1 file changed, 12 insertions(+) >>>> >>>> diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml >>>> index 8d54ea768d38..4090240f45b1 100644 >>>> --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml >>>> +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml >>>> @@ -45,6 +45,9 @@ properties: >>>> - description: SCMI compliant firmware with OP-TEE transport >>>> items: >>>> - const: linaro,scmi-optee >>>> + - description: SCMI compliant firmware with Qualcomm hvc/shmem transport >>>> + items: >>>> + - const: qcom,scmi-hvc-shmem >>> Can it be simply "qcom,scmi-smc" for 2 reasons ? >>> 1. We don't support SMC/HVC without shmem, so what is your argument to add >>> '-shmem' in the compatible here ? >> In our platforms, there are multiple ways to allocate memory. One is >> preallocated shmem as used here, another is dynamically by hypervisor APIs. >> shmem was to just to indicate it is preallocated. >> > Let us keep it without shmem. If it is dynamically allocated, you must not > need another compatible as you can check it at the runtime. > >>> 2. The exact conduit(SMC/HVC) used is detected runtime, so I prefer to keep >>> '-smc' instead of '-hvc' in the compatible just to avoid giving an illusion >>> that HVC is the conduit chosen here based on the compatible. It can be true >>> for other reason but I don't want to mislead here by using HVC. >> IUUC, currently, conduit comes from PSCI dt node. We have been using smc for >> PSCI but want to use hvc here. That being said, I am fine to explore if we >> can change PSCI to use hvc too. >> > I think only OPTEE has explicit conduit other than PSCI and it is continued > for legacy/compatibility reasons IIUC and IIRC. Anything else depends on > the conduit used by PSCI to be consistent. So yes you need to use what the > PSCI conduit is and you don't need the extra information from the DT either > as new property or in the compatible. Ok, will use conduit then. Thanks! >
This change adds the support for SCMI message exchange on Qualcomm
virtual platforms.
The hypervisor associates an object-id also known as capability-id
with each hvc doorbell object. The capability-id is used to identify the
doorbell from the VM's capability namespace, similar to a file-descriptor.
The hypervisor, in addition to the function-id, expects the capability-id
to be passed in x1 register when HVC call is invoked.
The function-id & capability-id are allocated by the hypervisor on bootup
and are stored in the shmem region by the firmware before starting Linux.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
drivers/firmware/arm_scmi/driver.c | 1 +
drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
2 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 87383c05424b..ea344bc6ae49 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
#ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
{ .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
{ .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
+ { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
index 0a0b7e401159..94ec07fdc14a 100644
--- a/drivers/firmware/arm_scmi/smc.c
+++ b/drivers/firmware/arm_scmi/smc.c
@@ -50,6 +50,9 @@
* @func_id: smc/hvc call function id
* @param_page: 4K page number of the shmem channel
* @param_offset: Offset within the 4K page of the shmem channel
+ * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
+ * platforms
+ * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
*/
struct scmi_smc {
@@ -63,6 +66,8 @@ struct scmi_smc {
u32 func_id;
u32 param_page;
u32 param_offset;
+ u64 cap_id;
+ bool qcom_xport;
};
static irqreturn_t smc_msg_done_isr(int irq, void *data)
@@ -129,6 +134,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
struct resource res;
struct device_node *np;
u32 func_id;
+ u64 cap_id;
int ret;
if (!tx)
@@ -158,9 +164,34 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
return -EADDRNOTAVAIL;
}
- ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
- if (ret < 0)
- return ret;
+ if (of_device_is_compatible(dev->of_node, "qcom,scmi-hvc-shmem")) {
+ scmi_info->qcom_xport = true;
+
+ /* The func-id & capability-id are kept in last 16 bytes of shmem.
+ * +-------+
+ * | |
+ * | shmem |
+ * | |
+ * | |
+ * +-------+ <-- (size - 16)
+ * | funcId|
+ * +-------+ <-- (size - 8)
+ * | capId |
+ * +-------+ <-- size
+ */
+
+ func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
+#ifdef CONFIG_ARM64
+ cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
+#else
+ /* capability-id is 32 bit wide on 32bit machines */
+ cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8);
+#endif
+ } else {
+ ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
+ if (ret < 0)
+ return ret;
+ }
if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
scmi_info->param_page = SHMEM_PAGE(res.start);
@@ -184,6 +215,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
}
scmi_info->func_id = func_id;
+ scmi_info->cap_id = cap_id;
scmi_info->cinfo = cinfo;
smc_channel_lock_init(scmi_info);
cinfo->transport_info = scmi_info;
@@ -213,6 +245,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
struct arm_smccc_res res;
unsigned long page = scmi_info->param_page;
unsigned long offset = scmi_info->param_offset;
+ unsigned long cap_id = (unsigned long)scmi_info->cap_id;
/*
* Channel will be released only once response has been
@@ -222,8 +255,12 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
- arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
- &res);
+ if (scmi_info->qcom_xport)
+ arm_smccc_1_1_hvc(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0, 0,
+ &res);
+ else
+ arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0,
+ 0, 0, &res);
/* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
if (res.a0) {
--
2.17.1
On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
> This change adds the support for SCMI message exchange on Qualcomm
> virtual platforms.
>
> The hypervisor associates an object-id also known as capability-id
> with each hvc doorbell object. The capability-id is used to identify the
> doorbell from the VM's capability namespace, similar to a file-descriptor.
>
> The hypervisor, in addition to the function-id, expects the capability-id
> to be passed in x1 register when HVC call is invoked.
>
> The function-id & capability-id are allocated by the hypervisor on bootup
> and are stored in the shmem region by the firmware before starting Linux.
>
> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
> ---
> drivers/firmware/arm_scmi/driver.c | 1 +
> drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
> 2 files changed, 43 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 87383c05424b..ea344bc6ae49 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
> #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
> { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
> { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
> + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
> #endif
> #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
> { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> index 0a0b7e401159..94ec07fdc14a 100644
> --- a/drivers/firmware/arm_scmi/smc.c
> +++ b/drivers/firmware/arm_scmi/smc.c
> @@ -50,6 +50,9 @@
> * @func_id: smc/hvc call function id
> * @param_page: 4K page number of the shmem channel
> * @param_offset: Offset within the 4K page of the shmem channel
> + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
> + * platforms
> + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
> */
>
> struct scmi_smc {
> @@ -63,6 +66,8 @@ struct scmi_smc {
> u32 func_id;
> u32 param_page;
> u32 param_offset;
> + u64 cap_id;
Can it be unsigned long instead so that it just works for both 32 and 64 bit.
> + bool qcom_xport;
Do we really need this ?
> };
>
> static irqreturn_t smc_msg_done_isr(int irq, void *data)
> @@ -129,6 +134,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> struct resource res;
> struct device_node *np;
> u32 func_id;
> + u64 cap_id;
Ditto..
> int ret;
>
> if (!tx)
> @@ -158,9 +164,34 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> return -EADDRNOTAVAIL;
> }
>
> - ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
> - if (ret < 0)
> - return ret;
> + if (of_device_is_compatible(dev->of_node, "qcom,scmi-hvc-shmem")) {
> + scmi_info->qcom_xport = true;
> +
> + /* The func-id & capability-id are kept in last 16 bytes of shmem.
> + * +-------+
> + * | |
> + * | shmem |
> + * | |
> + * | |
> + * +-------+ <-- (size - 16)
> + * | funcId|
> + * +-------+ <-- (size - 8)
> + * | capId |
> + * +-------+ <-- size
> + */
> +
> + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
So unlike 'arm,scmi-smc', you don't want 'arm,smc-id' in the DT ? Any
particular reason ? Just to get both FID and cap ID from shmem ?
> +#ifdef CONFIG_ARM64
I would rather make this arch agnostic using CONFIG_64BIT
> + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
Do you need __iomem typecast here ? Is scmi_info->shmem not already __iomem ?
Also scmi_info->shmem is ioremapped just few steps above and you are using
read* here, is that safe ?
> +#else
> + /* capability-id is 32 bit wide on 32bit machines */
> + cap_id = rieadl((void __iomem *)(scmi_info->shmem) + size - 8);
Other thought once you move for u64 to unsigned long you need not have
#ifdeffery, just do copy of sizeof(unsigned long)
> +#endif
> + } else {
> + ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
> + if (ret < 0)
> + return ret;
> + }
>
> if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
> scmi_info->param_page = SHMEM_PAGE(res.start);
> @@ -184,6 +215,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> }
>
> scmi_info->func_id = func_id;
> + scmi_info->cap_id = cap_id;
> scmi_info->cinfo = cinfo;
> smc_channel_lock_init(scmi_info);
> cinfo->transport_info = scmi_info;
> @@ -213,6 +245,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
> struct arm_smccc_res res;
> unsigned long page = scmi_info->param_page;
> unsigned long offset = scmi_info->param_offset;
> + unsigned long cap_id = (unsigned long)scmi_info->cap_id;
>
> /*
> * Channel will be released only once response has been
> @@ -222,8 +255,12 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>
> shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
>
> - arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
> - &res);
> + if (scmi_info->qcom_xport)
Just make sure cap_id is set only for qcom and just use that as your flag.
No point in setting always true scmi_info->qcom_xport and using it here.
> + arm_smccc_1_1_hvc(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0, 0,
> + &res);
> + else
> + arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0,
> + 0, 0, &res);
>
> /* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
> if (res.a0) {
> --
> 2.17.1
>
--
Regards,
Sudeep
On 10/3/2023 4:19 AM, Sudeep Holla wrote:
> On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
>> This change adds the support for SCMI message exchange on Qualcomm
>> virtual platforms.
>>
>> The hypervisor associates an object-id also known as capability-id
>> with each hvc doorbell object. The capability-id is used to identify the
>> doorbell from the VM's capability namespace, similar to a file-descriptor.
>>
>> The hypervisor, in addition to the function-id, expects the capability-id
>> to be passed in x1 register when HVC call is invoked.
>>
>> The function-id & capability-id are allocated by the hypervisor on bootup
>> and are stored in the shmem region by the firmware before starting Linux.
>>
>> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
>> ---
>> drivers/firmware/arm_scmi/driver.c | 1 +
>> drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
>> 2 files changed, 43 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
>> index 87383c05424b..ea344bc6ae49 100644
>> --- a/drivers/firmware/arm_scmi/driver.c
>> +++ b/drivers/firmware/arm_scmi/driver.c
>> @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
>> #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
>> { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
>> { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
>> + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
>> #endif
>> #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
>> { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
>> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
>> index 0a0b7e401159..94ec07fdc14a 100644
>> --- a/drivers/firmware/arm_scmi/smc.c
>> +++ b/drivers/firmware/arm_scmi/smc.c
>> @@ -50,6 +50,9 @@
>> * @func_id: smc/hvc call function id
>> * @param_page: 4K page number of the shmem channel
>> * @param_offset: Offset within the 4K page of the shmem channel
>> + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
>> + * platforms
>> + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
>> */
>>
>> struct scmi_smc {
>> @@ -63,6 +66,8 @@ struct scmi_smc {
>> u32 func_id;
>> u32 param_page;
>> u32 param_offset;
>> + u64 cap_id;
> Can it be unsigned long instead so that it just works for both 32 and 64 bit.
My first version of this patch was ulong but Bjorn suggested to make
this structure size fixed i.e. architecture independent. Hence changed
it to u64. If you are ok with ulong, I can change it back to ulong.
>
>> + bool qcom_xport;
> Do we really need this ?
Not if we initialize it with a negative value since 0 is a valid value
for cap-id.
>
>> };
>>
>> static irqreturn_t smc_msg_done_isr(int irq, void *data)
>> @@ -129,6 +134,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
>> struct resource res;
>> struct device_node *np;
>> u32 func_id;
>> + u64 cap_id;
> Ditto..
Answered in earlier comment.
>> int ret;
>>
>> if (!tx)
>> @@ -158,9 +164,34 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
>> return -EADDRNOTAVAIL;
>> }
>>
>> - ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
>> - if (ret < 0)
>> - return ret;
>> + if (of_device_is_compatible(dev->of_node, "qcom,scmi-hvc-shmem")) {
>> + scmi_info->qcom_xport = true;
>> +
>> + /* The func-id & capability-id are kept in last 16 bytes of shmem.
>> + * +-------+
>> + * | |
>> + * | shmem |
>> + * | |
>> + * | |
>> + * +-------+ <-- (size - 16)
>> + * | funcId|
>> + * +-------+ <-- (size - 8)
>> + * | capId |
>> + * +-------+ <-- size
>> + */
>> +
>> + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
> So unlike 'arm,scmi-smc', you don't want 'arm,smc-id' in the DT ? Any
> particular reason ? Just to get both FID and cap ID from shmem ?
I could use smc-id binding for func-id, it's just two parameters will
come from two different places so thought of keeping everything at one
place to maintain consistency. Since DT can't take cap-id, I decided to
move func-id. I am fine if you want me to use smc-id binding.
>> +#ifdef CONFIG_ARM64
> I would rather make this arch agnostic using CONFIG_64BIT
ok.
>
>> + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
> Do you need __iomem typecast here ? Is scmi_info->shmem not already __iomem ?
> Also scmi_info->shmem is ioremapped just few steps above and you are using
> read* here, is that safe ?
I saw some compilation warnings without __iomem. I will use ioread* API
instead of read*.
>
>> +#else
>> + /* capability-id is 32 bit wide on 32bit machines */
>> + cap_id = rieadl((void __iomem *)(scmi_info->shmem) + size - 8);
> Other thought once you move for u64 to unsigned long you need not have
> #ifdeffery, just do copy of sizeof(unsigned long)
Right, my first version was like that only.
>
>> +#endif
>> + } else {
>> + ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
>> + if (ret < 0)
>> + return ret;
>> + }
>>
>> if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
>> scmi_info->param_page = SHMEM_PAGE(res.start);
>> @@ -184,6 +215,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
>> }
>>
>> scmi_info->func_id = func_id;
>> + scmi_info->cap_id = cap_id;
>> scmi_info->cinfo = cinfo;
>> smc_channel_lock_init(scmi_info);
>> cinfo->transport_info = scmi_info;
>> @@ -213,6 +245,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>> struct arm_smccc_res res;
>> unsigned long page = scmi_info->param_page;
>> unsigned long offset = scmi_info->param_offset;
>> + unsigned long cap_id = (unsigned long)scmi_info->cap_id;
>>
>> /*
>> * Channel will be released only once response has been
>> @@ -222,8 +255,12 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>>
>> shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
>>
>> - arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
>> - &res);
>> + if (scmi_info->qcom_xport)
> Just make sure cap_id is set only for qcom and just use that as your flag.
> No point in setting always true scmi_info->qcom_xport and using it here.
ok, I can remove that. Though 0 is a valid value for cap-id so will have
to init cap-id with a negative value.
>
>> + arm_smccc_1_1_hvc(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0, 0,
>> + &res);
>> + else
>> + arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0,
>> + 0, 0, &res);
>>
>> /* Only SMCCC_RET_NOT_SUPPORTED is valid error code */
>> if (res.a0) {
>> --
>> 2.17.1
>>
On Tue, Oct 03, 2023 at 09:16:27AM -0700, Nikunj Kela wrote:
>
> On 10/3/2023 4:19 AM, Sudeep Holla wrote:
> > On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
> > > This change adds the support for SCMI message exchange on Qualcomm
> > > virtual platforms.
> > >
> > > The hypervisor associates an object-id also known as capability-id
> > > with each hvc doorbell object. The capability-id is used to identify the
> > > doorbell from the VM's capability namespace, similar to a file-descriptor.
> > >
> > > The hypervisor, in addition to the function-id, expects the capability-id
> > > to be passed in x1 register when HVC call is invoked.
> > >
> > > The function-id & capability-id are allocated by the hypervisor on bootup
> > > and are stored in the shmem region by the firmware before starting Linux.
> > >
> > > Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
> > > ---
> > > drivers/firmware/arm_scmi/driver.c | 1 +
> > > drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
> > > 2 files changed, 43 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> > > index 87383c05424b..ea344bc6ae49 100644
> > > --- a/drivers/firmware/arm_scmi/driver.c
> > > +++ b/drivers/firmware/arm_scmi/driver.c
> > > @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
> > > #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
> > > { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
> > > { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
> > > + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
> > > #endif
> > > #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
> > > { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
> > > diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> > > index 0a0b7e401159..94ec07fdc14a 100644
> > > --- a/drivers/firmware/arm_scmi/smc.c
> > > +++ b/drivers/firmware/arm_scmi/smc.c
> > > @@ -50,6 +50,9 @@
> > > * @func_id: smc/hvc call function id
> > > * @param_page: 4K page number of the shmem channel
> > > * @param_offset: Offset within the 4K page of the shmem channel
> > > + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
> > > + * platforms
> > > + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
> > > */
> > > struct scmi_smc {
> > > @@ -63,6 +66,8 @@ struct scmi_smc {
> > > u32 func_id;
> > > u32 param_page;
> > > u32 param_offset;
> > > + u64 cap_id;
> > Can it be unsigned long instead so that it just works for both 32 and 64 bit.
>
> My first version of this patch was ulong but Bjorn suggested to make this
> structure size fixed i.e. architecture independent. Hence changed it to u64.
> If you are ok with ulong, I can change it back to ulong.
>
SMCCC pre-v1.2 used the common structure in that way. I don't see any issue
with that. I haven't followed Bjorn suggestions/comments though.
>
> >
> > > + bool qcom_xport;
> > Do we really need this ?
>
> Not if we initialize it with a negative value since 0 is a valid value for
> cap-id.
>
Fine with negative value(-EINVAL may be).
> > > int ret;
> > > if (!tx)
> > > @@ -158,9 +164,34 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> > > return -EADDRNOTAVAIL;
> > > }
> > > - ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
> > > - if (ret < 0)
> > > - return ret;
> > > + if (of_device_is_compatible(dev->of_node, "qcom,scmi-hvc-shmem")) {
> > > + scmi_info->qcom_xport = true;
> > > +
> > > + /* The func-id & capability-id are kept in last 16 bytes of shmem.
> > > + * +-------+
> > > + * | |
> > > + * | shmem |
> > > + * | |
> > > + * | |
> > > + * +-------+ <-- (size - 16)
> > > + * | funcId|
> > > + * +-------+ <-- (size - 8)
> > > + * | capId |
> > > + * +-------+ <-- size
> > > + */
> > > +
> > > + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
> > So unlike 'arm,scmi-smc', you don't want 'arm,smc-id' in the DT ? Any
> > particular reason ? Just to get both FID and cap ID from shmem ?
>
I am fine either way. If you use from DT(via arm,smc-id), then "qcom,scmi"
can be just addition compatible that expects you to read cap-id from the
shmem. May need adjustment in the binding as you allow both
"qcom,scmi-smc", "arm,scmi-smc". I will leave the details to you.
> I could use smc-id binding for func-id, it's just two parameters will come
> from two different places so thought of keeping everything at one place to
> maintain consistency. Since DT can't take cap-id, I decided to move
> func-id. I am fine if you want me to use smc-id binding.
>
Up to you. If you want to make "qcom,scmi-smc" and "arm,scmi-smc"
compatible in way in that way or you can keep it incompatible as you have
proposed in this patch set.
>
> > > +#ifdef CONFIG_ARM64
> > I would rather make this arch agnostic using CONFIG_64BIT
> ok.
> >
> > > + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
> > Do you need __iomem typecast here ? Is scmi_info->shmem not already __iomem ?
> > Also scmi_info->shmem is ioremapped just few steps above and you are using
> > read* here, is that safe ?
>
> I saw some compilation warnings without __iomem. I will use ioread* API
> instead of read*.
>
That was the clue that you were using __iomem with read* calls IMO.
>
> >
> > > +#else
> > > + /* capability-id is 32 bit wide on 32bit machines */
> > > + cap_id = rieadl((void __iomem *)(scmi_info->shmem) + size - 8);
> > Other thought once you move for u64 to unsigned long you need not have
> > #ifdeffery, just do copy of sizeof(unsigned long)
> Right, my first version was like that only.
OK
> >
> > > +#endif
> > > + } else {
> > > + ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
> > > + if (ret < 0)
> > > + return ret;
> > > + }
> > > if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
> > > scmi_info->param_page = SHMEM_PAGE(res.start);
> > > @@ -184,6 +215,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> > > }
> > > scmi_info->func_id = func_id;
> > > + scmi_info->cap_id = cap_id;
> > > scmi_info->cinfo = cinfo;
> > > smc_channel_lock_init(scmi_info);
> > > cinfo->transport_info = scmi_info;
> > > @@ -213,6 +245,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
> > > struct arm_smccc_res res;
> > > unsigned long page = scmi_info->param_page;
> > > unsigned long offset = scmi_info->param_offset;
> > > + unsigned long cap_id = (unsigned long)scmi_info->cap_id;
> > > /*
> > > * Channel will be released only once response has been
> > > @@ -222,8 +255,12 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
> > > shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
> > > - arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
> > > - &res);
> > > + if (scmi_info->qcom_xport)
> > Just make sure cap_id is set only for qcom and just use that as your flag.
> > No point in setting always true scmi_info->qcom_xport and using it here.
> ok, I can remove that. Though 0 is a valid value for cap-id so will have to
> init cap-id with a negative value.
Yes as mentioned above.
--
Regards,
Sudeep
On Wed, Oct 04, 2023 at 05:06:30PM +0100, Sudeep Holla wrote:
> On Tue, Oct 03, 2023 at 09:16:27AM -0700, Nikunj Kela wrote:
> > On 10/3/2023 4:19 AM, Sudeep Holla wrote:
> > > On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
> > > > diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
[..]
> > > > @@ -63,6 +66,8 @@ struct scmi_smc {
> > > > u32 func_id;
> > > > u32 param_page;
> > > > u32 param_offset;
> > > > + u64 cap_id;
> > > Can it be unsigned long instead so that it just works for both 32 and 64 bit.
> >
> > My first version of this patch was ulong but Bjorn suggested to make this
> > structure size fixed i.e. architecture independent. Hence changed it to u64.
> > If you are ok with ulong, I can change it back to ulong.
> >
>
> SMCCC pre-v1.2 used the common structure in that way. I don't see any issue
> with that. I haven't followed Bjorn suggestions/comments though.
>
My request was that funcId and capId is an ABI between the firmware and
the OS, so I'd like for that to use well defined, fixed sized, data
types - if nothing else just for documentation purpose.
These values will be truncated when passed to arm_smccc_1_1_invoke()
anyways, so I don't have any opinion against using unsigned long here...
PS. I understand why func_id is u32, but why are param_page and
param_offset u32?
Regards,
Bjorn
On Thu, Oct 05, 2023 at 03:20:16PM -0700, Bjorn Andersson wrote:
> On Wed, Oct 04, 2023 at 05:06:30PM +0100, Sudeep Holla wrote:
> > On Tue, Oct 03, 2023 at 09:16:27AM -0700, Nikunj Kela wrote:
> > > On 10/3/2023 4:19 AM, Sudeep Holla wrote:
> > > > On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
> > > > > diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> [..]
> > > > > @@ -63,6 +66,8 @@ struct scmi_smc {
> > > > > u32 func_id;
> > > > > u32 param_page;
> > > > > u32 param_offset;
> > > > > + u64 cap_id;
> > > > Can it be unsigned long instead so that it just works for both 32 and 64 bit.
> > >
> > > My first version of this patch was ulong but Bjorn suggested to make this
> > > structure size fixed i.e. architecture independent. Hence changed it to u64.
> > > If you are ok with ulong, I can change it back to ulong.
> > >
> >
> > SMCCC pre-v1.2 used the common structure in that way. I don't see any issue
> > with that. I haven't followed Bjorn suggestions/comments though.
> >
>
> My request was that funcId and capId is an ABI between the firmware and
> the OS, so I'd like for that to use well defined, fixed sized, data
> types - if nothing else just for documentation purpose.
>
> These values will be truncated when passed to arm_smccc_1_1_invoke()
> anyways, so I don't have any opinion against using unsigned long here...
>
>
> PS. I understand why func_id is u32, but why are param_page and
> param_offset u32?
>
Good point. Sorry I somehow missed your original comment, my bad.
Yes, it is good to be consistent. Sorry if I added any confusion by
missing o read your comment and understanding it before I responded.
--
Regards,
Sudeep
On 10/5/2023 3:20 PM, Bjorn Andersson wrote:
> On Wed, Oct 04, 2023 at 05:06:30PM +0100, Sudeep Holla wrote:
>> On Tue, Oct 03, 2023 at 09:16:27AM -0700, Nikunj Kela wrote:
>>> On 10/3/2023 4:19 AM, Sudeep Holla wrote:
>>>> On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
>>>>> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> [..]
>>>>> @@ -63,6 +66,8 @@ struct scmi_smc {
>>>>> u32 func_id;
>>>>> u32 param_page;
>>>>> u32 param_offset;
>>>>> + u64 cap_id;
>>>> Can it be unsigned long instead so that it just works for both 32 and 64 bit.
>>> My first version of this patch was ulong but Bjorn suggested to make this
>>> structure size fixed i.e. architecture independent. Hence changed it to u64.
>>> If you are ok with ulong, I can change it back to ulong.
>>>
>> SMCCC pre-v1.2 used the common structure in that way. I don't see any issue
>> with that. I haven't followed Bjorn suggestions/comments though.
>>
> My request was that funcId and capId is an ABI between the firmware and
> the OS, so I'd like for that to use well defined, fixed sized, data
> types - if nothing else just for documentation purpose.
>
> These values will be truncated when passed to arm_smccc_1_1_invoke()
> anyways, so I don't have any opinion against using unsigned long here...
>
>
> PS. I understand why func_id is u32, but why are param_page and
> param_offset u32?
That was done to keep it uniform across smc32/smc64 conventions.
>
> Regards,
> Bjorn
On 10/4/2023 9:06 AM, Sudeep Holla wrote:
> On Tue, Oct 03, 2023 at 09:16:27AM -0700, Nikunj Kela wrote:
>> On 10/3/2023 4:19 AM, Sudeep Holla wrote:
>>> On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
>>>> This change adds the support for SCMI message exchange on Qualcomm
>>>> virtual platforms.
>>>>
>>>> The hypervisor associates an object-id also known as capability-id
>>>> with each hvc doorbell object. The capability-id is used to identify the
>>>> doorbell from the VM's capability namespace, similar to a file-descriptor.
>>>>
>>>> The hypervisor, in addition to the function-id, expects the capability-id
>>>> to be passed in x1 register when HVC call is invoked.
>>>>
>>>> The function-id & capability-id are allocated by the hypervisor on bootup
>>>> and are stored in the shmem region by the firmware before starting Linux.
>>>>
>>>> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
>>>> ---
>>>> drivers/firmware/arm_scmi/driver.c | 1 +
>>>> drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
>>>> 2 files changed, 43 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
>>>> index 87383c05424b..ea344bc6ae49 100644
>>>> --- a/drivers/firmware/arm_scmi/driver.c
>>>> +++ b/drivers/firmware/arm_scmi/driver.c
>>>> @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
>>>> #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
>>>> { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
>>>> { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
>>>> + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
>>>> #endif
>>>> #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
>>>> { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
>>>> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
>>>> index 0a0b7e401159..94ec07fdc14a 100644
>>>> --- a/drivers/firmware/arm_scmi/smc.c
>>>> +++ b/drivers/firmware/arm_scmi/smc.c
>>>> @@ -50,6 +50,9 @@
>>>> * @func_id: smc/hvc call function id
>>>> * @param_page: 4K page number of the shmem channel
>>>> * @param_offset: Offset within the 4K page of the shmem channel
>>>> + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
>>>> + * platforms
>>>> + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
>>>> */
>>>> struct scmi_smc {
>>>> @@ -63,6 +66,8 @@ struct scmi_smc {
>>>> u32 func_id;
>>>> u32 param_page;
>>>> u32 param_offset;
>>>> + u64 cap_id;
>>> Can it be unsigned long instead so that it just works for both 32 and 64 bit.
>> My first version of this patch was ulong but Bjorn suggested to make this
>> structure size fixed i.e. architecture independent. Hence changed it to u64.
>> If you are ok with ulong, I can change it back to ulong.
>>
> SMCCC pre-v1.2 used the common structure in that way. I don't see any issue
> with that. I haven't followed Bjorn suggestions/comments though.
Ok.
>>>> + bool qcom_xport;
>>> Do we really need this ?
>> Not if we initialize it with a negative value since 0 is a valid value for
>> cap-id.
>>
> Fine with negative value(-EINVAL may be).
Ok.
>>>> int ret;
>>>> if (!tx)
>>>> @@ -158,9 +164,34 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
>>>> return -EADDRNOTAVAIL;
>>>> }
>>>> - ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
>>>> - if (ret < 0)
>>>> - return ret;
>>>> + if (of_device_is_compatible(dev->of_node, "qcom,scmi-hvc-shmem")) {
>>>> + scmi_info->qcom_xport = true;
>>>> +
>>>> + /* The func-id & capability-id are kept in last 16 bytes of shmem.
>>>> + * +-------+
>>>> + * | |
>>>> + * | shmem |
>>>> + * | |
>>>> + * | |
>>>> + * +-------+ <-- (size - 16)
>>>> + * | funcId|
>>>> + * +-------+ <-- (size - 8)
>>>> + * | capId |
>>>> + * +-------+ <-- size
>>>> + */
>>>> +
>>>> + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
>>> So unlike 'arm,scmi-smc', you don't want 'arm,smc-id' in the DT ? Any
>>> particular reason ? Just to get both FID and cap ID from shmem ?
> I am fine either way. If you use from DT(via arm,smc-id), then "qcom,scmi"
> can be just addition compatible that expects you to read cap-id from the
> shmem. May need adjustment in the binding as you allow both
> "qcom,scmi-smc", "arm,scmi-smc". I will leave the details to you.
Ok.
>> I could use smc-id binding for func-id, it's just two parameters will come
>> from two different places so thought of keeping everything at one place to
>> maintain consistency. Since DT can't take cap-id, I decided to move
>> func-id. I am fine if you want me to use smc-id binding.
>>
> Up to you. If you want to make "qcom,scmi-smc" and "arm,scmi-smc"
> compatible in way in that way or you can keep it incompatible as you have
> proposed in this patch set.
Ok.
>>>> +#ifdef CONFIG_ARM64
>>> I would rather make this arch agnostic using CONFIG_64BIT
>> ok.
>>>> + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
>>> Do you need __iomem typecast here ? Is scmi_info->shmem not already __iomem ?
>>> Also scmi_info->shmem is ioremapped just few steps above and you are using
>>> read* here, is that safe ?
>> I saw some compilation warnings without __iomem. I will use ioread* API
>> instead of read*.
>>
> That was the clue that you were using __iomem with read* calls IMO.
Ok.
>>>> +#else
>>>> + /* capability-id is 32 bit wide on 32bit machines */
>>>> + cap_id = rieadl((void __iomem *)(scmi_info->shmem) + size - 8);
>>> Other thought once you move for u64 to unsigned long you need not have
>>> #ifdeffery, just do copy of sizeof(unsigned long)
>> Right, my first version was like that only.
> OK
>
>>>> +#endif
>>>> + } else {
>>>> + ret = of_property_read_u32(dev->of_node, "arm,smc-id", &func_id);
>>>> + if (ret < 0)
>>>> + return ret;
>>>> + }
>>>> if (of_device_is_compatible(dev->of_node, "arm,scmi-smc-param")) {
>>>> scmi_info->param_page = SHMEM_PAGE(res.start);
>>>> @@ -184,6 +215,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
>>>> }
>>>> scmi_info->func_id = func_id;
>>>> + scmi_info->cap_id = cap_id;
>>>> scmi_info->cinfo = cinfo;
>>>> smc_channel_lock_init(scmi_info);
>>>> cinfo->transport_info = scmi_info;
>>>> @@ -213,6 +245,7 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>>>> struct arm_smccc_res res;
>>>> unsigned long page = scmi_info->param_page;
>>>> unsigned long offset = scmi_info->param_offset;
>>>> + unsigned long cap_id = (unsigned long)scmi_info->cap_id;
>>>> /*
>>>> * Channel will be released only once response has been
>>>> @@ -222,8 +255,12 @@ static int smc_send_message(struct scmi_chan_info *cinfo,
>>>> shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
>>>> - arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
>>>> - &res);
>>>> + if (scmi_info->qcom_xport)
>>> Just make sure cap_id is set only for qcom and just use that as your flag.
>>> No point in setting always true scmi_info->qcom_xport and using it here.
>> ok, I can remove that. Though 0 is a valid value for cap-id so will have to
>> init cap-id with a negative value.
> Yes as mentioned above.
Ok.
>
On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
> This change adds the support for SCMI message exchange on Qualcomm
> virtual platforms.
>
> The hypervisor associates an object-id also known as capability-id
> with each hvc doorbell object. The capability-id is used to identify the
> doorbell from the VM's capability namespace, similar to a file-descriptor.
>
> The hypervisor, in addition to the function-id, expects the capability-id
> to be passed in x1 register when HVC call is invoked.
>
> The function-id & capability-id are allocated by the hypervisor on bootup
> and are stored in the shmem region by the firmware before starting Linux.
>
> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
> ---
> drivers/firmware/arm_scmi/driver.c | 1 +
> drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
> 2 files changed, 43 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 87383c05424b..ea344bc6ae49 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
> #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
> { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
> { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
> + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
> #endif
> #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
> { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> index 0a0b7e401159..94ec07fdc14a 100644
> --- a/drivers/firmware/arm_scmi/smc.c
> +++ b/drivers/firmware/arm_scmi/smc.c
> @@ -50,6 +50,9 @@
> * @func_id: smc/hvc call function id
> * @param_page: 4K page number of the shmem channel
> * @param_offset: Offset within the 4K page of the shmem channel
> + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
> + * platforms
> + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
> */
>
> struct scmi_smc {
> @@ -63,6 +66,8 @@ struct scmi_smc {
> u32 func_id;
> u32 param_page;
> u32 param_offset;
> + u64 cap_id;
> + bool qcom_xport;
> };
[snip]
> static irqreturn_t smc_msg_done_isr(int irq, void *data)
> @@ -129,6 +134,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> struct resource res;
> struct device_node *np;
> u32 func_id;
> + u64 cap_id;
> int ret;
[snip]
> + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
> +#ifdef CONFIG_ARM64
> + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
> +#else
> + /* capability-id is 32 bit wide on 32bit machines */
> + cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8);
> +#endif
The 32 bit case is defined as a u64 in two places above.
> +
> + /* The func-id & capability-id are kept in last 16 bytes of shmem.
> + * +-------+
> + * | |
> + * | shmem |
> + * | |
> + * | |
> + * +-------+ <-- (size - 16)
> + * | funcId|
> + * +-------+ <-- (size - 8)
> + * | capId |
> + * +-------+ <-- size
> + */
Personally I'd add one more space to the right side of the table after
funcId.
> - arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
> - &res);
> + if (scmi_info->qcom_xport)
> + arm_smccc_1_1_hvc(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0, 0,
> + &res);
> + else
> + arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0,
> + 0, 0, &res);
Does it make sense to call this variable qcom_xport? Would hvc_xport be
a more appropriate name?
Brian
On 10/2/2023 11:34 AM, Brian Masney wrote:
> On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
>> This change adds the support for SCMI message exchange on Qualcomm
>> virtual platforms.
>>
>> The hypervisor associates an object-id also known as capability-id
>> with each hvc doorbell object. The capability-id is used to identify the
>> doorbell from the VM's capability namespace, similar to a file-descriptor.
>>
>> The hypervisor, in addition to the function-id, expects the capability-id
>> to be passed in x1 register when HVC call is invoked.
>>
>> The function-id & capability-id are allocated by the hypervisor on bootup
>> and are stored in the shmem region by the firmware before starting Linux.
>>
>> Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
>> ---
>> drivers/firmware/arm_scmi/driver.c | 1 +
>> drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
>> 2 files changed, 43 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
>> index 87383c05424b..ea344bc6ae49 100644
>> --- a/drivers/firmware/arm_scmi/driver.c
>> +++ b/drivers/firmware/arm_scmi/driver.c
>> @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
>> #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
>> { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
>> { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
>> + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
>> #endif
>> #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
>> { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
>> diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
>> index 0a0b7e401159..94ec07fdc14a 100644
>> --- a/drivers/firmware/arm_scmi/smc.c
>> +++ b/drivers/firmware/arm_scmi/smc.c
>> @@ -50,6 +50,9 @@
>> * @func_id: smc/hvc call function id
>> * @param_page: 4K page number of the shmem channel
>> * @param_offset: Offset within the 4K page of the shmem channel
>> + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
>> + * platforms
>> + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
>> */
>>
>> struct scmi_smc {
>> @@ -63,6 +66,8 @@ struct scmi_smc {
>> u32 func_id;
>> u32 param_page;
>> u32 param_offset;
>> + u64 cap_id;
>> + bool qcom_xport;
>> };
> [snip]
>
>> static irqreturn_t smc_msg_done_isr(int irq, void *data)
>> @@ -129,6 +134,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
>> struct resource res;
>> struct device_node *np;
>> u32 func_id;
>> + u64 cap_id;
>> int ret;
> [snip]
>
>> + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
>> +#ifdef CONFIG_ARM64
>> + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
>> +#else
>> + /* capability-id is 32 bit wide on 32bit machines */
>> + cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8);
>> +#endif
> The 32 bit case is defined as a u64 in two places above.
That is done to make sure the size of the structure in memory is not
architecture dependent. This was recommended in one of the previous
version of this patch.
>
>> +
>> + /* The func-id & capability-id are kept in last 16 bytes of shmem.
>> + * +-------+
>> + * | |
>> + * | shmem |
>> + * | |
>> + * | |
>> + * +-------+ <-- (size - 16)
>> + * | funcId|
>> + * +-------+ <-- (size - 8)
>> + * | capId |
>> + * +-------+ <-- size
>> + */
> Personally I'd add one more space to the right side of the table after
> funcId.
I could do that but then in 32bit case, you would want one more space
right after cap-id since it is 32 bit on 32 bit platform. If it helps, I
can have two lay out one for 32bit and one for 64 bit.
>> - arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0, 0, 0,
>> - &res);
>> + if (scmi_info->qcom_xport)
>> + arm_smccc_1_1_hvc(scmi_info->func_id, cap_id, 0, 0, 0, 0, 0, 0,
>> + &res);
>> + else
>> + arm_smccc_1_1_invoke(scmi_info->func_id, page, offset, 0, 0, 0,
>> + 0, 0, &res);
> Does it make sense to call this variable qcom_xport? Would hvc_xport be
> a more appropriate name?
>
> Brian
Cap-id is QCOM specific ABI parameter not HVC.
>
On Mon, Oct 02, 2023 at 11:42:22AM -0700, Nikunj Kela wrote:
>
> On 10/2/2023 11:34 AM, Brian Masney wrote:
> > On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote:
> > > This change adds the support for SCMI message exchange on Qualcomm
> > > virtual platforms.
> > >
> > > The hypervisor associates an object-id also known as capability-id
> > > with each hvc doorbell object. The capability-id is used to identify the
> > > doorbell from the VM's capability namespace, similar to a file-descriptor.
> > >
> > > The hypervisor, in addition to the function-id, expects the capability-id
> > > to be passed in x1 register when HVC call is invoked.
> > >
> > > The function-id & capability-id are allocated by the hypervisor on bootup
> > > and are stored in the shmem region by the firmware before starting Linux.
> > >
> > > Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
> > > ---
> > > drivers/firmware/arm_scmi/driver.c | 1 +
> > > drivers/firmware/arm_scmi/smc.c | 47 ++++++++++++++++++++++++++----
> > > 2 files changed, 43 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> > > index 87383c05424b..ea344bc6ae49 100644
> > > --- a/drivers/firmware/arm_scmi/driver.c
> > > +++ b/drivers/firmware/arm_scmi/driver.c
> > > @@ -2915,6 +2915,7 @@ static const struct of_device_id scmi_of_match[] = {
> > > #ifdef CONFIG_ARM_SCMI_TRANSPORT_SMC
> > > { .compatible = "arm,scmi-smc", .data = &scmi_smc_desc},
> > > { .compatible = "arm,scmi-smc-param", .data = &scmi_smc_desc},
> > > + { .compatible = "qcom,scmi-hvc-shmem", .data = &scmi_smc_desc},
> > > #endif
> > > #ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
> > > { .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
> > > diff --git a/drivers/firmware/arm_scmi/smc.c b/drivers/firmware/arm_scmi/smc.c
> > > index 0a0b7e401159..94ec07fdc14a 100644
> > > --- a/drivers/firmware/arm_scmi/smc.c
> > > +++ b/drivers/firmware/arm_scmi/smc.c
> > > @@ -50,6 +50,9 @@
> > > * @func_id: smc/hvc call function id
> > > * @param_page: 4K page number of the shmem channel
> > > * @param_offset: Offset within the 4K page of the shmem channel
> > > + * @cap_id: hvc doorbell's capability id to be used on Qualcomm virtual
> > > + * platforms
> > > + * @qcom_xport: Flag to indicate the transport on Qualcomm virtual platforms
> > > */
> > > struct scmi_smc {
> > > @@ -63,6 +66,8 @@ struct scmi_smc {
> > > u32 func_id;
> > > u32 param_page;
> > > u32 param_offset;
> > > + u64 cap_id;
> > > + bool qcom_xport;
> > > };
> > [snip]
> >
> > > static irqreturn_t smc_msg_done_isr(int irq, void *data)
> > > @@ -129,6 +134,7 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
> > > struct resource res;
> > > struct device_node *np;
> > > u32 func_id;
> > > + u64 cap_id;
> > > int ret;
> > [snip]
> >
> > > + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
> > > +#ifdef CONFIG_ARM64
> > > + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
> > > +#else
> > > + /* capability-id is 32 bit wide on 32bit machines */
> > > + cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8);
> > > +#endif
> > The 32 bit case is defined as a u64 in two places above.
>
> That is done to make sure the size of the structure in memory is not
> architecture dependent. This was recommended in one of the previous version
> of this patch.
>
>
> >
> > > +
> > > + /* The func-id & capability-id are kept in last 16 bytes of shmem.
> > > + * +-------+
> > > + * | |
> > > + * | shmem |
> > > + * | |
> > > + * | |
> > > + * +-------+ <-- (size - 16)
> > > + * | funcId|
> > > + * +-------+ <-- (size - 8)
> > > + * | capId |
> > > + * +-------+ <-- size
> > > + */
> > Personally I'd add one more space to the right side of the table after
> > funcId.
>
> I could do that but then in 32bit case, you would want one more space right
> after cap-id since it is 32 bit on 32 bit platform. If it helps, I can have
> two lay out one for 32bit and one for 64 bit.
>
IIUC, it was just a cosmetic change requested. Instead of this,
+-------+ <-- (size - 16)
| funcId|
+-------+ <-- (size - 8)
something like this, just a extra space after 'funcId' text.
+--------+ <-- (size - 16)
| funcId |
+--------+ <-- (size - 8)
--
Regards,
Sudeep
On Mon, Oct 02, 2023 at 02:34:06PM -0400, Brian Masney wrote: > On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote: > > + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16); > > +#ifdef CONFIG_ARM64 > > + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8); > > +#else > > + /* capability-id is 32 bit wide on 32bit machines */ > > + cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8); > > +#endif > > The 32 bit case is defined as a u64 in two places above. Also should the 32 bit case be 'size - 4' instead of 'size - 8'? Sorry I just noticed that as soon as I pressed send. Brian
On 10/2/2023 11:39 AM, Brian Masney wrote: > On Mon, Oct 02, 2023 at 02:34:06PM -0400, Brian Masney wrote: >> On Mon, Sep 11, 2023 at 12:43:59PM -0700, Nikunj Kela wrote: >>> + func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16); >>> +#ifdef CONFIG_ARM64 >>> + cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8); >>> +#else >>> + /* capability-id is 32 bit wide on 32bit machines */ >>> + cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8); >>> +#endif >> The 32 bit case is defined as a u64 in two places above. > Also should the 32 bit case be 'size - 4' instead of 'size - 8'? Sorry > I just noticed that as soon as I pressed send. > > Brian I already addressed this in one of your previous comments. We are keeping last 16 bytes reserved for these two parameters regardless of the architecture.
On 18.07.2023 18:08, Nikunj Kela wrote: > This change introduce a new transport channel for Qualcomm virtual > platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC. > The difference between the two transports is that a parameter is passed in > the hypervisor call to identify which doorbell to assert. This parameter is > dynamically generated at runtime on the device and insuitable to pass via > the devicetree. > > The function ID and parameter are stored by firmware in the shmem region. > > This has been tested on ARM64 virtual Qualcomm platform. What can we test it on? Konrad
On 9/7/2023 9:16 AM, Konrad Dybcio wrote: > On 18.07.2023 18:08, Nikunj Kela wrote: >> This change introduce a new transport channel for Qualcomm virtual >> platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC. >> The difference between the two transports is that a parameter is passed in >> the hypervisor call to identify which doorbell to assert. This parameter is >> dynamically generated at runtime on the device and insuitable to pass via >> the devicetree. >> >> The function ID and parameter are stored by firmware in the shmem region. >> >> This has been tested on ARM64 virtual Qualcomm platform. > What can we test it on? > > Konrad This is being developed for SA8775p platform.
This change introduce a new transport channel for Qualcomm virtual
platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC.
The difference between the two transports is that a parameter is passed in
the hypervisor call to identify which doorbell to assert. This parameter is
dynamically generated at runtime on the device and insuitable to pass via
the devicetree.
The function ID and parameter are stored by firmware in the shmem region.
This has been tested on ARM64 virtual Qualcomm platform.
---
v3 -> fix the compilation error reported by the test bot,
add support for polling based instances
v2 -> use allOf construct in dtb schema,
remove wrappers from mutexes,
use architecture independent channel layout
v1 -> original patches
Nikunj Kela (3):
dt-bindings: arm: convert nested if-else construct to allOf
dt-bindings: arm: Add qcom specific hvc transport for SCMI
firmware: arm_scmi: Add qcom hvc/shmem transport
.../bindings/firmware/arm,scmi.yaml | 67 ++---
drivers/firmware/arm_scmi/Kconfig | 13 +
drivers/firmware/arm_scmi/Makefile | 2 +
drivers/firmware/arm_scmi/common.h | 3 +
drivers/firmware/arm_scmi/driver.c | 4 +
drivers/firmware/arm_scmi/qcom_hvc.c | 232 ++++++++++++++++++
6 files changed, 293 insertions(+), 28 deletions(-)
create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c
--
2.17.1
On 8/11/2023 10:57 AM, Nikunj Kela wrote: > This change introduce a new transport channel for Qualcomm virtual > platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC. > The difference between the two transports is that a parameter is passed in > the hypervisor call to identify which doorbell to assert. This parameter is > dynamically generated at runtime on the device and insuitable to pass via > the devicetree. > > The function ID and parameter are stored by firmware in the shmem region. > > This has been tested on ARM64 virtual Qualcomm platform. > > --- > v3 -> fix the compilation error reported by the test bot, > add support for polling based instances > > v2 -> use allOf construct in dtb schema, > remove wrappers from mutexes, > use architecture independent channel layout > > v1 -> original patches > > Nikunj Kela (3): > dt-bindings: arm: convert nested if-else construct to allOf > dt-bindings: arm: Add qcom specific hvc transport for SCMI > firmware: arm_scmi: Add qcom hvc/shmem transport > > .../bindings/firmware/arm,scmi.yaml | 67 ++--- > drivers/firmware/arm_scmi/Kconfig | 13 + > drivers/firmware/arm_scmi/Makefile | 2 + > drivers/firmware/arm_scmi/common.h | 3 + > drivers/firmware/arm_scmi/driver.c | 4 + > drivers/firmware/arm_scmi/qcom_hvc.c | 232 ++++++++++++++++++ > 6 files changed, 293 insertions(+), 28 deletions(-) > create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c Gentle Ping!
On 05/09/2023 18:06, Nikunj Kela wrote: > > On 8/11/2023 10:57 AM, Nikunj Kela wrote: >> This change introduce a new transport channel for Qualcomm virtual >> platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC. >> The difference between the two transports is that a parameter is passed in >> the hypervisor call to identify which doorbell to assert. This parameter is >> dynamically generated at runtime on the device and insuitable to pass via >> the devicetree. >> >> The function ID and parameter are stored by firmware in the shmem region. >> >> This has been tested on ARM64 virtual Qualcomm platform. >> >> --- >> v3 -> fix the compilation error reported by the test bot, >> add support for polling based instances >> >> v2 -> use allOf construct in dtb schema, >> remove wrappers from mutexes, >> use architecture independent channel layout >> >> v1 -> original patches >> >> Nikunj Kela (3): >> dt-bindings: arm: convert nested if-else construct to allOf >> dt-bindings: arm: Add qcom specific hvc transport for SCMI >> firmware: arm_scmi: Add qcom hvc/shmem transport >> >> .../bindings/firmware/arm,scmi.yaml | 67 ++--- >> drivers/firmware/arm_scmi/Kconfig | 13 + >> drivers/firmware/arm_scmi/Makefile | 2 + >> drivers/firmware/arm_scmi/common.h | 3 + >> drivers/firmware/arm_scmi/driver.c | 4 + >> drivers/firmware/arm_scmi/qcom_hvc.c | 232 ++++++++++++++++++ >> 6 files changed, 293 insertions(+), 28 deletions(-) >> create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c > Gentle Ping! It's third ping these two weeks from Qualcomm. Folks, it is merge window. What do you think will happen with your ping during this time? Best regards, Krzysztof
On Tue, Sep 05, 2023 at 06:37:14PM +0200, Krzysztof Kozlowski wrote: > On 05/09/2023 18:06, Nikunj Kela wrote: > > > > On 8/11/2023 10:57 AM, Nikunj Kela wrote: > >> This change introduce a new transport channel for Qualcomm virtual > >> platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC. > >> The difference between the two transports is that a parameter is passed in > >> the hypervisor call to identify which doorbell to assert. This parameter is > >> dynamically generated at runtime on the device and insuitable to pass via > >> the devicetree. > >> > >> The function ID and parameter are stored by firmware in the shmem region. > >> > >> This has been tested on ARM64 virtual Qualcomm platform. > >> > >> --- > >> v3 -> fix the compilation error reported by the test bot, > >> add support for polling based instances > >> > >> v2 -> use allOf construct in dtb schema, > >> remove wrappers from mutexes, > >> use architecture independent channel layout > >> > >> v1 -> original patches > >> > >> Nikunj Kela (3): > >> dt-bindings: arm: convert nested if-else construct to allOf > >> dt-bindings: arm: Add qcom specific hvc transport for SCMI > >> firmware: arm_scmi: Add qcom hvc/shmem transport > >> > >> .../bindings/firmware/arm,scmi.yaml | 67 ++--- > >> drivers/firmware/arm_scmi/Kconfig | 13 + > >> drivers/firmware/arm_scmi/Makefile | 2 + > >> drivers/firmware/arm_scmi/common.h | 3 + > >> drivers/firmware/arm_scmi/driver.c | 4 + > >> drivers/firmware/arm_scmi/qcom_hvc.c | 232 ++++++++++++++++++ > >> 6 files changed, 293 insertions(+), 28 deletions(-) > >> create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c > > Gentle Ping! Pong ! > > It's third ping these two weeks from Qualcomm. Folks, it is merge > window. What do you think will happen with your ping during this time? > +1 Okay, here is the deal with this patch set. As you are aware that a previous merged solution was abandoned by Qcom in a single kernel release cycle. So I decided to ignore this for one or 2 kernel release cycle to make sure Qcom makes up their mind on the design and then we can see how to proceed. Qcom must understand upstream kernel is not a playground to push their design which they might decided to drop support for in such short period. Please understand the upstream kernel supports platforms that are more than few decades old. It is not like the mobile platforms that are hardly supported for couple of years. And similarly, we push core support if and only if we know for sure it will be used on some platform. I trusted Qcom with the previous extension of SMC/HVC transport but I was proven wrong. Also, I definitely don't like the way you have copied the whole smc.c and changed it to Qcom's need and made it qcom_hvc.c. Just add the required changes in smc.c. -- Regards, Sudeep
On 9/7/2023 3:36 AM, Sudeep Holla wrote: > On Tue, Sep 05, 2023 at 06:37:14PM +0200, Krzysztof Kozlowski wrote: >> On 05/09/2023 18:06, Nikunj Kela wrote: >>> On 8/11/2023 10:57 AM, Nikunj Kela wrote: >>>> This change introduce a new transport channel for Qualcomm virtual >>>> platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC. >>>> The difference between the two transports is that a parameter is passed in >>>> the hypervisor call to identify which doorbell to assert. This parameter is >>>> dynamically generated at runtime on the device and insuitable to pass via >>>> the devicetree. >>>> >>>> The function ID and parameter are stored by firmware in the shmem region. >>>> >>>> This has been tested on ARM64 virtual Qualcomm platform. >>>> >>>> --- >>>> v3 -> fix the compilation error reported by the test bot, >>>> add support for polling based instances >>>> >>>> v2 -> use allOf construct in dtb schema, >>>> remove wrappers from mutexes, >>>> use architecture independent channel layout >>>> >>>> v1 -> original patches >>>> >>>> Nikunj Kela (3): >>>> dt-bindings: arm: convert nested if-else construct to allOf >>>> dt-bindings: arm: Add qcom specific hvc transport for SCMI >>>> firmware: arm_scmi: Add qcom hvc/shmem transport >>>> >>>> .../bindings/firmware/arm,scmi.yaml | 67 ++--- >>>> drivers/firmware/arm_scmi/Kconfig | 13 + >>>> drivers/firmware/arm_scmi/Makefile | 2 + >>>> drivers/firmware/arm_scmi/common.h | 3 + >>>> drivers/firmware/arm_scmi/driver.c | 4 + >>>> drivers/firmware/arm_scmi/qcom_hvc.c | 232 ++++++++++++++++++ >>>> 6 files changed, 293 insertions(+), 28 deletions(-) >>>> create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c >>> Gentle Ping! > Pong ! > >> It's third ping these two weeks from Qualcomm. Folks, it is merge >> window. What do you think will happen with your ping during this time? >> > +1 > > Okay, here is the deal with this patch set. As you are aware that a previous > merged solution was abandoned by Qcom in a single kernel release cycle. So > I decided to ignore this for one or 2 kernel release cycle to make sure > Qcom makes up their mind on the design and then we can see how to proceed. > Qcom must understand upstream kernel is not a playground to push their > design which they might decided to drop support for in such short period. > Please understand the upstream kernel supports platforms that are more than > few decades old. It is not like the mobile platforms that are hardly supported > for couple of years. And similarly, we push core support if and only if we > know for sure it will be used on some platform. I trusted Qcom with the > previous extension of SMC/HVC transport but I was proven wrong. > > Also, I definitely don't like the way you have copied the whole smc.c > and changed it to Qcom's need and made it qcom_hvc.c. Just add the required > changes in smc.c. > > -- > Regards, > Sudeep Completely understand your concerns and extending my apologies once again on the patch that was abandoned. I will rework the patch to include changes in smc.c. Thanks so much for your response!
Nested if-else construct is not scalable therefore, convert
it to allOf:if-else.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
.../bindings/firmware/arm,scmi.yaml | 55 +++++++++----------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index b138f3d23df8..8d54ea768d38 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -284,35 +284,34 @@ $defs:
required:
- compatible
-if:
- properties:
- compatible:
- contains:
- const: arm,scmi
-then:
- properties:
- interrupts: false
- interrupt-names: false
-
- required:
- - mboxes
- - shmem
-
-else:
- if:
- properties:
- compatible:
- contains:
- enum:
- - arm,scmi-smc
- - arm,scmi-smc-param
- then:
- required:
- - arm,smc-id
- - shmem
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: arm,scmi
+ then:
+ properties:
+ interrupts: false
+ interrupt-names: false
+
+ required:
+ - mboxes
+ - shmem
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - arm,scmi-smc
+ - arm,scmi-smc-param
+ then:
+ required:
+ - arm,smc-id
+ - shmem
- else:
- if:
+ - if:
properties:
compatible:
contains:
--
2.17.1
Introduce compatible "qcom,scmi-hvc-shmem" for SCMI
transport channel for Qualcomm virtual platforms.
The compatible mandates a shared memory channel.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
.../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index 8d54ea768d38..4090240f45b1 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -45,6 +45,9 @@ properties:
- description: SCMI compliant firmware with OP-TEE transport
items:
- const: linaro,scmi-optee
+ - description: SCMI compliant firmware with Qualcomm hvc/shmem transport
+ items:
+ - const: qcom,scmi-hvc-shmem
interrupts:
description:
@@ -320,6 +323,15 @@ allOf:
required:
- linaro,optee-channel-id
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: qcom,scmi-hvc-shmem
+ then:
+ required:
+ - shmem
+
examples:
- |
firmware {
--
2.17.1
Add a new transport channel to the SCMI firmware interface driver for
SCMI message exchange on Qualcomm virtual platforms.
The hypervisor associates an object-id also known as capability-id
with each hvc doorbell object. The capability-id is used to identify the
doorbell from the VM's capability namespace, similar to a file-descriptor.
The hypervisor, in addition to the function-id, expects the capability-id
to be passed in x1 register when HVC call is invoked.
The qcom hvc doorbell/shared memory transport uses a statically defined
shared memory region that binds with "arm,scmi-shmem" device tree node.
The function-id & capability-id are allocated by the hypervisor on bootup
and are stored in the shmem region by the firmware before starting Linux.
Currently, there is no usecase for the atomic support therefore this driver
doesn't include the changes for the same.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
drivers/firmware/arm_scmi/Kconfig | 13 ++
drivers/firmware/arm_scmi/Makefile | 2 +
drivers/firmware/arm_scmi/common.h | 3 +
drivers/firmware/arm_scmi/driver.c | 4 +
drivers/firmware/arm_scmi/qcom_hvc.c | 232 +++++++++++++++++++++++++++
5 files changed, 254 insertions(+)
create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c
diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
index ea0f5083ac47..40d07329ebf7 100644
--- a/drivers/firmware/arm_scmi/Kconfig
+++ b/drivers/firmware/arm_scmi/Kconfig
@@ -99,6 +99,19 @@ config ARM_SCMI_TRANSPORT_OPTEE
If you want the ARM SCMI PROTOCOL stack to include support for a
transport based on OP-TEE SCMI service, answer Y.
+config ARM_SCMI_TRANSPORT_QCOM_HVC
+ bool "SCMI transport based on hvc doorbell & shmem for Qualcomm SoCs"
+ depends on ARCH_QCOM
+ select ARM_SCMI_HAVE_TRANSPORT
+ select ARM_SCMI_HAVE_SHMEM
+ default y
+ help
+ Enable hvc doorbell & shmem based transport for SCMI.
+
+ If you want the ARM SCMI PROTOCOL stack to include support for a
+ hvc doorbell and shmem transport on Qualcomm virtual platforms,
+ answer Y.
+
config ARM_SCMI_TRANSPORT_SMC
bool "SCMI transport based on SMC"
depends on HAVE_ARM_SMCCC_DISCOVERY
diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile
index b31d78fa66cc..aaeba724b5e6 100644
--- a/drivers/firmware/arm_scmi/Makefile
+++ b/drivers/firmware/arm_scmi/Makefile
@@ -10,6 +10,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_SMC) += smc.o
scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o
+scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_QCOM_HVC) += qcom_hvc.o
scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o
scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y)
@@ -24,4 +25,5 @@ ifeq ($(CONFIG_THUMB2_KERNEL)$(CONFIG_CC_IS_CLANG),yy)
# pointer in Thumb2 mode, which is forcibly enabled by Clang when profiling
# hooks are inserted via the -pg switch.
CFLAGS_REMOVE_smc.o += $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_qcom_hvc.o += $(CC_FLAGS_FTRACE)
endif
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
index c46dc5215af7..5c98cbb1278b 100644
--- a/drivers/firmware/arm_scmi/common.h
+++ b/drivers/firmware/arm_scmi/common.h
@@ -298,6 +298,9 @@ extern const struct scmi_desc scmi_virtio_desc;
#ifdef CONFIG_ARM_SCMI_TRANSPORT_OPTEE
extern const struct scmi_desc scmi_optee_desc;
#endif
+#ifdef CONFIG_ARM_SCMI_TRANSPORT_QCOM_HVC
+extern const struct scmi_desc scmi_qcom_hvc_desc;
+#endif
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv);
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index b5957cc12fee..c54519596c29 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2918,6 +2918,10 @@ static const struct of_device_id scmi_of_match[] = {
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
+#endif
+#ifdef CONFIG_ARM_SCMI_TRANSPORT_QCOM_HVC
+ { .compatible = "qcom,scmi-hvc-shmem",
+ .data = &scmi_qcom_hvc_desc },
#endif
{ /* Sentinel */ },
};
diff --git a/drivers/firmware/arm_scmi/qcom_hvc.c b/drivers/firmware/arm_scmi/qcom_hvc.c
new file mode 100644
index 000000000000..87dc36805967
--- /dev/null
+++ b/drivers/firmware/arm_scmi/qcom_hvc.c
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * System Control and Management Interface (SCMI) Message
+ * Qualcomm HVC/shmem Transport driver
+ *
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright 2020 NXP
+ *
+ * This is based on drivers/firmware/arm_scmi/smc.c
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/slab.h>
+
+#include "common.h"
+
+/**
+ * struct scmi_qcom_hvc - Structure representing a SCMI qcom hvc transport
+ *
+ * @irq: An optional IRQ for completion
+ * @cinfo: SCMI channel info
+ * @shmem: Transmit/Receive shared memory area
+ * @shmem_lock: Lock to protect access to Tx/Rx shared memory area.
+ * @func_id: hvc call function-id
+ * @cap_id: hvc doorbell's capability id
+ */
+
+struct scmi_qcom_hvc {
+ int irq;
+ struct scmi_chan_info *cinfo;
+ struct scmi_shared_mem __iomem *shmem;
+ /* Protect access to shmem area */
+ struct mutex shmem_lock;
+ u32 func_id;
+ u64 cap_id;
+};
+
+static irqreturn_t qcom_hvc_msg_done_isr(int irq, void *data)
+{
+ struct scmi_qcom_hvc *scmi_info = data;
+
+ scmi_rx_callback(scmi_info->cinfo, shmem_read_header(scmi_info->shmem), NULL);
+
+ return IRQ_HANDLED;
+}
+
+static bool qcom_hvc_chan_available(struct device_node *of_node, int idx)
+{
+ struct device_node *np = of_parse_phandle(of_node, "shmem", 0);
+
+ if (!np)
+ return false;
+
+ of_node_put(np);
+ return true;
+}
+
+static int qcom_hvc_chan_setup(struct scmi_chan_info *cinfo,
+ struct device *dev, bool tx)
+{
+ struct device *cdev = cinfo->dev;
+ struct scmi_qcom_hvc *scmi_info;
+ struct device_node *np;
+ resource_size_t size;
+ struct resource res;
+ u32 func_id;
+ u64 cap_id;
+ int ret;
+
+ if (!tx)
+ return -ENODEV;
+
+ scmi_info = devm_kzalloc(dev, sizeof(*scmi_info), GFP_KERNEL);
+ if (!scmi_info)
+ return -ENOMEM;
+
+ np = of_parse_phandle(cdev->of_node, "shmem", 0);
+ if (!of_device_is_compatible(np, "arm,scmi-shmem")) {
+ of_node_put(np);
+ return -ENXIO;
+ }
+
+ ret = of_address_to_resource(np, 0, &res);
+ of_node_put(np);
+ if (ret) {
+ dev_err(cdev, "failed to get SCMI Tx shared memory\n");
+ return ret;
+ }
+
+ size = resource_size(&res);
+
+ /* The func-id & capability-id are kept in last 16 bytes of shmem.
+ * +-------+
+ * | |
+ * | shmem |
+ * | |
+ * | |
+ * +-------+ <-- (size - 16)
+ * | funcId|
+ * +-------+ <-- (size - 8)
+ * | capId |
+ * +-------+ <-- size
+ */
+
+ scmi_info->shmem = devm_ioremap(dev, res.start, size);
+ if (!scmi_info->shmem) {
+ dev_err(dev, "failed to ioremap SCMI Tx shared memory\n");
+ return -EADDRNOTAVAIL;
+ }
+
+ func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
+
+#ifdef CONFIG_ARM64
+ cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
+#else
+ /* capability-id is 32 bit long on 32bit machines */
+ cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8);
+#endif
+
+ /*
+ * If there is an interrupt named "a2p", then the service and
+ * completion of a message is signaled by an interrupt rather than by
+ * the return of the hvc call.
+ */
+ scmi_info->irq = of_irq_get_byname(cdev->of_node, "a2p");
+ if (scmi_info->irq > 0) {
+ ret = request_irq(scmi_info->irq, qcom_hvc_msg_done_isr,
+ IRQF_NO_SUSPEND, dev_name(dev), scmi_info);
+ if (ret) {
+ dev_err(dev, "failed to setup SCMI completion irq\n");
+ return ret;
+ }
+ } else {
+ cinfo->no_completion_irq = true;
+ }
+
+ scmi_info->func_id = func_id;
+ scmi_info->cap_id = cap_id;
+ scmi_info->cinfo = cinfo;
+ mutex_init(&scmi_info->shmem_lock);
+ cinfo->transport_info = scmi_info;
+
+ return 0;
+}
+
+static int qcom_hvc_chan_free(int id, void *p, void *data)
+{
+ struct scmi_chan_info *cinfo = p;
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+
+ /* Ignore any possible further reception on the IRQ path */
+ if (scmi_info->irq > 0)
+ free_irq(scmi_info->irq, scmi_info);
+
+ cinfo->transport_info = NULL;
+ scmi_info->cinfo = NULL;
+
+ return 0;
+}
+
+static int qcom_hvc_send_message(struct scmi_chan_info *cinfo,
+ struct scmi_xfer *xfer)
+{
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+ struct arm_smccc_res res;
+
+ /*
+ * Channel will be released only once response has been
+ * surely fully retrieved, so after .mark_txdone()
+ */
+ mutex_lock(&scmi_info->shmem_lock);
+
+ shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
+
+ arm_smccc_1_1_hvc(scmi_info->func_id, (unsigned long)scmi_info->cap_id,
+ 0, 0, 0, 0, 0, 0, &res);
+
+ if (res.a0) {
+ mutex_unlock(&scmi_info->shmem_lock);
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static void qcom_hvc_fetch_response(struct scmi_chan_info *cinfo,
+ struct scmi_xfer *xfer)
+{
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+
+ shmem_fetch_response(scmi_info->shmem, xfer);
+}
+
+static void qcom_hvc_mark_txdone(struct scmi_chan_info *cinfo, int ret,
+ struct scmi_xfer *__unused)
+{
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+
+ mutex_unlock(&scmi_info->shmem_lock);
+}
+
+static bool
+qcom_hvc_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)
+{
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+
+ return shmem_poll_done(scmi_info->shmem, xfer);
+}
+
+static const struct scmi_transport_ops scmi_qcom_hvc_ops = {
+ .chan_available = qcom_hvc_chan_available,
+ .chan_setup = qcom_hvc_chan_setup,
+ .chan_free = qcom_hvc_chan_free,
+ .send_message = qcom_hvc_send_message,
+ .mark_txdone = qcom_hvc_mark_txdone,
+ .fetch_response = qcom_hvc_fetch_response,
+ .poll_done = qcom_hvc_poll_done,
+};
+
+const struct scmi_desc scmi_qcom_hvc_desc = {
+ .ops = &scmi_qcom_hvc_ops,
+ .max_rx_timeout_ms = 30,
+ .max_msg = 20,
+ .max_msg_size = 128,
+};
--
2.17.1
This change introduce a new transport channel for Qualcomm virtual
platforms. The transport is mechanically similar to ARM_SCMI_TRANSPORT_SMC.
The difference between the two transports is that a parameter is passed in
the hypervisor call to identify which doorbell to assert. This parameter is
dynamically generated at runtime on the device and insuitable to pass via
the devicetree.
The function ID and parameter are stored by firmware in the shmem region.
This has been tested on ARM64 virtual Qualcomm platform.
---
v2 -> use allOf construct in dtb schema,
remove wrappers from mutexes,
use architecture independent channel layout
v1 -> original patches
Nikunj Kela (3):
dt-bindings: arm: convert nested if-else construct to allOf
dt-bindings: arm: Add qcom specific hvc transport for SCMI
firmware: arm_scmi: Add qcom hvc/shmem transport
.../bindings/firmware/arm,scmi.yaml | 67 +++---
drivers/firmware/arm_scmi/Kconfig | 13 +
drivers/firmware/arm_scmi/Makefile | 1 +
drivers/firmware/arm_scmi/common.h | 3 +
drivers/firmware/arm_scmi/driver.c | 4 +
drivers/firmware/arm_scmi/qcom_hvc.c | 224 ++++++++++++++++++
6 files changed, 284 insertions(+), 28 deletions(-)
create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c
--
2.17.1
Nested if-else construct is not scalable therefore, convert
it to allOf:if-else.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
.../bindings/firmware/arm,scmi.yaml | 55 +++++++++----------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index b138f3d23df8..8d54ea768d38 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -284,35 +284,34 @@ $defs:
required:
- compatible
-if:
- properties:
- compatible:
- contains:
- const: arm,scmi
-then:
- properties:
- interrupts: false
- interrupt-names: false
-
- required:
- - mboxes
- - shmem
-
-else:
- if:
- properties:
- compatible:
- contains:
- enum:
- - arm,scmi-smc
- - arm,scmi-smc-param
- then:
- required:
- - arm,smc-id
- - shmem
+allOf:
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: arm,scmi
+ then:
+ properties:
+ interrupts: false
+ interrupt-names: false
+
+ required:
+ - mboxes
+ - shmem
+
+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - arm,scmi-smc
+ - arm,scmi-smc-param
+ then:
+ required:
+ - arm,smc-id
+ - shmem
- else:
- if:
+ - if:
properties:
compatible:
contains:
--
2.17.1
On 24/07/2023 18:44, Nikunj Kela wrote: > Nested if-else construct is not scalable therefore, convert > it to allOf:if-else. > > Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> > --- > .../bindings/firmware/arm,scmi.yaml | 55 +++++++++---------- > 1 file changed, 27 insertions(+), 28 deletions(-) > Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof
Introduce compatible "qcom,scmi-hvc-shmem" for SCMI
transport channel for Qualcomm virtual platforms.
The compatible mandates a shared memory channel.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
.../devicetree/bindings/firmware/arm,scmi.yaml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
index 8d54ea768d38..4090240f45b1 100644
--- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
+++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml
@@ -45,6 +45,9 @@ properties:
- description: SCMI compliant firmware with OP-TEE transport
items:
- const: linaro,scmi-optee
+ - description: SCMI compliant firmware with Qualcomm hvc/shmem transport
+ items:
+ - const: qcom,scmi-hvc-shmem
interrupts:
description:
@@ -320,6 +323,15 @@ allOf:
required:
- linaro,optee-channel-id
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: qcom,scmi-hvc-shmem
+ then:
+ required:
+ - shmem
+
examples:
- |
firmware {
--
2.17.1
On 24/07/2023 18:44, Nikunj Kela wrote: > Introduce compatible "qcom,scmi-hvc-shmem" for SCMI > transport channel for Qualcomm virtual platforms. > The compatible mandates a shared memory channel. > > Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com> > --- Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> This looks fine for me, but I did not investigate whether Sudeep's concerns were solved/answered fully. Best regards, Krzysztof
Add a new transport channel to the SCMI firmware interface driver for
SCMI message exchange on Qualcomm virtual platforms.
The hypervisor associates an object-id also known as capability-id
with each hvc doorbell object. The capability-id is used to identify the
doorbell from the VM's capability namespace, similar to a file-descriptor.
The hypervisor, in addition to the function-id, expects the capability-id
to be passed in x1 register when HVC call is invoked.
The qcom hvc doorbell/shared memory transport uses a statically defined
shared memory region that binds with "arm,scmi-shmem" device tree node.
The function-id & capability-id are allocated by the hypervisor on bootup
and are stored in the shmem region by the firmware before starting Linux.
Currently, there is no usecase for the atomic support therefore this driver
doesn't include the changes for the same.
Signed-off-by: Nikunj Kela <quic_nkela@quicinc.com>
---
drivers/firmware/arm_scmi/Kconfig | 13 ++
drivers/firmware/arm_scmi/Makefile | 1 +
drivers/firmware/arm_scmi/common.h | 3 +
drivers/firmware/arm_scmi/driver.c | 4 +
drivers/firmware/arm_scmi/qcom_hvc.c | 224 +++++++++++++++++++++++++++
5 files changed, 245 insertions(+)
create mode 100644 drivers/firmware/arm_scmi/qcom_hvc.c
diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
index ea0f5083ac47..40d07329ebf7 100644
--- a/drivers/firmware/arm_scmi/Kconfig
+++ b/drivers/firmware/arm_scmi/Kconfig
@@ -99,6 +99,19 @@ config ARM_SCMI_TRANSPORT_OPTEE
If you want the ARM SCMI PROTOCOL stack to include support for a
transport based on OP-TEE SCMI service, answer Y.
+config ARM_SCMI_TRANSPORT_QCOM_HVC
+ bool "SCMI transport based on hvc doorbell & shmem for Qualcomm SoCs"
+ depends on ARCH_QCOM
+ select ARM_SCMI_HAVE_TRANSPORT
+ select ARM_SCMI_HAVE_SHMEM
+ default y
+ help
+ Enable hvc doorbell & shmem based transport for SCMI.
+
+ If you want the ARM SCMI PROTOCOL stack to include support for a
+ hvc doorbell and shmem transport on Qualcomm virtual platforms,
+ answer Y.
+
config ARM_SCMI_TRANSPORT_SMC
bool "SCMI transport based on SMC"
depends on HAVE_ARM_SMCCC_DISCOVERY
diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile
index b31d78fa66cc..ba1ff5893ec0 100644
--- a/drivers/firmware/arm_scmi/Makefile
+++ b/drivers/firmware/arm_scmi/Makefile
@@ -10,6 +10,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_SMC) += smc.o
scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o
scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o
+scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_QCOM_HVC) += qcom_hvc.o
scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o
scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y)
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
index c46dc5215af7..5c98cbb1278b 100644
--- a/drivers/firmware/arm_scmi/common.h
+++ b/drivers/firmware/arm_scmi/common.h
@@ -298,6 +298,9 @@ extern const struct scmi_desc scmi_virtio_desc;
#ifdef CONFIG_ARM_SCMI_TRANSPORT_OPTEE
extern const struct scmi_desc scmi_optee_desc;
#endif
+#ifdef CONFIG_ARM_SCMI_TRANSPORT_QCOM_HVC
+extern const struct scmi_desc scmi_qcom_hvc_desc;
+#endif
void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv);
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index b5957cc12fee..c54519596c29 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2918,6 +2918,10 @@ static const struct of_device_id scmi_of_match[] = {
#endif
#ifdef CONFIG_ARM_SCMI_TRANSPORT_VIRTIO
{ .compatible = "arm,scmi-virtio", .data = &scmi_virtio_desc},
+#endif
+#ifdef CONFIG_ARM_SCMI_TRANSPORT_QCOM_HVC
+ { .compatible = "qcom,scmi-hvc-shmem",
+ .data = &scmi_qcom_hvc_desc },
#endif
{ /* Sentinel */ },
};
diff --git a/drivers/firmware/arm_scmi/qcom_hvc.c b/drivers/firmware/arm_scmi/qcom_hvc.c
new file mode 100644
index 000000000000..9aa60d6bb797
--- /dev/null
+++ b/drivers/firmware/arm_scmi/qcom_hvc.c
@@ -0,0 +1,224 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * System Control and Management Interface (SCMI) Message
+ * Qualcomm HVC/shmem Transport driver
+ *
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright 2020 NXP
+ *
+ * This is based on drivers/firmware/arm_scmi/smc.c
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/slab.h>
+
+#include "common.h"
+
+/**
+ * struct scmi_qcom_hvc - Structure representing a SCMI qcom hvc transport
+ *
+ * @irq: An optional IRQ for completion
+ * @cinfo: SCMI channel info
+ * @shmem: Transmit/Receive shared memory area
+ * @shmem_lock: Lock to protect access to Tx/Rx shared memory area.
+ * @func_id: hvc call function-id
+ * @cap_id: hvc doorbell's capability id
+ */
+
+struct scmi_qcom_hvc {
+ int irq;
+ struct scmi_chan_info *cinfo;
+ struct scmi_shared_mem __iomem *shmem;
+ /* Protect access to shmem area */
+ struct mutex shmem_lock;
+ u32 func_id;
+ u64 cap_id;
+};
+
+static irqreturn_t qcom_hvc_msg_done_isr(int irq, void *data)
+{
+ struct scmi_qcom_hvc *scmi_info = data;
+
+ scmi_rx_callback(scmi_info->cinfo, shmem_read_header(scmi_info->shmem), NULL);
+
+ return IRQ_HANDLED;
+}
+
+static bool qcom_hvc_chan_available(struct device_node *of_node, int idx)
+{
+ struct device_node *np = of_parse_phandle(of_node, "shmem", 0);
+
+ if (!np)
+ return false;
+
+ of_node_put(np);
+ return true;
+}
+
+static int qcom_hvc_chan_setup(struct scmi_chan_info *cinfo,
+ struct device *dev, bool tx)
+{
+ struct device *cdev = cinfo->dev;
+ struct scmi_qcom_hvc *scmi_info;
+ struct device_node *np;
+ resource_size_t size;
+ struct resource res;
+ u32 func_id;
+ u64 cap_id;
+ int ret;
+
+ if (!tx)
+ return -ENODEV;
+
+ scmi_info = devm_kzalloc(dev, sizeof(*scmi_info), GFP_KERNEL);
+ if (!scmi_info)
+ return -ENOMEM;
+
+ np = of_parse_phandle(cdev->of_node, "shmem", 0);
+ if (!of_device_is_compatible(np, "arm,scmi-shmem")) {
+ of_node_put(np);
+ return -ENXIO;
+ }
+
+ ret = of_address_to_resource(np, 0, &res);
+ of_node_put(np);
+ if (ret) {
+ dev_err(cdev, "failed to get SCMI Tx shared memory\n");
+ return ret;
+ }
+
+ size = resource_size(&res);
+
+ /* The func-id & capability-id are kept in last 16 bytes of shmem.
+ * +-------+
+ * | |
+ * | shmem |
+ * | |
+ * | |
+ * +-------+ <-- (size - 16)
+ * | funcId|
+ * +-------+ <-- (size - 8)
+ * | capId |
+ * +-------+ <-- size
+ */
+
+ scmi_info->shmem = devm_ioremap(dev, res.start, size);
+ if (!scmi_info->shmem) {
+ dev_err(dev, "failed to ioremap SCMI Tx shared memory\n");
+ return -EADDRNOTAVAIL;
+ }
+
+ func_id = readl((void __iomem *)(scmi_info->shmem) + size - 16);
+
+#ifdef CONFIG_ARM64
+ cap_id = readq((void __iomem *)(scmi_info->shmem) + size - 8);
+#else
+ /* capability-id is 32 bit long on 32bit machines */
+ cap_id = readl((void __iomem *)(scmi_info->shmem) + size - 8);
+#endif
+
+ /*
+ * If there is an interrupt named "a2p", then the service and
+ * completion of a message is signaled by an interrupt rather than by
+ * the return of the hvc call.
+ */
+ scmi_info->irq = of_irq_get_byname(cdev->of_node, "a2p");
+ if (scmi_info->irq > 0) {
+ ret = request_irq(scmi_info->irq, qcom_hvc_msg_done_isr,
+ IRQF_NO_SUSPEND, dev_name(dev), scmi_info);
+ if (ret) {
+ dev_err(dev, "failed to setup SCMI completion irq\n");
+ return ret;
+ }
+ } else {
+ cinfo->no_completion_irq = true;
+ }
+
+ scmi_info->func_id = func_id;
+ scmi_info->cap_id = cap_id;
+ scmi_info->cinfo = cinfo;
+ mutex_init(&scmi_info->shmem_lock);
+ cinfo->transport_info = scmi_info;
+
+ return 0;
+}
+
+static int qcom_hvc_chan_free(int id, void *p, void *data)
+{
+ struct scmi_chan_info *cinfo = p;
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+
+ /* Ignore any possible further reception on the IRQ path */
+ if (scmi_info->irq > 0)
+ free_irq(scmi_info->irq, scmi_info);
+
+ cinfo->transport_info = NULL;
+ scmi_info->cinfo = NULL;
+
+ return 0;
+}
+
+static int qcom_hvc_send_message(struct scmi_chan_info *cinfo,
+ struct scmi_xfer *xfer)
+{
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+ struct arm_smccc_res res;
+
+ /*
+ * Channel will be released only once response has been
+ * surely fully retrieved, so after .mark_txdone()
+ */
+ mutex_lock(&scmi_info->shmem_lock);
+
+ shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
+
+ arm_smccc_1_1_hvc(scmi_info->func_id, (unsigned long)scmi_info->cap_id,
+ 0, 0, 0, 0, 0, 0, &res);
+
+ if (res.a0) {
+ mutex_unlock(&scmi_info->shmem_lock);
+ return -EOPNOTSUPP;
+ }
+
+ return 0;
+}
+
+static void qcom_hvc_fetch_response(struct scmi_chan_info *cinfo,
+ struct scmi_xfer *xfer)
+{
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+
+ shmem_fetch_response(scmi_info->shmem, xfer);
+}
+
+static void qcom_hvc_mark_txdone(struct scmi_chan_info *cinfo, int ret,
+ struct scmi_xfer *__unused)
+{
+ struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
+
+ mutex_unlock(&scmi_info->shmem_lock);
+}
+
+static const struct scmi_transport_ops scmi_qcom_hvc_ops = {
+ .chan_available = qcom_hvc_chan_available,
+ .chan_setup = qcom_hvc_chan_setup,
+ .chan_free = qcom_hvc_chan_free,
+ .send_message = qcom_hvc_send_message,
+ .mark_txdone = qcom_hvc_mark_txdone,
+ .fetch_response = qcom_hvc_fetch_response,
+};
+
+const struct scmi_desc scmi_qcom_hvc_desc = {
+ .ops = &scmi_qcom_hvc_ops,
+ .max_rx_timeout_ms = 30,
+ .max_msg = 20,
+ .max_msg_size = 128,
+ .sync_cmds_completed_on_ret = true,
+};
--
2.17.1
Hi Nikunj,
kernel test robot noticed the following build errors:
[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.5-rc4 next-20230801]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Nikunj-Kela/dt-bindings-arm-convert-nested-if-else-construct-to-allOf/20230725-004613
base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link: https://lore.kernel.org/r/20230724164419.16092-4-quic_nkela%40quicinc.com
patch subject: [PATCH v2 3/3] firmware: arm_scmi: Add qcom hvc/shmem transport
config: arm-randconfig-r004-20230731 (https://download.01.org/0day-ci/archive/20230801/202308011516.voJRAbHr-lkp@intel.com/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
reproduce: (https://download.01.org/0day-ci/archive/20230801/202308011516.voJRAbHr-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308011516.voJRAbHr-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/firmware/arm_scmi/qcom_hvc.c:182:2: error: write to reserved register 'R7'
arm_smccc_1_1_hvc(scmi_info->func_id, (unsigned long)scmi_info->cap_id,
^
include/linux/arm-smccc.h:536:48: note: expanded from macro 'arm_smccc_1_1_hvc'
#define arm_smccc_1_1_hvc(...) __arm_smccc_1_1(SMCCC_HVC_INST, __VA_ARGS__)
^
include/linux/arm-smccc.h:398:24: note: expanded from macro 'SMCCC_HVC_INST'
#define SMCCC_HVC_INST __HVC(0)
^
arch/arm/include/asm/opcodes-virt.h:11:22: note: expanded from macro '__HVC'
#define __HVC(imm16) __inst_arm_thumb32( \
^
arch/arm/include/asm/opcodes.h:215:2: note: expanded from macro '__inst_arm_thumb32'
__inst_thumb32(thumb_opcode)
^
arch/arm/include/asm/opcodes.h:205:27: note: expanded from macro '__inst_thumb32'
#define __inst_thumb32(x) ___inst_thumb32( \
^
arch/arm/include/asm/opcodes.h:230:2: note: expanded from macro '___inst_thumb32'
".short " __stringify(first) ", " __stringify(second) "\n\t"
^
1 error generated.
vim +/R7 +182 drivers/firmware/arm_scmi/qcom_hvc.c
167
168 static int qcom_hvc_send_message(struct scmi_chan_info *cinfo,
169 struct scmi_xfer *xfer)
170 {
171 struct scmi_qcom_hvc *scmi_info = cinfo->transport_info;
172 struct arm_smccc_res res;
173
174 /*
175 * Channel will be released only once response has been
176 * surely fully retrieved, so after .mark_txdone()
177 */
178 mutex_lock(&scmi_info->shmem_lock);
179
180 shmem_tx_prepare(scmi_info->shmem, xfer, cinfo);
181
> 182 arm_smccc_1_1_hvc(scmi_info->func_id, (unsigned long)scmi_info->cap_id,
183 0, 0, 0, 0, 0, 0, &res);
184
185 if (res.a0) {
186 mutex_unlock(&scmi_info->shmem_lock);
187 return -EOPNOTSUPP;
188 }
189
190 return 0;
191 }
192
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Mon, Jul 24, 2023 at 09:44:19AM -0700, Nikunj Kela wrote: > Add a new transport channel to the SCMI firmware interface driver for > SCMI message exchange on Qualcomm virtual platforms. > > The hypervisor associates an object-id also known as capability-id > with each hvc doorbell object. The capability-id is used to identify the > doorbell from the VM's capability namespace, similar to a file-descriptor. > > The hypervisor, in addition to the function-id, expects the capability-id > to be passed in x1 register when HVC call is invoked. > > The qcom hvc doorbell/shared memory transport uses a statically defined > shared memory region that binds with "arm,scmi-shmem" device tree node. > > The function-id & capability-id are allocated by the hypervisor on bootup > and are stored in the shmem region by the firmware before starting Linux. > > Currently, there is no usecase for the atomic support therefore this driver > doesn't include the changes for the same. > Hi Nikunj, so basically this new SCMI transport that you are introducing is just exactly like the existing SMC transport with the only difference that you introduced even another new way to configure func_id, a new cap_id param AND the fact that you use HVC instead of SMC... all of this tied to a new compatible to identify this new transport mechanism.... ..but all in all is just a lot of plain duplicated code to maintain... ...why can't you fit this other smc/hvc transport variant into the existing SMC transport by properly picking and configuring func_id/cap_id and "doorbell" method (SMC vs HVC) in the chan_setup() step ? ..I mean ... you can decide where to pick your params based on compatibles and also you can setup your invokation method (SMC vs HVC) based on those...while keeping all the other stuff exactly the same... ...including support for atomic exchanges...if not, when you'll need that too in your QC_HVC transport you'll have to duplicate also that (and my bugs too probably :P) (... well maybe in this scenario also the transport itself should be renamed from SMC to something more general...) Not sure if I am missing something, or if Sudeep will be horrified by this unifying proposal of mine, but in this series as it stands now I just see a lot of brutally duplicated stuff that just differs by naming and a very minimal change in logic that could be addressed changing and generalizing the original SMC transport code instead. Thanks, Cristian
On 7/25/2023 10:03 AM, Cristian Marussi wrote: > On Mon, Jul 24, 2023 at 09:44:19AM -0700, Nikunj Kela wrote: >> Add a new transport channel to the SCMI firmware interface driver for >> SCMI message exchange on Qualcomm virtual platforms. >> >> The hypervisor associates an object-id also known as capability-id >> with each hvc doorbell object. The capability-id is used to identify the >> doorbell from the VM's capability namespace, similar to a file-descriptor. >> >> The hypervisor, in addition to the function-id, expects the capability-id >> to be passed in x1 register when HVC call is invoked. >> >> The qcom hvc doorbell/shared memory transport uses a statically defined >> shared memory region that binds with "arm,scmi-shmem" device tree node. >> >> The function-id & capability-id are allocated by the hypervisor on bootup >> and are stored in the shmem region by the firmware before starting Linux. >> >> Currently, there is no usecase for the atomic support therefore this driver >> doesn't include the changes for the same. >> > Hi Nikunj, > > so basically this new SCMI transport that you are introducing is just > exactly like the existing SMC transport with the only difference that > you introduced even another new way to configure func_id, a new cap_id > param AND the fact that you use HVC instead of SMC... all of this tied > to a new compatible to identify this new transport mechanism.... > ..but all in all is just a lot of plain duplicated code to maintain... > > ...why can't you fit this other smc/hvc transport variant into the > existing SMC transport by properly picking and configuring func_id/cap_id > and "doorbell" method (SMC vs HVC) in the chan_setup() step ? > > ..I mean ... you can decide where to pick your params based on > compatibles and also you can setup your invokation method (SMC vs HVC) > based on those...while keeping all the other stuff exactly the same... > ...including support for atomic exchanges...if not, when you'll need that > too in your QC_HVC transport you'll have to duplicate also that (and my > bugs too probably :P) > > (... well maybe in this scenario also the transport itself should be > renamed from SMC to something more general...) > > Not sure if I am missing something, or if Sudeep will be horrified by > this unifying proposal of mine, but in this series as it stands now I > just see a lot of brutally duplicated stuff that just differs by naming > and a very minimal change in logic that could be addressed changing and > generalizing the original SMC transport code instead. > > Thanks, > Cristian Hi Christian, I totally agree with you and will be happy to include my changes in smc.c if Sudeep agrees with that approach. Thanks
On 7/25/2023 10:12 AM, Nikunj Kela wrote: > > On 7/25/2023 10:03 AM, Cristian Marussi wrote: >> On Mon, Jul 24, 2023 at 09:44:19AM -0700, Nikunj Kela wrote: >>> Add a new transport channel to the SCMI firmware interface driver for >>> SCMI message exchange on Qualcomm virtual platforms. >>> >>> The hypervisor associates an object-id also known as capability-id >>> with each hvc doorbell object. The capability-id is used to identify >>> the >>> doorbell from the VM's capability namespace, similar to a >>> file-descriptor. >>> >>> The hypervisor, in addition to the function-id, expects the >>> capability-id >>> to be passed in x1 register when HVC call is invoked. >>> >>> The qcom hvc doorbell/shared memory transport uses a statically defined >>> shared memory region that binds with "arm,scmi-shmem" device tree node. >>> >>> The function-id & capability-id are allocated by the hypervisor on >>> bootup >>> and are stored in the shmem region by the firmware before starting >>> Linux. >>> >>> Currently, there is no usecase for the atomic support therefore this >>> driver >>> doesn't include the changes for the same. >>> >> Hi Nikunj, >> >> so basically this new SCMI transport that you are introducing is just >> exactly like the existing SMC transport with the only difference that >> you introduced even another new way to configure func_id, a new cap_id >> param AND the fact that you use HVC instead of SMC... all of this tied >> to a new compatible to identify this new transport mechanism.... >> ..but all in all is just a lot of plain duplicated code to maintain... >> >> ...why can't you fit this other smc/hvc transport variant into the >> existing SMC transport by properly picking and configuring >> func_id/cap_id >> and "doorbell" method (SMC vs HVC) in the chan_setup() step ? >> >> ..I mean ... you can decide where to pick your params based on >> compatibles and also you can setup your invokation method (SMC vs HVC) >> based on those...while keeping all the other stuff exactly the same... >> ...including support for atomic exchanges...if not, when you'll need >> that >> too in your QC_HVC transport you'll have to duplicate also that (and my >> bugs too probably :P) >> >> (... well maybe in this scenario also the transport itself should be >> renamed from SMC to something more general...) >> >> Not sure if I am missing something, or if Sudeep will be horrified by >> this unifying proposal of mine, but in this series as it stands now I >> just see a lot of brutally duplicated stuff that just differs by naming >> and a very minimal change in logic that could be addressed changing and >> generalizing the original SMC transport code instead. >> >> Thanks, >> Cristian > > Hi Christian, > > I totally agree with you and will be happy to include my changes in > smc.c if Sudeep agrees with that approach. > > Thanks Hi Sudeep, Could you please provide your feedback on this? Thanks
© 2016 - 2026 Red Hat, Inc.