Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp253867pxu; Tue, 6 Oct 2020 05:45:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoQyG/gkzhfhfJj04YXfXyuMNBqYZNzmcgqbpgxQqBZoLJmD25WLn4ZYtCUEBuxyuZ6gmQ X-Received: by 2002:a17:906:e24c:: with SMTP id gq12mr5248948ejb.359.1601988346168; Tue, 06 Oct 2020 05:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601988346; cv=none; d=google.com; s=arc-20160816; b=dsqlPKywqknWpLfDsNqnb709wv8gRCFVA6sZw8tzgQAxbVFoTruq4uqVueFDxtHRcs 05d5Bhq1/isogeoTNel0QioK5uSpMs7HdBtSOlnY1Mv64pYhSWn8RNiE6e6oudxng2hS OzfnVyqsdkmMTF7ZXMpqdM0ZRJYjDHDvofQ97CUvVkwGkhQRcNBgLj9s8XoY6ncREXaa XgEr6XkuC5/4u52s/6gpVb1Q90XKaCrg85bA7npFm/o0LblNbb0Id7xZJHZNXPhfYVZ1 Y3mDCs+kYFQTprxkMQHdWqoDTJhBbIehO9W+ukGg7sLWEsD9ptrLDqJBHxEe+ZzjDVHF LKqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=vAj9JE4eqj8FhfohvFYZxoqCcBarf5zqltsQxUiI1tk=; b=df/lQiTA6K/hsyybuipHBEbnhKKodJ2UYYXci9AKFxrXY4DnNOyQk+ha2SjFwOamsf U9QAF2AEbclylKjaYC2DlSO6CydcjJlYLeCKjQO26al//0aJa9m3Vp92h4UBFGBlmeE6 x07w+W4EIR52KwzB63E0noJ+EpxV5fhwLyNnEuW7lTc5iIEI7DMKrWvRkPz/kLsDGXTB /PTCsJbTq552I9K6CrldioUGfYmVMdZyJqblcmB6gnVDdICExoZqfUNKSn8YKh9C3/lK YUT++I4XfywqhpsM2qxyrwI0YzFipWKmA9pY7B6kT3RbtYDFbLoNErN+p8bMfPYMzdHe IMyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VhmsWAgN; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si2206511edh.445.2020.10.06.05.45.23; Tue, 06 Oct 2020 05:45:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VhmsWAgN; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgJFMnw (ORCPT + 99 others); Tue, 6 Oct 2020 08:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgJFMnw (ORCPT ); Tue, 6 Oct 2020 08:43:52 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB6A3C061755; Tue, 6 Oct 2020 05:43:51 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1601988230; 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: in-reply-to:in-reply-to:references:references; bh=vAj9JE4eqj8FhfohvFYZxoqCcBarf5zqltsQxUiI1tk=; b=VhmsWAgNyVmBH7+ZdeqYiGj1kqUi6dTRhFBV7hC8xg7Yy6GtMZ9KpR8Hai1TOsSHr0erPg JPlWoQaGMAMRziJhFbs6FGfVBjJMgw7sea/7IJyc7jVAeq6efncgcJihLh73cc9vmYv5HZ WuCgaEO+Dt/bfw25tmlaJNyiqX4eT4E3mnsTSxPVDNhLWD4akM5i691HI444+dlvYSjSwn LmOQZogIdscqsg/gKxEadHv35+EsmcZuS8QhmvltqfwxMrdLYc66c8Lv+iD01P33KVU4IG lTTtzgolBf62iwt114zQV/3I0VO85vfFbFfhSl4Ny821OdLwD9QfWRxE104x/g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1601988230; 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: in-reply-to:in-reply-to:references:references; bh=vAj9JE4eqj8FhfohvFYZxoqCcBarf5zqltsQxUiI1tk=; b=E5M0EBf6SmNEwcbN4HI+3LephINpMn63Ks6D1Mx6WzzMGDnIGpiZs3/dvGpMQRdqQynHwN Ri0QaKPbjpUmUoAQ== To: Ulf Hansson Cc: Jerome Brunet , Kevin Hilman , "open list\:ARM\/Amlogic Meson..." , Linux Kernel Mailing List , "linux-mmc\@vger.kernel.org" , Brad Harper , Sebastian Andrzej Siewior Subject: Re: [PATCH] mmc: meson-gx: remove IRQF_ONESHOT In-Reply-To: <87wo052grp.fsf@nanos.tec.linutronix.de> References: <20201002164915.938217-1-jbrunet@baylibre.com> <87wo052grp.fsf@nanos.tec.linutronix.de> Date: Tue, 06 Oct 2020 14:43:49 +0200 Message-ID: <87v9fn7ce2.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 05 2020 at 10:55, Thomas Gleixner wrote: > On Mon, Oct 05 2020 at 10:22, Ulf Hansson wrote: >> On Fri, 2 Oct 2020 at 18:49, Jerome Brunet wrote: >>> >>> IRQF_ONESHOT was added to this driver to make sure the irq was not enabled >>> again until the thread part of the irq had finished doing its job. >>> >>> Doing so upsets RT because, under RT, the hardirq part of the irq handler >>> is not migrated to a thread if the irq is claimed with IRQF_ONESHOT. >>> In this case, it has been reported to eventually trigger a deadlock with >>> the led subsystem. >>> >>> Preventing RT from doing this migration was certainly not the intent, the >>> description of IRQF_ONESHOT does not really reflect this constraint: >>> >>> > IRQF_ONESHOT - Interrupt is not reenabled after the hardirq handler finished. >>> > Used by threaded interrupts which need to keep the >>> > irq line disabled until the threaded handler has been run. >>> >>> This is exactly what this driver was trying to acheive so I'm still a bit >>> confused whether this is a driver or an RT issue. >>> >>> Anyway, this can be solved driver side by manually disabling the IRQs >>> instead of the relying on the IRQF_ONESHOT. IRQF_ONESHOT may then be removed >>> while still making sure the irq won't trigger until the threaded part of >>> the handler is done. >> >> Thomas, may I have your opinion on this one. >> >> I have no problem to apply $subject patch, but as Jerome also >> highlights above - this kind of makes me wonder if this is an RT >> issue, that perhaps deserves to be solved in a generic way. >> >> What do you think? > > Let me stare at the core code. Something smells fishy. The point is that for threaded interrupts (without a primary handler) the core needs to be told that the interrupt line should be masked until the threaded handler finished. That's what IRQF_ONESHOT is for. For interrupts which have both a primary and a threaded handler that's a different story. The primary handler decides whether the thread should be woken and it decides whether to block further interrupt delivery in the device or keep it enabled. When forced interrupt threading is enabled (even independent of RT) then we have the following cases: 1) Regular device interrupt (primary handler only) The primary handler is replaced with the default 'wake up thread' handler and the original primary handler becomes the threaded handler. This enforces IRQF_ONESHOT so that the interupt line (for level interrupts) stays masked until the thread completed handling. 2) Threaded interrupts Interrupts which have been requested as threaded handler (no primary handler) are not changed obvioulsy 3) Interrupts which have both a primary and a thread handler Here IRQF_ONESHOT decides whether the primary handler will be forced threaded or not. That's a bit unfortunate and ill defined and was not intended to be used that way. We rather should make interrupts which need to have their primary handler in hard interrupt context to set IRQF_NO_THREAD. That should at the same time confirm that the primary handler is RT safe. Let me stare at the core code and the actual usage sites some more. Thanks, tglx