Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2657048pxv; Sun, 11 Jul 2021 21:42:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy07OHCyAphewJ6M6k9cePyKR2U0gHFVAQEjEb34R3/RsJLgZWhLIXqxCH9R0HnI5blwuSQ X-Received: by 2002:a05:6402:22e1:: with SMTP id dn1mr26805211edb.8.1626064958523; Sun, 11 Jul 2021 21:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626064958; cv=none; d=google.com; s=arc-20160816; b=Y755FHmOVqcASE3Cr1o/ZyKQv6z+NB7lKe5+aO4eVAl8HoI4o0RJ31GtljvrE9+Ul4 jkH83+T0z9HSSmBE7LT+vXCz0avUsDdNvGikOt9tNIoYDJp75M257lGXsigGe8SZtxE0 wBBXOpQmSAaRpMGBRPG/rOx773T5Gdmk3ZpF8to6z2aHYUUSG98UGjuyHy6I1o61+jdj ucjj+Ui+mpWZGg5AtzacoQ1kyM2NMgEuUh1FO0dYzCns1c3CMQd4RuVj/LSbdPpdlZ// vb5HXNJj6yzIMSqoLmLcZx/eeE/usl6Y4UzkmHc219E19Visub2CmHLS0vXbZTnatnme M6fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZL0bec2agHsc0j6ce/Gb5bsSghII65P7kEsioPLg7/I=; b=U1eiXdpj7omHj3tK5mVHsixXuA+IP9s3MFyM0UoRlQevIFlRddhgKo56mH8EqxaK1B 3IRKo579KcDq+jynG2/6VEdcBkc/4D/HegCl3wTsvw1JD4p9yeFZ9Jny+rdVdUjcnkyo KT/kOIwFIUMrEYO3o5AiBSthIA70oFhtEia6eoIguQSoZXNf/jGWsQoUkFvQ2Ox+Wcvs oOEZsHL1r5XhlEiHMAkfdWhzvSxmjsBMqO4H4LFAQjbQBTzCcaW81ocRxtpruGtHj2Lz JhP6ZAEZOI43YbvhCmXPNXAzu8PzsZlIVfdJsbq+n+AEnoj757CME3QjMMtaPWAn6HKG FbCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPci+XbT; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j29si14768513ejj.60.2021.07.11.21.42.15; Sun, 11 Jul 2021 21:42:38 -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=@linaro.org header.s=google header.b=WPci+XbT; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229849AbhGLEoE (ORCPT + 99 others); Mon, 12 Jul 2021 00:44:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbhGLEoD (ORCPT ); Mon, 12 Jul 2021 00:44:03 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB132C0613E5 for ; Sun, 11 Jul 2021 21:41:15 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id o3-20020a17090a6783b0290173ce472b8aso880034pjj.2 for ; Sun, 11 Jul 2021 21:41:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZL0bec2agHsc0j6ce/Gb5bsSghII65P7kEsioPLg7/I=; b=WPci+XbTcvjEfOXEze65WR/kHiJj7UnotldAAu3YV5QxlaYIadepyymWghBbbGgVhR S9Lezk9hED0qIXMmE07/fHAeTk0Tu+2zzWJa38fGbKb1jvqBRxN26Nl4R8cmK9EO/NbE O7HFlaT8Vh2s0HQL0mutd3aGJcZW969KDbu7cVK84yZDtn+lQutF8Ap2xKeLMxmjiYkk SSR4D7i5jnaRKH6bwcidT5MLu7HqcW20j6GW7w/qG3Pba1DyV0zt14wq7xnpEbugEHvk Gx8kbYIY4/bOsIg7wfcutupfK46FJeJ38nH3mTO2r2SrSgfzBg/rjZdu2VCInk47K0k+ Ma/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZL0bec2agHsc0j6ce/Gb5bsSghII65P7kEsioPLg7/I=; b=pxFVFJ1Li1MqejgssChWevBSDNTUZ+ceuYvPmerharPjnGU7qXqRFJk9SCwB13BCYG NwYRs3ggkq5kkVln4s9+1Lynjxf9nwRaELGf+ui6j38duX5qcR2znVI+DqP+TzDtXY4x q8dXOEtZBlThJyZjgx3HmggDyKACMxeW4wgBYv+ibDHBQzUC4BQBN0NDQBnHjCdF6Mt7 Ht1KpbPoVIHwUlboaoxwHGEd9n0vQ5zYsSAOtuGqrCZUDsu2xsf0GwyTB9yW0Ce3CJ48 emyVpZB/tQ4I0v8iywWXhgiOSMA8BBzX7JmavnfMb0PM7csgyIxvocAR4RB6bKsZJyAS OPBQ== X-Gm-Message-State: AOAM533i2ZYoa0mE2FHZU7ti59Fp7zJvmBaE4Gh7dmrzitLkoqB6y6gi U00SRb3lEoV7QnX8Cyamhzb2Ww== X-Received: by 2002:a17:90a:db98:: with SMTP id h24mr23092454pjv.156.1626064875097; Sun, 11 Jul 2021 21:41:15 -0700 (PDT) Received: from localhost ([106.201.108.2]) by smtp.gmail.com with ESMTPSA id s36sm6810167pgk.64.2021.07.11.21.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Jul 2021 21:41:14 -0700 (PDT) Date: Mon, 12 Jul 2021 10:11:12 +0530 From: Viresh Kumar To: Thara Gopinath Cc: agross@kernel.org, bjorn.andersson@linaro.org, rui.zhang@intel.com, daniel.lezcano@linaro.org, rjw@rjwysocki.net, robh+dt@kernel.org, tdas@codeaurora.org, mka@chromium.org, linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [Patch v3 3/6] cpufreq: qcom-cpufreq-hw: Add dcvs interrupt support Message-ID: <20210712044112.svhlagrktcfvyj35@vireshk-i7> References: <20210708120656.663851-1-thara.gopinath@linaro.org> <20210708120656.663851-4-thara.gopinath@linaro.org> <20210709064646.7vjgiba2o7beudly@vireshk-i7> <5a98ef2a-d170-f52d-cc48-b838cddaa5c2@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5a98ef2a-d170-f52d-cc48-b838cddaa5c2@linaro.org> User-Agent: NeoMutt/20180716-391-311a52 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09-07-21, 11:37, Thara Gopinath wrote: > On 7/9/21 2:46 AM, Viresh Kumar wrote: > > > @@ -389,6 +503,10 @@ static int qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy) > > > dev_pm_opp_remove_all_dynamic(cpu_dev); > > > dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); > > > + if (data->lmh_dcvs_irq > 0) { > > > + devm_free_irq(cpu_dev, data->lmh_dcvs_irq, data); > > > > Why using devm variants here and while requesting the irq ? Missed this one ? > > > > > + cancel_delayed_work_sync(&data->lmh_dcvs_poll_work); > > > + } > > > > Please move this to qcom_cpufreq_hw_lmh_exit() or something. > > Ok. > > > > > Now with sequence of disabling interrupt, etc, I see a potential > > problem. > > > > CPU0 CPU1 > > > > qcom_cpufreq_hw_cpu_exit() > > -> devm_free_irq(); > > qcom_lmh_dcvs_poll() > > -> qcom_lmh_dcvs_notify() > > -> enable_irq() > > > > -> cancel_delayed_work_sync(); > > > > > > What will happen if enable_irq() gets called after freeing the irq ? > > Not sure, but it looks like you will hit this then from manage.c: > > > > WARN(!desc->irq_data.chip, KERN_ERR "enable_irq before > > setup/request_irq: irq %u\n", irq)) > > > > ? > > > > You got a chicken n egg problem :) > > Yes indeed! But also it is a very rare chicken and egg problem. > The scenario here is that the cpus are busy and running load causing a > thermal overrun and lmh is engaged. At the same time for this issue to be > hit the cpu is trying to exit/disable cpufreq. Yes, it is a very specific case but it needs to be resolved anyway. You don't want to get this ever :) > Calling > cancel_delayed_work_sync first could solve this issue, right ? > cancel_delayed_work_sync guarantees the work not to be pending even if > it requeues itself on return. So once the delayed work is cancelled, the > interrupts can be safely disabled. Thoughts ? I don't think even that would provide such guarantees to you here, as there is a chance the work gets queued again because of an interrupt that triggers right after you cancel the work. The basic way of solving such issues is that once you cancel something, you need to guarantee that it doesn't get triggered again, no matter what. The problem here I see is with your design itself, both delayed work and irq can enable each other, so no matter which one you disable first, won't be sufficient. You need to fix that design somehow. -- viresh