Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp49682ybm; Thu, 28 May 2020 15:47:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI7ynsoam1IEyp8xnf1vsvEHlyESX9TJYZcAu6CTPdX5jUMzOUYojF3YU+hoLsZxOygRtf X-Received: by 2002:a05:6402:2216:: with SMTP id cq22mr5575951edb.167.1590706070478; Thu, 28 May 2020 15:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590706070; cv=none; d=google.com; s=arc-20160816; b=oTeTJokntJxpdpCmwz7AfuRX8VgksKWldPRgVPQjiCqzltt/HJ68+EiVErFmnQrS/2 jPcsX+gWJhIZk6wcNm+/7nc29BM2oi5t1cIIL/5PFItSlgx7XQRQyIV0VhZj+aibAV91 b6FcE3yv+ruNrFFeAK9b0MAUyieZ1/idjHdKft59gsu7DtBwsVxkVv7kIFdQqcxSr7uh 313wamT+zDRigxduYRtVPfaiJ1sUZ/m/pqf+tidMytGWq1v8i52lrwrzz5EGz+uIe2wf IVbv/28pLiiea+KHNHVwhGUUhTxjoC6he3FEG7YIHIlDZYmrpiXDoE3IoM4K1cupuE9u wvwA== 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=CzlwaQBhB6X7vtfLTVD7DA58u/rA562/f1SXevkBPwc=; b=mrRxitQvNc+EgLCTLbVGg4qemrgxZ0KBRF/Pvax6oTQT8zFDhh5QMIaU/tx9Qr1Ru1 C35u75C1YeDivd2ya+kIEVUQrUDjkspI9Db4l7qZpOYLEuQEobAIO8vfycehqr1gurL+ cKXU91MEdAR+zs6TVk+VHszFiK/+13wz4yumyc3RnWIrXc6WWrhkPWh8ts+Abdg6G0pJ yhjEsIoDSiVnjn21xl4V62IKYn8kMqsmcBQS1h9UuJXINMGMTIO//zqlW0bGcYLDwJt2 WK1YdEkfy1EK8x3y2RWWrXvTY/YJx//52Be3X9qBKztcBRgkpvOevYcCifwyMGfXS2+a Y3pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VmAFHRbf; 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 b8si3394434edn.355.2020.05.28.15.47.26; Thu, 28 May 2020 15:47:50 -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=VmAFHRbf; 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 S2437307AbgE1Wox (ORCPT + 99 others); Thu, 28 May 2020 18:44:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437279AbgE1Wou (ORCPT ); Thu, 28 May 2020 18:44:50 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4687C08C5C6 for ; Thu, 28 May 2020 15:44:50 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id d10so312880pgn.4 for ; Thu, 28 May 2020 15:44:50 -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=CzlwaQBhB6X7vtfLTVD7DA58u/rA562/f1SXevkBPwc=; b=VmAFHRbfcJExWJg8IgA6FKmejubQ9aKrIMIpPgpBFIhi+OMjmGfyYIhaTxzH6Poy/w jdvuOtq2cPl5F0semT5ERouwcWiYv5TlPYJ933Xqr+/eboqx/JeNEHqXDYbWa6RA3L5u gvsCSQ26kDVhEfH0T0/kDNwzv32S1XZYOCkFs= 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=CzlwaQBhB6X7vtfLTVD7DA58u/rA562/f1SXevkBPwc=; b=B8gj4/mYXaUecEzrHZqSh1HhlS8Sq62IN1dID0d5hoYzvBMYqoJOCd31oZMg3yBnBA 2CkonpSUqUprCmWepy66dxAFnQsZtinRPB9yMCqP1FZ+7SdQvd63+FI4pt44GASleZFr z1ZWZK6skzLtcCgeeWkRkLWShlMW3Yp5viihVItf6HNgmgH67zlrBHeQS2b/fib4roSK eAB3BWyen+NVCrWOHheBR5CDuy0enqB3/n9btCTo78Kb9/hfvPLDrFINR9Ofs5SQDWjZ MWyqWUm7RZeUpLib30zaxyAIPlNGFxlQf/7UaYBSsvwig0mMJAVWITYY9WA/we9A1ik5 72qA== X-Gm-Message-State: AOAM530MLd39pw/IxDKUNvC8CuoggPu59MiS8oZ1zm+kLRwWVTk0J3ME mR3TfhZNuPQfDYFJ9c0UtlKvRg== X-Received: by 2002:a05:6a00:1486:: with SMTP id v6mr5324082pfu.83.1590705890029; Thu, 28 May 2020 15:44:50 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id z18sm5600812pfj.148.2020.05.28.15.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 15:44:49 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200528074530.1.Ib86e5b406fe7d16575ae1bb276d650faa144b63c@changeid> References: <20200528074530.1.Ib86e5b406fe7d16575ae1bb276d650faa144b63c@changeid> Subject: Re: [PATCH] soc: qcom: rpmh-rsc: Don't use ktime for timeout in write_tcs_reg_sync() From: Stephen Boyd Cc: Maulik Shah , Douglas Anderson , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org To: Andy Gross , Bjorn Andersson , Douglas Anderson Date: Thu, 28 May 2020 15:44:48 -0700 Message-ID: <159070588846.69627.5268638209383373410@swboyd.mtv.corp.google.com> User-Agent: alot/0.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >=20 > 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. >=20 > 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. >=20 > Fixes: 91160150aba0 ("soc: qcom: rpmh-rsc: Timeout after 1 second in writ= e_tcs_reg_sync()") > Reported-by: Maulik Shah > Signed-off-by: Douglas Anderson > --- Reviewed-by: Stephen Boyd 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. Spinning for a second with irqs disabled is also insane for realtime so there's that problem too. Maybe we should try to kick timekeeping forward from these loops manually. Anyway, not problems with this patch so not important to fix immediately.