From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.153 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796395757; b=Kw9RKdvFdObSfWCaE+/gYhjgX4XyhVeXX6t2z8z+3xilB/sGaxqjnmldmMgNNUDiAKrl KP7k6/kHA0GJvcC6TlyiOgbxi2xwFyoX0Ywy+hJpDGWoWCnd4ovYTM6pzcFjRrFnKdeIH rvVMLxSJiOW8AaGDHxablTxfFfstG1eXjyMxxfkS0XE2cZ6toSuJwG9w4hbRg1sMTxxUi /zJD69jqDWA6Wrnz2UFiK9Hx2LZIZaBbTdKqCAmIlp1464i9gCsWSvAy7ViZfenM+4zm2 QN8sDuSX+DKe/sON27QOOk+qWyB4g4v3hpImh8JpwztYfOXvTMgzo+NEb8G+so06Ejg== 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=saOmCcM4UU940qSaxfEYnBrkqLv0lNq8LLP5KSSDkXnWgGYcUTShrDC0ODDnCJSf4BKK /YDPh8bQZP3a1oScdZxNQ0W6oUOcVNfUE64L/hpaZ3BOhO7pMuns33xB7rp+sni7I87cE i4PG2ZcFqJ0Q0vUaQsAEO0h3gCpY9KWIRaoq1AxcPBJjG9hSyI/e1v0ExR17R4gGN+/Nx eS0Jc+bSCPAtdxSAvB7pvkp0gBzIxQ0VJT3MvSMSkdQ/GkYEdBfiuHfq6HjGyaf8h6P5W ZrZYsLzJw8G8rj/ZM2CPcBlKvjiVq40oVGnFxgyhp8MQUMCoygqHDpBvnLxyKvJJ8+w== 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.153 Received: from mta0.migadu.com (out-153.mta0.migadu.com [91.218.175.153]) (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 BC297606A32C for ; Fri, 4 Dec 2026 14:49:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC297606A32C 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-rtc@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-rtc@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-rtc@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.