From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.150 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796395757; b=phCS69n9wTaEquumKLPpU6OvpBGHTXQMNvD/jMjfnRED936w4VutF4EhADf3bydoxqJ8 kDWiQrgsgiuL77WMEuM+VYy/OGLemxV6LSd6USqE3mLmZN9T1r52XIelS/uKvKwAI4HXH gbllx6c9krC5t/a+usXYdSnj3nJPgcYIz783YOFU3T+T08aWzlZWW11Jpmya0WnOFV6Vo aonm5bF30E0x5bFt3ahTBNewgCVE4ctr1utLtM2cc/jBVtZv8cb3TnZb/ILwbYWX5Es1J BWT21mHJJOe69ryMyt29XHUmSU+/2a4bJcdsCA1rtCOJ5bqLDfuOCcmtpBkyJAJP1BA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796395757; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=BH9PiBPSneIDGhI17JIreRLBeJhSclyLeDLml8cGOIs=; b=wvM1Kcdl0THU4zMn2GCy4jMijjQEhm2c6C/kLlch4LUd3tX3ABDNj1xkUlZ3Y1kxhyfI C/dk6RRrw6lQNJJ0rFsSFN3k2fnpkvbhRihlw5AUR/oEdneFDD3vWIpbAVRfHikeXAzkZ wuzUsVX02XO7pjdgM2hmfshG/OhZ48YJLbCsF59Ld17yEZqZZRSBhhbGdNLd5173NmeYu e8xxFmAvhSpiU1SW7a/2YZXxHhMES9v2XC5bUBZoGaIPC7a5xIv3r408eo1CH7DjQVmMp sbkFOJB8o7VjCXwrQ8lvYbt3z5wghNCD2n0AS72X4VC1AiO3ZiLzjIN2dUHHHf+I++A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XG1jt+nJ; arc=none smtp.remote-ip=91.218.175.150 Received: from mta0.migadu.com (out-150.mta0.migadu.com [91.218.175.150]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5B64606A336 for ; Fri, 4 Dec 2026 14:49:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C5B64606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XG1jt+nJ X-Envelope-To: linux-hwmon@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=FURXE7uMfn105AxWi2fNbZa/6hli5r23lurWmRvOHvI=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796395754; v=1; x=1797000554; b=XG1jt+nJd/vJ9TlA4TIobmRGheHby6xr97ZrJKOht5quIx0DNT5Naixjp5A8H0RguznQLmeP u2khBuTQ/Q3mfIUVHq9fopun2355KMTaR1VPGLjXG6Zo4W7rKchSXmlqmqVX+4j95Iz49r847Xw dI+Tjme45pBecmXFVrmcNlvU= X-Envelope-To: linux-hwmon@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id a6070a5bd4e6f196; Fri, 04 Dec 2026 14:49:14 +0000 X-Mizu-Trace-ID: a6070a5bd4e6f196 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Fri, 4 Dec 2026 20:18:54 +0530 X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 07/14] rtc: add support for x86 macs in macsmc-rtc To: Andy Shevchenko , Atharva Tiwari Cc: Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , "Rafael J. Wysocki" , Len Brown , Linus Walleij , Bartosz Golaszewski , Sven Peter , Janne Grunau , Neal Gompa , Guenter Roeck , Jonathan Cameron , David Lechner , =?UTF-8?Q?Nuno_S=C3=A1?= , Andy Shevchenko , Lee Jones , Pavel Machek , Griffin Kroah-Hartman , Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Sebastian Reichel , Alexandre Belloni , Wim Van Sebroeck , Jarkko Sakkinen , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , Paul Moore , James Morris , "Serge E. Hallyn" , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, linux-leds@vger.kernel.org, mfd@lists.linux.dev, platform-driver-x86@vger.kernel.org, linux-pm@vger.kernel.org, linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org References: <20261204131619.5059-1-atharvatiwarilinuxdev@gmail.com> <20261204131619.5059-8-atharvatiwarilinuxdev@gmail.com> Content-Language: en-US From: Aditya Garg In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 04-Dec-26 07:42 PM, Andy Shevchenko wrote: > On Fri, Dec 04, 2026 at 08:12:47AM -0500, Atharva Tiwari wrote: >> Make macsmc-rtc work on Intel Macs. The ACPI RTC doesn't >> work correctly on T2 Macs, so the clock from the SMC is >> used instead. >> >> On these machines the time offset is kept in the SMC instead >> of NVMEM, and the clock rate is read from the SMC too. > > ... > >> +static bool force_clkm; >> +module_param(force_clkm, bool, 0644); >> +MODULE_PARM_DESC(force_clkm, "Force CLKM Key, instead of trying to use CLKL"); > > No, why?! > > ... > >> struct macsmc_rtc { >> struct device *dev; >> struct apple_smc *smc; >> struct rtc_device *rtc_dev; >> struct nvmem_cell *rtc_offset; >> + uint8_t shift; > > No, use kernel types. > >> + bool async_rtc; >> }; > > ... > >> +static int macsmc_rtc_read_clkl(struct macsmc_rtc *rtc, u64 *ctr) >> +{ >> + u64 request = 0xffffffffffffULL; >> + u64 response = 0; >> + int i, j, ret; >> + >> + for (i = 0; i < 4; i++) { >> + for (j = 0; j < 40; j++) { >> + ret = apple_smc_write(rtc->smc, SMC_KEY(CLKL), &request, RTC_BYTES); >> + if (ret == RTC_BYTES) >> + break; >> + } >> + if (ret != RTC_BYTES) >> + continue; >> + >> + msleep(20); >> + >> + for (j = 0; j < 20; j++) { >> + ret = apple_smc_read(rtc->smc, SMC_KEY(CLKL), &response, RTC_BYTES); >> + if (ret == RTC_BYTES) { >> + if ((response & 0x7fff) == 5 || (response & 0x7fff) == 6) >> + return -EAGAIN; >> + >> + if (response != 0xffffffffffffULL) { >> + *ctr = response; >> + return RTC_BYTES; >> + } >> + } >> + fsleep(1000); >> + } >> + } >> + >> + return -EIO; >> +} > > Really, folks, read the last a year code or so to understand why the above is > no go (style-wise). It's your homework, you can find all of the typical issues > in the mailing list archives. > > ... > >> +MODULE_ALIAS("platform:macsmc-rtc"); > > Are you sure it's a best approach? > > ... > > Overall impression that you copied'n'pasted AI slop without much effort made on > editing and understanding. Also looks like each patch requires a logical split > to a mini-series. > The whole code is being developed before AI was compatible enough to generate all this. Thanks for the AI insight. The logical split is good enough IMO. Pretty much same as what Asahi Linux did. I would be nicer if you could elaborate the split by a few examples rather than just making a statement.