Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3969683pxj; Mon, 21 Jun 2021 10:28:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW7IzXVD+6n9nDMMEl/YjEMA5tSwE1JlUL6J/FjkZLfLEbYLbqi2IWzZr/X8S15zxZkma5 X-Received: by 2002:a92:c792:: with SMTP id c18mr1527569ilk.75.1624296501533; Mon, 21 Jun 2021 10:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624296501; cv=none; d=google.com; s=arc-20160816; b=0wRAF8n0LqZ9YX9DqgC9CEKnLIoIPxT0D1vs22FUNeQ9m2HxypxiHidVOk9MiQQ5OO 6c0RKgiyNNWbRCp/t8GhUxdmTm3DweM4aduzXG8phniz6UAG4o4P6tPqAFBuW8P2zrL2 CxAeTKY77W9f1MB/Grof/1z9AN9f8n8JHQtI3Z2jWx8NmWJt77AkASJ4NGCbCCnUDpd1 krkpwlkpQhd02T/xk53SOS7SASg258l7DSsRKJky54/3iP/GKDvKv2pzgYjEF2vfu2u4 n9GPMEZR3VTu0Vzj1z6VSIl9WjWSl2uu9towUnMdmqnSEapq8eFjBon9mo8jvcyiz/Ab 1Bbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=zqPQFoGEbBMFlWcvLDwWf+sWtebWAshWctMFrJXETCI=; b=oul3V0QuHj24bcx88yoIx6IQxMP2WFs5rOAyHY2QP+Q87eEl8FRgQpoMDGBI5ITZsY 0OaI2oZsQkGBwxuM47Jlr04cVcDej3Nla3cpk34tnan6IeO7ox+UestKcjEZ6HxLUlOz rg7NwrpbI+YnTzy2OevKrqd5AbwoEoGUtJjNC9lhxhJlzn9pB2yWq4q9tntv7OgD49Mr UomM839NZIykN57cbtekfQWHM6QbZLn6tQwDATPMVtoBJpaOBkSGbE2vFTrwTwCsZo0K LLR45MOm7KEDrDS6pejLP51OU29ZOJcziBvHs1NCB4t3jVt+VVl/udQ0/RZ7EMQFaqI3 CN0Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j25si16921787jaj.93.2021.06.21.10.28.08; Mon, 21 Jun 2021 10:28:21 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbhFUR2a (ORCPT + 99 others); Mon, 21 Jun 2021 13:28:30 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:59582 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbhFUR23 (ORCPT ); Mon, 21 Jun 2021 13:28:29 -0400 Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 2.1.0) id aad6e4917f8b4308; Mon, 21 Jun 2021 19:26:13 +0200 Received: from kreacher.localnet (89-64-82-37.dynamic.chello.pl [89.64.82.37]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 3B1C0669A35; Mon, 21 Jun 2021 19:26:13 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM , Viresh Kumar Cc: LKML Subject: [PATCH] cpufreq: Make cpufreq_online() call driver->offline() on errors Date: Mon, 21 Jun 2021 19:26:12 +0200 Message-ID: <11788436.O9o76ZdvQC@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 89.64.82.37 X-CLIENT-HOSTNAME: 89-64-82-37.dynamic.chello.pl X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledrfeefledguddufecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhephfegtdffjeehkeegleejveevtdeugfffieeijeduuddtkefgjedvheeujeejtedvnecukfhppeekledrieegrdekvddrfeejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepkeelrdeigedrkedvrdefjedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehvihhrvghshhdrkhhumhgrrheslhhinhgrrhhordhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki In the CPU removal path the ->offline() callback provided by the driver is always invoked before ->exit(), but in the cpufreq_online() error path it is not, so ->exit() is somehow expected to know the context in which it has been called and act accordingly. That is less than straightforward, so make cpufreq_online() invoke the driver's ->offline() callback before ->exit() too. This only potentially affects intel_pstate at this point. Fixes: 91a12e91dc39 ("cpufreq: Allow light-weight tear down and bring up of CPUs") Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 3 +++ 1 file changed, 3 insertions(+) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -1516,6 +1516,9 @@ out_destroy_policy: up_write(&policy->rwsem); out_exit_policy: + if (cpufreq_driver->offline) + cpufreq_driver->offline(policy); + if (cpufreq_driver->exit) cpufreq_driver->exit(policy);