From patchwork Wed Oct 19 08:40:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: guanjun X-Patchwork-Id: 4555 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp204580wrs; Wed, 19 Oct 2022 01:46:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7py6wSx8MB1kTwXEXXg77YeG+2AUWKV5p/GVjf66+eIqvvSRGiTj8fntqfj0ur4wXGCwWm X-Received: by 2002:a17:902:e9ca:b0:17f:93b5:5ec8 with SMTP id 10-20020a170902e9ca00b0017f93b55ec8mr7254945plk.59.1666169193798; Wed, 19 Oct 2022 01:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169193; cv=none; d=google.com; s=arc-20160816; b=lmjzAPFuJoEvvgtzmh1BhyRxKvTy1bq857nweinRTq+dNm+aHYhLLIc1d0j1vImD0G LuUdGRmI63q3BcVYIWGfRRkMUHYImbZoK+8oTPulcnJYz6PBObxsWDAztwdwNJsDFcCx 92DsB2Av4JAXAuW9YI3UbgMk40WFCxQwJPU9HgjggGmNzF0zhKLrqFw2IUioihRxI5Wx 0BlhUh272NrwpDr52FkBYMD0F7UGJFFOvLPV4g84+eU/74BgKR0GzakQ3P/n8tZFiv5d SMHGDWD10sSz+NBV+euR022ZyTPdDGk6EY97xBgK53CqIT0xDmtS2VwDitFStlRT8Obn NI3Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lp5-20020a17090b4a8500b0020d9ddbf2a7si22891247pjb.171.2022.10.19.01.46.19; Wed, 19 Oct 2022 01:46:33 -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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747105028702624088?= X-GMAIL-MSGID: =?utf-8?q?1747105028702624088?= 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;