Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2453369ybh; Fri, 24 Jul 2020 13:16:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8iM1AH3vSpdAGxkQbgtmBkrqQNBF5tuJbvXb1bPIVPyUKO7NhALSoBd90Z6zoDD46IhpL X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr10170474edb.191.1595621773901; Fri, 24 Jul 2020 13:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595621773; cv=none; d=google.com; s=arc-20160816; b=sc/J6fIvUGnlRD+7pRtak1R7qrujKMeiijwyBoug5eYAr4ZWJW53n4iEoQywpcXn+f fSxJZutqtRp8G/kia6te2KGLajsb3w7pXv2P58ZWPiSLkz17OpJj8I/TtP38ayxBN3Da 7YCNDrNVNvha+I26FKSWQfmRrw1FrX7fuIJzw0UeWGJ+lpCVQbt3GUywbkyu5yU6KaxI 4Na86dMWSoac8aJ67xSp09jrnZWm9SYtPiZbR71e94cc0Z5w4d9ZeYV9wN15o1gWiG4w Lz0ULSbIUoczQWJGGykXmmg48Ne+de9mNpf7PKwnK/yRPlD3N0pRiWaLV6oTVySYfAyT Yqyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=LM5eS2EeRGKww+dYskRfhmE9ybbsR8gCTRM+LVzEnYc=; b=EJ0nG8LIwOJ0FM+dpAQ7bihrDLOmKKKVZ+BzmxCytj6KQxDehNbmzmfQjobHcpsHxW oEltr+0zA+ZXo6eVcAcBqnUFqVfrmiaN3yVYDZrfKYK8c3LBbExlTvr6nejF5Zdu+vIk WnEtAQviFRaBna1IuGVzxtyjIq7pEtEn6jDG+o094vEeyn6AN5neXk9LEXWnGcK0twiE WfOuh+I0+Jt22ddKRpdP57gp9HBrcLQR/QaSrOn/ghfnD/Hzz661jwszA9fVzOZZUIA0 6ZWaEDdRASaqbFEzKGPc4LaZSU67i7atAoFKJtqax4fJ/2HqC3YM087bNKsS65RUjwbJ ra4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iwSz087a; 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 s9si1083034edw.12.2020.07.24.13.15.51; Fri, 24 Jul 2020 13:16:13 -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=iwSz087a; 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 S1726702AbgGXUMR (ORCPT + 99 others); Fri, 24 Jul 2020 16:12:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbgGXUMQ (ORCPT ); Fri, 24 Jul 2020 16:12:16 -0400 Received: from mail-vs1-xe44.google.com (mail-vs1-xe44.google.com [IPv6:2607:f8b0:4864:20::e44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC0CC0619E4 for ; Fri, 24 Jul 2020 13:12:15 -0700 (PDT) Received: by mail-vs1-xe44.google.com with SMTP id 1so895640vsl.1 for ; Fri, 24 Jul 2020 13:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LM5eS2EeRGKww+dYskRfhmE9ybbsR8gCTRM+LVzEnYc=; b=iwSz087aaVUaiSy1oH9aa8XJaarVKSzVfLzp/O4LysKy3u1QVPScnmr13iFwMv3SCT 0gIzFILLrv2w2raEeGSNDRBWD+3817WlhnydMdgxhGKHReLuPGu6kF6KAWjIGa2MzykV JruC9nRwh9hvoMlHT7vihvIaF/VdfgBjqJfLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LM5eS2EeRGKww+dYskRfhmE9ybbsR8gCTRM+LVzEnYc=; b=Y9cSNQm395gM5J++RqC1Fah7SvKG7GXKfemJBz5onNEWVXG60hlrsk8AWobm6muxXQ 0L7PsHeCxDlrO5kL3c7k5MQByNxZ4/zcoIJeyhHM6CjPdj8lVNQhtzyvOg6zLJNR9CZ7 8qY7ki6oeCdrWX+lTBb6motklvWssyOWP9mXRVnfe0zuO5hSuDqcaxFaHb5DNnr5Z0yB gCKTRGqMJsiTk+GjLNwChj4KPHEmQzm5BqgJwXrhsi0ND1ZXFOwPwgn+FzFEdhpeb0W3 0chrZfKi+F7gYJdwiuyOb/oyohQxB72EYG1/43TmLa1izu397UnWEel+29HIDZ0VeVaC 2q4w== X-Gm-Message-State: AOAM533jI84Kwny3gKAS474EIcHTbzeoWz6C5CFdZrBo9gZjDACpqN23 C2ehQAJLQyy8Ub3OXQPBjsQuJy4cGE4= X-Received: by 2002:a05:6102:126a:: with SMTP id q10mr8614894vsg.35.1595621533792; Fri, 24 Jul 2020 13:12:13 -0700 (PDT) Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com. [209.85.217.46]) by smtp.gmail.com with ESMTPSA id j189sm215776vsd.24.2020.07.24.13.12.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Jul 2020 13:12:12 -0700 (PDT) Received: by mail-vs1-f46.google.com with SMTP id m6so5525164vsl.12 for ; Fri, 24 Jul 2020 13:12:12 -0700 (PDT) X-Received: by 2002:a67:ec0f:: with SMTP id d15mr8730677vso.121.1595621531870; Fri, 24 Jul 2020 13:12:11 -0700 (PDT) MIME-Version: 1.0 References: <20200723010137.3127584-1-swboyd@chromium.org> <159561988523.3847286.14763422711224252201@swboyd.mtv.corp.google.com> <159562087212.3847286.9484527206999948907@swboyd.mtv.corp.google.com> In-Reply-To: <159562087212.3847286.9484527206999948907@swboyd.mtv.corp.google.com> From: Doug Anderson Date: Fri, 24 Jul 2020 13:11:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] soc: qcom: rpmh-rsc: Sleep waiting for tcs slots to be free To: Stephen Boyd Cc: Andy Gross , Bjorn Andersson , LKML , linux-arm-msm , Maulik Shah , Lina Iyer Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Jul 24, 2020 at 1:01 PM Stephen Boyd wrote: > > Quoting Doug Anderson (2020-07-24 12:49:56) > > Hi, > > > > On Fri, Jul 24, 2020 at 12:44 PM Stephen Boyd wrote: > > > > > > > > - if (ret) > > > > > - goto unlock; > > > > > > > > > > - ret = find_free_tcs(tcs); > > > > > - if (ret < 0) > > > > > - goto unlock; > > > > > - tcs_id = ret; > > > > > + wait_event_lock_irq(drv->tcs_wait, > > > > > + (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 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 = claim_tcs_for_req(drv, tcs, msg)) != -EBUSY > > > > > > instead of >= 0? It should return the tcs_id that was claimed, not just > > > 0 or -EBUSY. > > > > 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. > > > > 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 >= 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 >= 0 > or != -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. I wasn't suggesting adding a timeout. I was just saying that if claim_tcs_for_req() were to ever return an error code other than -EBUSY that we'd need a check for it because otherwise we'd interpret the result as a tcs_id. -Doug