From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB6EC433E0 for ; Wed, 10 Jun 2020 11:20:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37E7220656 for ; Wed, 10 Jun 2020 11:20:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BsqzSleZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37E7220656 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date: In-reply-to:Subject:To:From:References:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=j5U4oru1SJtSIipz9fsGvxch8LuDppZIHC6vKowPhOM=; b=BsqzSleZSOCaeXqaI20FFrNW6L NMWLAWRL4a4Wb7UpHdzyTQOwsC3N7FayX2khID0SrsT9JhQUFd7JF6PWiFEVEWwNpdmEfd6TaPgYp eFDjwuH+Ju4JQi5ymtvQlmFeFiTunFdwfAlNdrQJrZJwLD/b8HahL2pdQOxkWr+Z/xU3V12CgHLAO +ER37Ak20QmAVwBx6TiFvhuisydmi+s3b1S0qkNunlmjXeywuETUqjxp28x3gXWpO6WlDg1hzpKpO yt76rWtCBovbf3Qtrx+foLDAoOlQGofZABNSS47vBIAYpJEJNJX19+7ButH0cB6LozsoYFSS7zqp/ ZyYwidSA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiymC-0008FJ-KB; Wed, 10 Jun 2020 11:20:12 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiym9-0007AD-AS for linux-arm-kernel@lists.infradead.org; Wed, 10 Jun 2020 11:20:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B7D6B1FB; Wed, 10 Jun 2020 04:20:06 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 257703F66F; Wed, 10 Jun 2020 04:20:05 -0700 (PDT) References: <20200609115825.10748-1-benjamin.gaignard@st.com> <20200609115825.10748-3-benjamin.gaignard@st.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Benjamin Gaignard Subject: Re: [PATCH v5 2/3] media: stm32-dcmi: Set minimum cpufreq requirement In-reply-to: <20200609115825.10748-3-benjamin.gaignard@st.com> Date: Wed, 10 Jun 2020 12:20:02 +0100 Message-ID: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200610_042009_414982_69BD4E1B X-CRM114-Status: GOOD ( 11.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.torgue@st.com, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, mcoquelin.stm32@gmail.com, hugues.fruchet@st.com, mchehab@kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Benjamin, On 09/06/20 12:58, Benjamin Gaignard wrote: > +static void dcmi_set_min_frequency(struct stm32_dcmi *dcmi, s32 freq) > +{ > + struct irq_affinity_notify *notify = &dcmi->notify; > + struct cpumask clear; > + > + mutex_lock(&dcmi->freq_lock); > + dcmi->targeted_frequency = freq; > + mutex_unlock(&dcmi->freq_lock); > + > + if (freq) { > + dcmi_irq_notifier_notify(notify, > + irq_get_affinity_mask(dcmi->irq)); > + } else { > + cpumask_clear(&clear); > + dcmi_irq_notifier_notify(notify, &clear); > + } > +} > + IIUC the changes in this version, you would now need a call to freq_qos_update_request() in the notifier. That's because you can now go through the notifier callback with targeted_frequency = FREQ_QOS_MIN_DEFAULT_VALUE yet still add CPUs to the boosted mask. I think you were pretty close to a decent solution in your previous version, with some notifier registration movement. This is what I had in mind (the diff is against v4; ofc absolutely untested!): --- diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index c2389776a958..cc147de6ea70 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -801,15 +801,22 @@ static void dcmi_set_min_frequency(struct stm32_dcmi *dcmi, s32 freq) struct irq_affinity_notify *notify = &dcmi->notify; if (freq) { + /* + * Register the notifier before doing any change, so the + * callback can be queued if an affinity change happens *while* + * we are requesting the boosts. + */ + irq_set_affinity_notifier(dcmi->irq, notify); dcmi_irq_notifier_notify(notify, irq_get_affinity_mask(dcmi->irq)); - - notify->notify = dcmi_irq_notifier_notify; - notify->release = dcmi_irq_notifier_release; - irq_set_affinity_notifier(dcmi->irq, notify); } else { struct cpumask clear; + /* + * Unregister the notifier before clearing the boost requests, + * as we don't want to boost again if an affinity change happens + * *while* we are clearing the requests + */ irq_set_affinity_notifier(dcmi->irq, NULL); cpumask_clear(&clear); dcmi_irq_notifier_notify(notify, &clear); @@ -2032,6 +2039,9 @@ static int dcmi_probe(struct platform_device *pdev) if (!alloc_cpumask_var(&dcmi->boosted, GFP_KERNEL)) return -ENODEV; + dcmi->notify->notify = dcmi_irq_notifier_notify; + dcmi->notify->release = dcmi_irq_notifier_release; + q = &dcmi->queue; dcmi->v4l2_dev.mdev = &dcmi->mdev; --- Does that make sense to you? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E537DC433DF for ; Wed, 10 Jun 2020 11:20:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB7A52074B for ; Wed, 10 Jun 2020 11:20:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbgFJLUH (ORCPT ); Wed, 10 Jun 2020 07:20:07 -0400 Received: from foss.arm.com ([217.140.110.172]:57230 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728264AbgFJLUH (ORCPT ); Wed, 10 Jun 2020 07:20:07 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B7D6B1FB; Wed, 10 Jun 2020 04:20:06 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 257703F66F; Wed, 10 Jun 2020 04:20:05 -0700 (PDT) References: <20200609115825.10748-1-benjamin.gaignard@st.com> <20200609115825.10748-3-benjamin.gaignard@st.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Benjamin Gaignard Cc: hugues.fruchet@st.com, mchehab@kernel.org, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-media@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, vincent.guittot@linaro.org, rjw@rjwysocki.net Subject: Re: [PATCH v5 2/3] media: stm32-dcmi: Set minimum cpufreq requirement In-reply-to: <20200609115825.10748-3-benjamin.gaignard@st.com> Date: Wed, 10 Jun 2020 12:20:02 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Benjamin, On 09/06/20 12:58, Benjamin Gaignard wrote: > +static void dcmi_set_min_frequency(struct stm32_dcmi *dcmi, s32 freq) > +{ > + struct irq_affinity_notify *notify = &dcmi->notify; > + struct cpumask clear; > + > + mutex_lock(&dcmi->freq_lock); > + dcmi->targeted_frequency = freq; > + mutex_unlock(&dcmi->freq_lock); > + > + if (freq) { > + dcmi_irq_notifier_notify(notify, > + irq_get_affinity_mask(dcmi->irq)); > + } else { > + cpumask_clear(&clear); > + dcmi_irq_notifier_notify(notify, &clear); > + } > +} > + IIUC the changes in this version, you would now need a call to freq_qos_update_request() in the notifier. That's because you can now go through the notifier callback with targeted_frequency = FREQ_QOS_MIN_DEFAULT_VALUE yet still add CPUs to the boosted mask. I think you were pretty close to a decent solution in your previous version, with some notifier registration movement. This is what I had in mind (the diff is against v4; ofc absolutely untested!): --- diff --git a/drivers/media/platform/stm32/stm32-dcmi.c b/drivers/media/platform/stm32/stm32-dcmi.c index c2389776a958..cc147de6ea70 100644 --- a/drivers/media/platform/stm32/stm32-dcmi.c +++ b/drivers/media/platform/stm32/stm32-dcmi.c @@ -801,15 +801,22 @@ static void dcmi_set_min_frequency(struct stm32_dcmi *dcmi, s32 freq) struct irq_affinity_notify *notify = &dcmi->notify; if (freq) { + /* + * Register the notifier before doing any change, so the + * callback can be queued if an affinity change happens *while* + * we are requesting the boosts. + */ + irq_set_affinity_notifier(dcmi->irq, notify); dcmi_irq_notifier_notify(notify, irq_get_affinity_mask(dcmi->irq)); - - notify->notify = dcmi_irq_notifier_notify; - notify->release = dcmi_irq_notifier_release; - irq_set_affinity_notifier(dcmi->irq, notify); } else { struct cpumask clear; + /* + * Unregister the notifier before clearing the boost requests, + * as we don't want to boost again if an affinity change happens + * *while* we are clearing the requests + */ irq_set_affinity_notifier(dcmi->irq, NULL); cpumask_clear(&clear); dcmi_irq_notifier_notify(notify, &clear); @@ -2032,6 +2039,9 @@ static int dcmi_probe(struct platform_device *pdev) if (!alloc_cpumask_var(&dcmi->boosted, GFP_KERNEL)) return -ENODEV; + dcmi->notify->notify = dcmi_irq_notifier_notify; + dcmi->notify->release = dcmi_irq_notifier_release; + q = &dcmi->queue; dcmi->v4l2_dev.mdev = &dcmi->mdev; --- Does that make sense to you?