From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5B44386C0F for ; Thu, 21 May 2026 11:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779362185; cv=none; b=BN7zUqYALL/ptKq0PCNOTVac4nn5PNZj3xvLVi22tuMCkaU4fih9mmZRxUXHD7/phlwHfh7ByxtpLcrdVXJYiAS33heXSSqJjEqFpe+ztzm11cbAYu6j+DwEtP9NbGq180QFL9ECQHI3A5EKbA9hnPCC2nEjCvJLjcd8X6GHi3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779362185; c=relaxed/simple; bh=VqS+MmMkt0nnuZK1oTuFUfQCyaQWJ2P/ng5uGmC6tzs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QCWSWTsOrEFmTaNAK930/Hnd8cuKtrpo5t2Ie1qvUON+Ur8ywm1RcU0atLfP/tevN+9T397oZvX4q3/oDfQ70YuEgNQoza+BLKw1ojsVZMoycXn5s8hHpLjNRRi+sjrqX2zpKKstjQcok6cAf8uS0ni2GfyqdOEJoRxnW9yCyMY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=NKOhzjZj; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=bOAGWd2u; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="NKOhzjZj"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="bOAGWd2u" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L99ugQ3772794 for ; Thu, 21 May 2026 11:16:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 4g/Ih03nz0JfyJaaDPDrFXF4/nl9W1h0BCYiGYmduFo=; b=NKOhzjZjyuo+LjGl qBRn899jTmASxrs/A/sM8akkTl6EMd7HFrYF0xVbaDfC0RxFUx72f3+DLdLwZWPl sR5Ad2Vro6L6ZoNnN/vSMv1ilRP6zAjZMjT9Et6fTgjrzFBrekV7VqOiBg8czCk/ yaayehjzfHCV3Mnf9v3crRmZoWX2QscU8OFXUqr+h0rrnhTmm8KtcN2zEQt/SAv6 2qzLyfC5cVEH/jgecMWkUQEByFkd+EANEL/+4g4gUl1RcpMSAAsnF+V+TbxZ6pd0 EqEX5DhhPGdqZq2y8P0vv3zJeQ9eyIGKx7PhR5XxuFWHNKBZpEpIr/8RHDOUsXCk 95X5Zw== Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e9ma42wty-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 21 May 2026 11:16:22 +0000 (GMT) Received: by mail-vs1-f70.google.com with SMTP id ada2fe7eead31-631cad875f3so396761137.3 for ; Thu, 21 May 2026 04:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779362181; x=1779966981; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=4g/Ih03nz0JfyJaaDPDrFXF4/nl9W1h0BCYiGYmduFo=; b=bOAGWd2uJ4csfd3Rb9F6adhOGDVj0XjoGJirpBx/q8aOmKoIr50hRVG7HFvYfxJyIf +vLWsuGAept1gvhVVmf1DpoxRB5WZZTA2M1OfiGfmuFvr1dvxe1r+01GmRcFMLh1wM21 O5SAqLGKzn3I7VBQ74CcMUECu9EALniUhKMooaRVQeJC3VqxRqhcb/EVDUxBXdqIXYlD lhEUMsuO771+/h8z/wrVPa3KkKehWIt+lzfBAdnQeYlD9y1KTdWAOiZhPaLIJSQE0DY0 kcGPWZqemk/BJPXXLOoQgID9MxUEVMIoJhSi9GIdzEKVZ1TDbbwXcRnsUcI/GAYwI0ih hUqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779362181; x=1779966981; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4g/Ih03nz0JfyJaaDPDrFXF4/nl9W1h0BCYiGYmduFo=; b=S+qZCrbHN0tllKAtP+/r44t4RWXx4QJ/Bfs4u2BfF7E5CRtgnoBAYvEyvRRs9xpvfo 76hMnJ/MyON4wG6apvqWg6XT/WsjnWrhz5B39mxOdxWdAvb/TQf3jg3lglUtI3Ibpw+N ukWOZYJxrMA0qFlYPA3FOpdRmV0tY8mHkPotteO+yXv7hHMG9kHb22FQvl9uOWoQr13n nqJ9h/9gV/F5Ci4pRNdsh7MrmFr1KlDOC0QtYZUfjFGTQkmISZdSSFg8TuHKQoGbvwbo +Y4NlwQqFESM5RgkC53od8pbv7asauhxfeBVq1evk/GKzmRv+9kdO4Qe0ArThAth942V I9Hw== X-Forwarded-Encrypted: i=1; AFNElJ/tUjrK2TVZxzH8kkwffNSPwf+N77o+8uy8bu0pAofuXBPekibBggsRXzZFDVJi9fcoMg6rlcA4hQAO@vger.kernel.org X-Gm-Message-State: AOJu0YwapyznQnZssjyIh3IbVAxldX29UDtVrKeUzvSrVd9gYfOpr00x HYpNH0chTKmz7l+YB6dCXLKvGaYgFpeBUdwmaCygrtBwBMtk9syBC7GEOBT17037hoCigP9+VyY X4OjlLL6FRQeoGhPhD8jmspBizSKKCM/RygxZSI2gNkdbAp3BsBcGtzre6ovS1mTZ X-Gm-Gg: Acq92OGI9HPdp4UNTF+jj0WrY4gB9mC8CufsDuAWiEH0I/d+97D1VnrkJmy5zGQV3az MmCQaMqJ+QezeNXim3Yblu2Rji4LfPnmI1LprG6me7DArsC4NbFiRJn3Vz2o2GL4UXb149Y3A4g xk7fBd3hsW+suUH7wZxPsYhfqa/Y6VoedA/sGHX9Qg6aEe6iUQbhlea/IV/uv4iWjU1Ea8g3rXa 0EXXK+Rnx0Yf81tBhR5MsAy+RjVg83FoH6Q5sDvPjTTdnl6wwrBVmmR12X+rYXZL/mghcK1rgpS yuS/Foce8p16F3aS4Eu9pMmfkvsoEOmiRRNwCK5mf7ZpBuHj94WtPsfJ4zLoz1GePjNz2LFJRgv XwjZpR1OpdIJUJy+L6LkzEvl3drCF7vkf+lt9e3Kq/Up/S3sgvc0pcmSaDvPu4rY/50XQXq1hfE k1z6mCLuUZeSja/Q== X-Received: by 2002:a67:e886:0:b0:631:25ab:8bbe with SMTP id ada2fe7eead31-6739dc9a040mr354052137.5.1779362181131; Thu, 21 May 2026 04:16:21 -0700 (PDT) X-Received: by 2002:a67:e886:0:b0:631:25ab:8bbe with SMTP id ada2fe7eead31-6739dc9a040mr354039137.5.1779362180695; Thu, 21 May 2026 04:16:20 -0700 (PDT) Received: from [192.168.119.254] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bdc87890b46sm33705866b.13.2026.05.21.04.16.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 May 2026 04:16:19 -0700 (PDT) Message-ID: <7ea2f2cc-ef11-4727-810c-e32e815bd973@oss.qualcomm.com> Date: Thu, 21 May 2026 13:16:17 +0200 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] powercap: qcom: Add SPEL powercap driver To: Manaf Meethalavalappu Pallikunhi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "Rafael J. Wysocki" , Bjorn Andersson , Konrad Dybcio , Daniel Lezcano Cc: linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Gaurav Kohli References: <20260519-qcom_spel_driver_upstream-v1-0-75356d1b7f94@oss.qualcomm.com> <20260519-qcom_spel_driver_upstream-v1-2-75356d1b7f94@oss.qualcomm.com> Content-Language: en-US From: Konrad Dybcio In-Reply-To: <20260519-qcom_spel_driver_upstream-v1-2-75356d1b7f94@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=K9kS2SWI c=1 sm=1 tr=0 ts=6a0ee986 cx=c_pps a=N1BjEkVkxJi3uNfLdpvX3g==:117 a=FpWmc02/iXfjRdCD7H54yg==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=8bRiB-4Q7LyQZs0zT0oA:9 a=QEXdDO2ut3YA:10 a=crWF4MFLhNY0qMRaF8an:22 X-Proofpoint-GUID: KVxj9pZHg7ryqSmoH4YseiVII7UYyvIV X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDExMiBTYWx0ZWRfX8Pft1Y3+cKVk ldRK76TpAGOWOjy+XL9soFP7AGYQUZYefLdJZ0XWU4dwu8GlNnBp1RVY7AHT5z1EiCVksPy9Tqb giBw5nDXwBz2WEUcrm49oTIroqdAG6gpMq11LRQ1dP+cVnIgyASlgwcwqM01Rnsw3iwQJMB9EOP Y/yZQMsJTHFkYm+XxsIjSEhXHq7m7yQUdadT1GTnTswe4lUXm8QUYqbMHD/0UFKZNgQf9qsCU8m XUPYX5Hx1PSuTbnECvHqK8+tfFnUqpGyC4diQdmTyUQ4TH0b2mPgI3PKYrG2AAzSqSi5z7boqRX Df4OBZPlNtSFCTYRPvw3q8pmFbkp66jRUCPeoy2FU9s7+fiC0SBXfPoENBV5vdCUH9/vCTM0Lou VWuku7phxiYDbWZax9SQkQemZdA829GyAhMlqJEzczFHOy3RYuJTb2IplmBFQYvVYgvegwNJHd4 uUCNvZi5gVNhtlvxuFA== X-Proofpoint-ORIG-GUID: KVxj9pZHg7ryqSmoH4YseiVII7UYyvIV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-21_01,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210112 On 5/19/26 12:49 PM, Manaf Meethalavalappu Pallikunhi wrote: > The Qualcomm SoC Power and Electrical Limits (SPEL) provides hardware > based power monitoring and limiting capabilities for various power > domains including System, SoC, CPU clusters, GPU, and various other > subsystems. > > The driver integrates with the Linux powercap framework, exposing SPEL > capabilities through powercap sysfs interfaces. > > Signed-off-by: Manaf Meethalavalappu Pallikunhi > --- [...] > +/* SPEL register bitmasks */ > +#define ENERGY_STATUS_MASK 0xFFFFFFFF GENMASK(m, n), across the other defines too, please Then, you can drop the _OFFSET defines as FIELD_PREP/GET/MODIFY accessors will derive them from the mask Please also use lowercase hex, file-wide [...] > +/* Constraint configuration */ > +static struct spel_constraint_info constraints[] = { > + /* SYS domain constraints */ > + { 0x10, 0x70, BIT(0), SPEL_DOMAIN_SYS, POWER_LIMIT1 }, > + { 0x14, 0x74, BIT(1), SPEL_DOMAIN_SYS, POWER_LIMIT2 }, > + { 0x18, 0x78, BIT(2), SPEL_DOMAIN_SYS, POWER_LIMIT3 }, > + { 0x1C, 0x7C, BIT(3), SPEL_DOMAIN_SYS, POWER_LIMIT4 }, > + /* SOC domain constraints */ "SoC" > +/* Helper functions */ > +static bool is_pl_valid(struct spel_domain *sd, int pl) > +{ > + if (pl < POWER_LIMIT1 || pl >= NR_POWER_LIMITS) > + return false; > + return sd->pl_name[pl] ? true : false; return !!sd->pl_name[pl] [...] > +static u64 spel_unit_xlate(struct spel_domain *sd, enum unit_type type, > + u64 value, int to_raw) > +{ > + struct spel_system *sp = sd->sp; > + u64 units = 1; > + u64 scale = 1; > + > + switch (type) { > + case POWER_UNIT: > + units = sp->power_unit; > + break; > + case ENERGY_UNIT: > + scale = ENERGY_UNIT_SCALE; > + units = sp->energy_unit; > + break; > + case TIME_UNIT: > + units = sp->time_unit; > + break; > + default: > + return value; nit: maybe setting units and scale explicitly in each entry could be better for maintainability, but potayto/potahto > +static int spel_register_powercap(struct spel_system *sp) > +{ > + struct spel_domain *sd; > + struct powercap_zone *power_zone = NULL; > + int nr_pl, ret, i; > + > + /* Register SYS domain as parent zone */ > + for (sd = sp->domains; sd < sp->domains + SPEL_DOMAIN_MAX; sd++) { > + if (sd->id == SPEL_DOMAIN_SYS) { > + nr_pl = spel_find_nr_power_limit(sd); > + > + power_zone = powercap_register_zone(&sd->power_zone, > + sp->control_type, sd->name, > + NULL, &zone_ops, nr_pl, > + &constraint_ops); > + if (IS_ERR(power_zone)) { > + dev_err(sp->dev, "Failed to register power zone %s\n", > + sd->name); > + return PTR_ERR(power_zone); > + } > + sp->power_zone = power_zone; > + break; > + } > + } > + > + if (!power_zone) { I believe this is only possible if ARRAY_SIZE(sp->domains) == 0, but it's not obivous that it's to protect it from that specifically [...] > + /* Map spel domain registers (energy counters) */ > + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nodes"); > + if (!res) { > + dev_err(dev, "Failed to get nodes resource\n"); > + return -EINVAL; > + } > + sp->node_base = devm_ioremap_resource(dev, res); > + if (IS_ERR(sp->node_base)) > + return PTR_ERR(sp->node_base); devm_platform_get_and_ioremap_resource() [...] > +static void spel_remove(struct platform_device *pdev) > +{ > + struct spel_system *sp = platform_get_drvdata(pdev); > + int i; > + > + if (!sp) > + return; > + > + /* Unregister in reverse order: children first, then SOC, then SYS */ > + for (i = SPEL_DOMAIN_MAX - 1; i >= 0; i--) > + powercap_unregister_zone(sp->control_type, &sp->domains[i].power_zone); Could you try adding a devm_ variant of these register functions? [...] > +static const struct of_device_id spel_of_match[] = { > + { .compatible = "qcom,spel" }, The compatible must contain a SoC name Konrad