Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1380936rwd; Thu, 15 Jun 2023 09:44:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wpbTY3atLSM++2pFM9gnpSih/5kDnOAqVEcs5cM7kRScXPREoA9DSplh//WRmiOeUhfkL X-Received: by 2002:a05:6a20:430c:b0:f0:b6e3:90c9 with SMTP id h12-20020a056a20430c00b000f0b6e390c9mr39059pzk.4.1686847479576; Thu, 15 Jun 2023 09:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686847479; cv=none; d=google.com; s=arc-20160816; b=nCJ+fXYK3OgAMZahD0IK4c65+zmgvc7tu1fvQjtlnoDboAA/0RGFo6aVKgBsxa6/xq s7Pe3mA+191ASjLswILyeapcwglzqIR9aBJ8okuIksm4JQ3c8eEfGmt6YVr/gCfHBJvJ wO1/IM4CrgFKR/FSvP9EfqX5NGXse6XchZa4sI8aPSCz1nz3njaP4HvFtvRMT1BmHyvb DHP1Qh/PfCHe7UUvuOadYafVByw4qn/dMw4QJ2EFiCcE0NbsfVnED7F0tfeWG12prkTx YclyuDnHf8yLBzspyrWeldfTXBmbPW96M6EBf+0G7Dnrd+02AOe3jEp7xDQwrNFjlu4z C65Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=+lD/3Mkh14Lci88zYUo+ksKYINuM3RnSQl+UuKgq+Dg=; b=wOoIIeFnM96ZelySHO4GTeo5yC7WSHjHkRrWQxYAieWO6MjOHxyoq60cv99Ub5qDrx LmmW/gGNyKevut+G+tWNiUoRDwhbF5X+A9OAWYyz/on495vM5dryZ7sMqyDTI1oycfIc g5gtG4YZOgOuVnRO4W9VN+Wi/gXcu6uez4A2dbJUbLxPLic6LCz5GUrT8Ty+YBFUN/07 CysPdNLxzgVBqGPu7Bc0l9tyg+sJTp8PkNwooM/z4bH00yGM8bhml4wZlE9WQ5yG6Iff 9gff2qrFWaAO554ngEDtU91qaPS4Kv+ojG6FK8bln0sx61Say0fNV9C/a7PqqpcOsVPK ieUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a654b8d000000b00543c84bf588si13315621pgq.473.2023.06.15.09.44.27; Thu, 15 Jun 2023 09:44:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229511AbjFOQQd convert rfc822-to-8bit (ORCPT + 99 others); Thu, 15 Jun 2023 12:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232599AbjFOQQ1 (ORCPT ); Thu, 15 Jun 2023 12:16:27 -0400 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A60919B5; Thu, 15 Jun 2023 09:16:26 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-9787d11a410so182343266b.0; Thu, 15 Jun 2023 09:16:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686845784; x=1689437784; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3YxB57F6iRPfxYgCyQDt6O4M+2ztrVFXMcR28M9UUao=; b=R0ExtFr+xjCfa2CCySwnV2M+/8D0xCxJTa6mYE4BKAwUtit10etfrewz5wHMiqG2Y5 TA8RQpIhnAZk/Mb5S2SXpv3QcvpVXZJo7PXhcOmOEm3ATStfP3tKl4N1gJTvbwWStrL2 2aJSGuuu4Q6QFIuqzOE/+ex9BE42YyZKOqKGcqOrmyzPAPNCd6rFuWh1h5JTneflwWGx 3/9VOXJ8eaieoy+xCBcmhyYvtu40XIvVftDkWa69y8NgShUJ3LK8RGAXQ9ou3/Hn5p6B eLdQG8tfknxzDELAepm7SETRjYUdPghfxKsMfQyzgUpMvz+jyVs57RT4k5IouPRrzSu6 B0lA== X-Gm-Message-State: AC+VfDwQhUU8HCljDtTzS3djKhpRQF+jyQ/op2aWTip1yuI/CjJWLtHO Gb4+asAF3KDX4OguhoSlCAEx4CU2/bQL4RAz98QEE0Xx X-Received: by 2002:a17:906:289:b0:977:ead3:c91 with SMTP id 9-20020a170906028900b00977ead30c91mr14683806ejf.1.1686845784419; Thu, 15 Jun 2023 09:16:24 -0700 (PDT) MIME-Version: 1.0 References: <20230529142551.6726-1-wyes.karny@amd.com> In-Reply-To: <20230529142551.6726-1-wyes.karny@amd.com> From: "Rafael J. Wysocki" Date: Thu, 15 Jun 2023 18:16:13 +0200 Message-ID: Subject: Re: [PATCH v4.1] cpufreq: Fail driver register if it has adjust_perf without fast_switch To: Wyes Karny Cc: rafael@kernel.org, viresh.kumar@linaro.org, ray.huang@amd.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, gautham.shenoy@amd.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 29, 2023 at 4:26 PM Wyes Karny wrote: > > If fast_switch_possible flag is set by the scaling driver, the governor > is free to select fast_switch function even if adjust_perf is set. Some > scaling drivers which use adjust_perf don't set fast_switch thinking > that the governor would never fall back to fast_switch. But the governor > can fall back to fast_switch even in runtime if frequency invariance is > disabled due to some reason. This could crash the kernel if the driver > didn't set the fast_switch function pointer. > > Therefore, fail driver registration if it has adjust_perf without > fast_switch. > > Suggested-by: Rafael J. Wysocki > Suggested-by: Viresh Kumar > Signed-off-by: Wyes Karny > --- > drivers/cpufreq/cpufreq.c | 3 ++- > include/linux/cpufreq.h | 5 ++++- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 6b52ebe5a890..50bbc969ffe5 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2828,7 +2828,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) > (driver_data->setpolicy && (driver_data->target_index || > driver_data->target)) || > (!driver_data->get_intermediate != !driver_data->target_intermediate) || > - (!driver_data->online != !driver_data->offline)) > + (!driver_data->online != !driver_data->offline) || > + (driver_data->adjust_perf && !driver_data->fast_switch)) > return -EINVAL; > > pr_debug("trying to register driver %s\n", driver_data->name); > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index 26e2eb399484..172ff51c1b2a 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -340,7 +340,10 @@ struct cpufreq_driver { > /* > * ->fast_switch() replacement for drivers that use an internal > * representation of performance levels and can pass hints other than > - * the target performance level to the hardware. > + * the target performance level to the hardware. This can only be set > + * if ->fast_switch is set too, because in those cases (under specific > + * conditions) scale invariance can be disabled, which causes the > + * schedutil governor to fall back to the latter. > */ > void (*adjust_perf)(unsigned int cpu, > unsigned long min_perf, > -- Applied as 6.5 material, thanks!