Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp792260rwl; Fri, 31 Mar 2023 02:23:32 -0700 (PDT) X-Google-Smtp-Source: AKy350bWNpNZoEelX70TIY376sQLB5x3G6G0wg31Lo6sCZxywofzLUHALc1DHdzZgrKOrceh37ia X-Received: by 2002:a17:906:297:b0:932:170:e07b with SMTP id 23-20020a170906029700b009320170e07bmr3939270ejf.7.1680254612244; Fri, 31 Mar 2023 02:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680254612; cv=none; d=google.com; s=arc-20160816; b=f/hakpg4woU0kz4zeXoWZ/ZFx36fNGhr/ptYK8xaV3ZIFle7Cw0xhWZVQrj1NFcabO XSLWaOYuGEkmnPpnDTVuRFsY+twUw/bneUxqMSxgceGLynwEDwe4SbHEimRyv9l9D4ga HPr5lDU/ELg2GzEaLQjvzxmeYcGfn52Vf2nLk3UPfYKKD5NbPf9EjiifA/2nZWZP71gC o4gkvqy24genxOIa7nI6hFkuQn0mvc9DoG5wF2RxZUvSqZlZhVhJ6DU6Mcl73mgxwc1d qMC1wBdUb9IJ03bNBWnDdJEOSSgAMt9lV9KmDj2oH81HZGPdczF+C9+7NYOg7rokNn6u 1rgw== 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=/nglx6pxgYdu7RBfAqMRpdMvNedLUgpGqGlMJV85xSg=; b=WWFVrqynVIxV+Jl+fq02wbs8JrgvuWYA+dBhgLFs+XZs6GcrCiSIz3gEcr6+vplAtL X44CBVyO21vvR5GsF6CjPAZd36nbGrjjeQ+8dEvPSGyZXkbgz3gxIE/eCbs+rGfzHgs/ 62i7KOfVQYITZUjGWJ9zRF9znShRYYt0fNjc84iC6q021YzMJwOzc1pwlyhimnw3AoJP 52n70liQCIu2jv4+NsPllyc11gVO6ssMOv0UilUalrb74fpJgySrRro/89bv6AKLS/ry gv0OErIDTUo/M/rpzUeDQVWV+iCOTR63C80Wx2KwwpBjtAIhcCshEALJLADsheydSipD cD5A== 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 h7-20020a17090619c700b0092744b8d1b8si1478121ejd.904.2023.03.31.02.23.07; Fri, 31 Mar 2023 02:23:32 -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 S232021AbjCaJMd convert rfc822-to-8bit (ORCPT + 99 others); Fri, 31 Mar 2023 05:12:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231968AbjCaJMR (ORCPT ); Fri, 31 Mar 2023 05:12:17 -0400 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 809BF1E71A; Fri, 31 Mar 2023 02:12:12 -0700 (PDT) Received: by mail-ed1-f49.google.com with SMTP id i5so87217423eda.0; Fri, 31 Mar 2023 02:12:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680253931; 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=ikgiRsxaZelZuPk3v/sEzGG6Y7xqHAIP/w4zhpKwmXI=; b=56e0hMJVyxpMKARoXDqLizCeDWo82ZAW/4iSadhDqNofwnTM09C1HXO0JZZyhaxeeV qe/cZGX4/GoWctPN17BRhw8490klzSKRdff7OSZUNZdDBMs/VFQgAG1GzF9RwrIC1kR9 U8s8Ic0V+7NhSEW/WQTigdlJkH1Rz8hB4ROc8iBoXnv6/wT/w9LJC5Fj4gUE0qOsybYH 3KC9pmGQhdTla9xSO2qMXDYlBEIctKOPHNJROgNqFgk5nMyjLrRX+LkDI3nlS409IEIq umvIVsb6pWl1w27ixOBjgM1gqJtHyajJmbMK8Fc9Poncso8SAyiZJGupELEBm3jKyLzv hvYQ== X-Gm-Message-State: AAQBX9eZJFnX3psD6bgk3IDn02W4AMlCsP3bPtsw5VbhTcXWWLIqy/ub 4UllFdHh1BK980X6k6L9bt2UnRK0XrJBsmx64LPJtIFdv4I= X-Received: by 2002:a50:cc94:0:b0:4fb:c8e3:1ae2 with SMTP id q20-20020a50cc94000000b004fbc8e31ae2mr13363269edi.3.1680253930767; Fri, 31 Mar 2023 02:12:10 -0700 (PDT) MIME-Version: 1.0 References: <20230330141314.1364083-1-wyes.karny@amd.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 31 Mar 2023 11:11:59 +0200 Message-ID: Subject: Re: [PATCH] amd-pstate: Fix amd_pstate mode switch To: Wyes Karny Cc: "Rafael J. Wysocki" , viresh.kumar@linaro.org, ray.huang@amd.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Kardashevskiy , Mario Limonciello , Perry Yuan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 Fri, Mar 31, 2023 at 8:12 AM Wyes Karny wrote: > > Hi Rafael, > > On 30 Mar 20:19, Rafael J. Wysocki wrote: > > On Thu, Mar 30, 2023 at 4:13 PM Wyes Karny wrote: > > > > > > amd_pstate mode can be changed by writing the mode name to the `status` > > > sysfs. But some combinations are not working. Fix this issue by taking > > > care of the edge cases. > > > > > > Before the fix the mode change combination test fails: > > > > > > #./pst_test.sh > > > Test passed: from: disable, to > > > Test passed: from: disable, to disable > > > Test failed: 1, From mode: disable, to mode: passive > > > Test failed: 1, From mode: disable, to mode: active > > > Test failed: 1, From mode: passive, to mode: active > > > Test passed: from: passive, to disable > > > Test failed: 1, From mode: passive, to mode: passive > > > Test failed: 1, From mode: passive, to mode: active > > > Test failed: 1, From mode: active, to mode: active > > > Test passed: from: active, to disable > > > Test failed: 1, From mode: active, to mode: passive > > > Test failed: 1, From mode: active, to mode: active > > > > > > After the fix test passes: > > > > > > #./pst_test.sh > > > Test passed: from: disable, to > > > Test passed: from: disable, to disable > > > Test passed: from: disable, to passive > > > Test passed: from: disable, to active > > > Test passed: from: passive, to active > > > Test passed: from: passive, to disable > > > Test passed: from: passive, to passive > > > Test passed: from: passive, to active > > > Test passed: from: active, to active > > > Test passed: from: active, to disable > > > Test passed: from: active, to passive > > > Test passed: from: active, to active > > > > > > Fixes: abd61c08ef349 ("cpufreq: amd-pstate: add driver working mode switch support") > > > > > > Acked-by: Huang Rui > > > Reviewed-by: Alexey Kardashevskiy > > > Signed-off-by: Wyes Karny > > > > > > Cc: "Rafael J. Wysocki" > > > Cc: Viresh Kumar > > > Cc: Mario Limonciello > > > Cc: Perry Yuan > > > > This is all fine, but you need to tell me how it interacts with the > > amd-pstate changes in linux-next. > > > > Does it affect the code in linux-next at all or is it only for 6.3-rc? > > > > This is only for 6.3-rc. > The commit 3ca7bc818d8c ("cpufreq: amd-pstate: Add guided mode control > support via sysfs") in linux-next may not apply cleanly after this fix. > Please let me know if I need to rebase and send the guided mode patches [1]. > > [1]: https://lore.kernel.org/linux-pm/20230307112740.132338-1-wyes.karny@amd.com/ Well, instead, you please let me know how to resolve the merge conflict between the patch below and your series. Can I simply assume that the code added by commit 3ca7bc818d8c replaces the code modified by the $subject patch? > > > --- > > > drivers/cpufreq/amd-pstate.c | 18 ++++++++---------- > > > 1 file changed, 8 insertions(+), 10 deletions(-) > > > > > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > > > index 73c7643b2697..8dd46fad151e 100644 > > > --- a/drivers/cpufreq/amd-pstate.c > > > +++ b/drivers/cpufreq/amd-pstate.c > > > @@ -840,22 +840,20 @@ static int amd_pstate_update_status(const char *buf, size_t size) > > > > > > switch(mode_idx) { > > > case AMD_PSTATE_DISABLE: > > > - if (!current_pstate_driver) > > > - return -EINVAL; > > > - if (cppc_state == AMD_PSTATE_ACTIVE) > > > - return -EBUSY; > > > - cpufreq_unregister_driver(current_pstate_driver); > > > - amd_pstate_driver_cleanup(); > > > + if (current_pstate_driver) { > > > + cpufreq_unregister_driver(current_pstate_driver); > > > + amd_pstate_driver_cleanup(); > > > + } > > > break; > > > case AMD_PSTATE_PASSIVE: > > > if (current_pstate_driver) { > > > if (current_pstate_driver == &amd_pstate_driver) > > > return 0; > > > cpufreq_unregister_driver(current_pstate_driver); > > > - cppc_state = AMD_PSTATE_PASSIVE; > > > - current_pstate_driver = &amd_pstate_driver; > > > } > > > > > > + current_pstate_driver = &amd_pstate_driver; > > > + cppc_state = AMD_PSTATE_PASSIVE; > > > ret = cpufreq_register_driver(current_pstate_driver); > > > break; > > > case AMD_PSTATE_ACTIVE: > > > @@ -863,10 +861,10 @@ static int amd_pstate_update_status(const char *buf, size_t size) > > > if (current_pstate_driver == &amd_pstate_epp_driver) > > > return 0; > > > cpufreq_unregister_driver(current_pstate_driver); > > > - current_pstate_driver = &amd_pstate_epp_driver; > > > - cppc_state = AMD_PSTATE_ACTIVE; > > > } > > > > > > + current_pstate_driver = &amd_pstate_epp_driver; > > > + cppc_state = AMD_PSTATE_ACTIVE; > > > ret = cpufreq_register_driver(current_pstate_driver); > > > break; > > > default: > > > -- > > > 2.34.1 > > >