Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp513011lqc; Fri, 8 Mar 2024 04:32:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUMkjW8WMuZR77RYV31xywBrl87qiikBaQPAD4rBQeFj+yQiIRQv8C2IJe+gC9bDEEULNjjLM3HO/waDe1F+QFRYA36Z5m6ArQZLDPnnw== X-Google-Smtp-Source: AGHT+IHvNkUBrB5XoICSvuymCMYWzZ/j0WkLbSPouUonwP9z9kMHF3mCqz7csI4yseI6VXTP1SFn X-Received: by 2002:a17:906:8d6:b0:a44:3056:1ed0 with SMTP id o22-20020a17090608d600b00a4430561ed0mr13622457eje.62.1709901121608; Fri, 08 Mar 2024 04:32:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709901121; cv=pass; d=google.com; s=arc-20160816; b=CMVGdcevLURiHnhDFh5MuODP0QgEs9QWDEkbiIAyI41NuYDiLxgi8Ppm6iTJx7dgE+ y3zVWL3A2RUPiCmcORao532aeIWruanbgbq4H4FwWetfncfv3qUrgq9+5q3tAFByLUA9 +XKAyJQCgvVOY/OkG6pv7r9oSbhLu7vpSjkQw6EDC0/005d43TuWpU7gW3LpNZuBEHUZ KwOa748dHiMjahPgEUSct4FBlU/SKbOiyLil3gU6yyyG4Fix/5T3ZlOxDgDlnhH+2TW/ O1+9BNZ62fULl2Qe0xr3tMdJIiz8bSoBYGLJlZD3dXHjpiYFnb1lC1IbKR7O5wBCabsd BYQw== 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:message-id:date:subject:cc:to :from; bh=mpfF6SfeotDJMr5X+UpoZI3YYy2kzSDiBMDTAlBiUIY=; fh=ya3GTNrm1lzcCDJ6MlUwPB8oM2Ew1gN5CcQI7SucC+0=; b=wZBUFJMjtA1y/3SBf7F2De9H8lsgqcSPS2VtifDG53a78S+U0nIjEVRcMqPHjusMz1 9UOCaiFElzLdfXh7btVstNP9c3aqiay+TkYl3pLkv+JmapDPUENBX3FrWyOUyQFCeHG+ OZrrcjSpZXbV1xv3MY1mmCmaYE0kCUDdQUky0/01cUjWjQTFZ1WvAAT6rMt8vr4sB+uq osPqWHULooOXSSxyd22W5f/R7sFfGmsUst4X8EBcAdZ5YdJCW0nEIkNiVr2mcICRSqNU hmFJlju6naS8gCPZdlK+UTCceQCUD2Oj4g/M06iY12TH2B0MmLQ5sXBZOBi+c02/nUmo Bl1Q==; 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-97006-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bh21-20020a170906a0d500b00a45acb1955csi3063765ejb.736.2024.03.08.04.32.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 04:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97006-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-97006-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97006-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 554891F21D6C for ; Fri, 8 Mar 2024 12:32:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82E89EEA9; Fri, 8 Mar 2024 12:31:53 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30C9E17EF; Fri, 8 Mar 2024 12:31:50 +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=1709901113; cv=none; b=TWAn0UsByrCF4M6JHfMZFWm+XFbVUhhJ/yF8EKAB50xhs6Bo0/+0wnPsjioEJMsV4fh34WnrlNwMpg6wakFlz1ghooaSe2Ze1HIcQfkUBVsfnkm5hAgiDKSFLG7UFCCHQegIHh1o7pN+CLRqDuBXi+axlwLRp6ML/DuVCVoK98I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709901113; c=relaxed/simple; bh=7wC84AYFOmapT7dzQoGkHlDqzNSWk22jBdSheuL8DfY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Ou8hHxrMrrQ16p1pni+XT6PvTEvVj815jPzDaIHvXogGxh5XqOvhkzuyYZ/58VN3wmn/EnCD268ENkzrupMX9AMIODg5/paN+SAUU8GA0YIgwnZkyvSWigQ7J53nW+2GQ+xrkXyGAVGOf4QJVJRLMQDyzG8ezzvsOXHw9Vsanog= 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 4148BC15; Fri, 8 Mar 2024 04:32:27 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.10.181]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5B30F3F73F; Fri, 8 Mar 2024 04:31:49 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, poshao.chen@mediatek.com Subject: [PATCH] PM: EM: Force device drivers to provide power in uW Date: Fri, 8 Mar 2024 12:32:03 +0000 Message-Id: <20240308123203.196644-1-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The EM only supports power in uW. Make sure that it is not possible to register some downstream driver which doesn't provide power in uW. The only exception is artificial EM, but that EM is ignored by the rest of kernel frameworks (thermal, powercap, etc). Reported-by: PoShao Chen Signed-off-by: Lukasz Luba --- Hi all, The was an issue reported recently that the EM could be used with not aligned drivers which provide milli-Watts. This patch prevents such drivers to register EM (although there are no such in upstream). Regards, Lukasz kernel/power/energy_model.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c index b686ac0345bd9..9e1c9aa399ea9 100644 --- a/kernel/power/energy_model.c +++ b/kernel/power/energy_model.c @@ -612,6 +612,17 @@ int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, else if (cb->get_cost) flags |= EM_PERF_DOMAIN_ARTIFICIAL; + /* + * EM only supports uW (exception is artificial EM). + * Therefore, check and force the drivers to provide + * power in uW. + */ + if (!microwatts && !(flags & EM_PERF_DOMAIN_ARTIFICIAL)) { + dev_err(dev, "EM: only supports uW power values\n"); + ret = -EINVAL; + goto unlock; + } + ret = em_create_pd(dev, nr_states, cb, cpus, flags); if (ret) goto unlock; -- 2.25.1