Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6674943iob; Wed, 11 May 2022 02:55:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaOeKiIMaSdnP5eOf7+bOkG6Um2INylB5Cv6R4jFDyrQXP1iRuoqFLUhugZh0XmxOfuwkV X-Received: by 2002:a05:6402:40ce:b0:427:c926:29fd with SMTP id z14-20020a05640240ce00b00427c92629fdmr27604807edb.7.1652262901498; Wed, 11 May 2022 02:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652262901; cv=none; d=google.com; s=arc-20160816; b=eCfAOmepStoY6EPp/oduZE57b+kvNa+37iqF2oUOgsz1AX7SIQ6sBoPs8viU+N2aVL yeXHhgnZXNiPcNKPg0ix89/a2UyCyoBVb9YhZCRpP8lQjvlMFr6xxZKIYrrKTeppgtSA X6xer+v6/dxPUHYFIuRUY5B9iD46/gVNatl/nNRjiXG5RdXr2WwyaNi+fOHzbQyD8AR8 A53dPWtLz8TAA9HU+wwILf9JJLzYVy1cxCgD5ZGUpvQzDH78ipHCu2p6vInYaKZzWm// xNOtc28id641cezc0IQCK+JlFtS99+PqAQsQk3pmKIztYw4M+yq0iKVBSSeeb5L2yF1y MjEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Fq+oZz2bjF731NGdKZNUr3dzuBaJi/CRJPrMERuJXfs=; b=MomPl04H+9cejWfLcx92TrUm58SDI1hvUx5oH6C1fMcV73pzHp4ARLyPC/HdvHwhNa OQ5oHYGSQ8eiCXjjlnwhozy5zOC7f92jXTI71W0Fz6s0djW31IPvTncr9YNynStkQUZ2 2eLVt0kkB9+He6N9q11R+nMTMmj68/GvZABX0itg/FlYqaA9xvL3Ic7dole6Cyx1HX0I XQRyEDMoHw82FsKNk9qwA+HzhqfyjgB8NlNsB1bSWGakilF8cHVcMONZnxpQ+71F8Enl 68dORCcC1P8kAvh7HH+cG9iI9lkPOi1sBrvBAbXIE2hOhpRTS13Wn/gpD+hWF1W+RdyY VbvA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e21-20020a17090681d500b006df76385ee7si1629325ejx.903.2022.05.11.02.54.36; Wed, 11 May 2022 02:55:01 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243585AbiEKIYJ (ORCPT + 99 others); Wed, 11 May 2022 04:24:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232443AbiEKIYG (ORCPT ); Wed, 11 May 2022 04:24:06 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F141A562D6; Wed, 11 May 2022 01:24:04 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A67FF106F; Wed, 11 May 2022 01:24:04 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.3.187]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A24923F73D; Wed, 11 May 2022 01:24:00 -0700 (PDT) Date: Wed, 11 May 2022 09:23:56 +0100 From: Mark Rutland To: Thomas Gleixner Cc: Lukas Wunner , maz@kernel.org, Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Octavian Purdila , linux-kernel@vger.kernel.org, aou@eecs.berkeley.edu, catalin.marinas@arm.com, deanbo422@gmail.com, green.hu@gmail.com, guoren@kernel.org, jonas@southpole.se, kernelfans@gmail.com, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, nickhu@andestech.com, palmer@dabbelt.com, paul.walmsley@sifive.com, shorne@gmail.com, stefan.kristiansson@saunalahti.fi, tsbogend@alpha.franken.de, vgupta@kernel.org, vladimir.murzin@arm.com, will@kernel.org, Peter Zijlstra Subject: Re: [PATCH v2 17/17] irq: remove handle_domain_{irq,nmi}() Message-ID: References: <20211026092504.27071-1-mark.rutland@arm.com> <20211026092504.27071-18-mark.rutland@arm.com> <20220506203242.GA1855@wunner.de> <20220510121320.GA3020@wunner.de> <87a6bpov9u.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a6bpov9u.ffs@tglx> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, May 11, 2022 at 12:52:29AM +0200, Thomas Gleixner wrote: > On Tue, May 10 2022 at 15:15, Mark Rutland wrote: > > On Tue, May 10, 2022 at 02:13:20PM +0200, Lukas Wunner wrote: > >> For gpio-dln2.c, I believe it from inspection. > >> > >> For smsc95xx.c, I'm actually seeing it go wrong in practice, > >> unedited dmesg splat is included below FWIW. > > > > Thanks; having the trace makes this much easier to analyse. > > which confirmes what I talked about before: > > >> WARNING: CPU: 3 PID: 75 at kernel/irq/irqdesc.c:702 generic_handle_domain_irq+0x88/0x94 > >> generic_handle_domain_irq from smsc95xx_status+0x54/0xb0 > >> smsc95xx_status from intr_complete+0x80/0x84 > >> intr_complete from __usb_hcd_giveback_urb+0xa4/0x12c > >> __usb_hcd_giveback_urb from usb_hcd_giveback_urb+0x118/0x11c > >> usb_hcd_giveback_urb from completion_tasklet_func+0x7c/0xc8 > >> completion_tasklet_func from tasklet_callback+0x20/0x24 > >> tasklet_callback from tasklet_action_common.constprop.0+0x148/0x220 > >> tasklet_action_common.constprop.0 from tasklet_hi_action+0x28/0x30 > >> tasklet_hi_action from __do_softirq+0x154/0x3e8 > >> __do_softirq from __local_bh_enable_ip+0x12c/0x1a8 > >> __local_bh_enable_ip from irq_forced_thread_fn+0x7c/0xac > >> irq_forced_thread_fn from irq_thread+0x16c/0x228 > >> irq_thread from kthread+0x100/0x140 > > So what happens here: > > interrupt > -> wakeup threaded handler > > threaded handler runs > local_bh_disable(); > .... > schedules tasklet > ... > local_bh_enable() > do_softirq() > run_tasklet() > urb_completion() > smsc95xx_status() > generic_handle_domain_irq() > > That interrupt in question is an interrupt, which is not handled by the > primary CPU interrupt chips. It's a synthetic interrupt which is > generated from the received USB packet. > > + /* USB interrupts are received in softirq (tasklet) context. > + * Switch to hardirq context to make genirq code happy. > + */ > + local_irq_save(flags); > + __irq_enter_raw(); > + > if (intdata & INT_ENP_PHY_INT_) > - ; > + generic_handle_domain_irq(pdata->irqdomain, PHY_HWIRQ); > > This __irq_enter_raw() is really wrong. This is _not_ running in hard > interrupt context. Pretending so creates more problems than it > solves. It breaks context tracking, confuses lockdep ... > > We also have demultiplexed interrupts which are nested in a threaded > interrupt handler and share the thread context. No, we are not going to > pretend that they run in hard interrupt context either. > > So we need a clear distinction between interrupts which really happen in > hard interrupt context and those which are synthetic and can be invoked > from pretty much any context. > > Anything else is just a recipe for disaster and endless supply of half > baken hacks. Agreed. IIUC everyone agrees the __irq_enter_raw() usage is a hack, but what's not clear is what we *should* do -- sorry if I'm being thick here. I suspect that given we have generic_handle_irq_safe() for situations like this we should add a generic_handle_domain_irq_safe(), and use that in this driver? That way we can keep the `WARN_ON_ONCE(!in_hardirq())` in generic_handle_domain_irq(). ... or do you think we should do something else entirely? Thanks, Mark.