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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBBA5C54E76 for ; Tue, 17 Jan 2023 21:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2HGrDBLKfT9jHoz0wcHUdTUXIhsSVUVgpc+gTfcyqqQ=; b=dYJB/guyzVn8TS 8AGx85hYGulBUg+ALMOeJuAkNCU6SbvKHDR9klK2/XKu8Zca4AmG6InHaKkT72YneYo30S3GyieiC tb5UgkpSok6jM5WAxyp1lkv4VTI05SUk+6ZVgwWl8FPpGthvn5ihJlpuZb8X/F7aRfc+eGjpEgSqM IjMpOhJ/EqmCXFo7hyQJ5yS8Y90el2YsJumrTBneZFxNfSY7a8rvgEJEutWghGC5Q05yRahFKgaCP wNQVji2aMKfTpv3Y/qDZWMsoGVxS68UqLrc0bhpggKcuKBFNuPV6OlVLJvz0etOnaJvWmRJu7XMC+ FgeF39iIdjlcBrOv3Yqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHtgT-00FzRe-EJ; Tue, 17 Jan 2023 21:39:57 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHtgQ-00FzQk-4H for linux-arm-kernel@lists.infradead.org; Tue, 17 Jan 2023 21:39:55 +0000 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673991592; 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=MGlhxDfvMswyv1SvAr4PTIZoEWhp6ukErC3lnvtfzms=; b=WCrx1f1BxleMDIz8u0yeTbWlkiEiKEN122P+7xwcPwRYApnZsKV1L7CNPoYK9myJHRs+Y4 pDyXg+Ki+0F5eGyXxqr9iMuHGNsqAXgYYBNmbh2B47lQQJTBGHsk+ahQKIpx386EeT0UIA UHvdcGsnWrvn4lq605gpRNzK+0UTQzwGFe4lOzBs7fcxIjFnPjFrLuMUu6w+EWSPFjT0K2 omrVWTQ85N3CKAu2PX6dYrQn8R/C8LbwpTqI4OnC18PBbPi6PJP0UCmScHk/5uatomXpiC mnlpFyjwlFt+B41gfzJuveVNkzsAMukT7zWeOtC8AJXTxr3rl8dq0OXR7/5E2g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673991592; 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=MGlhxDfvMswyv1SvAr4PTIZoEWhp6ukErC3lnvtfzms=; b=N6LgIkMUYxa6WRP/QzNw6ztcv7ZBHwqm2zHX/j2/UL0W2IqnlpbLf0d4Yx1U6dZcAdnhk4 yL+zZjZdkX1kfsBg== To: Johan Hovold , Marc Zyngier Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Dmitry Torokhov , Jon Hunter , Hsin-Yi Wang , Mark-PK Tsai Subject: Re: [PATCH v4 09/19] irqdomain: Fix mapping-creation race In-Reply-To: <20230116135044.14998-10-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> <20230116135044.14998-10-johan+linaro@kernel.org> Date: Tue, 17 Jan 2023 22:39:51 +0100 Message-ID: <87sfg8kfh4.ffs@tglx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230117_133954_331421_124AE871 X-CRM114-Status: GOOD ( 15.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jan 16 2023 at 14:50, Johan Hovold wrote: > Parallel probing (e.g. due to asynchronous probing) of devices that share > interrupts can currently result in two mappings for the same hardware > interrupt to be created. This lacks an explanation why this can happen. > @@ -802,6 +811,8 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) > if (WARN_ON(type & ~IRQ_TYPE_SENSE_MASK)) > type &= IRQ_TYPE_SENSE_MASK; > > + mutex_lock(&irq_domain_mutex); > + > /* > * If we've already configured this interrupt, > * don't do it again, or hell will break loose. > @@ -814,7 +825,7 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) > * interrupt number. > */ > if (type == IRQ_TYPE_NONE || type == irq_get_trigger_type(virq)) > - return virq; > + goto out; > > /* > * If the trigger type has not been set yet, then set > @@ -823,36 +834,43 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) > if (irq_get_trigger_type(virq) == IRQ_TYPE_NONE) { > irq_data = irq_get_irq_data(virq); > if (!irq_data) > - return 0; > + goto err; > > irqd_set_trigger_type(irq_data, type); > - return virq; > + goto out; > } > > pr_warn("type mismatch, failed to map hwirq-%lu for %s!\n", > hwirq, of_node_full_name(to_of_node(fwspec->fwnode))); > - return 0; > + goto err; > } > > if (irq_domain_is_hierarchy(domain)) { > - virq = irq_domain_alloc_irqs(domain, 1, NUMA_NO_NODE, fwspec); > + virq = ___irq_domain_alloc_irqs(domain, -1, 1, NUMA_NO_NODE, > + fwspec, false, NULL); > if (virq <= 0) > - return 0; > + goto err; > } else { > /* Create mapping */ > virq = __irq_create_mapping_affinity(domain, hwirq, NULL); > if (!virq) > - return virq; > + goto err; > } > > irq_data = irq_get_irq_data(virq); > if (WARN_ON(!irq_data)) > - return 0; > + goto err; > > /* Store trigger type */ > irqd_set_trigger_type(irq_data, type); > +out: > + mutex_unlock(&irq_domain_mutex); > > return virq; > +err: > + mutex_unlock(&irq_domain_mutex); > + > + return 0; > } > EXPORT_SYMBOL_GPL(irq_create_fwspec_mapping); You can spare that goto churn by renaming the existing function to irq_create_fwspec_mapping_locked() and invoked that guarded by the mutex, no? Thanks, tglx _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel