From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F33EFC56201 for ; Thu, 12 Nov 2020 14:27:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9198E2224A for ; Thu, 12 Nov 2020 14:27:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="gOgejDqq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728346AbgKLO1B (ORCPT ); Thu, 12 Nov 2020 09:27:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:44172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbgKLO1A (ORCPT ); Thu, 12 Nov 2020 09:27:00 -0500 Received: from localhost (230.sub-72-107-127.myvzw.com [72.107.127.230]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B1462065C; Thu, 12 Nov 2020 14:26:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605191219; bh=1IoHlqpsRwY5CT95U1E/+G3sJL3pYss31+rujjdCFjo=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=gOgejDqqkdm78cAdn75U1X8N2FUHKqdLNQVNGnfvP8TpiZoTC4SdxKtAeU/QD+oQ5 8Fa+0o9MxbDmYvXA9/NEcyOX9JmKLwjtbYW60gFwnkjA9iPqtmrXTnrKydmKTrWody ttSKopvLl3XNUk4yDS8LAiQxjDnbiuNZGmv7uRmo= Date: Thu, 12 Nov 2020 08:26:57 -0600 From: Bjorn Helgaas To: Thomas Gleixner Cc: Martin Kaiser , Ley Foon Tan , Lorenzo Pieralisi , Bjorn Helgaas , rfi@lists.rocketboards.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Saenz Julienne , Jingoo Han , Gustavo Pimentel , Toan Le , Florian Fainelli Subject: Re: [PATCH] PCI: altera-msi: Remove irq handler and data in one go Message-ID: <20201112142657.GA1011805@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pn4in0p9.fsf@nanos.tec.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Thu, Nov 12, 2020 at 02:50:42PM +0100, Thomas Gleixner wrote: > On Thu, Nov 12 2020 at 12:28, Thomas Gleixner wrote: > > On Wed, Nov 11 2020 at 16:16, Bjorn Helgaas wrote: > >> On Wed, Nov 11, 2020 at 10:43:55PM +0100, Martin Kaiser wrote: > >> Thomas, it looks like irq_domain_set_info() and msi_domain_ops_init() > >> set the handler itself before setting the handler data: > >> > >> irq_domain_set_info > >> irq_set_chip_and_handler_name(virq, chip, handler, ...) > >> irq_set_handler_data(virq, handler_data) > >> > >> msi_domain_ops_init > >> __irq_set_handler(virq, info->handler, ...) > >> if (info->handler_data) > >> irq_set_handler_data(virq, info->handler_data) > >> > >> That looks at least superficially similar to the race you fixed with > >> 2cf5a03cb29d ("PCI/keystone: Fix race in installing chained IRQ > >> handler"). > >> > >> Should irq_domain_set_info() and msi_domain_ops_init() swap the order, > >> too? > > > > In theory yes. Practically it should not matter because that happens > > during the allocation way before the interrupt can actually fire. I'll > > have a deeper look nevertheless. > > So I had a closer look and the reason why it only matters for the > chained handler case is that > > __irq_set_handler(..., is_chained = true, ...) > > starts up the interrupt immediately. So the order for this _must_ be: > > set_handler_data() -> set_handler() > > For regular interrupts it's really the mapping and allocation code which > does this long before the interrupt is started up. So the ordering does > not matter because the handler can't be reached before the full > setup is finished and the interrupt is actually started up. If the order truly doesn't matter here, maybe it's worth changing it to "set data, set handler" to avoid the need for a closer look to verify correctness and to make it harder to copy and paste to a place where it *does* matter? Bjorn