From patchwork Wed Nov 9 12:15:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 17525 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp299458wru; Wed, 9 Nov 2022 04:17:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf4zw/HJQQ18Wb0lMy7CjhXywMprJ7k7ojMbNiHmrHAJlyeSnV+tKvL+0beuIhQqDgHGN6xv X-Received: by 2002:a17:90a:64c5:b0:217:346c:6ed2 with SMTP id i5-20020a17090a64c500b00217346c6ed2mr27929691pjm.202.1667996241889; Wed, 09 Nov 2022 04:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667996241; cv=none; d=google.com; s=arc-20160816; b=XykaOk7YDvXPJsM4YcyrjIxSnN6AmW0U1MRaEluaZvLFhiYmliZI5eojShoPBVnbOA UONbiJrZQDS5jrrL54bdUIRWDCmxAPMCykHJozV4Irg9DOa6CQ5BBIGB5fhNZOQNlq5W O89KbNJKsfjkLmF4Haj5Kc6Oao1VXRtVtzgaieDFhqEGodKd/Lb5QTeWUJr82vvZ86Y7 c44970HjGOLPfXHOW7QcLq8HwE+5/12A42pEmIAnL5WejK5M2YVT38ajs89tv2damaZH 0LPm64bUuwpZAMKKfjdn417ygonUsn7L4sgBHtx4CcyWVXkrVtmRr1Nw8/HYccz12UB1 7Z0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=MMyA4HuigOlWeWfAgO4cg0YctJ53MC4eKhiFiknUldU=; b=V1cdf8QEi5Pnj4hVxMkChCYkriQtrl8AVJZFFzjpG8eXSfJqIY6RjCCnNWnOXnQPDD 6+6DXGzfO8ZfAm00lcefXPRg6V75JSore6ajlN8P+zgnDNwJ/eKrN+nFOwvJ8WecMo6o 6XSLoNIMd2sLEHyv5sfTNoY8OWFsJgP1gsyY+TGkvEioQX2/ixIvzAlk+69c/QULCcin 10cVqhhKoqc+FmyIXBcaWP9zX73uGZx4f6d1LAsJYhRPkznuX45OZQHVwz9zgexOuZ3T iyr3Kwi209B+qyiM40/K1RbQUjszJO5AL/CKIL3bCVfjbQ12vgRUed8VWjIxYbRffCFB kzBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z17-20020a170902ccd100b001870464adb6si17528439ple.183.2022.11.09.04.17.08; Wed, 09 Nov 2022 04:17:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbiKIMPv (ORCPT + 99 others); Wed, 9 Nov 2022 07:15:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiKIMPt (ORCPT ); Wed, 9 Nov 2022 07:15:49 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D07F13E9E; Wed, 9 Nov 2022 04:15:47 -0800 (PST) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id f64f02712e042cbc; Wed, 9 Nov 2022 13:15:44 +0100 Received: from kreacher.localnet (unknown [213.134.163.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 0EB3C66EBA7; Wed, 9 Nov 2022 13:15:44 +0100 (CET) Authentication-Results: v370.home.net.pl; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: v370.home.net.pl; spf=fail smtp.mailfrom=rjwysocki.net From: "Rafael J. Wysocki" To: Alexandre Belloni , linux-rtc@vger.kernel.org Cc: Linux ACPI , LKML , Linux PM , Zhang Rui , Alessandro Zummo , Andy Shevchenko , Bjorn Helgaas Subject: [PATCH v2 5/5] rtc: rtc-cmos: Disable ACPI RTC event on removal Date: Wed, 09 Nov 2022 13:15:36 +0100 Message-ID: <2224609.iZASKD2KPV@kreacher> In-Reply-To: <5640233.DvuYhMxLoT@kreacher> References: <5640233.DvuYhMxLoT@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.163.195 X-CLIENT-HOSTNAME: 213.134.163.195 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvgedrfedvgdefjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudeifedrudelheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduieefrdduleehpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeelpdhrtghpthhtoheprghlvgigrghnughrvgdrsggvlhhlohhnihessghoohhtlhhinhdrtghomhdprhgtphhtthhopehlihhnuhigqdhrthgtsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghl rdhorhhgpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomhdprhgtphhtthhopegrrdiiuhhmmhhosehtohifvghrthgvtghhrdhithdprhgtphhtthhopegrnhgurhhihidrshhhvghvtghhvghnkhhosehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohephhgvlhhgrggrsheskhgvrhhnvghlrdhorhhg X-DCC--Metrics: v370.home.net.pl 1024; Body=9 Fuz1=9 Fuz2=9 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749020827233387627?= X-GMAIL-MSGID: =?utf-8?q?1749020827233387627?= From: Rafael J. Wysocki Make cmos_do_remove() drop the ACPI RTC fixed event handler so as to prevent it from operating on stale data in case the event triggers after driver removal. Fixes: 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET") Signed-off-by: Rafael J. Wysocki --- v1 -> v2: * Do not clear the driver data pointer (the driver core does that) (Andy) * Adjust the code pattern in acpi_rtc_event_cleanup() (Andy) * Drop inline from the full definition of acpi_rtc_event_cleanup() --- drivers/rtc/rtc-cmos.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) Index: linux-pm/drivers/rtc/rtc-cmos.c =================================================================== --- linux-pm.orig/drivers/rtc/rtc-cmos.c +++ linux-pm/drivers/rtc/rtc-cmos.c @@ -798,6 +798,14 @@ static void acpi_rtc_event_setup(struct acpi_disable_event(ACPI_EVENT_RTC, 0); } +static void acpi_rtc_event_cleanup(void) +{ + if (acpi_disabled) + return; + + acpi_remove_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler); +} + static void rtc_wake_on(struct device *dev) { acpi_clear_event(ACPI_EVENT_RTC); @@ -884,6 +892,10 @@ static inline void acpi_rtc_event_setup( { } +static inline void acpi_rtc_event_cleanup(void) +{ +} + static inline void acpi_cmos_wake_setup(struct device *dev) { } @@ -1138,6 +1150,9 @@ static void cmos_do_remove(struct device hpet_unregister_irq_handler(cmos_interrupt); } + if (!dev_get_platdata(dev)) + acpi_rtc_event_cleanup(); + cmos->rtc = NULL; ports = cmos->iomem;