Received: by 10.223.185.116 with SMTP id b49csp74464wrg; Thu, 8 Mar 2018 13:07:38 -0800 (PST) X-Google-Smtp-Source: AG47ELtlKUJOBbbQY19W9jiPYqHOGg3E83y54QIeG5WE/dtTbnn7v7KW1Lxvfq2+JGUDdtR7miga X-Received: by 2002:a17:902:b2c7:: with SMTP id x7-v6mr6101345plw.298.1520543258485; Thu, 08 Mar 2018 13:07:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520543258; cv=none; d=google.com; s=arc-20160816; b=WNGbjfFd3O9IM0zVW5typELmwH++iSDtHSfwT54nuUY69DD0WOt2IsLd9JD5y/6LiJ +k5knJ/A9tJrArMQtMUooNFT99AteRn/wjfrTuX6Z6naer9/2XJvDTzJscY4kzNeo077 PcwjPKRT7Ij/nwNWX45AOHZqnCnZwmR1vUmiU1vlnh3R3NcAPmC8NhbKMeKsAjBcUs5x Vh53g6ouWi/7pb3erk39YgDgrkaERsqBhsFlz9IlvhUqUfpgVzoPpflaADCwnG4U48kK 04skEtrRiUEayXOy37Riwsw89JTEsO9uIQEvn+9bvpBLKD97NLQUmqReVZL+BPQwCm9/ 7IBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=qVetALZ68zUmMN1PppF//YJvEzgqgYXL65W48ZVcefQ=; b=qSfRcm049pqQicKZcn1NVuWcv142pQZCwvEhfXJPohMcT1f7UflParF7QcqlXxxCCc h1RPzDd+uVc8YebC6hkCackxhGs3Bd421TPFNbRgurAr1zZuAV0gfETWrtU/sod41ro7 DAXUS7TDQk4f7VuD0Uf4jrBEIH57zIGwAcGx91govwXu3ksdgB4b8k8oIrwFdpw7x6VE JHFm2VY7Qlu49Zb6OXcOC2sQOP/hrckLXMZwHbRoJRxtH97XjVMWXjsXJSTR89pDugYS eA9LJH0G6xh22qDu14XsM0i1gJsj1jBs47QdS4Y2N0v35Cg7Acj8FroL7E1EmJEJkVRK XrLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jArAYDhn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f30-v6si15472909plf.654.2018.03.08.13.07.23; Thu, 08 Mar 2018 13:07:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jArAYDhn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751157AbeCHVGN (ORCPT + 99 others); Thu, 8 Mar 2018 16:06:13 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:44909 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750909AbeCHVGM (ORCPT ); Thu, 8 Mar 2018 16:06:12 -0500 Received: by mail-pg0-f66.google.com with SMTP id l4so2707399pgp.11 for ; Thu, 08 Mar 2018 13:06:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:to:from:in-reply-to:cc :references:message-id:user-agent:subject:date; bh=qVetALZ68zUmMN1PppF//YJvEzgqgYXL65W48ZVcefQ=; b=jArAYDhnT3jFOt2UkhEySDgZmZOwSSjs0jBaQthEgvu/wUbyC1Wzf+cxIJoaI/zM1F WGx2SHoLcQm051JTnunw0qx7z3zEydjx4lSQNe7BzvfRfmiPwl7WUt2XKPYgw5i8kOtI fKI5InrR3N3dOjfMNZLlL9Y9S7GazfS7I331I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding:to:from :in-reply-to:cc:references:message-id:user-agent:subject:date; bh=qVetALZ68zUmMN1PppF//YJvEzgqgYXL65W48ZVcefQ=; b=lrrfyzSxzx/VJnMqYt25qhDWNkmRBppF3m9kIRDgQB8hXdDKjpTaX1xXfWpbWaPw2e 21oVs5H9aLUk2Ms/frROtituE/53JweELvHCdnCHBW/EYFlsGkrATRdaZ0nawDMcUwZc 7UuXcRAmeL+boJuUfcYhULUTKlhxHlbvWozBibYQi5gtcWL/xfmuH2mE9Ht+axbOQ99q zg7DJQPsSyn8/xVbgCpzUHfQmknkLzboP5lkuM30fy2tST4piuRYPN9fMIZBh1LubjXm mIaAahJadHqxFRY6sauRhLAXM1OD1H8q3dnOPckpP2HvqopptqoqFX4gr3QJ/u5TvVzr rC0A== X-Gm-Message-State: APf1xPBNZbcZV/qet3USaKc5puMCGI9g117eghwzpqJpElWjWs23NaJ2 3yKPJS090QRimddNbRLHM0U39A== X-Received: by 10.99.122.12 with SMTP id v12mr22394417pgc.128.1520543171481; Thu, 08 Mar 2018 13:06:11 -0800 (PST) Received: from localhost ([2620:0:1000:1501:422f:ca5c:71a2:c3b3]) by smtp.gmail.com with ESMTPSA id b88sm42861326pfd.108.2018.03.08.13.06.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Mar 2018 13:06:10 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: Lina Iyer , andy.gross@linaro.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org From: Stephen Boyd In-Reply-To: <20180302164317.10554-9-ilina@codeaurora.org> Cc: rnayak@codeaurora.org, bjorn.andersson@linaro.org, linux-kernel@vger.kernel.org, Lina Iyer References: <20180302164317.10554-1-ilina@codeaurora.org> <20180302164317.10554-9-ilina@codeaurora.org> Message-ID: <152054316996.219802.9903507378142636932@swboyd.mtv.corp.google.com> User-Agent: alot/0.7 Subject: Re: [PATCH v3 08/10] drivers: qcom: rpmh: allow requests to be sent asynchronously Date: Thu, 08 Mar 2018 13:06:09 -0800 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Lina Iyer (2018-03-02 08:43:15) > @@ -69,6 +71,7 @@ struct rpmh_request { > atomic_t *wait_count; > struct rpmh_client *rc; > int err; > + struct rpmh_request *free; > }; > = > /** > @@ -114,6 +117,8 @@ void rpmh_tx_done(struct tcs_request *msg, int r) > "RPMH TX fail in msg addr 0x%x, err=3D%d\n", > rpm_msg->msg.payload[0].addr, r); > = > + kfree(rpm_msg->free); Is this potentially freeing something which is then used after this call later in this function? It looks like the compiler could be reloading from freed memory for the wc and compl variables after this kfree is called. At the least, please add some sort of comment or if we don't ever need to free a _different_ rpm_msg than the existing one, make it a flag so it becomes very obvious that we're freeing the same memory that we loaded from in this function. > + > /* Signal the blocking thread we are done */ > if (wc && atomic_dec_and_test(wc) && compl) > complete(compl); > @@ -257,6 +262,53 @@ static int __rpmh_write(struct rpmh_client *rc, enum= rpmh_state state, > return ret; > } > = > +static struct rpmh_request *__get_rpmh_msg_async(struct rpmh_client *rc, > + enum rpmh_state state, > + struct tcs_cmd *cmd, int = n) > +{ > + struct rpmh_request *req; > + > + if (IS_ERR_OR_NULL(rc) || !cmd || n <=3D 0 || n > MAX_RPMH_PAYLOA= D) unsigned n? > + return ERR_PTR(-EINVAL); > + > + req =3D kcalloc(1, sizeof(*req), GFP_ATOMIC); kzalloc()? > + if (!req) > + return ERR_PTR(-ENOMEM); > + > + memcpy(req->cmd, cmd, n * sizeof(*cmd)); > + > + req->msg.state =3D state; > + req->msg.payload =3D req->cmd; > + req->msg.num_payload =3D n; > + req->free =3D req; > + > + return req; > +} > + > +/** > + * rpmh_write_async: Write a set of RPMH commands ... and don't wait for a result? > + * > + * @rc: The RPMh handle got from rpmh_get_dev_channel > + * @state: Active/sleep set > + * @cmd: The payload data > + * @n: The number of elements in payload > + * > + * Write a set of RPMH commands, the order of commands is maintained > + * and will be sent as a single shot. > + */ > +int rpmh_write_async(struct rpmh_client *rc, enum rpmh_state state, > + struct tcs_cmd *cmd, int n) > +{ > + struct rpmh_request *rpm_msg; > + > + rpm_msg =3D __get_rpmh_msg_async(rc, state, cmd, n); > + if (IS_ERR(rpm_msg)) > + return PTR_ERR(rpm_msg); > + > + return __rpmh_write(rc, state, rpm_msg); > +} > +EXPORT_SYMBOL(rpmh_write_async); > + > /** > * rpmh_write: Write a set of RPMH commands and block until response > *