Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1529841pxj; Fri, 18 Jun 2021 09:04:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXqdXzR9KyNKHBsj40KYlf/YAbZK4DX4KCRslOHAFrsozJymIdi7IPLeGpojo0MYpA2PYG X-Received: by 2002:a17:906:a281:: with SMTP id i1mr11571209ejz.307.1624032267896; Fri, 18 Jun 2021 09:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624032267; cv=none; d=google.com; s=arc-20160816; b=VVKJ6bWGA1e/sC9ffnb5m6l917JIgJ0vbHpmkG7Bb84DoZ3wPlLBiXA83bELYNAsz2 mu2yDlYNpeku1J/TL3MCRun6XtEO/eEbXTpA0d2x/dKQNu7TjFCuM4Tul8rWwoDhUxMe Ob1t0UVy4m6gjz+EbveUif+yRrQlHl6CjWxruYUtRvMw8tRs36L4Kgf2y5EdtCdH7VIj E9S4mk8rpFchmFtKGmfJnDhb8HL4uKX5VhHFOJhIMvV0R/pBCpT/c0Qt9LaEqCIzCZcz car/DBecEAIko1b3k0xHR/9pyCwDe9+tq/UhhqIll6dQfPiL8LARzzopgT2hoG1dDnYw Id6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=rUMzu/K3B6PimF7v/SKPUw8+mIM9nScsj4NJiw7kNYY=; b=z6clG9rTfWX974q8a7XFgMUFG5Hbp3c8xIzHi7cwic40uyRf7avB6z9VHyauO7jGHQ 7PO/s5qx1s60ADYcu93ybqPNf2FZUQ9o6NBf5tXAuGxRd2Lqr6HUP319TtVFeYG81CBX 3UAVt06X/byt1bStkCJpHMiJYGW4vkL5XFbb9kyHPBRSuBUvwtszubQjlq8rr8Eq8Cgu gdqHjxLsQ/yN/xMTjecG5HTPzaYTpGpZSv8nlL/LXtiWrfMRMPushvEU0Yt86oDzZTsR nCljqoeafFv+UwazrMx7QMlKP0yE4hPV8mr44R/d49tooTVLDDYeeB911BIHq7KWDLRQ IgAQ== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c5si6119609eds.128.2021.06.18.09.03.54; Fri, 18 Jun 2021 09:04:27 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230480AbhFRMDP (ORCPT + 99 others); Fri, 18 Jun 2021 08:03:15 -0400 Received: from mail-ot1-f41.google.com ([209.85.210.41]:44892 "EHLO mail-ot1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbhFRMDO (ORCPT ); Fri, 18 Jun 2021 08:03:14 -0400 Received: by mail-ot1-f41.google.com with SMTP id f3-20020a0568301c23b029044ce5da4794so2811541ote.11; Fri, 18 Jun 2021 05:01:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rUMzu/K3B6PimF7v/SKPUw8+mIM9nScsj4NJiw7kNYY=; b=HKxxDJRN31u5tezSAqPCn255Ex/5ygIIZMl01jJi/vhcpdQSqQYNZu/GeEPeby4YJS jhxK3P7BYsqLUcXOcE80v3/GqrW5/eQJSfyvEOaBfT6nr8QuWnsAw9dOYYeXQ2/oG3Vk 0W8JueMOM+elHI+JYolA+l30ele7ejpTtgfdU3ZIlv6+/pBgSVtrcYVzY1ERXvQ0wd3o fiER3zOkkpVX6CTX2LD7dJwB8T3NIxE49Hecyl6cIWX/EEee7sldEJ14OeuyjR+3I9rC SbX59wyQFQiuufxywABmH++pwM2KIIepec292qBiugfH7Iv+g2sw8mGcvhVgIaizcP4+ sOUg== X-Gm-Message-State: AOAM531MnJnwleA9n+yGQPcG2lwhF3gVGPoXy2jSknFQlwQeNZe1dUU5 0YlffYF7G2GAiPeo3Ppk3E/xpzDA0QzplbuC9xo= X-Received: by 2002:a05:6830:1bf7:: with SMTP id k23mr9458774otb.206.1624017665309; Fri, 18 Jun 2021 05:01:05 -0700 (PDT) MIME-Version: 1.0 References: <5c8da9d378dee39d9c6063713b093f51d271fa9d.1623825358.git.viresh.kumar@linaro.org> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 18 Jun 2021 14:00:54 +0200 Message-ID: Subject: Re: [PATCH V3 2/3] cpufreq: intel_pstate: Migrate away from ->stop_cpu() callback To: Viresh Kumar Cc: Rafael Wysocki , Srinivas Pandruvada , Len Brown , Linux PM , Vincent Guittot , Dirk Brandewie , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 18, 2021 at 5:22 AM Viresh Kumar wrote: > > commit 367dc4aa932b ("cpufreq: Add stop CPU callback to cpufreq_driver > interface") added the stop_cpu() callback to allow the drivers to do > clean up before the CPU is completely down and its state can't be > modified. > > At that time the CPU hotplug framework used to call the cpufreq core's > registered notifier for different events like CPU_DOWN_PREPARE and > CPU_POST_DEAD. The stop_cpu() callback was called during the > CPU_DOWN_PREPARE event. > > This is no longer the case, cpuhp_cpufreq_offline() is called only once > by the CPU hotplug core now and we don't really need to separately > call stop_cpu() for cpufreq drivers. > > Migrate to using the exit() and offline() callbacks instead of > stop_cpu(). > > We need to clear util hook from both the callbacks, exit() and > offline(), since it is possible that only exit() gets called sometimes > (specially on errors) or both get called at other times. > intel_pstate_clear_update_util_hook() anyway have enough protection in > place if it gets called a second time and will return early then. > > Cc: Dirk Brandewie > Signed-off-by: Viresh Kumar > --- > V2->V3: > - Update intel_pstate_cpu_offline() as well. > - Improved commit log. > > drivers/cpufreq/intel_pstate.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c > index 0e69dffd5a76..8f8a2d9d7daa 100644 > --- a/drivers/cpufreq/intel_pstate.c > +++ b/drivers/cpufreq/intel_pstate.c > @@ -2335,6 +2335,8 @@ static int intel_pstate_cpu_offline(struct cpufreq_policy *policy) > > pr_debug("CPU %d going offline\n", cpu->cpu); > > + intel_pstate_clear_update_util_hook(policy->cpu); > + > if (cpu->suspended) > return 0; > > @@ -2374,17 +2376,12 @@ static int intel_pstate_cpu_online(struct cpufreq_policy *policy) > return 0; > } > > -static void intel_pstate_stop_cpu(struct cpufreq_policy *policy) > -{ > - pr_debug("CPU %d stopping\n", policy->cpu); > - > - intel_pstate_clear_update_util_hook(policy->cpu); > -} > - > static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) > { > pr_debug("CPU %d exiting\n", policy->cpu); > > + intel_pstate_clear_update_util_hook(policy->cpu); This change is not needed now, because ->offline always runs before ->exit if present. > + > policy->fast_switch_possible = false; > > return 0; > @@ -2451,7 +2448,6 @@ static struct cpufreq_driver intel_pstate = { > .resume = intel_pstate_resume, > .init = intel_pstate_cpu_init, > .exit = intel_pstate_cpu_exit, > - .stop_cpu = intel_pstate_stop_cpu, > .offline = intel_pstate_cpu_offline, > .online = intel_pstate_cpu_online, > .update_limits = intel_pstate_update_limits, > -- > 2.31.1.272.g89b43f80a514 >