From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.157 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796395762; b=guGYtB7AGPAwrCoGVf575zIl/iwiJqFLg8Xn3GhC+bUzUSO0sSkRnfP+odNbguAe+6OV dGmxto9Z1ZR3DBt3fJXpOeYqhRsjR5a3xocrmqFFZWaTHiRyKGl1hj/fHNkNKgWjajXf3 2QqoawvGPm4muvai2w1f7xer6IfsUl1/CC7kLS/9+zbfvNmMd61Q12YRFxX6raMHqqS8+ 0asyATgDRfvSOkplbnjVhRmpZHqdIwmfhqWXuO591lafal9fG9iHgjrOr4OyE3wkiFMFH fAaZeZxnDfJmxAyb4sUNoYDv9OL6NFR06LHw3UIEzfQyJxumiNWOZ4dhdsAJE+K95vw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796395762; 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=AZYEJ7AnlT+BSQ4AgquFGyWBhx4E9RIX3J4XnKuyjmOvwm3RTD/qpQYDA9AZcXBK3EEn PJ2MzrpkG4GUf1Xhjdc+mbQ0hjPUS17RGlsCuxmEV0PFgv6SP0/gatU9BOP57pO7GumUZ tNHzYiRHhqA8CzLiWsd8jnLn35dp7tOBoXBxrKhYeJb4oFWWhzWBewXlrKFgb57TZsG2P 4GXSLo6vhKep4XaC0EVU/jiszF3ELIoO16rIjPirtxgWvjcb+k8DXpAzpvLagpPXTIINo 7J2E0FAWayCkoUVuxczlMWXXlzDGShdk3NQfa0CsD/8Y0vGmTHsSdzhR8J+eMFjbgCQ== 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=91.218.175.157 Received: from mta0.migadu.com (out-157.mta0.migadu.com [91.218.175.157]) (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 C1E19606A332 for ; Fri, 4 Dec 2026 14:49:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1E19606A332 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-security-module@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-security-module@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-security-module@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.