Re: [PATCH v5 4/5] soc: qcom: rpmh-rsc: Simplify locking by eliminating the per-TCS lock

From: Stephen Boyd
Date: Fri Apr 24 2020 - 14:06:11 EST


Quoting Douglas Anderson (2020-04-24 09:46:56)
> @@ -581,24 +575,19 @@ static int tcs_write(struct rsc_drv *drv, const struct tcs_request *msg)
> if (IS_ERR(tcs))
> return PTR_ERR(tcs);
>
> - spin_lock_irqsave(&tcs->lock, flags);
> - spin_lock(&drv->lock);
> + spin_lock_irqsave(&drv->lock, flags);
> /*
> * The h/w does not like if we send a request to the same address,
> * when one is already in-flight or being processed.
> */
> ret = check_for_req_inflight(drv, tcs, msg);
> - if (ret) {
> - spin_unlock(&drv->lock);
> - goto done_write;
> - }
> + if (ret)
> + goto unlock;
>
> - tcs_id = find_free_tcs(tcs);
> - if (tcs_id < 0) {
> - ret = tcs_id;
> - spin_unlock(&drv->lock);
> - goto done_write;
> - }
> + ret = find_free_tcs(tcs);
> + if (ret < 0)
> + goto unlock;
> + tcs_id = ret;

Sorry, missed this. We should keep the tcs_id = find_free_tcs() thing
and then assign ret to it on failure. Otherwise the return value of this
function is -EBUSY or the tcs_id number instead of -EBUSY or 0.

>
> tcs->req[tcs_id - tcs->offset] = msg;
> set_bit(tcs_id, drv->tcs_in_use);