Re: [PATCH v8 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs

2018-05-23 Thread Raju P L S S S N

Hi,

On 5/12/2018 1:45 AM, Doug Anderson wrote:

Hi,

On Wed, May 9, 2018 at 10:01 AM, Lina Iyer  wrote:

+int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg)
+{
+   int ret;
+
+   if (!msg || !msg->cmds || !msg->num_cmds ||
+   msg->num_cmds > MAX_RPMH_PAYLOAD) {
+   WARN_ON(1);
+   return -EINVAL;
+   }
+
+   do {
+   ret = tcs_write(drv, msg);
+   if (ret == -EBUSY) {
+   pr_info_ratelimited("TCS Busy, retrying RPMH message send: 
addr=%#x\n",
+   msg->cmds[0].addr);
+   udelay(10);
+   }
+   } while (ret == -EBUSY);
+
+   return ret;
+}
+EXPORT_SYMBOL(rpmh_rsc_send_data);


Here and elsewhere in this series: why EXPORT_SYMBOL in this case?
This is only exported to rpmh.c, right?  You don't need EXPORT_SYMBOL
for that.  The Makefile puts rpmh.c and rpmh-rsc.c together in the
same "qcom_rpmh.o", and then even further the KConfig lists this as
bool so both are builtin to the kernel.

-Doug


Sure. I Will change in v9.

Thanks for your review Doug,
Raju


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: [PATCH v8 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs

2018-05-23 Thread Raju P L S S S N

Hi,

On 5/12/2018 1:45 AM, Doug Anderson wrote:

Hi,

On Wed, May 9, 2018 at 10:01 AM, Lina Iyer  wrote:

+int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg)
+{
+   int ret;
+
+   if (!msg || !msg->cmds || !msg->num_cmds ||
+   msg->num_cmds > MAX_RPMH_PAYLOAD) {
+   WARN_ON(1);
+   return -EINVAL;
+   }
+
+   do {
+   ret = tcs_write(drv, msg);
+   if (ret == -EBUSY) {
+   pr_info_ratelimited("TCS Busy, retrying RPMH message send: 
addr=%#x\n",
+   msg->cmds[0].addr);
+   udelay(10);
+   }
+   } while (ret == -EBUSY);
+
+   return ret;
+}
+EXPORT_SYMBOL(rpmh_rsc_send_data);


Here and elsewhere in this series: why EXPORT_SYMBOL in this case?
This is only exported to rpmh.c, right?  You don't need EXPORT_SYMBOL
for that.  The Makefile puts rpmh.c and rpmh-rsc.c together in the
same "qcom_rpmh.o", and then even further the KConfig lists this as
bool so both are builtin to the kernel.

-Doug


Sure. I Will change in v9.

Thanks for your review Doug,
Raju


--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



Re: [PATCH v8 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs

2018-05-11 Thread Doug Anderson
Hi,

On Wed, May 9, 2018 at 10:01 AM, Lina Iyer  wrote:
> +int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg)
> +{
> +   int ret;
> +
> +   if (!msg || !msg->cmds || !msg->num_cmds ||
> +   msg->num_cmds > MAX_RPMH_PAYLOAD) {
> +   WARN_ON(1);
> +   return -EINVAL;
> +   }
> +
> +   do {
> +   ret = tcs_write(drv, msg);
> +   if (ret == -EBUSY) {
> +   pr_info_ratelimited("TCS Busy, retrying RPMH message 
> send: addr=%#x\n",
> +   msg->cmds[0].addr);
> +   udelay(10);
> +   }
> +   } while (ret == -EBUSY);
> +
> +   return ret;
> +}
> +EXPORT_SYMBOL(rpmh_rsc_send_data);

Here and elsewhere in this series: why EXPORT_SYMBOL in this case?
This is only exported to rpmh.c, right?  You don't need EXPORT_SYMBOL
for that.  The Makefile puts rpmh.c and rpmh-rsc.c together in the
same "qcom_rpmh.o", and then even further the KConfig lists this as
bool so both are builtin to the kernel.

-Doug


Re: [PATCH v8 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs

2018-05-11 Thread Doug Anderson
Hi,

On Wed, May 9, 2018 at 10:01 AM, Lina Iyer  wrote:
> +int rpmh_rsc_send_data(struct rsc_drv *drv, const struct tcs_request *msg)
> +{
> +   int ret;
> +
> +   if (!msg || !msg->cmds || !msg->num_cmds ||
> +   msg->num_cmds > MAX_RPMH_PAYLOAD) {
> +   WARN_ON(1);
> +   return -EINVAL;
> +   }
> +
> +   do {
> +   ret = tcs_write(drv, msg);
> +   if (ret == -EBUSY) {
> +   pr_info_ratelimited("TCS Busy, retrying RPMH message 
> send: addr=%#x\n",
> +   msg->cmds[0].addr);
> +   udelay(10);
> +   }
> +   } while (ret == -EBUSY);
> +
> +   return ret;
> +}
> +EXPORT_SYMBOL(rpmh_rsc_send_data);

Here and elsewhere in this series: why EXPORT_SYMBOL in this case?
This is only exported to rpmh.c, right?  You don't need EXPORT_SYMBOL
for that.  The Makefile puts rpmh.c and rpmh-rsc.c together in the
same "qcom_rpmh.o", and then even further the KConfig lists this as
bool so both are builtin to the kernel.

-Doug


[PATCH v8 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs

2018-05-09 Thread Lina Iyer
Add controller driver for QCOM SoCs that have hardware based shared
resource management. The hardware IP known as RSC (Resource State
Coordinator) houses multiple Direct Resource Voter (DRV) for different
execution levels. A DRV is a unique voter on the state of a shared
resource. A Trigger Control Set (TCS) is a bunch of slots that can house
multiple resource state requests, that when triggered will issue those
requests through an internal bus to the Resource Power Manager Hardened
(RPMH) blocks. These hardware blocks are capable of adjusting clocks,
voltages, etc. The resource state request from a DRV are aggregated
along with state requests from other processors in the SoC and the
aggregate value is applied on the resource.

Some important aspects of the RPMH communication -
- Requests are  with some header information
- Multiple requests (upto 16) may be sent through a TCS, at a time
- Requests in a TCS are sent in sequence
- Requests may be fire-n-forget or completion (response expected)
- Multiple TCS from the same DRV may be triggered simultaneously
- Cannot send a request if another request for the same addr is in
  progress from the same DRV
- When all the requests from a TCS are complete, an IRQ is raised
- The IRQ handler needs to clear the TCS before it is available for
  reuse
- TCS configuration is specific to a DRV
- Platform drivers may use DRV from different RSCs to make requests

Resource state requests made when CPUs are active are called 'active'
state requests. Requests made when all the CPUs are powered down (idle
state) are called 'sleep' state requests. They are matched by a
corresponding 'wake' state requests which puts the resources back in to
previously requested active state before resuming any CPU. TCSes are
dedicated for each type of requests. Active mode TCSes (AMC) are used to
send requests immediately to the resource, while control TCS are used to
provide specific information to the controller. Sleep and Wake TCS send
sleep and wake requests, after and before the system halt respectively.

Signed-off-by: Lina Iyer 
---

Changes in v8:
- introduce interrupt description in DT for all DRvs

Changes in v7:
- rename 'm' and 'n' variable names

Changes in v6:
- Remove tasklet and response object
- introduce rpm_write_tcs_cmd() function
- rename tcs_irq_handler()
- avoid bool in structures. Fix tcs.h.
Changes in v4:
- lots of variable name changes as suggested by Stephen B
- use of const for data pointers
- fix comments and other code syntax
- use of bitmap for tcs_in_use instead of atomic
---
 drivers/soc/qcom/Kconfig|  10 +
 drivers/soc/qcom/Makefile   |   1 +
 drivers/soc/qcom/rpmh-internal.h|  69 
 drivers/soc/qcom/rpmh-rsc.c | 483 
 include/dt-bindings/soc/qcom,rpmh-rsc.h |  14 +
 include/soc/qcom/tcs.h  |  56 +++
 6 files changed, 633 insertions(+)
 create mode 100644 drivers/soc/qcom/rpmh-internal.h
 create mode 100644 drivers/soc/qcom/rpmh-rsc.c
 create mode 100644 include/dt-bindings/soc/qcom,rpmh-rsc.h
 create mode 100644 include/soc/qcom/tcs.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 5c4535b545cc..1887e1b1f43b 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -56,6 +56,16 @@ config QCOM_RMTFS_MEM
 
  Say y here if you intend to boot the modem remoteproc.
 
+config QCOM_RPMH
+   bool "Qualcomm RPM-Hardened (RPMH) Communication"
+   depends on ARCH_QCOM && ARM64 && OF || COMPILE_TEST
+   help
+ Support for communication with the hardened-RPM blocks in
+ Qualcomm Technologies Inc (QTI) SoCs. RPMH communication uses an
+ internal bus to transmit state requests for shared resources. A set
+ of hardware components aggregate requests for these resources and
+ help apply the aggregated state on the resource.
+
 config QCOM_SMEM
tristate "Qualcomm Shared Memory Manager (SMEM)"
depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index dcebf2814e6d..39d3a059ee50 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_QCOM_PM)   +=  spm.o
 obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o
 qmi_helpers-y  += qmi_encdec.o qmi_interface.o
 obj-$(CONFIG_QCOM_RMTFS_MEM)   += rmtfs_mem.o
+obj-$(CONFIG_QCOM_RPMH)+=  rpmh-rsc.o
 obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) += smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
new file mode 100644
index ..cc29176f1303
--- /dev/null
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -0,0 +1,69 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2016-2018, The Linux Foundation. All rights 

[PATCH v8 01/10] drivers: qcom: rpmh-rsc: add RPMH controller for QCOM SoCs

2018-05-09 Thread Lina Iyer
Add controller driver for QCOM SoCs that have hardware based shared
resource management. The hardware IP known as RSC (Resource State
Coordinator) houses multiple Direct Resource Voter (DRV) for different
execution levels. A DRV is a unique voter on the state of a shared
resource. A Trigger Control Set (TCS) is a bunch of slots that can house
multiple resource state requests, that when triggered will issue those
requests through an internal bus to the Resource Power Manager Hardened
(RPMH) blocks. These hardware blocks are capable of adjusting clocks,
voltages, etc. The resource state request from a DRV are aggregated
along with state requests from other processors in the SoC and the
aggregate value is applied on the resource.

Some important aspects of the RPMH communication -
- Requests are  with some header information
- Multiple requests (upto 16) may be sent through a TCS, at a time
- Requests in a TCS are sent in sequence
- Requests may be fire-n-forget or completion (response expected)
- Multiple TCS from the same DRV may be triggered simultaneously
- Cannot send a request if another request for the same addr is in
  progress from the same DRV
- When all the requests from a TCS are complete, an IRQ is raised
- The IRQ handler needs to clear the TCS before it is available for
  reuse
- TCS configuration is specific to a DRV
- Platform drivers may use DRV from different RSCs to make requests

Resource state requests made when CPUs are active are called 'active'
state requests. Requests made when all the CPUs are powered down (idle
state) are called 'sleep' state requests. They are matched by a
corresponding 'wake' state requests which puts the resources back in to
previously requested active state before resuming any CPU. TCSes are
dedicated for each type of requests. Active mode TCSes (AMC) are used to
send requests immediately to the resource, while control TCS are used to
provide specific information to the controller. Sleep and Wake TCS send
sleep and wake requests, after and before the system halt respectively.

Signed-off-by: Lina Iyer 
---

Changes in v8:
- introduce interrupt description in DT for all DRvs

Changes in v7:
- rename 'm' and 'n' variable names

Changes in v6:
- Remove tasklet and response object
- introduce rpm_write_tcs_cmd() function
- rename tcs_irq_handler()
- avoid bool in structures. Fix tcs.h.
Changes in v4:
- lots of variable name changes as suggested by Stephen B
- use of const for data pointers
- fix comments and other code syntax
- use of bitmap for tcs_in_use instead of atomic
---
 drivers/soc/qcom/Kconfig|  10 +
 drivers/soc/qcom/Makefile   |   1 +
 drivers/soc/qcom/rpmh-internal.h|  69 
 drivers/soc/qcom/rpmh-rsc.c | 483 
 include/dt-bindings/soc/qcom,rpmh-rsc.h |  14 +
 include/soc/qcom/tcs.h  |  56 +++
 6 files changed, 633 insertions(+)
 create mode 100644 drivers/soc/qcom/rpmh-internal.h
 create mode 100644 drivers/soc/qcom/rpmh-rsc.c
 create mode 100644 include/dt-bindings/soc/qcom,rpmh-rsc.h
 create mode 100644 include/soc/qcom/tcs.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 5c4535b545cc..1887e1b1f43b 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -56,6 +56,16 @@ config QCOM_RMTFS_MEM
 
  Say y here if you intend to boot the modem remoteproc.
 
+config QCOM_RPMH
+   bool "Qualcomm RPM-Hardened (RPMH) Communication"
+   depends on ARCH_QCOM && ARM64 && OF || COMPILE_TEST
+   help
+ Support for communication with the hardened-RPM blocks in
+ Qualcomm Technologies Inc (QTI) SoCs. RPMH communication uses an
+ internal bus to transmit state requests for shared resources. A set
+ of hardware components aggregate requests for these resources and
+ help apply the aggregated state on the resource.
+
 config QCOM_SMEM
tristate "Qualcomm Shared Memory Manager (SMEM)"
depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index dcebf2814e6d..39d3a059ee50 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_QCOM_PM)   +=  spm.o
 obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o
 qmi_helpers-y  += qmi_encdec.o qmi_interface.o
 obj-$(CONFIG_QCOM_RMTFS_MEM)   += rmtfs_mem.o
+obj-$(CONFIG_QCOM_RPMH)+=  rpmh-rsc.o
 obj-$(CONFIG_QCOM_SMD_RPM) += smd-rpm.o
 obj-$(CONFIG_QCOM_SMEM) += smem.o
 obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o
diff --git a/drivers/soc/qcom/rpmh-internal.h b/drivers/soc/qcom/rpmh-internal.h
new file mode 100644
index ..cc29176f1303
--- /dev/null
+++ b/drivers/soc/qcom/rpmh-internal.h
@@ -0,0 +1,69 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
+ */
+
+
+#ifndef