From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.158 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796395757; b=bQAvASt2YXKqNHL5QaBOlOe/l3b9LJ5a4AvOGBfDVA1nB1IWxPjBQLFfJvxSi9Hc6Nzm MZbDpQ4sG3JrV3cXViCPaXjmizOGweDQcQPBvIuGfgAh91GxFeDJiagvANsnjLUzUgToM PUnGWcchZesEeKHt8gXS0L88uTBw02jLwR/Ay2GY6zqP9+b2H/i83fL38wAr5KqHimVqG tX2bWPj0n/xSicYaH7wGcJFw+7yXGudyHp0LrodVZmSl50H9FnvV7ccOHHTLINyuw0gNn Usb9+h/xVJgF95ShPnr9IVzB6n+49WsUmG7T0xrMOINXikPkJYRomSDd2tnlFmsZErQ== 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=Oph2v8TChI3maQZ1JqG8q6hP5chPvf2s/YHrvf8GPtQ1NjdiKFz7rcYahJZk+SNoeZl9 jkbenJ4D7w0814yJo79iHXCyDDXcgul5FqeUM/jfUC9c3fUVEb4DcnCjeTC9J9Y6RB7No ENXVHMKGRTSI/651AClw65Eq4WXAaNGf3Kc3Y6DZxqXdOdUNK/7KlrcCtS7I3iheTT5US k5L7l4WyW0a4OsJJwncQieOKgaN0Z3GMP7/z9WfKjHHmUmawEPvc2tScqZ7wD5w8F42u9 4bVOVd/NVTSLzg0LMsuMqaMYNUZiulY23EEMjDnJvBOPZEN5xSrozTBolBbo9GUg5oQ== 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=a9O8auC9; arc=none smtp.remote-ip=91.218.175.158 Received: from mta0.migadu.com (out-158.mta0.migadu.com [91.218.175.158]) (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 C3074606A335 for ; Fri, 4 Dec 2026 14:49:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3074606A335 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=a9O8auC9 X-Envelope-To: linux-pci@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=1796395755; v=1; x=1797000555; b=a9O8auC93z3q7cxgPUG5z/BCZNuV09KS6H5ZWI7IyKK3m+aXyHFAjFyOlcZPl8Gcgp+8Enca x0n10YtNMFmo5CtmboJpiIreWrtSYR69v06pbgAuflvKdHG/v8GePGXiAGVeLMDqxnxako3FXhj i50KpM4ny+4qgp/vMiR8ZKxE= X-Envelope-To: linux-pci@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-pci@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.