Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1951056lql; Wed, 13 Mar 2024 12:50:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTwzykWluqR21pAeZLlFotbGAg19s1xbbpkk/IOBThnT3gM945gISOOtbm/M/x8S1ahzj+HUS6KGwfxxGjAuEdwB+x8hX5I1hfxFmuFA== X-Google-Smtp-Source: AGHT+IHw04wJDv8lk1BGAPiNJVHf9u7VDW0wjJn52CFgm35NH4mdypvyhiN67NLqUWz+Yn/RD/LV X-Received: by 2002:a05:6512:2109:b0:513:8a02:9e1b with SMTP id q9-20020a056512210900b005138a029e1bmr2799399lfr.35.1710359401181; Wed, 13 Mar 2024 12:50:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710359401; cv=pass; d=google.com; s=arc-20160816; b=UeAMaGAaM+pQDeUercQu2WMpR11+pQFdy9CMJJbXopU1Zff+Cfviwtfa7yzPRnp6Jb RJPM01RWxCLhIM9Ibto/iarccMgZhrHHE1aFCoLMXIjqT5wNvwAehksViRn33eWSn2Wd kz4KtE8EwtrJKNaJpyuc0oXI/ANVAdpeDppHJSGsfjAnK3MpZLrVx2UlA4tyogTvV4Ig ew92zQlqwGR0U0dsegFbLRlFOm/g3PkCm4wPs429tyhCqlO056M3k8wVnTnt+fyi82mV FsHK+q+uOpu7wyhTrY8f0Zge3A33/UZGW0i1GZOyHYx+wY2sfGzC8IMawRXnqxZm5YeA 1baA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=sjGBA/d4OBZ6FVZbofQlr6HlcymtZvvTx/Uzs1a81RI=; fh=xARI4mnN/mKPaHohvFm3ceVTOU+H1IRx54cbtIBG1Dc=; b=gXDmdN1g7SHJz0j7Lyovn2BYOZM/E03b0IvuvutucqMhhSQYn0lrJVLNLCnjeejiHu rQihyEWyDgtKfxk1fuXc88PUZqfORmEGEgGA5YfhM7vSGakNjoeeAzm995tCzn9twHi9 Bbuvwr6vfILkw05fbHDB1LyQpYKgT8pVn31uHN7dDZdS3l/Z4eC3MSu7+C+CKswPu70D RO5VDD6UlQOddqXti1KnhSHzHFAonPYsfJWSBvMYD81XSZ4TlKeoOgU4I6PhRxzVXrjN 9ZrA+TGzAkDCTqUb82i0Z3pQCm9jCnxqaaWFDWtU93ZrUuR6uT91vv3F6xTFVtJ34ZPP uHQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102450-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lw27-20020a170906bcdb00b00a44dd2447ebsi4698618ejb.6.2024.03.13.12.50.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 12:50:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102450-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102450-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 DF2371F24407 for ; Wed, 13 Mar 2024 19:50:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9C6904CB38; Wed, 13 Mar 2024 19:49:52 +0000 (UTC) Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com [209.85.160.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0DC350243; Wed, 13 Mar 2024 19:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710359392; cv=none; b=ApG+wKeE5pS0C11yOW7yVx/36sbMiqp9HFx5Vll2yTO3jZOkrUnTeOhBLT9KPiLe1fOswkHkeqNwUjHJEe71KXtUwNwjLIskw8SO5bzgDWdfX2Qm6JSX0WLUcpbJNmwB2Im0N3gBYSJIQC1s1ZoeWfiaaWuN0exlP+cY2ofCTNA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710359392; c=relaxed/simple; bh=J9t0dvhtaq5ykc0MBVleUBfd953s0rO/2H9+VspMBH4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=eTa/mjyV4ac04wPi15lT5tN4lQsEnA3Wnt0DzuuKyiEv1sKf/tkoEPLLXsR5zAHqatMalDrRSLBlZHXF41yG+iAgjWKkQHWgf/6uNjZ6gUIqHc4hOh37kTqX+gFFC6F6OqPQ0EnAdKaq/Rg1g/21AZC0n30pq5OMi9tQAr9dmnA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.160.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-221d4c52759so51442fac.1; Wed, 13 Mar 2024 12:49:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710359390; x=1710964190; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sjGBA/d4OBZ6FVZbofQlr6HlcymtZvvTx/Uzs1a81RI=; b=a+X5mjYR7mdrqK0x9mhYyZ6YTletpWT1t75V8Gb1RJ7DzI9fnaMCdaVihW0OOf6wy0 MSVCOGEQA8H4MwcDAQkaHXzgLQ8qi7a+9m7j6r5Mz+3zBUSJcOXNxeBxCNbfckWjSb6D f/CIKkYpSjj0URH0NmzXctIs9NSX//6MQ/2UcpqPK1FrsK5ALD3EGF4x42snWaOjBI5i gyXq2mvuys3WZkxmIORynF5Z8mhu4qS46QHU7Ogk7365BATJMgfxKufaRJvWzn2KwmRv bCR0Ysz3OXlbuls6cKuVHSVRFIFNqiCyW0ZEMrt2ZezDD0M0AdsOQKybrNUN5FsAo9n1 88Kg== X-Forwarded-Encrypted: i=1; AJvYcCUm94Hae+1IuXLrDw9mVUaX63nxUoxM9czxXEhlKRIOjIcmgk+QnwO36ChfT3iikB9zTMv+VRfdc68FmpfKNeDHj9bHwLGWaz0= X-Gm-Message-State: AOJu0YxZ/MycFL78eD9TMH4BGxcPnmjCg/hXAoRA6SzLTqnbDtKcgxEf J1ByI9d25UHnFUkckHOeOcy01XE030AnhpbUIxEjLf99/xRX0uHSJFkUOpwQtF10B4de7c9/HGj K5UQUr6lVxEqBrK2lnnI4p/yu2WA= X-Received: by 2002:a05:6871:2895:b0:221:3b96:4e84 with SMTP id bq21-20020a056871289500b002213b964e84mr5988986oac.5.1710359389709; Wed, 13 Mar 2024 12:49:49 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240308123203.196644-1-lukasz.luba@arm.com> In-Reply-To: <20240308123203.196644-1-lukasz.luba@arm.com> From: "Rafael J. Wysocki" Date: Wed, 13 Mar 2024 20:49:38 +0100 Message-ID: Subject: Re: [PATCH] PM: EM: Force device drivers to provide power in uW To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, poshao.chen@mediatek.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 8, 2024 at 1:31=E2=80=AFPM Lukasz Luba wr= ote: > > 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 o= f > 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 |=3D 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 =3D -EINVAL; > + goto unlock; > + } > + > ret =3D em_create_pd(dev, nr_states, cb, cpus, flags); > if (ret) > goto unlock; > -- Applied as 6.9-rc material, thanks!