[v8,06/23] PM: EM: Check if the get_cost() callback is present in em_compute_costs()
Message ID | 20240208115557.1273962-7-lukasz.luba@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-57999-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp126085dyd; Thu, 8 Feb 2024 04:24:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGf1+14Hdw0aHJaldDBF0d5r/dCJcL+YnYbIkUQZENm7tOOvJFsVyMZRYsKSINQQ62VF6VR X-Received: by 2002:a05:6a00:2d81:b0:6e0:25d7:debc with SMTP id fb1-20020a056a002d8100b006e025d7debcmr6610875pfb.24.1707395093000; Thu, 08 Feb 2024 04:24:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707395092; cv=pass; d=google.com; s=arc-20160816; b=IiJy5fx5y06bzEPCV08Wg8ov8HmU2bNtq5e4vOm6JLbQ73zGmceV7Ati8XxJKpYbqV N5IWS3M7VPoV9CpvTchE70RMMkJhYGp3zhyx4KuhhQav9rW1r1yRxAk8JNWbX2UWHz5i 7yDxCpFmbs7L1CD8UpdejVxf8N1q8uplA4aU+LlFSidR0HTYGs23xTKqvckAiaOFMUAw JjDtYPH1cGQGBTFQsm0UrsKkOOzRCqar1H/z06gWcQChXLjgBOqvcFbzG4BZy7+zsG3y 84UCMajXhxj46+BUV8JMtD5wRqPgbTWlLZg1FA3bQLLtoIzQ0souo3ODjXo/OVCWEcMb TKdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=pNudkuW67175AYZXExAU7FwVK78v0+Vc4RQALB3xfw8=; fh=YdKtU6dg5End+ya/IRdW0AfHlvtLVwNcv0KS0TdAPrQ=; b=kNgApK699zmW9NpcTg0fPC8Fwgd2ttvPblppGPlAq03FEHpIDHQSGCih4pGhWCzsEn GRkIxZ+YQOP7iu4joGn5cv048Cg0z9hrhpFFisMXm0qI7TQj0Ozzo1tsEw5Oex0DT7Xd WpT/jvSh23p8h+cvpYWABak0Wb4J8JoitQk5+O/pAGgi1ZJgToTXJo77iKYe+569BIBF ELdUVeJMMP9dweK4vgXu4dlDGW0clN9+LD5HqGZNjRGxX548EOM3BR1YyPvwmR9IYpTA 4RNJa7FqsHpU2QMhqy0AZgVKznc9I/7Ca1qNtl5NtJPuhkY88y9tlbKWTtTT/HgLWKxF ZfKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-57999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57999-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVPjKUW2ttnvCtiqaJXa9Qp0NLttsPdfkqupnCeND4GjIai2N0n89ecppniGm/mjOJLBO583IpgCL5P/qY0ssOSoAsZ6Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id by23-20020a056a02059700b005dbf27229f0si4348185pgb.303.2024.02.08.04.24.52 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:24:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-57999-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57999-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A84AFB2B976 for <ouuuleilei@gmail.com>; Thu, 8 Feb 2024 11:58:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F423D76415; Thu, 8 Feb 2024 11:56:27 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7854B763EF; Thu, 8 Feb 2024 11:56:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393386; cv=none; b=phkc+KWI+3moz0NlZYszUOi3dfKU6NCR/11pAXqVZOBGdFCoop8jw9JVoNdZZBtu/tq6up2s9lnmu2+n+mNk6D/fWMGUhtOv/vEXfhuX6wao1ajA5eBmWKpXZHWYwZq0mNwN8Bdvii3aLc3Uk5++No2nrhmP5WTwr22dh9Ay0CY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393386; c=relaxed/simple; bh=Da4Wg14h1CcjXL0JhFy9dAEG/iSfGR93L/E4kBh6W60=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mwR4z9TQIJ3uYydZtMgCfMK2m2L6W/NoJ1I86THIWWBQ4j6Esf/UgqMqQPFzrFDT6RFjRDPlFvt25FkCISpLnfQWxUdpNn9tYxT/56aiEfhtvoDivpY2uyyBylIKF65sBQIoCcfkDZn7ABVb/8WJCaDvFj1HdEtkKbAUu5rwS4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D2741FB; Thu, 8 Feb 2024 03:57:06 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.8.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 08FFE3F5A1; Thu, 8 Feb 2024 03:56:20 -0800 (PST) From: Lukasz Luba <lukasz.luba@arm.com> To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com, xuewen.yan94@gmail.com Subject: [PATCH v8 06/23] PM: EM: Check if the get_cost() callback is present in em_compute_costs() Date: Thu, 8 Feb 2024 11:55:40 +0000 Message-Id: <20240208115557.1273962-7-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208115557.1273962-1-lukasz.luba@arm.com> References: <20240208115557.1273962-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790333516937367439 X-GMAIL-MSGID: 1790333516937367439 |
Series |
Introduce runtime modifiable Energy Model
|
|
Commit Message
Lukasz Luba
Feb. 8, 2024, 11:55 a.m. UTC
Subsequent changes will introduce a case in which 'cb->get_cost' may not be set in em_compute_costs(), so add a check to ensure that it is not NULL before attempting to dereference it. Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> --- kernel/power/energy_model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index 5c47caaf270e..21d761223255 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -116,7 +116,7 @@ static int em_compute_costs(struct device *dev, struct em_perf_state *table, for (i = nr_states - 1; i >= 0; i--) { unsigned long power_res, cost; - if (flags & EM_PERF_DOMAIN_ARTIFICIAL) { + if ((flags & EM_PERF_DOMAIN_ARTIFICIAL) && cb->get_cost) { ret = cb->get_cost(dev, table[i].frequency, &cost); if (ret || !cost || cost > EM_MAX_POWER) { dev_err(dev, "EM: invalid cost %lu %d\n",