Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5370565rdb; Wed, 13 Dec 2023 06:59:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5cQan0eqx6xRTiWYQG4fJ3/9LXsFEB1RqyscsyEpe3j2unAjGuPt/jfMoaZHJQzQEw8XQ X-Received: by 2002:a05:6a00:4b49:b0:6ce:49a7:16a3 with SMTP id kr9-20020a056a004b4900b006ce49a716a3mr8203246pfb.58.1702479594213; Wed, 13 Dec 2023 06:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702479594; cv=none; d=google.com; s=arc-20160816; b=R64PG91Ns+0BQRGOMB/SNe+WlaMMUlQYbOy/4Evj1Ysm56UHuKla4Def/rtE2gdZD7 xdBHbmv96LgUb0xNC86942rvNP7BNmgwupLdNYcyU60f5Srr0soE5uEJxh6eMFHf8SUz Aqt+gISBRdu4nx+68xi2iG82FiYw3td0xgrq4UpXca+xUTYh7qHl80tmnyMte3vY+fgN 1QeG0joR11H4yHiZP+XPQNmIAE3Gdc+KMWTDBbqR1xt5psivOteZtF9DCBYXvyxLk2xz QA2tHmKHDfQqJFtl8kh9znusyRKp7OVsQ8WEvbQnI59/RNjPGf0iSrEbjnoN7zWW6o5H gabA== 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 :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=foW+ZiDixud3U2NWD+f47jXaCIGRQEuK1RL8JyJXNEg=; fh=khex85CfyqHncI5ZxZ/Nyd9/Lq9HaEnm/WOz89yQGYM=; b=PAD/AstSoUpAKJxdP55m1KXNs0D8yPf7TIptYHh/nBt65LQ8sd8MQBQ263S3M1zDpw 7B9oTI3G2bZ172nsVXMTdFc+PBxHJX4CvJ9MQRvVsMGJ3AnwjO5sbD4gbOgiC5W9fCy9 /uRcBqPM06KyDJeSqvN8szROFMrsE2G5ZT0NfhRd+MScfnHn4DngPjxygHNSA5JOmEeQ S5vnGt1HYDC+/NqiSsJTnos5ogxtmU1mRCgmCGmvhaUKVdKssX1t33a6nIjAn46rJXl7 PjhPAiE0yoTOB8qjx7r3MW3M4fTgVrpzCNYb8SMRJfNRDthluI60moWQS/yFup7fa3kA 7Low== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1Dk+2Wow; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=uST60tem; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id m5-20020a632605000000b005acb92781fbsi9774968pgm.415.2023.12.13.06.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 06:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1Dk+2Wow; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=uST60tem; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D96E4801BAED; Wed, 13 Dec 2023 06:59:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442011AbjLMO72 (ORCPT + 99 others); Wed, 13 Dec 2023 09:59:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1441963AbjLMO71 (ORCPT ); Wed, 13 Dec 2023 09:59:27 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB32393; Wed, 13 Dec 2023 06:59:33 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702479572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=foW+ZiDixud3U2NWD+f47jXaCIGRQEuK1RL8JyJXNEg=; b=1Dk+2WowdGiO+Nc6YoCeRk4MBUkLTmEwK1mTz1+Vnbq0zDiUYn03tPXac7qQ3Z8PrUaVyG uxT+XMkLI7qjPKpo3QtzqODBn4rg1LBdIdXjpQM1Ejr39aCZXJljpnO3YAbGaH7h1qltsZ NpcKEB80J+0EVgBA27u819GQ0quMT3V7rlemWWKFDLjGK/GkW4kKrGeiQueSuqJIkYe4l/ H0aFiiYw6q+mgLU9q4YP6TG/Qo53kW2OgnZASTZCkUTih4lyGcT9tjhJQ8AYhwftuT2AsW OeK2dxLagtBG5LTY6Qvbu2k4rG60jJnJITnVWnBMhbMYVCq44qVU8FNma/Nqng== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702479572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=foW+ZiDixud3U2NWD+f47jXaCIGRQEuK1RL8JyJXNEg=; b=uST60temtwUPk5nrXczqgBP/EwCCDyRB14JgeVhMZ8CGUimz2/EkOl9pnl/fM76Vjxi/ym wmL30e05LKJRA8Dw== To: xiongxin , jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, stable@vger.kernel.org, Riwen Lu , hoan@os.amperecomputing.com, fancer.lancer@gmail.com, linus.walleij@linaro.org, brgl@bgdev.pl, andy@kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] irq: Resolve that mask_irq/unmask_irq may not be called in pairs In-Reply-To: References: <20231207014003.12919-1-xiongxin@kylinos.cn> <87ttosssxd.ffs@tglx> <874jgnqwlo.ffs@tglx> Date: Wed, 13 Dec 2023 15:59:31 +0100 Message-ID: <875y12p2r0.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 06:59:51 -0800 (PST) On Wed, Dec 13 2023 at 10:29, xiongxin wrote: > =E5=9C=A8 2023/12/12 23:17, Thomas Gleixner =E5=86=99=E9=81=93: > Sorry, the previous reply may not have clarified the BUG process. I=20 > re-debugged and confirmed it yesterday. The current BUG execution=20 > sequence is described as follows: It's the sequence how this works and it works correctly. Just because it does not work on your machine it does not mean that this is incorrect and a BUG. You are trying to fix a symptom and thereby violating guarantees of the core code. > That is, there is a time between the 1:handle_level_irq() and=20 > 3:irq_thread_fn() calls for the 2:disable_irq() call to acquire the lock= =20 > and then implement the irq_state_set_disabled() operation. When finally=20 > call irq_thread_fn()->irq_finalize_oneshot(), it cannot enter the=20 > unmask_thread_irq() process. Correct, because the interrupt has been DISABLED in the mean time. > In this case, the gpio irq_chip irq_mask()/irq_unmask() callback pairs=20 > are not called in pairs, so I think this is a BUG, but not necessarily=20 > fixed from the irq core code layer. No. It is _NOT_ a BUG. unmask() is not allowed to be invoked when the interrupt is DISABLED. That's the last time I'm going to tell you that. Only enable_irq() can undo the effect of disable_irq(), period. > Next, when the gpio controller driver calls the suspend/resume process,=20 > it is as follows: > > suspend process: > dwapb_gpio_suspend() > ctx->int_mask =3D dwapb_read(gpio, GPIO_INTMASK); > > resume process: > dwapb_gpio_resume() > dwapb_write(gpio, GPIO_INTMASK, ctx->int_mask); Did you actually look at the sequence I gave you? Suspend: i2c_hid_core_suspend() disable_irq(); <- Marks it disabled and eventually masks it. gpio_irq_suspend() save_registers(); <- Saves masked interrupt Resume: gpio_irq_resume() restore_registers(); <- Restores masked interrupt i2c_hid_core_resume() enable_irq(); <- Unmasks interrupt and removes the disabled marker Have you verified that this order of invocations is what happens on your machine? Thanks, tglx