Commit 814a0d46 authored by Stephen Boyd's avatar Stephen Boyd Committed by Bjorn Andersson

soc: qcom: rpmh-rsc: Remove tcs_is_free() API

This API does very little. Let's replace all the callsites with the
normal operations that would be done on top of the bitmap that
tcs_in_use is. This simplifies and reduces the code size.
Reviewed-by: default avatarMaulik Shah <mkshah@codeaurora.org>
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Cc: Maulik Shah <mkshah@codeaurora.org>
Cc: Douglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarStephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20200521060425.24285-2-swboyd@chromium.orgSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 62fef634
...@@ -194,22 +194,6 @@ static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id, ...@@ -194,22 +194,6 @@ static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id,
data, tcs_id, reg); data, tcs_id, reg);
} }
/**
* tcs_is_free() - Return if a TCS is totally free.
* @drv: The RSC controller.
* @tcs_id: The global ID of this TCS.
*
* Returns true if nobody has claimed this TCS (by setting tcs_in_use).
*
* Context: Must be called with the drv->lock held.
*
* Return: true if the given TCS is free.
*/
static bool tcs_is_free(struct rsc_drv *drv, int tcs_id)
{
return !test_bit(tcs_id, drv->tcs_in_use);
}
/** /**
* tcs_invalidate() - Invalidate all TCSes of the given type (sleep or wake). * tcs_invalidate() - Invalidate all TCSes of the given type (sleep or wake).
* @drv: The RSC controller. * @drv: The RSC controller.
...@@ -520,7 +504,7 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id, ...@@ -520,7 +504,7 @@ static void __tcs_buffer_write(struct rsc_drv *drv, int tcs_id, int cmd_id,
* *
* Return: 0 if nothing in flight or -EBUSY if we should try again later. * Return: 0 if nothing in flight or -EBUSY if we should try again later.
* The caller must re-enable interrupts between tries since that's * The caller must re-enable interrupts between tries since that's
* the only way tcs_is_free() will ever return true and the only way * the only way tcs_in_use will ever be updated and the only way
* RSC_DRV_CMD_ENABLE will ever be cleared. * RSC_DRV_CMD_ENABLE will ever be cleared.
*/ */
static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
...@@ -528,17 +512,14 @@ static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, ...@@ -528,17 +512,14 @@ static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
{ {
unsigned long curr_enabled; unsigned long curr_enabled;
u32 addr; u32 addr;
int i, j, k; int j, k;
int tcs_id = tcs->offset; int i = tcs->offset;
for (i = 0; i < tcs->num_tcs; i++, tcs_id++) {
if (tcs_is_free(drv, tcs_id))
continue;
curr_enabled = read_tcs_reg(drv, RSC_DRV_CMD_ENABLE, tcs_id); for_each_set_bit_from(i, drv->tcs_in_use, tcs->offset + tcs->num_tcs) {
curr_enabled = read_tcs_reg(drv, RSC_DRV_CMD_ENABLE, i);
for_each_set_bit(j, &curr_enabled, MAX_CMDS_PER_TCS) { for_each_set_bit(j, &curr_enabled, MAX_CMDS_PER_TCS) {
addr = read_tcs_cmd(drv, RSC_DRV_CMD_ADDR, tcs_id, j); addr = read_tcs_cmd(drv, RSC_DRV_CMD_ADDR, i, j);
for (k = 0; k < msg->num_cmds; k++) { for (k = 0; k < msg->num_cmds; k++) {
if (addr == msg->cmds[k].addr) if (addr == msg->cmds[k].addr)
return -EBUSY; return -EBUSY;
...@@ -556,18 +537,19 @@ static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, ...@@ -556,18 +537,19 @@ static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
* *
* Must be called with the drv->lock held since that protects tcs_in_use. * Must be called with the drv->lock held since that protects tcs_in_use.
* *
* Return: The first tcs that's free. * Return: The first tcs that's free or -EBUSY if all in use.
*/ */
static int find_free_tcs(struct tcs_group *tcs) static int find_free_tcs(struct tcs_group *tcs)
{ {
int i; const struct rsc_drv *drv = tcs->drv;
unsigned long i;
for (i = 0; i < tcs->num_tcs; i++) { unsigned long max = tcs->offset + tcs->num_tcs;
if (tcs_is_free(tcs->drv, tcs->offset + i))
return tcs->offset + i;
}
i = find_next_zero_bit(drv->tcs_in_use, max, tcs->offset);
if (i >= max)
return -EBUSY; return -EBUSY;
return i;
} }
/** /**
...@@ -754,8 +736,9 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg) ...@@ -754,8 +736,9 @@ int rpmh_rsc_write_ctrl_data(struct rsc_drv *drv, const struct tcs_request *msg)
*/ */
static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv) static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv)
{ {
int m; unsigned long set;
struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS]; const struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS];
unsigned long max;
/* /*
* If we made an active request on a RSC that does not have a * If we made an active request on a RSC that does not have a
...@@ -766,12 +749,10 @@ static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv) ...@@ -766,12 +749,10 @@ static bool rpmh_rsc_ctrlr_is_busy(struct rsc_drv *drv)
if (!tcs->num_tcs) if (!tcs->num_tcs)
tcs = &drv->tcs[WAKE_TCS]; tcs = &drv->tcs[WAKE_TCS];
for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { max = tcs->offset + tcs->num_tcs;
if (!tcs_is_free(drv, m)) set = find_next_bit(drv->tcs_in_use, max, tcs->offset);
return true;
}
return false; return set < max;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment