* [PATCH] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation
@ 2020-04-14 17:41 Douglas Anderson
2020-04-14 17:56 ` Joe Perches
2020-04-14 19:44 ` Stephen Boyd
0 siblings, 2 replies; 4+ messages in thread
From: Douglas Anderson @ 2020-04-14 17:41 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson
Cc: mkshah, mka, swboyd, joe, evgreen, Douglas Anderson,
linux-arm-msm, linux-kernel
We can make some of the register access functions more readable by
factoring out the calculations a little bit.
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
drivers/soc/qcom/rpmh-rsc.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
index 732316bb67dc..de1f9c7732e1 100644
--- a/drivers/soc/qcom/rpmh-rsc.c
+++ b/drivers/soc/qcom/rpmh-rsc.c
@@ -136,36 +136,45 @@
* +---------------------------------------------------+
*/
+static inline void __iomem *
+tcs_reg_addr(struct rsc_drv *drv, int reg, int tcs_id)
+{
+ return drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg;
+}
+
+static inline void __iomem *
+tcs_cmd_addr(struct rsc_drv *drv, int reg, int tcs_id, int cmd_id)
+{
+ return tcs_reg_addr(drv, reg, tcs_id) + RSC_DRV_CMD_OFFSET * cmd_id;
+}
+
static u32 read_tcs_cmd(struct rsc_drv *drv, int reg, int tcs_id, int cmd_id)
{
- return readl_relaxed(drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg +
- RSC_DRV_CMD_OFFSET * cmd_id);
+ return readl_relaxed(tcs_cmd_addr(drv, reg, tcs_id, cmd_id));
}
static u32 read_tcs_reg(struct rsc_drv *drv, int reg, int tcs_id)
{
- return readl_relaxed(drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg);
+ return readl_relaxed(tcs_reg_addr(drv, reg, tcs_id));
}
static void write_tcs_cmd(struct rsc_drv *drv, int reg, int tcs_id, int cmd_id,
u32 data)
{
- writel_relaxed(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg +
- RSC_DRV_CMD_OFFSET * cmd_id);
+ writel_relaxed(data, tcs_cmd_addr(drv, reg, tcs_id, cmd_id));
}
static void write_tcs_reg(struct rsc_drv *drv, int reg, int tcs_id, u32 data)
{
- writel_relaxed(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg);
+ writel_relaxed(data, tcs_reg_addr(drv, reg, tcs_id));
}
static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, int tcs_id,
u32 data)
{
- writel(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg);
+ writel(data, tcs_reg_addr(drv, reg, tcs_id));
for (;;) {
- if (data == readl(drv->tcs_base + reg +
- RSC_DRV_TCS_OFFSET * tcs_id))
+ if (data == readl(tcs_reg_addr(drv, reg, tcs_id)))
break;
udelay(1);
}
--
2.26.0.110.g2183baf09c-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation
2020-04-14 17:41 [PATCH] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation Douglas Anderson
@ 2020-04-14 17:56 ` Joe Perches
2020-04-14 18:46 ` Doug Anderson
2020-04-14 19:44 ` Stephen Boyd
1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2020-04-14 17:56 UTC (permalink / raw)
To: Douglas Anderson, Andy Gross, Bjorn Andersson
Cc: mkshah, mka, swboyd, evgreen, linux-arm-msm, linux-kernel
On Tue, 2020-04-14 at 10:41 -0700, Douglas Anderson wrote:
> We can make some of the register access functions more readable by
> factoring out the calculations a little bit.
unrelated trivia:
> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
[]
> static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, int tcs_id,
> u32 data)
> {
> - writel(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg);
> + writel(data, tcs_reg_addr(drv, reg, tcs_id));
> for (;;) {
> - if (data == readl(drv->tcs_base + reg +
> - RSC_DRV_TCS_OFFSET * tcs_id))
> + if (data == readl(tcs_reg_addr(drv, reg, tcs_id)))
> break;
> udelay(1);
> }
There a lockup potential here.
It might be better to use some max loop counter with
an error/warning emitted instead of a continuous retry.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation
2020-04-14 17:56 ` Joe Perches
@ 2020-04-14 18:46 ` Doug Anderson
0 siblings, 0 replies; 4+ messages in thread
From: Doug Anderson @ 2020-04-14 18:46 UTC (permalink / raw)
To: Joe Perches
Cc: Andy Gross, Bjorn Andersson, Maulik Shah, Matthias Kaehlcke,
Stephen Boyd, Evan Green, linux-arm-msm, LKML
Hi,
On Tue, Apr 14, 2020 at 10:58 AM Joe Perches <joe@perches.com> wrote:
>
> On Tue, 2020-04-14 at 10:41 -0700, Douglas Anderson wrote:
> > We can make some of the register access functions more readable by
> > factoring out the calculations a little bit.
>
> unrelated trivia:
>
> > diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
> []
> > static void write_tcs_reg_sync(struct rsc_drv *drv, int reg, int tcs_id,
> > u32 data)
> > {
> > - writel(data, drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg);
> > + writel(data, tcs_reg_addr(drv, reg, tcs_id));
> > for (;;) {
> > - if (data == readl(drv->tcs_base + reg +
> > - RSC_DRV_TCS_OFFSET * tcs_id))
> > + if (data == readl(tcs_reg_addr(drv, reg, tcs_id)))
> > break;
> > udelay(1);
> > }
>
> There a lockup potential here.
>
> It might be better to use some max loop counter with
> an error/warning emitted instead of a continuous retry.
Yeah, I noticed that too but I assumed that it was probably OK. I
think in this case it's really just confirming that the write made it
across the bus since it's checking the same bit that it's writing.
...but I wouldn't be opposed to this changing to use
readl_poll_timeout().
-Doug
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation
2020-04-14 17:41 [PATCH] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation Douglas Anderson
2020-04-14 17:56 ` Joe Perches
@ 2020-04-14 19:44 ` Stephen Boyd
1 sibling, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2020-04-14 19:44 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Douglas Anderson
Cc: mkshah, mka, joe, evgreen, Douglas Anderson, linux-arm-msm, linux-kernel
Quoting Douglas Anderson (2020-04-14 10:41:34)
> We can make some of the register access functions more readable by
> factoring out the calculations a little bit.
>
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
> drivers/soc/qcom/rpmh-rsc.c | 27 ++++++++++++++++++---------
> 1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/soc/qcom/rpmh-rsc.c b/drivers/soc/qcom/rpmh-rsc.c
> index 732316bb67dc..de1f9c7732e1 100644
> --- a/drivers/soc/qcom/rpmh-rsc.c
> +++ b/drivers/soc/qcom/rpmh-rsc.c
> @@ -136,36 +136,45 @@
> * +---------------------------------------------------+
> */
>
> +static inline void __iomem *
> +tcs_reg_addr(struct rsc_drv *drv, int reg, int tcs_id)
const drv?
> +{
> + return drv->tcs_base + RSC_DRV_TCS_OFFSET * tcs_id + reg;
> +}
> +
> +static inline void __iomem *
> +tcs_cmd_addr(struct rsc_drv *drv, int reg, int tcs_id, int cmd_id)
const drv?
> +{
> + return tcs_reg_addr(drv, reg, tcs_id) + RSC_DRV_CMD_OFFSET * cmd_id;
> +}
> +
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-14 19:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 17:41 [PATCH] soc: qcom: rpmh-rsc: Factor "tcs_reg_addr" and "tcs_cmd_addr" calculation Douglas Anderson
2020-04-14 17:56 ` Joe Perches
2020-04-14 18:46 ` Doug Anderson
2020-04-14 19:44 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).