Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp758614rwi; Wed, 19 Oct 2022 02:31:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uQbvFSsFTBLPa3MsXZsEbZunIs5Slik2SyugALGJMwf6nuWS0PtATTh0lHV3KKEK5gi5g X-Received: by 2002:a17:90b:17c7:b0:20b:7cb:9397 with SMTP id me7-20020a17090b17c700b0020b07cb9397mr39265413pjb.191.1666171869481; Wed, 19 Oct 2022 02:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666171869; cv=none; d=google.com; s=arc-20160816; b=b+UQiks/y37Lw+3AewykXQ57BiOcH10owACpFIXzGAHvpzH00sYRmFtbXlwQRst9TU E3J844DXUkKLvsK3fCMXCTii69MNHnmFE3L0C/L6lilyFgBrQyFIcLKHUv9SAcp1Yz36 1xnKYdz4byRcwyKiIVm0Kfs8v56R3I16kleGs/HyP9pJZqjzD9javNfoJLEmPH0EnPQR 9AD6ySj9McspakKmvpTYCLCwsVSK447BwyvACeR/wVpiNmGqdhAz8K5B/E6KEAxyfFJf yT5VvzoB5SkhiQCIqYGJAkvkQOkYdZPtV+ditiEnzdepmZK6vnjCFHRUZH8c7Q9KDP8X 7t2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=PNZB1dsDFWUvDaTuDzULTQ8Nw/DcHXKBxuk6PE1dRWs=; b=B6Sj5MSbGXkrZqDBdUDg1iaWDpxFzq9V3eipgHskXUi1RK4PDba0FliYnmM/RJFu5q zLpNnV5ihqX1yeYITtUkLfFi4odMQAxmrGPwHgRpJYvdnSfbdSog+0xlXAl4zDEA0vR1 0K6tMxUlch+zMDFcN8stpmyIw4dk/O1F52/A/p5obsm/VLNwVvmuqPt1PtRqmfHicJIe 3Ir14W0L+XpsjHEKpEHmRBt7ygSOKzYaYZYTG9HNs2FjBPTawDk++wircW/WNn+kBGH1 QQsjBM897Va+E68h6zv5ZcI7i6A/Asrs7HiystQyrBK2WSaHxm6Ox8xFXBCnv2j2sF0K dUEg== 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a170902e84800b00176953fee67si19627634plg.86.2022.10.19.02.30.52; Wed, 19 Oct 2022 02:31:09 -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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbiJSIp5 (ORCPT + 99 others); Wed, 19 Oct 2022 04:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbiJSIoW (ORCPT ); Wed, 19 Oct 2022 04:44:22 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9165D89967; Wed, 19 Oct 2022 01:43:27 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R831e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=guanjun@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VSZvGwx_1666168846; Received: from localhost(mailfrom:guanjun@linux.alibaba.com fp:SMTPD_---0VSZvGwx_1666168846) by smtp.aliyun-inc.com; Wed, 19 Oct 2022 16:40:47 +0800 From: 'Guanjun' To: schspa@gmail.com, rafael@kernel.org, viresh.kumar@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, guanjun@linux.alibaba.com, zelin.deng@linux.alibaba.com Subject: [PATCH 1/1] cpufreq: Fix show()/store() issue for hotplugging offline CPU Date: Wed, 19 Oct 2022 16:40:45 +0800 Message-Id: <1666168845-67690-2-git-send-email-guanjun@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1666168845-67690-1-git-send-email-guanjun@linux.alibaba.com> References: <1666168845-67690-1-git-send-email-guanjun@linux.alibaba.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 From: Zelin Deng After brought one CPU offline, lscpu returned failure: lscpu: cannot read /sys/devices/system/cpu/cpu64/cpufreq/cpuinfo_max_freq: Device or resource busy which had blocked all outputs of lscpu. This is not the case mentioned in commit d4627a287e251, as the policy had been created successfully but is inactive due to CPU gets offline. To fix this issue, just add an addtional check whether CPU is online or not. Fixes: d4627a287e251 ("cpufreq: Abort show()/store() for half-initialized policies") Signed-off-by: Zelin Deng Signed-off-by: Guanjun --- drivers/cpufreq/cpufreq.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 69b3d61852ac..aa238ba7d2fe 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -956,8 +956,12 @@ static ssize_t show(struct kobject *kobj, struct attribute *attr, char *buf) return -EIO; down_read(&policy->rwsem); - if (likely(!policy_is_inactive(policy))) - ret = fattr->show(policy, buf); + if (unlikely(policy_is_inactive(policy) && cpu_online(policy->cpu))) + goto err; + + ret = fattr->show(policy, buf); + +err: up_read(&policy->rwsem); return ret; @@ -974,8 +978,12 @@ static ssize_t store(struct kobject *kobj, struct attribute *attr, return -EIO; down_write(&policy->rwsem); - if (likely(!policy_is_inactive(policy))) - ret = fattr->store(policy, buf, count); + if (unlikely(policy_is_inactive(policy) && cpu_online(policy->cpu))) + goto err; + + ret = fattr->store(policy, buf, count); + +err: up_write(&policy->rwsem); return ret; -- 2.32.0.GIT