Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp702472ybm; Fri, 29 May 2020 10:05:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz52OxqMSyxEjjEQxWG+1Ugf03OthpdIOSS+wxYmXNG+cDi0V2Kxs3LTv1KXLVfsb5pZq2g X-Received: by 2002:a05:6402:17f9:: with SMTP id t25mr9497444edy.134.1590771922977; Fri, 29 May 2020 10:05:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590771922; cv=none; d=google.com; s=arc-20160816; b=hVxu8NzI+SxTL/amtkmoeOslwarNgtFfo+gm6pvDHtk4mlj3X/Mu8Benl+1+gfWKwW AwrgertH2OQmUoScwflquca2MbhHJ7CqH/fGjEygga+/96jGtio3N3EG8o4M+fQCN4Bl S03tw6qWghFXarQAi0MRCDDZ5I4rrzNK6dwnvHKk0W6yEgIO9qWHet59EnLwtnckiUEz LYS+i/shsK2aZFfXZUYlsjq5jrc5MjOCQWqoBqkeCdqqMpedbzKtZmLxgXpjLhCxtlnS 4k8S2l4Z9oGjY0xXJwpjkViRnZuvIvbBUD3py31Yfspz1594mOGAFo9CjPThUwAcVUZg FeUw== 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=4NakxdxLfiVqwrqYq3ygcYPN3b3c2MjleuUer7TJH2s=; b=QXwZAB07qBGqZhOiuBko+NkSGssDoUNU60F7XDz/fF8AsD2wFXK5+UKJyE+pt9FErR DmSzuoWjhRYmNklv7yojlMzk7c9j2DzBQymuwaFM3zeJiI9A5MhO5LzK8bbsx0eCCiS2 DU8JadSrrhOPQUe+EZX5ocecbFaxAsTq0y+SJdEL2bBZDm/D4amZm32swk99fGXnWnnJ uOWp142xJyw2aDlO6f5F3RbHrPar36C8zBdDl1zz8Xdlojo06xdDS6oaPU74itGcyb3g SvnvSY4LP1Sm13h3wMJGebMVxyPf52/pQOt4kpUAjozBxzTRHzzsxmaGX5ohpAqSyTQJ aCxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="hHVUwA/+"; 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 o12si6337838edq.34.2020.05.29.10.05.00; Fri, 29 May 2020 10:05:22 -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="hHVUwA/+"; 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 S1726954AbgE2RBO (ORCPT + 99 others); Fri, 29 May 2020 13:01:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726555AbgE2RBO (ORCPT ); Fri, 29 May 2020 13:01:14 -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 3B042C08C5C8 for ; Fri, 29 May 2020 10:01:13 -0700 (PDT) Received: by mail-vs1-xe44.google.com with SMTP id b13so1870240vsm.13 for ; Fri, 29 May 2020 10:01:13 -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=4NakxdxLfiVqwrqYq3ygcYPN3b3c2MjleuUer7TJH2s=; b=hHVUwA/+2FePatIbmmArTLqs4AgISB2ytYBtKxy2MPSOdXgRG0fYZJRtGIUTeKmGPk XPgs9a+KUmIyIDoDK04nN1kdWUxD1KB5j/dw6hOf+28M1mjqoPgFPkenJRAqUvmH4xzu EtcrRVo5X47+iFdX69c+3aYh5lMwwawDD7HpM= 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=4NakxdxLfiVqwrqYq3ygcYPN3b3c2MjleuUer7TJH2s=; b=IPhRbaxrw6s3m4dFvENMZIl/seNV5Bjr8hJaHMv5jT8aDaI/tj8hc69y353T1ixFUO 3rpslBsYI/ssFiFS43v+ZO1B+ZfVnUZgM3QSUfmj9aRWSYId8fAX7wAcJ6C3clmrZb/Y 6AngNHozs0u3o/tWxB1X5px27cRA4D8fLrOyOBNNmQLfdOtLO2JRFiNxoNdGtL/Jqv3j zwMziM84riaMig+SaDZmVJ6nIp9QfinLfS+so0hBHzYxKFAowhtz7VpIRGZj+z6w7rLu dTAA9nVX5oRs60D/cCIUzdrgNhtYcgLqmnv4R2PwfDaivH+6XkviwZL0js5b6YAhVU6z j4+w== X-Gm-Message-State: AOAM533tcXN/MZM2YxY58rC2T40IqFarHrr2uxaS9w+VpQTVJ75Q/j7F LYCI3f4MF88j0RLCFGzI4yk16jvD9V4= X-Received: by 2002:a67:ed16:: with SMTP id l22mr6135283vsp.30.1590771672117; Fri, 29 May 2020 10:01:12 -0700 (PDT) Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com. [209.85.217.47]) by smtp.gmail.com with ESMTPSA id x144sm1330549vke.18.2020.05.29.10.01.11 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 May 2020 10:01:11 -0700 (PDT) Received: by mail-vs1-f47.google.com with SMTP id u7so1898337vsp.7 for ; Fri, 29 May 2020 10:01:11 -0700 (PDT) X-Received: by 2002:a67:b14b:: with SMTP id z11mr6575412vsl.109.1590771670806; Fri, 29 May 2020 10:01:10 -0700 (PDT) MIME-Version: 1.0 References: <20200528074530.1.Ib86e5b406fe7d16575ae1bb276d650faa144b63c@changeid> <159070588846.69627.5268638209383373410@swboyd.mtv.corp.google.com> In-Reply-To: <159070588846.69627.5268638209383373410@swboyd.mtv.corp.google.com> From: Doug Anderson Date: Fri, 29 May 2020 10:00:59 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] soc: qcom: rpmh-rsc: Don't use ktime for timeout in write_tcs_reg_sync() To: Stephen Boyd Cc: Andy Gross , Bjorn Andersson , Maulik Shah , linux-arm-msm , LKML 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 Thu, May 28, 2020 at 3:44 PM Stephen Boyd wrote: > > Quoting Douglas Anderson (2020-05-28 07:48:34) > > The write_tcs_reg_sync() may be called after timekeeping is suspended > > so it's not OK to use ktime. The readl_poll_timeout_atomic() macro > > implicitly uses ktime. This was causing a warning at suspend time. > > > > Change to just loop 1000000 times with a delay of 1 us between loops. > > This may give a timeout of more than 1 second but never less and is > > safe even if timekeeping is suspended. > > > > NOTE: I don't have any actual evidence that we need to loop here. > > It's possibly that all we really need to do is just read the value > > back to ensure that the pipes are cleaned and the looping/comparing is > > totally not needed. I never saw the loop being needed in my tests. > > However, the loop shouldn't hurt. > > > > Fixes: 91160150aba0 ("soc: qcom: rpmh-rsc: Timeout after 1 second in write_tcs_reg_sync()") > > Reported-by: Maulik Shah > > Signed-off-by: Douglas Anderson > > --- > > Reviewed-by: Stephen Boyd Thanks! > Although I don't think ktime_get() inside of readl_poll_timeout_atomic() > is correct. The timekeeping base won't be able to update when a loop is > spinning in an irq disabled region. We need the tick interrupt to come > in and update the base. Is this really a problem? I'm not totally familiar with the timekeeping code, but I know I've used ktime to time things while interrupts are disabled in the past. It looks as if things are OK as long as the base is updated every once in a while and it just does deltas from there... > Spinning for a second with irqs disabled is also > insane for realtime so there's that problem too. Yeah. I just arbitrarily picked 1 second originally so we didn't loop infinitely. The expectation is that we'd never actually hit this timeout. If we do then there's (presumably) some type of serious problem that needs to be debugged. -Doug