2023-10-25 12:05:59

by Mukesh Ojha

[permalink] [raw]
Subject: [PATCH v8 0/3] Misc SCM changes

These changes are needed to enable download mode on chipset
like IPQ9574 and IPQ5332 SoCs or also will help enabling crash
dump on multiple Qualcomm Soc with proper handling of download
mode bits.

First two changes(1/3-2/3) are SCM driver specific while 3/3 from
pinctrl try to use the introduced API(1/3) via removing the existing
logic.

Changes from v7: https://lore.kernel.org/lkml/[email protected]/
- Rebased it on next-20231025.
- Added reviewed-by tag and take care of comment made about
commit text should be in imperative mode.
- Modified the name of the API to qcom_scm_io_rmw() as per suggestion
made by [Dmitry]
- Moved spinlock inside qcom_scm structure.
- Corrected the patch order as per subsystem SCM first then pinctrl.

Change from minidump-v5(13/17-15/17):https://lore.kernel.org/lkml/[email protected]/
- Removed mistakenly added macros.
https://lore.kernel.org/lkml/[email protected]/
- Added Acked-by tag from Linus.w to 2/3.

Changes from dload series v6: https://lore.kernel.org/lkml/[email protected]/
- Rebased it on latest tag available on linux-next
- Added missed Poovendhan sign-off on 15/17 and tested-by tag from
Kathiravan. Thanks to him for testing and reminding me of missing sign-off.
- Addressed comments made on dload mode patch v6 version

Changes in v6:
- Applied suggested API change(at v4) by [dmitry.baryshkov]

Changes in v5: https://lore.kernel.org/lkml/[email protected]/
- Tried to fix the issue reported by kernel test robot
https://lore.kernel.org/lkml/[email protected]/

- Applied some of the improvement suggested by [Bjorn.andersson]

. Dropped 'both' instead support full,mini or mini,full for setting download
mode to collect both minidump and full dump.

. logging improvement.


Changes in v4: https://lore.kernel.org/lkml/[email protected]/
- val should be shifted within the function [srinivas.kandagatla]
i.e new = (old & ~mask) | (val << ffs(mask) - 1);
- Added Acked-by [linus.walleij] on pinctrl change.

Changes in v3 : https://lore.kernel.org/lkml/[email protected]/
- Removed [1] from the series and sent as a separate patch[2], although this series
should be applied on top [2].
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/lkml/[email protected]/
- Introduce new exported symbol on suggestion from [srinivas.kandagatla]
- Use the symbol from drivers/pinctrl/qcom/pinctrl-msm.c.
- Addressed comment given by [dmitry.baryshkov]
- Converted non-standard Originally-by to Signed-off-by.

Changes in v2: https://lore.kernel.org/lkml/[email protected]/
- Addressed comment made by [bjorn]
- Added download mask.
- Passed download mode as parameter
- Accept human accepatable download mode string.
- enable = !!dload_mode
- Shifted module param callback to somewhere down in
the file so that it no longer need to know the
prototype of qcom_scm_set_download_mode()
- updated commit text.


Mukesh Ojha (3):
firmware: qcom_scm: provide a read-modify-write function
firmware: scm: Modify only the download bits in TCSR register
pinctrl: qcom: Use qcom_scm_io_rmw() function

drivers/firmware/qcom/qcom_scm.c | 38 ++++++++++++++++++++++++++++++++--
drivers/pinctrl/qcom/pinctrl-msm.c | 10 ++++-----
include/linux/firmware/qcom/qcom_scm.h | 1 +
3 files changed, 41 insertions(+), 8 deletions(-)

--
2.7.4


2023-10-25 12:06:37

by Mukesh Ojha

[permalink] [raw]
Subject: [PATCH v8 1/3] firmware: qcom_scm: provide a read-modify-write function

It was realized by Srinivas K. that there is a need of
read-modify-write scm exported function so that it can
be used by multiple clients.

Let's introduce qcom_scm_io_rmw() which masks out the bits
and write the passed value to that bit-offset.

Suggested-by: Srinivas Kandagatla <[email protected]>
Signed-off-by: Mukesh Ojha <[email protected]>
Tested-by: Kathiravan Thirumoorthy <[email protected]> # IPQ9574 and IPQ5332
---
drivers/firmware/qcom/qcom_scm.c | 26 ++++++++++++++++++++++++++
include/linux/firmware/qcom/qcom_scm.h | 1 +
2 files changed, 27 insertions(+)

diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
index 520de9b5633a..25549178a30f 100644
--- a/drivers/firmware/qcom/qcom_scm.c
+++ b/drivers/firmware/qcom/qcom_scm.c
@@ -19,6 +19,7 @@
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+#include <linux/spinlock.h>
#include <linux/reset-controller.h>
#include <linux/types.h>

@@ -41,6 +42,8 @@ struct qcom_scm {
int scm_vote_count;

u64 dload_mode_addr;
+ /* Atomic context only */
+ spinlock_t lock;
};

struct qcom_scm_current_perm_info {
@@ -481,6 +484,28 @@ static int qcom_scm_disable_sdi(void)
return ret ? : res.result[0];
}

+int qcom_scm_io_rmw(phys_addr_t addr, unsigned int mask, unsigned int val)
+{
+ unsigned int old, new;
+ int ret;
+
+ if (!__scm)
+ return -EINVAL;
+
+ spin_lock(&__scm->lock);
+ ret = qcom_scm_io_readl(addr, &old);
+ if (ret)
+ goto unlock;
+
+ new = (old & ~mask) | (val & mask);
+
+ ret = qcom_scm_io_writel(addr, new);
+unlock:
+ spin_unlock(&__scm->lock);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_scm_io_rmw);
+
static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
{
struct qcom_scm_desc desc = {
@@ -1824,6 +1849,7 @@ static int qcom_scm_probe(struct platform_device *pdev)
return ret;

mutex_init(&scm->scm_bw_lock);
+ spin_lock_init(&scm->lock);

scm->path = devm_of_icc_get(&pdev->dev, NULL);
if (IS_ERR(scm->path))
diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
index ccaf28846054..3a8bb2e603b3 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -82,6 +82,7 @@ bool qcom_scm_pas_supported(u32 peripheral);

int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val);
int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
+int qcom_scm_io_rmw(phys_addr_t addr, unsigned int mask, unsigned int val);

bool qcom_scm_restore_sec_cfg_available(void);
int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare);
--
2.7.4