From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.27 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796395757; b=Ywqx7FsvBi5d3IvHSDgOVCYmbjE9qoQFljs5/yp1Koh3Ud9QtjhZHbzE6Ite00E+OC8Q YVJ7sEG97VffTfoDvtN8d8bjxSuIp7pY3tDWvMQ5+0+G6W8Y5oZmaod9LHAleTuPR8FAv fOMYHewHCey4CkkKUTAEONsH4PMF4IF6I/H6fgRW2K73Re7exEtZ0na5rgnxPUIT/JkPn JRfal4Hev8PIZt6wQ/Jv2o2zBuoow661yOFPXUe/1c4dlZ0i7shWROAmxR/rFpS2091DU L8Kn12QBsD2CkzYJCUlVb+VmhQq7rY/jj4A26q2UGk2NxVhXYLhQ5DpkEwlAIOCf16g== 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=SujaCBRJMT7mnYbApFqy8FtSgzeFFeSIZ96Q7FNMtO6ilGxtYc8gopZmnImG8Udh1IV+ EFlnJsdMM1spg2yKItEf9t/ra9qeGQNGql2iwxLL/+tTKo2vO0qQRikno6JdLOS2m+m3y nl8Xts2iouZonaN7PNzchL1yj3WJ/AXN2sUdgTRohkSF+uEPaZjb68R7DSpKHNkqnkQ6Q e9Jk9ikBfi5GcpDqaywcBuWnY15uz/WLLloFGfPO3GHyRzodnnoLchRix9BcrWScy6qmy kJXesxmqbs4gQPUENGf/vzfZuFn5NG1UbnQflskEVEK/iN2BJOTqe8vH2PNS3BKGzHw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=none smtp.remote-ip=95.215.58.27 Received: from mta1.migadu.com (out-27.mta1.migadu.com [95.215.58.27]) (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 BF4A1606A330 for ; Fri, 4 Dec 2026 14:49:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BF4A1606A330 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 X-Envelope-To: linux-leds@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-leds@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-leds@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.