Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1394949lqz; Mon, 1 Apr 2024 05:18:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUesTPq8mxGQcZIPYzo32I1z2cBnqt6A//a248Qw2OfKNH1FYPoYdkeAFiUWKYOw/yU3h5yv3FO5iwOLwKn7HVpm9Nma0S92Xb5zI67HQ== X-Google-Smtp-Source: AGHT+IELk9M/mBkHTrx1LHUdWOZizx1IxUMoA3UNvWxPCrAMYyTIPD0MpZw9OgEqzkG1nH9dV7W1 X-Received: by 2002:a17:906:d28e:b0:a4e:648c:1138 with SMTP id ay14-20020a170906d28e00b00a4e648c1138mr2078533ejb.67.1711973894100; Mon, 01 Apr 2024 05:18:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711973894; cv=pass; d=google.com; s=arc-20160816; b=VyO8ao8AmV43+ssGk47m5KxMqS/zM5qvc3J40tyBtkX6UJrbSr5NozsU6JuLT8fliM VUUsTrSa9fbxR8nw/om5RuX+WCsIn7xQJlrmRcEcU2JGRxIJgfhl0HMYgHVPytqeU6uS Ji9oEIk38aTo1n++ZvnccFrSIYMWBELcFo+woTtk6Fr0HbqmRrgdnGegyM5FCJs2RSUT Avn0GBLXBS5IWztkM8kIZbUZha6oWuwBtGNWjYJIiPffR9RCRz4xntXgk5DXUIYVWinu OBeEcNSkD8ZBZVpk8OrSW4PouAtuJ9HD+PHqajGZ9HvO24B32rdPiK3RwMPK+ecTYX1B nobg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:mail-followup-to :message-id:subject:to:from:date:feedback-id:dkim-signature :dkim-signature; bh=g4lS9ILyqST7PkjkOHUCDq9lcMtSt7QUR+20QTUdfgA=; fh=h91bI99B8QKaxyiKqPOvxiqHbDSPxi0JpRSX3XcjYBM=; b=jwFi4d7szOxJ0lvCRCjc+Koikyupsjd/bnUvYwTsa0eiXMsDCr3UxE/ba613AJwDVV Ty7UdBtQTen+KWLLonyRKcCV1GMaa0Uuq7mgqJQSmXhWb4tRmTQAuvL9bOoC3lpJDdsf tHvqK6Tr1fydGfZbzNwm+NprWK6bLCYXjFwn8op1V0DzrgLU7S0rBFoKNtxON1u/4yS0 GQkEkqKR1TdMPZW/H8W/cJHG5gEk9yL0Tu+LHkUPAX57OEqkAoSzBzLbLWIoUiypgate q4x22udb9kcfmMTFqO9ZdSePe3oIDhl1aULNBcdSiD5E6TzkZpe6/3zVCH5JxPRdxB9o se5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=Si1v+Kuy; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JMfqEmjQ; arc=pass (i=1 spf=pass spfdomain=sakamocchi.jp dkim=pass dkdomain=sakamocchi.jp dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sakamocchi.jp); spf=pass (google.com: domain of linux-kernel+bounces-126643-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126643-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z20-20020a17090655d400b00a44ea0ed34esi4347649ejp.911.2024.04.01.05.18.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 05:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126643-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm2 header.b=Si1v+Kuy; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=JMfqEmjQ; arc=pass (i=1 spf=pass spfdomain=sakamocchi.jp dkim=pass dkdomain=sakamocchi.jp dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=sakamocchi.jp); spf=pass (google.com: domain of linux-kernel+bounces-126643-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126643-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sakamocchi.jp Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 968B81F21054 for ; Mon, 1 Apr 2024 12:18:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BC4D374C2; Mon, 1 Apr 2024 12:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="Si1v+Kuy"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JMfqEmjQ" Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CFB236B00 for ; Mon, 1 Apr 2024 12:18:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711973887; cv=none; b=dSg1ffhND9j0UERLWjnkQOF6/BFOwGq8wbJsH7gzaX1AZRgWk6VRwmO8t/yIa/ho8Nxd6/KAj385cOyucE7AnngtRKu4RhGvPB5yzQT8xCSgNjxtoXVU2NbkTmJM9uqrtItSVox98/TurI9Jq+7B6eCf5QHH9h8N/ZWzdDtWIzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711973887; c=relaxed/simple; bh=MRGP5l1gSutLdKAGgSndTHEiRU6q2J7pxKy0toES4KY=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dCeyvS+gMz+BGK6oWJo8W5Inyp9SXKbNmlpGpxzf2LT5+w9dyiIHJyQWtoMuP4aDRpN8hfPWTkG55etFUfhaNfeYfty/l69ixGMr7AWGmg7hscjP2pJ3FgiHBmcDHw2aMdgJI1pi94iXc3/Zsbij5bJkR3Fa1gWCofc9AMdmC6E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp; spf=pass smtp.mailfrom=sakamocchi.jp; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b=Si1v+Kuy; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JMfqEmjQ; arc=none smtp.client-ip=64.147.123.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sakamocchi.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sakamocchi.jp Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id 16AF83200392; Mon, 1 Apr 2024 08:18:04 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 01 Apr 2024 08:18:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1711973883; x=1712060283; bh=g4lS9ILyqS T7PkjkOHUCDq9lcMtSt7QUR+20QTUdfgA=; b=Si1v+KuyaYPkEx2Zb/r2qzwS2b 91Y0YMIrI+bnud0PdRCUzTq4Ie22Y6lHGMxhuzvTdvva/3q7TNNewsz4+uUgUGJt zEYkS0gDo5i6Awx0ohrJNooIlsFSPsm1RIgWF630flBbq3onQLt0tJ2ZcgWIKTCc UIZyi5itwfPZjcumwI+Sfwgk0B16N7l7PfLhHVAggWePqncCbSreBIBfHeUygCwD Xdr3VvkFgF+9C5/Sc043n4H5ZNBsBqN+kWZhEUVb9ZSKk4VNXMfPB1JEzlkainic LMnlJrWBnelaWrmfobSQF5+M4NT+5QsuiB/Sl6//2bftaNlgVOV2mymDLT0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1711973883; x=1712060283; bh=g4lS9ILyqST7PkjkOHUCDq9lcMtS t7QUR+20QTUdfgA=; b=JMfqEmjQCRWC8DtDwt1eAr15DlEY17yDdiTPDZt09DBP 7XsxY1ukXytv9J9wkb2qcDhjrVhapSbkaGCmaiT35y/s0Zx9CYdOJ9V2y1OanuHu cw1+jPeNYsavLJJeNZeQBttW0dqsLrezP9u+yZL/5MU7TzbEo0/wIiYi1rF4mS8Y PWR8ciIyP2RzlO0sbMgqX9r1WGZa4zQ+GTJYpg6Bq1zqvj8DeUCbmfoX3wHYQj9a R+JzTG0v2ZX05r9GePuZDqRUiZkkNHqSC5qzXC/tHB8am2LuunmHj0FgIXUm/yBP 4wwyAhNQVEy/Gz6NKYbl41wSsVzOAh1hLJVZYW3eKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudeftddghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvrghkrghs hhhiucfurghkrghmohhtohcuoehoqdhtrghkrghshhhisehsrghkrghmohgttghhihdrjh hpqeenucggtffrrghtthgvrhhnpeejgeeifeeuveeufeeigeegjeelvdfgjeegffejgfdv keelhefgtdefteejleekjeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhh ihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Feedback-ID: ie8e14432:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 08:18:02 -0400 (EDT) Date: Mon, 1 Apr 2024 21:18:00 +0900 From: Takashi Sakamoto To: Adam Goldman , linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] firewire: ohci: mask bus reset interrupts between ISR and bottom half Message-ID: <20240401121800.GA220025@workstation.local> Mail-Followup-To: Adam Goldman , linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20240325005828.GB21329@workstation.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240325005828.GB21329@workstation.local> Hi Adam, On Mon, Mar 25, 2024 at 09:58:28AM +0900, Takashi Sakamoto wrote: > Hi, > > On Wed, Mar 20, 2024 at 02:15:19AM -0700, Adam Goldman wrote: > > In the FireWire OHCI interrupt handler, if a bus reset interrupt has > > occurred, mask bus reset interrupts until bus_reset_work has serviced and > > cleared the interrupt. > > > > Normally, we always leave bus reset interrupts masked. We infer the bus > > reset from the self-ID interrupt that happens shortly thereafter. A > > scenario where we unmask bus reset interrupts was introduced in 2008 in > > a007bb857e0b26f5d8b73c2ff90782d9c0972620: If > > OHCI_PARAM_DEBUG_BUSRESETS (8) is set in the debug parameter bitmask, we > > will unmask bus reset interrupts so we can log them. > > > > irq_handler logs the bus reset interrupt. However, we can't clear the bus > > reset event flag in irq_handler, because we won't service the event until > > later. irq_handler exits with the event flag still set. If the > > corresponding interrupt is still unmasked, the first bus reset will > > usually freeze the system due to irq_handler being called again each > > time it exits. This freeze can be reproduced by loading firewire_ohci > > with "modprobe firewire_ohci debug=-1" (to enable all debugging output). > > Apparently there are also some cases where bus_reset_work will get called > > soon enough to clear the event, and operation will continue normally. > > > > This freeze was first reported a few months after a007bb85 was committed, > > but until now it was never fixed. The debug level could safely be set > > to -1 through sysfs after the module was loaded, but this would be > > ineffectual in logging bus reset interrupts since they were only > > unmasked during initialization. > > > > irq_handler will now leave the event flag set but mask bus reset > > interrupts, so irq_handler won't be called again and there will be no > > freeze. If OHCI_PARAM_DEBUG_BUSRESETS is enabled, bus_reset_work will > > unmask the interrupt after servicing the event, so future interrupts > > will be caught as desired. > > > > As a side effect to this change, OHCI_PARAM_DEBUG_BUSRESETS can now be > > enabled through sysfs in addition to during initial module loading. > > However, when enabled through sysfs, logging of bus reset interrupts will > > be effective only starting with the second bus reset, after > > bus_reset_work has executed. > > > > Signed-off-by: Adam Goldman > > --- > > > > --- linux-6.8-rc1.orig/drivers/firewire/ohci.c 2024-01-21 14:11:32.000000000 -0800 > > +++ linux-6.8-rc1/drivers/firewire/ohci.c 2024-03-12 01:15:10.000000000 -0700 > > @@ -2060,6 +2060,8 @@ static void bus_reset_work(struct work_s > > > > ohci->generation = generation; > > reg_write(ohci, OHCI1394_IntEventClear, OHCI1394_busReset); > > + if (param_debug & OHCI_PARAM_DEBUG_BUSRESETS) > > + reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_busReset); > > > > if (ohci->quirks & QUIRK_RESET_PACKET) > > ohci->request_generation = generation; > > @@ -2125,12 +2127,14 @@ static irqreturn_t irq_handler(int irq, > > return IRQ_NONE; > > > > /* > > - * busReset and postedWriteErr must not be cleared yet > > + * busReset and postedWriteErr events must not be cleared yet > > * (OHCI 1.1 clauses 7.2.3.2 and 13.2.8.1) > > */ > > reg_write(ohci, OHCI1394_IntEventClear, > > event & ~(OHCI1394_busReset | OHCI1394_postedWriteErr)); > > log_irqs(ohci, event); > > + if (event & OHCI1394_busReset) > > + reg_write(ohci, OHCI1394_IntMaskClear, OHCI1394_busReset); > > > > if (event & OHCI1394_selfIDComplete) > > queue_work(selfid_workqueue, &ohci->bus_reset_work); > > Thanks for the patch. I pushed topic branch[1] for it, since I'm > considering about whether to send it to stable and longterm releases. > > I had realized that the debug=8 for firewire-ohci module provides tons > of logs triggering by the irq handler, since the irq for bus reset is > not unmasked, so I rely on selfID events when debugging bus-reset. I have > few objections to the change. > > My concern is how much invasive it is. The unmasking is kept until > bus_reset_work() is executed in the workqueue. When considering about > the delay of workqueue (since it is a kind of schedulable task), many > irq events for bus reset is potentially skipped from the logging. Of > course, it is the aim of change. > > Let me take more time to evaluate the change, but I'm willing to send it > to upstream until -rc3 or -rc4, at least, if receiving no objections > from the others. > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git/log/?h=v6.9-firewire-mask-bus-reset-event-during-handling As long as I tested, the patch is enough good to suppress the spurious IRQ event. I'll send it to mainline in this weekend. I sent an additional patch[1] to handle the bus-reset event at the first time. I'd like you to review and test it as well, especially under your environment in which 1394:1995 and 1394a phys exist. [1] https://lore.kernel.org/lkml/20240401121200.220013-1-o-takashi@sakamocchi.jp/ Thanks Takashi Sakamoto