Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1302814ybg; Tue, 2 Jun 2020 06:37:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxze3RjOE7j0hnmIPLDrqde2mgDZDa1sWeBQfe2iz7DO9jqv0f0cYC4eUj/GXYU5IXQ4pR4 X-Received: by 2002:aa7:d158:: with SMTP id r24mr20375665edo.272.1591105068117; Tue, 02 Jun 2020 06:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591105068; cv=none; d=google.com; s=arc-20160816; b=faosJnx9zfqvV60U3S3+5cHuXS5VWwUGhlC5Dy2DgW/mFN528qin0jo88rfCE7Lij/ 8Qtebaf8jRKN+NV9I9Uo8OB6giETqzgNb2fqt4uJTglVfMAJdjJx5BeE1OyLfioGIlHy mPyfXWdwisiHdiC3MfpN6LVSzVTFbtHEEkuEjVYbyISoY9WRv/qGWVoIEbgekRnPRszy eyePZUWzFAZRm3lI3IfmCmXBZ+nnjo4KfEguUjOCqKnd122gak/PHRUBcpITydBRox7I xCATAJmOkrby+ORPqA4GWbvrtYAythNTRAu2Xg+QuAx2sA/Nyt7jXlpguDTxE6tlB1K0 R+MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references; bh=fjQYd7RlDn5+sUYoSVDtocAkgYwSytHYJBYMC84e9nM=; b=fiSEsEGVyMyD3Z5zoIj2utKvPKCM63VR3PHB96KFPVPYEQtdPPVenfw3DWeIqm8ny3 vmajA18T9cd3xT5+jWTfDcVSj+6/cHnNw4Itfo7U6dIX/7WfGDuWonAEvP8G4txdvwwf B+pp3mpvEtQ5s8/Ahc3xmeCC1uEMcDdJXRP5GKzMvNMxImJsM3R0AUcJkillp5g7EWp9 m/SNLOSE5J+I0PSAIZN2UKLWZChXROXOwVhhfna4hZkFAOKTACil2/IX8d/2Lu2pUSSF YZB2pbpX+b9BiVznBxNXeJCnp4bM3npfYYEL8yr7oMH9ZfWPuLerF8xRqnRXW5ybIh5Q vmVQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h25si1408799ejt.604.2020.06.02.06.37.24; Tue, 02 Jun 2020 06:37:48 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726962AbgFBNfk (ORCPT + 99 others); Tue, 2 Jun 2020 09:35:40 -0400 Received: from foss.arm.com ([217.140.110.172]:50978 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725940AbgFBNfj (ORCPT ); Tue, 2 Jun 2020 09:35:39 -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 B5F721FB; Tue, 2 Jun 2020 06:35:38 -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 1EA783F305; Tue, 2 Jun 2020 06:35:37 -0700 (PDT) References: <20200527151613.16083-1-benjamin.gaignard@st.com> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Benjamin GAIGNARD Cc: Hugues FRUCHET , "mchehab\@kernel.org" , "mcoquelin.stm32\@gmail.com" , Alexandre TORGUE , "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] media: stm32-dcmi: Set minimum cpufreq requirement In-reply-to: Date: Tue, 02 Jun 2020 14:35:31 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/06/20 12:37, Benjamin GAIGNARD wrote: > On 6/2/20 11:31 AM, Valentin Schneider wrote: >>> @@ -99,6 +100,8 @@ enum state { >>> >>> #define OVERRUN_ERROR_THRESHOLD 3 >>> >>> +#define DCMI_MIN_FREQ 650000 /* in KHz */ >>> + >> This assumes the handling part is guaranteed to always run on the same CPU >> with the same performance profile (regardless of the platform). If that's >> not guaranteed, it feels like you'd want this to be configurable in some >> way. > Yes I could add a st,stm32-dcmi-min-frequency (in KHz) parameter the > device tree node. > Something like that - I'm not sure how well this fits with the DT landscape, as you could argue it isn't really a description of the hardware, more of a description of the performance expectations of the software. I won't really argue here. >> >>> struct dcmi_graph_entity { >>> struct v4l2_async_subdev asd; >>> >> [...] >>> @@ -2020,6 +2042,8 @@ static int dcmi_probe(struct platform_device *pdev) >>> goto err_cleanup; >>> } >>> >>> + dcmi->policy = cpufreq_cpu_get(0); >>> + >> Ideally you'd want to fetch the policy of the CPU your IRQ (and handling >> thread) is affined to; The only compatible DTS I found describes a single >> A7, which is somewhat limited in the affinity area... > If I move this code just before start streaming and use get_cpu(), would > it works ? > AFAIA streaming_start() is not necessarily executing on the same CPU as the one that will handle the interrupt. I was thinking you could use the IRQ's effective affinity as a hint of which CPU(s) to boost, i.e. something like: --- struct cpumask_var_t visited; struct irq_data *d = irq_get_irq_data(irq); err = alloc_cpumask_var(visited, GFP_KERNEL); /* ... */ for_each_cpu(cpu, irq_data_get_effective_affinity_mask(d)) { /* check if not already spanned */ if (cpumask_test_cpu(cpu, visited)) continue; policy = cpufreq_cpu_get(cpu); cpumask_or(visited, visited, policy->cpus); /* do the boost for that policy here */ /* ... */ cpufreq_cpu_put(policy); } --- That of course falls apart when hotplug gets involved, and the effective affinity changes... There's irq_set_affinity_notifier() out there, but it seems it's only about the affinity, not the effective_affinity, I'm not sure how valid it would be to query the effective_affinity in that notifier. > Benjamin >> >>> dev_info(&pdev->dev, "Probe done\n"); >>> >>> platform_set_drvdata(pdev, dcmi); >>> @@ -2049,6 +2073,9 @@ static int dcmi_remove(struct platform_device *pdev) >>> >>> pm_runtime_disable(&pdev->dev); >>> >>> + if (dcmi->policy) >>> + cpufreq_cpu_put(dcmi->policy); >>> + >>> v4l2_async_notifier_unregister(&dcmi->notifier); >>> v4l2_async_notifier_cleanup(&dcmi->notifier); >>> media_entity_cleanup(&dcmi->vdev->entity);