From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f169.google.com (mail-dy1-f169.google.com [74.125.82.169]) (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 AB87C347537 for ; Mon, 2 Mar 2026 21:45:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772487940; cv=none; b=nqYzcRva65+UbsAbOVwvPZ3NShL0ucpECm1zi7sYlhSlP56YuixkKWJHPp/2aAXrzfrCL+/zcJG0OmR65u4MeuYi9dt6ZcEIXQZ3AMyN4eq5NjsysliUZ9O8/+Xq69jkI2qJR5iv3JDXXGyhhaOywszqzNF/7/IjwN/2LomfPGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772487940; c=relaxed/simple; bh=BEueXD8bsR4vMFjH3PaJBmfnYkTtvORud6B8odsMRJ4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GEqM44i8/pxGQpuKoUm+CzuxhJ7CxwOgBHjW+SHPVnJ2+IVfBlizW4SFe8cvtUVw7ChQj8Dfy8IFzOXr7BTou2DsPw/JK1hOQTt+FdoxJvDJmyLzU/y/rTc8GC3oJMY42ey8CFF15Lp5tjqJbq1x3XKMvFrdKyt5G7gv3hffsRs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Jz0AZue4; arc=none smtp.client-ip=74.125.82.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jz0AZue4" Received: by mail-dy1-f169.google.com with SMTP id 5a478bee46e88-2be06a2be90so2788672eec.0 for ; Mon, 02 Mar 2026 13:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772487939; x=1773092739; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=eL/dEzicRCHaDVnBC7JpiXtFkqhNbNFEBocabI5n5b8=; b=Jz0AZue4h+AstCJq5g50ZE46twE7/eC1wYchZ1xnMLi8Hp5laSA0Q4ZnFh7PqJ2bBG jhZQqo9DO+c+8/oqsEub8N0D2Klo0o9PtutUCJ03dsO3JwpIGBMR9NlyG8mZZjEliJxv JgWjyVS0Zw+vnadvoFwd5UqvIqLhznDdOy0Yn1/dssE2aDXTwus7B1Yip1ZMQZVHTwPH 8lp3bqCzgRX99pAA5hlpQkPJtcAtdUXCOGMk0MH5knhgQCJ0d24e7MGsWz0Q9TU+3ib8 ow5u+RMu/f6T+xToauYcTHUavZ09OUXq8+mh++mvTnNdX67a8aYWoB559S9nk6dvrpFl xYeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772487939; x=1773092739; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=eL/dEzicRCHaDVnBC7JpiXtFkqhNbNFEBocabI5n5b8=; b=Tv16yu97EmgUupp968+Ek6eKCAupQ0t/sf3d33iW+vCPAK9eyfY+6Z8LJFeejDd9iH 1sIKqsWLTElOMTXzVQrxnOl6zlXMkZ95iZ1dcQMEYCH5A1AtIFUvbY3VMi3hLz6DGsIt uYeeG7IGQqCRVOl/cH6jXfFFV6mnHPYT6cmBdpJ766Kqe20qWh9hZaBOYF8I7qHuJ9Am pU4QQgxFlUt4jZ7TrnkDZTvOwux9W7AWAQ8aR4Msls1m1Oq266sPYOR/Y66CCagk6MYu J+cROuaB80cyrkgeyIfqlUebLXlgA+paO6r0BrCE/Gqo4QUbtPfRyURRtTkm/Ku/tCB4 kVhw== X-Forwarded-Encrypted: i=1; AJvYcCVlx8hTkB8csO5lHVsNpgIWfzoTVp+mNLrOiaqqiovOKh6smqZiZ1X4XOT0ZACT9GDslY1rYB33iDEec6c=@vger.kernel.org X-Gm-Message-State: AOJu0Yx26cEohSp60WK6UfGEPBId15mEQDMFs82VmzRdM/sSQ9glMHp3 lJDNJjlm1L3QGvZkxtijnenyMZ1VBDsg8Eoh16Z+pHy+uZP1L2BJsVDS7JRZAuu2 X-Gm-Gg: ATEYQzyAkcwQ1g7eS6noDWEdUthai9aaTGdLZ1x4Na7p6XCfCbsaKKEXIRGHjIFpxPl EDrloYrJpQ53+Qk2/HhEOZn6arMu7YUlsav66G8KlnkRiV0dL54utrADLuyNTcgI4j8KxAXf18q GyCZjj/YwZxMz8QIn9RewD44rU7aHe9RkUQ6ors5LAyvXzOkHKByy2DK7Rg0JO67LI/RJMTUaYO doBYoiVn8CjuaPD7d1+sRoFHEuzNDcLeqjLR3Fe5NE61/szoyhEE/nMQhyESKKZ9rqMQx3tOwVu vR/BqpOfbv735nUwtMNm5ZYJVSP5QDfqOXBZqW/k/Dr2ZcZBXSKkHY1v+cDwUEaMc4HvEAKIFjW opHK3e3c6JpJrSIjNRKocWH1kXDQJH67niB5MMdvfcHavz7DuSmrkUHRbNy9J9Z2V40ZvWIjSb0 D18lf7wy8xFyzY+MwPNfuYx+lOE6MTY5OMFccA X-Received: by 2002:a05:693c:40d7:b0:2be:1dc7:99ae with SMTP id 5a478bee46e88-2be1dc79bf1mr592214eec.6.1772487938710; Mon, 02 Mar 2026 13:45:38 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bdd1f7e955sm11781590eec.32.2026.03.02.13.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 13:45:38 -0800 (PST) Sender: Guenter Roeck Date: Mon, 2 Mar 2026 13:45:37 -0800 From: Guenter Roeck To: Mariano Abad Cc: linux-hwmon@vger.kernel.org, corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] hwmon: Add LattePanda Sigma EC driver Message-ID: References: <20260301023707.1184592-1-weimaraner@gmail.com> <20260302183514.3021503-1-weimaraner@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260302183514.3021503-1-weimaraner@gmail.com> On Mon, Mar 02, 2026 at 03:35:14PM -0300, Mariano Abad wrote: > The LattePanda Sigma is an x86 single-board computer made by DFRobot, > featuring an Intel Core i5-1340P and an ITE IT8613E Embedded Controller > that manages fan speed and thermal monitoring. > > The BIOS declares the ACPI Embedded Controller (PNP0C09) with _STA > returning 0 and provides only stub ECRD/ECWT methods. Since the kernel's > ACPI EC subsystem never initializes, ec_read() is not available and > direct port I/O to the standard ACPI EC ports (0x62/0x66) is used. As > ACPI never accesses the EC, no ACPI Global Lock or namespace mutex is > required. > > The driver exposes: > - CPU fan speed (RPM, read-only) > - Board temperature (unsigned 8-bit, degrees Celsius) > - CPU proximity temperature (unsigned 8-bit, degrees Celsius) > > DMI matching restricts the driver to verified LattePanda Sigma hardware > with BIOS version 5.27. A 'force' module parameter allows loading on > untested BIOS versions while still requiring vendor/product match. > > The EC register map was discovered through firmware reverse engineering > and confirmed by physical testing. > I had trouble to find this patch again and found that you sent it as reply to the first version. Documentation/process/submittingpatches.rst explains why you should never do that. Anyway, additional feedback: > +/* Read a 16-bit big-endian value from two consecutive EC registers. */ > +static int ec_read_reg16(u8 reg_hi, u8 reg_lo, u16 *val) > +{ > + int ret; > + u8 hi, lo; > + > + ret = ec_read_reg(reg_hi, &hi); > + if (ret) > + return ret; > + > + ret = ec_read_reg(reg_lo, &lo); > + if (ret) > + return ret; > + > + *val = ((u16)hi << 8) | lo; > + return 0; > +} Is it possible for the 16-bit value (e.g., fan RPM) to roll over between reading the high and low bytes? Without latching or verifying that the high byte did not change, reading a rapidly changing 16-bit value as two independent 8-bit reads can yield a corrupted result (e.g., if it rolls over from 0x0100 to 0x00FF between reads, producing 0x01FF). This is AI generated, but it does have a point. lm90 had a similar problem, which it kind of solved in lm90_read16(). You might want to consider using a similar approach unless it is guaranteed that this is not a problem. If so, please add a comment explaining why it is not a problem. Thanks, Guenter