Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2445787ybh; Fri, 24 Jul 2020 13:03:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0kErdrIsqI/Q/rDn2vDe1IGMnuwCGPXJ9odKmUMxR268Mg+fGx0QoV9jOkcKmBEdgw+yl X-Received: by 2002:a17:906:d106:: with SMTP id b6mr7069348ejz.125.1595621038079; Fri, 24 Jul 2020 13:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595621038; cv=none; d=google.com; s=arc-20160816; b=WwZKPDF5eSFPdHKdOr32oh1il8LFdPIHL56W5P6+i7d0Ajw6gUifHCne7qEA2Dc/gU f5ZbvhQwp0b0UXDBAlN8kEHmXRbXf8xk8pVk1w+tAMM+3c3QVnbgQ7qB4hI4oH/TC1g6 lKRGXz/gDtbYcUYbRSAJC7xHyinBgfJqvAkVoWGVWbnU0HgE2oCdvLovDXFxwQ2Xt4sV MXKLA8DiuWZK1c1dw/tOU6yejDElC8xFgSVz2QweefbZuIE57KUGBa8QmaUhjTw6iggW iQkGuwV4qt4SqSSGsOSFply320pN9J2ldCG3Xy8zb1hQxZMlUMGGrf9+/p988/NNLtFd jgnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=CF38ejeupSdGLQ8SJg5UVKB/UvbU/lVoIN0k+iE3qP0=; b=t9LkC9m6ir9nM+9v9dzBpECWnvTkgSOmOMezIdbz22Iy18j9CCW0CvDPAA6tC9w1A6 8u3zf7IN23ZxDKUWfBFKLn/ceOvnbGkV/TUqOiPKfrVu5wnF1KKauQbw3LsdDAIG5Guz VPrh7s20TiIaIeJQQ4BgyFd8RuBIqgOHyIUhX5L17ReZissjo+eq0vIjBIydOSyWpGoL bYig+SXHrw28cC1eLR+Lntdh4lgFe7Y/GZURAfJT9Y/0TlcdKVUAlvY6A9srT8uIF4I1 TUzXscZH+o/1sBTJ+EmLO0fIEM5namuHhbkLnK0RVoq6IyZGv95MjZDEDij+jyjiPpnG NrAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Tcg0l6Yi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id t2si1252362ejd.382.2020.07.24.13.03.35; Fri, 24 Jul 2020 13:03:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Tcg0l6Yi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726667AbgGXUBO (ORCPT + 99 others); Fri, 24 Jul 2020 16:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726455AbgGXUBO (ORCPT ); Fri, 24 Jul 2020 16:01:14 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F0FAC0619E4 for ; Fri, 24 Jul 2020 13:01:14 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id t15so5993494pjq.5 for ; Fri, 24 Jul 2020 13:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=CF38ejeupSdGLQ8SJg5UVKB/UvbU/lVoIN0k+iE3qP0=; b=Tcg0l6YibTvYMjZh4BV+v8/m9CpmT00Z5P0C8vjG89p7GV0rRLK3NFXh/rDz2pt4ki 0qUjFnOw9u6BGRfN7nhWgp6KpVrdRPDX4GayUdMXNYAUyPqOSmyEihmKjQUENfrgWwEl jYo7/U8rtG7haX9+GPmj8KMso+v8hNrbBAcUw= 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 :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=CF38ejeupSdGLQ8SJg5UVKB/UvbU/lVoIN0k+iE3qP0=; b=DMb51DLXx2N8H0zXjfLsHzdsY8ZI0qGX9Dv4DDf2WR39Rx5UEzOxXM0WYIPLDf7pYH plpZVxAli/1rNkS+Z4nfg4w5em1XvSlcs5+3CgZoTsi9c/Gu8emJZdgaLMMg3jnHqfN9 amzCEWL8yInvqOeij/nndrVtq1EgGIwZiOKk7Yk8GlElcweaMAoIXlzxWtT66JnmNdQr g96QSwBssDwxrevFr+Z9bzgOINcFy1N6xYYek6LSjug/h78VTsEuqqCiK5+6/NWmqnvX QGCXAy3TWOCkfetVJ8cPX1iy+gP4XMAplC1ehILT8t8bq7IrFCiZHdV7NosZ802nfJpX rFwA== X-Gm-Message-State: AOAM5313HqV+2uwI4OiEgeYrXrDwOvFlumTdiAnpIXcKjLhVRR2G8AOe EQx31HUW2yT8pmpB0G0aeYgfiA== X-Received: by 2002:a17:90a:750:: with SMTP id s16mr6847752pje.218.1595620873480; Fri, 24 Jul 2020 13:01:13 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:3e52:82ff:fe6c:83ab]) by smtp.gmail.com with ESMTPSA id u23sm6991699pgn.26.2020.07.24.13.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 13:01:12 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20200723010137.3127584-1-swboyd@chromium.org> <159561988523.3847286.14763422711224252201@swboyd.mtv.corp.google.com> Subject: Re: [PATCH] soc: qcom: rpmh-rsc: Sleep waiting for tcs slots to be free From: Stephen Boyd Cc: Andy Gross , Bjorn Andersson , LKML , linux-arm-msm , Maulik Shah , Lina Iyer To: Doug Anderson Date: Fri, 24 Jul 2020 13:01:12 -0700 Message-ID: <159562087212.3847286.9484527206999948907@swboyd.mtv.corp.google.com> User-Agent: alot/0.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Doug Anderson (2020-07-24 12:49:56) > Hi, >=20 > On Fri, Jul 24, 2020 at 12:44 PM Stephen Boyd wrote: > > > > > > - if (ret) > > > > - goto unlock; > > > > > > > > - ret =3D find_free_tcs(tcs); > > > > - if (ret < 0) > > > > - goto unlock; > > > > - tcs_id =3D ret; > > > > + wait_event_lock_irq(drv->tcs_wait, > > > > + (tcs_id =3D claim_tcs_for_req(drv, tcs,= msg)) >=3D 0, > > > > > > Even though claim_tcs_for_req() only returns 0 or -EBUSY today (IOW it > > > never returns error codes other than -EBUSY), should we handle it? If > > > we don't, claim_tcs_for_req() should be very clear that it shouldn't > > > return any errors other than -EBUSY. > > > > Do you mean you want to change it to be > > > > (tcs_id =3D claim_tcs_for_req(drv, tcs, msg)) !=3D -EBUSY > > > > instead of >=3D 0? It should return the tcs_id that was claimed, not ju= st > > 0 or -EBUSY. >=20 > Ah, right. Yes, you got it right. Of course then we have to add a > "if (tcd_id < 0) goto unlock", too. If you think it's not worth > adding this then we just need to make sure it's super obvious in > claim_tcs_for_req() that it's not allowed to return other errors. >=20 Hmm right now the code will wait forever for the condition to become true, so it will only ever continue past this point if tcs_id >=3D 0. We could add a timeout here in another patch, but I didn't want to change the behavior of what is there in this patch. I don't really care if >=3D 0 or !=3D -EBUSY is used here so I can change it to -EBUSY to provide clarity. If we add a timeout here, it would be better to change this driver to use a pull model instead of the push model it is using today so that the timeout isn't necessary. That would entail making a proper kthread that pulls requests off a queue of messages and then this asnyc call would append messages to the end of the queue and return immediately. That would be necessary if we want the async calls to work from non-sleeping contexts for example. I think Lina was alluding to this earlier in this thread.