Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp34063lqb; Thu, 14 Mar 2024 04:58:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVLs2BrvBWILHnUPKj44bNwPnpnVLSv3Hv5fLGToALKCV/GrWV2HDGGVWqvL8z46z8XcDNJjA/2e9IX0otROUAXF3BHpn+81OUDx8dwMg== X-Google-Smtp-Source: AGHT+IHIlR7YZbHC/LCxxZRrRDCJ3VNjjoKRIse8Soq9aW34CSvO6+qX8UqdhBflSkmctZcC3Hce X-Received: by 2002:a05:6a00:1990:b0:6e6:b0c7:c451 with SMTP id d16-20020a056a00199000b006e6b0c7c451mr1446641pfl.6.1710417529109; Thu, 14 Mar 2024 04:58:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710417529; cv=pass; d=google.com; s=arc-20160816; b=eVOjmELNNgTnvUxZozm1PIxF2iu2CHup1189WTHeP45soL9WI0kQJ8NGwJtFx47A61 X8Nr9B7tdgiWO7YxUplWXK1s1Yh4GT6IIUGfuvi1owz/0E81lj1s2L9kFzSQAvc5D6Ao qiN+GPsb/MDYXf9ui5tD/5ra15GBZYGSxfDjow3i4KNqNoWfmO0KqlcDWPAZ1fCgBOr8 ffxkDOnRy6E4NCPVbgcQ9bg7ZsDfbVenZ9rTMWRUH3E+lGvAgw94J19kHm4rxDoNc7bG 4RcMUacmRLhHI8WULPY7RyBxALoCJSbJ7rmVCQplIrEdjdUG7MER9/MmJ7l922DHcoPb 5x0A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=QDKN46iOx1If7pEywZVOKkP5haIU+INrvEU5huun06w=; fh=nUyC/zlHfG1XwVc8n7W9y4YHOQcNAY21pbfVwS47cvc=; b=hLlhzNDUabGIFofyG27wKDwbdi0DHUZ+jlMTzzv3rbC0475E12eBC8l9wjBrfzqsLv N7Sx6mK7pH1B/7hi0gf/yUruxRRlgARWyJn4khifYCPLqi+sfkBun8c/p4kKiRi4S3k4 3uYBoD9BYJKijO6c2Nb+l6CvIMg3mMdp19+fn4aRqRQoXVWbUOszphTtnre/INkoLn6p WONCTYWBHpYITLdFUxlcp6a3lmXiQMg78Jdw0xP8yQP5u7bx/3Wb8AqPQzrUtILzCieW 89jgbFNPR5dhAkG/jZRSWFyarKAm+kS20UI+twK6ZqoOn/7qZkkxex+x+JZWKpKf3YQ5 30KA==; 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-103207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103207-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id le3-20020a056a004fc300b006e6c5d59171si1326645pfb.353.2024.03.14.04.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 04:58:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-103207-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103207-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3CB002852AD for ; Thu, 14 Mar 2024 11:58:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1464A6F07C; Thu, 14 Mar 2024 11:57:55 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9812F6CDB5; Thu, 14 Mar 2024 11:57:52 +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=1710417474; cv=none; b=isL4bTB5893L6FFQKca5c+4LlPTSZMkvJDTwspwG4mNnGHZBj9xoQPM8Pd7+AMoeBnJHDuKrRswrBKFbE7CHlO+KE/iZrsQRXNsTsVFRu6hGFz9hGAOgPieinW051NfhSFcn7eV1J0biU89Jbm3HEkuIlW3k2vzTXRqgDejuU6M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710417474; c=relaxed/simple; bh=uVbNBR9AVHWckYq4Saa5wfB0njDgPv2cq2V2E6uxF0I=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=GybsoLuN0aYMCjV//dYdzezHoJy12xe52eTXzewsDL7A5imkNlWu1REHSck9v8enraqy9wsiVpA30dcPhyxAUa7Nub4EeogtTGQ/kcTOwU5tbTetknsNz636yZcj3/x+iUME5T71N59sxXu2V84XPIRIuwogdA8HiBruYbNKARY= 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 A23111007; Thu, 14 Mar 2024 04:58:27 -0700 (PDT) Received: from [10.57.13.158] (unknown [10.57.13.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 98D843F73F; Thu, 14 Mar 2024 04:57:50 -0700 (PDT) Message-ID: <1135db48-6430-4a36-b75a-2f0ededd4612@arm.com> Date: Thu, 14 Mar 2024 11:57:48 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] PM: EM: Force device drivers to provide power in uW Content-Language: en-US To: "Rafael J. Wysocki" Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, poshao.chen@mediatek.com References: <20240308123203.196644-1-lukasz.luba@arm.com> From: Lukasz Luba In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/13/24 19:49, Rafael J. Wysocki wrote: > On Fri, Mar 8, 2024 at 1:31 PM Lukasz Luba wrote: >> >> 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; >> -- > > Applied as 6.9-rc material, thanks! Thank you Rafael!