From patchwork Fri Sep 2 14:21:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 9311077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 18DC1607D2 for ; Fri, 2 Sep 2016 14:21:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AD19297B7 for ; Fri, 2 Sep 2016 14:21:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3A12297C0; Fri, 2 Sep 2016 14:21:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8A20297B7 for ; Fri, 2 Sep 2016 14:21:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932172AbcIBOVG (ORCPT ); Fri, 2 Sep 2016 10:21:06 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:35149 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932129AbcIBOVF (ORCPT ); Fri, 2 Sep 2016 10:21:05 -0400 Received: by mail-yw0-f194.google.com with SMTP id t137so181478ywg.2; Fri, 02 Sep 2016 07:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rzi1VyVYW+v2jbVZk0YmLhdt0sjsjUSaMckWsHj7/ws=; b=U9kfBtCVzyfI6Ag7kAp6/YZWAoFxE97bJQnGyD5fclFZZ755DveMdnGpdRv8CL5CUq x3WZ78pzm6RNdU0/Wlh8QQCv5F4H73cKB0DIQ69M3HqeHOIyVnZIHTXUDeBZCH1CqGEE ELjIgcBaXIcONOw34zEuJo8y80ZlJIDRfPb5GS/ML1z/J+93YRe5nLo0vBBUWuKqApQw nGaUufEnW+iR8EIa9M3WuH7BI26jgfN62s7yfv22d476/xOOgsapD29Z/jnIFSYymTs6 7sr7nQvoKQW66uEDdSezyf2Ol4jLLejJisWnz6YhJ6wHgxqsTTdMcSuFnEt9xlQ1anBP kR6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=rzi1VyVYW+v2jbVZk0YmLhdt0sjsjUSaMckWsHj7/ws=; b=hElr92IBMtd1gB2ArpkBrkGPcvrWECScnVQQd3n5Hhbua2vF2UeooB3oGC7ZinoSWD uFpGZwd1gAfHlh7W1byP9XBf+ZZNFGE11GBJNOiURODGbv9EFhhjStrTg+WEkDS0ZE24 jJheuXB/9il8qqdBcAwDCzypQP5iC0BRH1aDgEASE6iIOKA+9vxRvhRV36/s3lZl0n6x 1QWQppcfe2PQShGR02kBheWboZ94/5KsJGfZxuwU+P6jJgJ2bKeIrhkevvFJqppeTP52 kke7GEleqhNsiv/hWByr2Qsn63EG0Z+AKMJBKbpK+o2fNMhkQXZFK5vKJuWiAEvtAeR4 1U4w== X-Gm-Message-State: AE9vXwMOO65OjAOIdGRt4T97yoHDQAm6Hy0pc2zf79ll59ZwUHmyRifgpO6xX+ip1GEkcQ== X-Received: by 10.129.55.205 with SMTP id e196mr18162339ywa.243.1472826064266; Fri, 02 Sep 2016 07:21:04 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::a:11c7]) by smtp.gmail.com with ESMTPSA id y12sm4097026ywg.46.2016.09.02.07.21.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Sep 2016 07:21:02 -0700 (PDT) Date: Fri, 2 Sep 2016 10:21:02 -0400 From: Tejun Heo To: qiaozhou Cc: linux-pm@vger.kernel.org, Wang Wilbur , Wu Gang , linux-kernel@vger.kernel.org Subject: Re: [Question] about patch: don't use [delayed_]work_pending() Message-ID: <20160902142102.GG12660@htj.duckdns.org> References: <20160901184503.GD12660@htj.duckdns.org> <6b2fc72b-f99f-f7f1-3221-093943de0950@asrmicro.com> <20160902135007.GF12660@htj.duckdns.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160902135007.GF12660@htj.duckdns.org> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, Sep 02, 2016 at 09:50:07AM -0400, Tejun Heo wrote: > Hello, > > On Fri, Sep 02, 2016 at 09:17:04AM +0800, qiaozhou wrote: > > > > I don't know whether it's meaningful to still check pending work here, or > > > > it's not suggested to use pm_qos_update_request in this early boot up phase. > > > > Could you help to share some opinions? (I can fix this issue by adding the > > > > current qos value directly instead of default value, though.) > > > Hmmm... but I suppose this is super-early in the boot. Would it make > > > sense to have a static variable (e.g. bool clk_fully_initailized) to > > > gate the cancel_delayed_sync() call? > > > > You're right that it's indeed super-early stage. But currently we can't > > control the gate of can_delayed_work_sync, since it's inside > > pm_qos_update_request. Out of our control. We can choose to not call > > pm_qos_update_request to avoid this issue, and use pm_qos_add_request > > alternatively. Good to have it. > > Ah sorry, didn't understand that the offending cancel_sync call is in > the generic part. Hmm... but yeah, we should still be able to take > the same approach. I'll see what's the right thing to gate the > operation there. Does the following patch work? Subject: power: avoid calling cancel_delayed_work_sync() during early boot of_clk_init() ends up calling into pm_qos_update_request() very early during boot where irq is expected to stay disabled. pm_qos_update_request() uses cancel_delayed_work_sync() which correctly assumes that irq is enabled on invocation and unconditionally disables and re-enables it. Gate cancel_delayed_work_sync() invocation with kevented_up() to avoid enabling irq unexpectedly during early boot. Signed-off-by: Tejun Heo Reported-by: Qiao Zhou Link: http://lkml.kernel.org/r/d2501c4c-8e7b-bea3-1b01-000b36b5dfe9@asrmicro.com --- kernel/power/qos.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 97b0df7..168ff44 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -482,7 +482,16 @@ void pm_qos_update_request(struct pm_qos_request *req, return; } - cancel_delayed_work_sync(&req->work); + /* + * This function may be called very early during boot, for example, + * from of_clk_init(), where irq needs to stay disabled. + * cancel_delayed_work_sync() assumes that irq is enabled on + * invocation and re-enables it on return. Avoid calling it until + * workqueue is initialized. + */ + if (keventd_up()) + cancel_delayed_work_sync(&req->work); + __pm_qos_update_request(req, new_value); } EXPORT_SYMBOL_GPL(pm_qos_update_request);