From patchwork Mon Jan 16 13:50:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202690wrn; Mon, 16 Jan 2023 05:53:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXsumzqr14RLJMrpv34waPGcP816iO8lM1T7CMtAOfpcYwLw/w9w6FLUpT41w9oWQE0nd2NF X-Received: by 2002:aa7:cb51:0:b0:498:8c60:d7d9 with SMTP id w17-20020aa7cb51000000b004988c60d7d9mr28979142edt.12.1673877235662; Mon, 16 Jan 2023 05:53:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877235; cv=none; d=google.com; s=arc-20160816; b=BBxOXA65yNAMiTgd+FSvlUnHYXlqDnW4Mt+yVPKD5E4fB2waHnzAg+lkMIyhteMzxM YK7VE2xlhmK+x0u28KwAIXgg6J9Y1J1iVCEl9T/vhHb4zY7I/epq4ih7aRXqmPlTA/N2 ycjpBML7lQ2I+uUkFXQTHqR6BjllI2vDuOH/8oPK1TjCMfGAJVC8kklRL/e2Lf3hBjiT SniP2wu6QdchNrbIeUjMEhiEpmPuMfi4plUVeS4byFYzEJCctpWDUS3PJwPVeqYTdAU3 Up3cT2Jdw6WuhV8wtTrUY3/mNnM/PnTcmq4xaynn3fUpy/dtDShcusCVduN7o6y6+xq8 he9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V1zQysgpdSLCuvYLh+EosEX3Tiy3cO1wQ56i54jJfhY=; b=H56MQWqF6cEEaOuaJSK2xdBEsaP2YzqwIIgyYke50CqVrgawcE//7fIRGZEmqVi212 XhC6JS5NmsSxMkPm1/LIcVHFPjTMsY6y6qaCbkj9olIlZ9Ir1FjWQcJQMvVIb+bV199R NEn1OO0Wm4hATRxXBZ8OkfTRlPjhcYLgt13lqNEDF27UIRr26Y3JNi2uE3lBY6tHHDcJ coNByWimYiRILDQguLhe2BQeFw8KNR320UFGi3nu+D5leeP4UVu+CiSunWoPekfwV7wH +zMQIlyD2sj3Jnj1MlX+Sy1sCAxZCg8c4NN24ZMu+5WGbhmWULZBCHACByLaJJyzej7G Qalw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZ284EJZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a0564020f0600b0046351fa4ae2si5975003eda.99.2023.01.16.05.53.31; Mon, 16 Jan 2023 05:53:55 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gZ284EJZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbjAPNvQ (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231503AbjAPNuo (ORCPT ); Mon, 16 Jan 2023 08:50:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46AA22197B; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DE726B80F1A; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80150C433EF; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=heMSyTjPVavJ2Aad43hH/VAIkwpBj4Ge9/GVRzLpwHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gZ284EJZSZP2qsSjGnp5CKWQdPPkhVemAo44H1WSr+Yvra3KkzKEtNsKeqhRGpEa0 QkAZ2Xd9foHia2QJ8jv33WVY8EnvFYUniKtytP4BeqHlXcjcDs1DNTXLNHZUkSednx jkfsz8/1w9GUyQHGBwjZ6v3bIsqGmeWHHhivSjPrt3jzHAaqW0x5zBFU/lqy25fVyZ Z139nsEmuiK/ALPdUMVly8F0A/ruO0sZlsiJaPr67DsELzlAjGSZQYoMM6opNjGiyf sSyg4daW0Bhy+kQE2mM3vtGgM4xk8N0Jvh29ilFqRoOuLE6Yt+OxzanmFc1+PCXtZA 8fEcOGZOv8ukg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt5-0003uk-IO; Mon, 16 Jan 2023 14:50:59 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 01/19] irqdomain: Drop bogus fwspec-mapping error handling Date: Mon, 16 Jan 2023 14:50:26 +0100 Message-Id: <20230116135044.14998-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187496184662114?= X-GMAIL-MSGID: =?utf-8?q?1755187496184662114?= In case a newly allocated IRQ ever ends up not having any associated struct irq_data it would not even be possible to dispose the mapping. Replace the bogus disposal with a WARN_ON(). Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 8fe1da9614ee..bf67de1733ee 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -833,13 +833,8 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) } irq_data = irq_get_irq_data(virq); - if (!irq_data) { - if (irq_domain_is_hierarchy(domain)) - irq_domain_free_irqs(virq, 1); - else - irq_dispose_mapping(virq); + if (WARN_ON(!irq_data)) return 0; - } /* Store trigger type */ irqd_set_trigger_type(irq_data, type); From patchwork Mon Jan 16 13:50:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203134wrn; Mon, 16 Jan 2023 05:55:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXv35ewGFnsof4wPFiK1Qkqi4EUtdFmZ2G06DIKtadfX3vRlVlt0JeL0dGA4qAGPUvkYSXbM X-Received: by 2002:a17:907:8b11:b0:870:29fd:be41 with SMTP id sz17-20020a1709078b1100b0087029fdbe41mr5084594ejc.48.1673877312509; Mon, 16 Jan 2023 05:55:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877312; cv=none; d=google.com; s=arc-20160816; b=eO/2O5WxGbOYGzEDbEIj7HaS2miQAix2Mr5XXQCQ++URWbmeQF+w8HCOrMsYs171fr c0m16ZIfPCIGX3ACRsaOvJQElhb1J3lEt6UHkh7oLUvzqrdlC0XddL7AU64PgzSEdMXN cDBV/HUNg8DT6EF3LPMvIk68prq/LR3UBa1+7/wcsnPXO8wYRusRiTVrjC79qnGmSs3R zD2FzOsWHwmuZWTg1U2ftqSo31KmVOmP8+CEymMqrIkQgWCiIgJ3qLNCqla6X3ajKSbs uJB8L56pVjNlj2u+71RizMHUu6ZQ7EtQ7SlXPN7IPbdqxCfT2AyLFNmFsWragvNae/kA g1HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uBzIROytno0EkmK45RvRfOcNpx++3uMiCZX72HZ1GrQ=; b=pvtj+sz7DXUvky9kcpvIdJNobuujnkXGX7rhsSTyBkt5MMY+MiEfGiVU8WcRAIzTEN 4K6LLZE8Tea9x+kWYhrQ/QMTzSUNaRpUbyEVeHZRjr7W1gZHcYWS/4/GBZyqGjg0eC3C w4JTzfSgCoKcyvVNW9jh2LBsL0Q/F0qbxNHH8clGvMHk8eZCZxmirt76q1wxBzIYy9ou VKAnyQ22oypKPbQlW2yYSqvS5tEyKrf8O4WmTFC0jXHkM3sjxdlHM8Wvsjab8hNFVPTI huArjb4ArhzsUoYGj1vtsgN6k/gi/hBnVUQiIbLrhqPbDx+OrHLvWNUqOPepcmqlYSO1 ufMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S7gB9oP1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xc2-20020a170907074200b00780636887fesi181277ejb.797.2023.01.16.05.54.48; Mon, 16 Jan 2023 05:55:12 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=S7gB9oP1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231509AbjAPNuz (ORCPT + 99 others); Mon, 16 Jan 2023 08:50:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbjAPNun (ORCPT ); Mon, 16 Jan 2023 08:50:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 864272006B; Mon, 16 Jan 2023 05:50:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 25D1360F95; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F8F2C433D2; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=WOLEYv/LC2uRo2oOqpCuxx1j2Jg09eJ+FL+Ym0vCxkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S7gB9oP1nlNtzHy6VDK5Mbnw+MZRfv/CQ8NrAx76e1s+PSpferOR5tbrxFiNltPDM q/SPDI4AS+XNO2gPWB3FhMzrH8Qu+BYh1uFsbEJgepXZSN+bZJlj2yenpb/jMPjwYu 6N8WmfT35dhIpIjYZ4KL8rRz9IcYi5B48B/6tIKHfji6F7lJgEKWKDn602u09PaPwf usbjHvcXLR4HR2KAPJs5YFSc4CMLZo6HPRiPb5wyhRSRJRmYiMPyMMaXWGdrN2KJ1I ZRUdzuf11uKMNvgetNjirHXPM4Qv6ZgYhEZ8Fzi1zCbadCy/xsieBkDWhoc6OARX+P 23K36jP0fbovA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt5-0003um-Ku; Mon, 16 Jan 2023 14:50:59 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 02/19] irqdomain: Drop dead domain-name assignment Date: Mon, 16 Jan 2023 14:50:27 +0100 Message-Id: <20230116135044.14998-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187576393839910?= X-GMAIL-MSGID: =?utf-8?q?1755187576393839910?= Since commit d59f6617eef0 ("genirq: Allow fwnode to carry name information only") an IRQ domain is always given a name during allocation (e.g. used for the debugfs entry). Drop the leftover name assignment when allocating the first IRQ. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index bf67de1733ee..fe9ec53fe7aa 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -593,10 +593,6 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, mutex_unlock(&irq_domain_mutex); return ret; } - - /* If not already assigned, give the domain the chip's name */ - if (!domain->name && irq_data->chip) - domain->name = irq_data->chip->name; } domain->mapcount++; @@ -1118,10 +1114,6 @@ static void irq_domain_insert_irq(int virq) domain->mapcount++; irq_domain_set_mapping(domain, data->hwirq, data); - - /* If not already assigned, give the domain the chip's name */ - if (!domain->name && data->chip) - domain->name = data->chip->name; } irq_clear_status_flags(virq, IRQ_NOREQUEST); From patchwork Mon Jan 16 13:50:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202627wrn; Mon, 16 Jan 2023 05:53:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvSH87t4xTChu6cTLLI551geYKtBYyZ77FzyhWzWGTHu6w3Q7KQHzOmHDbvtlECTZK1ZGy6 X-Received: by 2002:a17:906:824f:b0:820:4046:1586 with SMTP id f15-20020a170906824f00b0082040461586mr11602092ejx.12.1673877224385; Mon, 16 Jan 2023 05:53:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877224; cv=none; d=google.com; s=arc-20160816; b=uB2nHo8Fz7rUTXkCawYKhltaKm1ujmpgygHwbP1zAfmV9H05KH/1umm5dPaSHHeEdK SfmQJqJjWE9DdUFoEs7ZkvBLvQbGYQJlk1Emy3q3ioU7Jm3w+VRG2OLNNyP9P8pcZrrL wFWqFJ0iHnMxFLR2zDTD5MZbdCcehbuuoMyDVVNS6cdg15wiPejvd5Uc81GIWQTZ5JKT XNBvzJ6JyLjdr9i0GQ8+4u+Pma+9oHV5cNmgZv7laDtZM7x6zYpt4kG1OYDLxx8oz/V5 IAAz59zdtiEwp2rG+N96gpV1FzEQfEkLrmTuYAfnFdd6TVJPaVHfSOmVWCLXqzy+w+Gd cz2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mYbAzJXrxfAZnjaIWvIzsJ1n+rVah/cW/98c2lAE80Y=; b=y0FzpPA1WNoQlcyjU1K8iHs4v831EomiEz09cN8GgMrwO71mM45q/971TuzDijoWx4 nk8RXAmnrzh2yQErRe0EuS5FVyNAaUXeJa0Fj/gMeHqfib7vydn/iwGzwRFqpLskYQuf vEylZamHpGheAF0YipQGvZNAVG+Jlb892XOhp3VGO3+lHKa7fKiJ4SSUIl9x+omeGeq7 cVHev7pMBhRVsWL4NH/nOTgiSl0K2kskkPL5WdheuyPIwL1Ujqo9Hcidsn1EESWzFuuX DXg93/55+qtKcOHZeYlrnv8YAjYagg3pp3US1r29P1+c5/IzkxxvwU9dSfXujeelJUl9 R7Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MCQANLu5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn3-20020a1709070d0300b008546dd18d16si22743643ejc.51.2023.01.16.05.53.20; Mon, 16 Jan 2023 05:53:44 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MCQANLu5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbjAPNvD (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbjAPNun (ORCPT ); Mon, 16 Jan 2023 08:50:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A315A21974; Mon, 16 Jan 2023 05:50:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3C52860FC7; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C0A8C433F2; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=Oycgtjbj5Je/2GUULN931D+KpOMY5u4TF17SbiYzKnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MCQANLu5lUMIayX0woy6ZFaEDn1mFl7y9QyW1Zksz0ZsxxCzmLeChINV4ZcbsucPs Ukk1k03scIziJ1c+gqy9tkrjFAUh7QAS6YvpS0PHxe/wB4Lo4n/KVWVMYFrDGpgidr K/IxXlyPsyZJfS3JkiaeZnph0OIyrsfZbzb3a5p4I2xG2P2HW0uBgDPGjCpmu0vLnu Ibkye6ETKn8m5wN89rbhv5Ptq9gKhoUwYjayNOOcgoIE/H/a/4l85/PVIql8WytZu3 lEjQAkBxlXxZguotXXTPBUeLOaVnjx/3sMD/kN6APt40RaILS+IdfeXQ3pMmJrnToK hxvtjSydPg1oA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt5-0003uo-NM; Mon, 16 Jan 2023 14:50:59 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 03/19] irqdomain: Drop leftover brackets Date: Mon, 16 Jan 2023 14:50:28 +0100 Message-Id: <20230116135044.14998-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187484244537617?= X-GMAIL-MSGID: =?utf-8?q?1755187484244537617?= Drop some unnecessary brackets that were left in place when the corresponding code was updated. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index fe9ec53fe7aa..dfd60bd49109 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -219,9 +219,8 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s domain->host_data = host_data; domain->hwirq_max = hwirq_max; - if (direct_max) { + if (direct_max) domain->flags |= IRQ_DOMAIN_FLAG_NO_MAP; - } domain->revmap_size = size; @@ -615,9 +614,8 @@ void irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base, pr_debug("%s(%s, irqbase=%i, hwbase=%i, count=%i)\n", __func__, of_node_full_name(of_node), irq_base, (int)hwirq_base, count); - for (i = 0; i < count; i++) { + for (i = 0; i < count; i++) irq_domain_associate(domain, irq_base + i, hwirq_base + i); - } } EXPORT_SYMBOL_GPL(irq_domain_associate_many); From patchwork Mon Jan 16 13:50:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44168 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203184wrn; Mon, 16 Jan 2023 05:55:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXvm9Kh4NnoKUkPlZnzfcp1wjFzSF0HRlpYYDFdatRU8T74HFPQEx0qA3j9Tl6nZ1GxNj5Yi X-Received: by 2002:a17:907:1316:b0:863:e08e:2ac3 with SMTP id vj22-20020a170907131600b00863e08e2ac3mr11331925ejb.63.1673877323169; Mon, 16 Jan 2023 05:55:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877323; cv=none; d=google.com; s=arc-20160816; b=bDh+PDJGaao4EBwHczPfiMGf/9RalLnGwlQUFd04b16Z0ENpis38gchZ1wasfbdd5H WMsbFS/rXnsJK6oqaNSJkSlJ9BNqKIVJ9iwKtUxXdvcYitzMUAPKpPoPKzaii3gMUfNV dtYXkhUR3SkP/OJo0TKSD2xmA3ss4qM+aDLi+TdP90ziMeQTs5rW7H9bz2S0N83E9uL2 hieQ3QSKbcg7iOgFnSoF6F47X+Bu7dEpxlOsGxTGHkHXrG9MW17MvUBqL4oM48zq0ge+ osvIX9VY7xkq0ZBWDcVqajQsSsnm/6mWalaBhQW3fkCUG6oL+vx1epenVa4UZnAdkEqY 6P8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4HhbBTJ/7ktfAg+IIgIwDczQOzDd5EpoFDj3t071iJk=; b=OlhAKd//KfH0c7AoItk7j4kyXZYJ0bKykQXx87OWYreO65h353gNjVO1UA8CqY2Pv1 loIa4OMXV3ZCrwO2YpjUJSg/I5Vr2ZL78KIzke3TsheUdqLz/fklBuUj3q+OQfO4NUcl jmwFAayMMCfdqMiNM4Pj3SyGdpRUIA6XslyjvgsmOVOq/SpBlFMwPS3/Si8HkhqweSNc xFEOM/teLl/vUrAbmhQxahdWBNX2IhSIT27cJCuFPNFKdfW1L49HlmpbqEVAeZCbvZ6B i6xMGWDQRLEnDdKpTcsKneyy1ERpWX+xQbWe+8LDbwM58ek2fN1rK/YCT/eB3aAPWfKz 0lGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fbViRa0D; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa31-20020a170907869f00b0086ffd881d1esi4967033ejc.290.2023.01.16.05.54.59; Mon, 16 Jan 2023 05:55:23 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fbViRa0D; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231431AbjAPNvA (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbjAPNun (ORCPT ); Mon, 16 Jan 2023 08:50:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2951421970; Mon, 16 Jan 2023 05:50:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B7D2B60FD1; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97BC7C43398; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=J9DOyi4U5wMa0WhON2OLMaU73RLt5W1A5vcDhDcrvxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fbViRa0DmWJ5ahdcpXurCQDjfkGK425ybWw3sSGBJ1zmY/AG6Uk+eytmfgMM6YL0q 4778CvnjzZcU/tQgx2balKxXO0I2NNzjn1WjyrI9GibUMu2reduMD9qco27qUyW1QC FM12dJP2KMoqElMTqBARlqNW5Z5MFHMHoX050RFywMQJMg79korNDYINV0vPNlh5wj a2k2iiglX359OHBOFv22+4oAQ5P8DVuM0OctnpDRlhIY7PhtfCVNHOScO2VVJXEt4m AHBS81XrkNrIn5q+7kqZwmL/RvG4WSireyHrUfOhtje/ZdxDxswRH4xFFmwOekHjd+ t9JFUNNOCZ0+w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt5-0003ur-QJ; Mon, 16 Jan 2023 14:50:59 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 04/19] irqdomain: Fix association race Date: Mon, 16 Jan 2023 14:50:29 +0100 Message-Id: <20230116135044.14998-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187588072292557?= X-GMAIL-MSGID: =?utf-8?q?1755187588072292557?= The sanity check for an already mapped virq was done outside of the irq_domain_mutex-protected section which meant that an (unlikely) racing association may not be detected. Fix this by factoring out the association implementation, which will also be used in follow-on changes to rework the locking. Fixes: ddaf144c61da ("irqdomain: Refactor irq_domain_associate_many()") Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index dfd60bd49109..b2087f55a1ac 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -558,8 +558,8 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) irq_domain_clear_mapping(domain, hwirq); } -int irq_domain_associate(struct irq_domain *domain, unsigned int virq, - irq_hw_number_t hwirq) +static int __irq_domain_associate(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq) { struct irq_data *irq_data = irq_get_irq_data(virq); int ret; @@ -572,7 +572,6 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, if (WARN(irq_data->domain, "error: virq%i is already associated", virq)) return -EINVAL; - mutex_lock(&irq_domain_mutex); irq_data->hwirq = hwirq; irq_data->domain = domain; if (domain->ops->map) { @@ -589,19 +588,29 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, } irq_data->domain = NULL; irq_data->hwirq = 0; - mutex_unlock(&irq_domain_mutex); return ret; } } domain->mapcount++; irq_domain_set_mapping(domain, hwirq, irq_data); - mutex_unlock(&irq_domain_mutex); irq_clear_status_flags(virq, IRQ_NOREQUEST); return 0; } + +int irq_domain_associate(struct irq_domain *domain, unsigned int virq, + irq_hw_number_t hwirq) +{ + int ret; + + mutex_lock(&irq_domain_mutex); + ret = __irq_domain_associate(domain, virq, hwirq); + mutex_unlock(&irq_domain_mutex); + + return ret; +} EXPORT_SYMBOL_GPL(irq_domain_associate); void irq_domain_associate_many(struct irq_domain *domain, unsigned int irq_base, From patchwork Mon Jan 16 13:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202823wrn; Mon, 16 Jan 2023 05:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXscaltLwnerweq0I1Wh637WueWb5v5mRhyd76OH+aRDNxyzpOyhjBw3H0QKAqhj6C5t8yOz X-Received: by 2002:aa7:c948:0:b0:48e:9afd:de66 with SMTP id h8-20020aa7c948000000b0048e9afdde66mr43711318edt.34.1673877257751; Mon, 16 Jan 2023 05:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877257; cv=none; d=google.com; s=arc-20160816; b=wqm612rv/4dy+bEMrKrCtFOlP/BIBNiEK1cBHq4VFl9JsStqM0tZr3gQyvpgoXmxPd DVyO02cPr2GCo2nWQ+If5dPBJziVBkCXrJ8X0539hvXcGHsevz1N6mPLmo0yTeqYC1vC QGPDgDPMAl3vKppmgoy31Nc2WIZxxHl5WJAtZ4tmlzwJCdPpwdB/VWWspF2O/SQFcW1i 99O+qgcU1626Dc/J9qSpf5vxxCD6f2TA9taLPVtDNiUvb4UB5RqBlnCY7XyPNewgwkfd aIgUpkYZpC6eQi9DbmwxO3fK5UlBKHTsE3ESsWQewemQfJKgkI3DD5++bRfuEt2JMnN5 4QNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2vcHyr1phmd57wwm8e5NaCmouuM8PHGr3Xmsu98rCJc=; b=AX4qSziH4GfN9AaMRdGS2xiWZe014HlCDNPJxUhAodk5VK7KJ2bmHvnc9dZ5xB9JgE Q8u44hU+uiGaxq9ZUYJMznyW6liqE6k/LqoaGLbnkKYJjYlyK3BQdCikvIpy4CZ8u+BU tSNqQZF72AU55ADgwy0N02a5bXwXRl8BNVz3NS9LhTTiVtdEdsk2VHLHW5H683ESGErq 5KQ0RMj4mkc5C5Cl3kSo3WhMLDBFUDAMkt7VdGDniuxcj+3MO2MOifE32thKHso0exk8 1vFGJqdZcKP5oTeaDstKq2hsq+VpvdueYe7mw546zMQIIMRBOASFwf3F5rJppsmC51w3 D7og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjndJlSR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be12-20020a1709070a4c00b007c087110276si7332523ejc.151.2023.01.16.05.53.53; Mon, 16 Jan 2023 05:54:17 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PjndJlSR; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231691AbjAPNvZ (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjAPNup (ORCPT ); Mon, 16 Jan 2023 08:50:45 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 202B321972; Mon, 16 Jan 2023 05:50:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 86905CE1161; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87F39C433F1; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=8NK6cMAg/Gp7SlI9n2MjOR/D97yEutmk49eysprJ2C4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjndJlSRpc1AnDOK4A7FI2Z6RWqNy6J9qyKZmOdPvNenH5WFdsKvUMZHDUCeh9/kS PA0jeJtbIeypY/8vQqex1EAw5WbNKZVhUmQmEePAm5WC17QIPH/4GBs6i4K3ps/L6P XgiFidY+Yg+6FafT2Dd2v8IxrjaH6zzHRqpBZSoSXLA5fDMeRg4jvk+EPUVze3MbqE OUu4iInoSzrbZYCsOXa/I0y0M4Pmds7Vj+8lwmUDrTpAhEUueX9lRvcOvNwdiEuhy1 SHvHTZKc5iDS0sGAqx68AmQXRRj6ZHMJnxoltE5upKUY0IRk0g/Kn1YseplcgiXfvB hyIZp2C4lxgcg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt5-0003uu-TT; Mon, 16 Jan 2023 14:50:59 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 05/19] irqdomain: Fix disassociation race Date: Mon, 16 Jan 2023 14:50:30 +0100 Message-Id: <20230116135044.14998-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187519784989090?= X-GMAIL-MSGID: =?utf-8?q?1755187519784989090?= The global irq_domain_mutex is held when mapping interrupts from non-hierarchical domains but currently not when disposing them. This specifically means that updates of the domain mapcount is racy (currently only used for statistics in debugfs). Make sure to hold the global irq_domain_mutex also when disposing mappings from non-hierarchical domains. Fixes: 9dc6be3d4193 ("genirq/irqdomain: Add map counter") Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index b2087f55a1ac..23f5919e58b7 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -537,6 +537,9 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) return; hwirq = irq_data->hwirq; + + mutex_lock(&irq_domain_mutex); + irq_set_status_flags(irq, IRQ_NOREQUEST); /* remove chip and handler */ @@ -556,6 +559,8 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) /* Clear reverse map for this hwirq */ irq_domain_clear_mapping(domain, hwirq); + + mutex_unlock(&irq_domain_mutex); } static int __irq_domain_associate(struct irq_domain *domain, unsigned int virq, From patchwork Mon Jan 16 13:50:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202577wrn; Mon, 16 Jan 2023 05:53:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXtRf8eQgJJuKDuz+/I4jL9RyH6X4c3t9jyK41Jo/iY3KXbe1FtZ1wfzDlq9NK/b8a8qvsHS X-Received: by 2002:a17:906:6dce:b0:7c3:e3ef:bca1 with SMTP id j14-20020a1709066dce00b007c3e3efbca1mr77236521ejt.60.1673877217175; Mon, 16 Jan 2023 05:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877217; cv=none; d=google.com; s=arc-20160816; b=Fr1FCfdbhJYjYw+KKBq24R7iXh3m9DFr9fGsSerjzTslYkxg/ap42ia64pnabQkX/B xR6TFL1o2NvbRBJOSZQUDsnjmKt85j9FTMDdct7eyi0+knCj1q+qhgOFdgRQ0DefIexp 5sIq1JyqRuVnd0D1vZ69CkX5kK3DmNdzXHbbigz8DaasqjJb3BqTpLGyJm7Sw/7cjoNq i42/SPPWQ62CR+DGXjMMASNS5y6OPtOwjY0s3QdwAMb5OUOQWFzoVg3L2IEyvRu4yBpF G6GoewawaQ0c6e9riZmTGeMCIkv6OtYwtNR057f04Y5qKGn1p1AMorNECPDHDtsDm1T6 T3yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rOQcjiJysgkAnLhPnpeszLDm///LM3zPVgI/U0Cn9hE=; b=U/xEAVc0OfcmoJAhWtjNtcIxMq5eQczDVclN4CkJxjcwa6JlW+imJCe8zHHB9nDAP7 9vzZ2MqtsAl39oJWEu8SSpNce4AOSXAQt0BoqJGlsD5xPqka/73rHxyg/9zBxK2BZj3S Uqzk1RC66WlHvFApCcRNucx+jOMWPvl3/qBES52hMk+3yqSAYBKJg/IJGUGRIKJPLhTJ Q7t41ZjKUWazicBHa1K9Xo+YOJNgliAPItfnJk3QUEjixSZN/KOKVL1gmIbUUidir7XO olduDsYT/UTh1pq2Jk9g0E8lVYLncxWdV0COxmnuZFuTaj5/lr4f6DGIN6/al0TfODhM soyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GZdwS8bA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw18-20020a170906479200b008641d4f0500si16820801ejc.301.2023.01.16.05.53.13; Mon, 16 Jan 2023 05:53:37 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GZdwS8bA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231628AbjAPNvI (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231436AbjAPNun (ORCPT ); Mon, 16 Jan 2023 08:50:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20C2421945; Mon, 16 Jan 2023 05:50:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B28DE60FC6; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9767DC43392; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=Sc/MXrEwZaxI4omzYCVHgWpM1c0Ozs8INEgkW+Kkfxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GZdwS8bAvdzWN/C6v/U15xmHvbQMQMJusVQTi9CqJfflW/jPFbn3aYdXTST2GS1hv ChWtwzHM9Mo6bKs2CLsEmdTjFdL/zEumhE3mzEhXtRCRsHvoeixjPySaA7MX0P6B55 Vhw9Kbo3g3EM6g0/QTjGYHErVQuIgXI6FpFpnntNtkCY56NtR4870LolZ9+RXwI0eW KjvIpJ5o/R9jTF1Dlw9S97JdX8yEZqI9ZaszR6vU9qk3jNFuBgQn5xOBl18KH7oGFb x0ft+UcfE6D4hkXHV3EOcU2UDR0XlFd/EaW6NVQItAnk0l2yIvJmHlMp8mS8jkV/Ya 5tidaNTVroP+Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt5-0003ux-Vi; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 06/19] irqdomain: Drop revmap mutex Date: Mon, 16 Jan 2023 14:50:31 +0100 Message-Id: <20230116135044.14998-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187476938496771?= X-GMAIL-MSGID: =?utf-8?q?1755187476938496771?= The global irq_domain_mutex is now held in all paths that update the revmap structures so there is no longer any need for the revmap mutex. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- include/linux/irqdomain.h | 2 -- kernel/irq/irqdomain.c | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 5b2718e1c6de..7fd3939328c2 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -143,7 +143,6 @@ struct irq_domain_chip_generic; * Revmap data, used internally by the irq domain code: * @revmap_size: Size of the linear map table @revmap[] * @revmap_tree: Radix map tree for hwirqs that don't fit in the linear map - * @revmap_mutex: Lock for the revmap * @revmap: Linear table of irq_data pointers */ struct irq_domain { @@ -171,7 +170,6 @@ struct irq_domain { irq_hw_number_t hwirq_max; unsigned int revmap_size; struct radix_tree_root revmap_tree; - struct mutex revmap_mutex; struct irq_data __rcu *revmap[]; }; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 23f5919e58b7..248e6acfafbe 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -214,7 +214,6 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s /* Fill structure */ INIT_RADIX_TREE(&domain->revmap_tree, GFP_KERNEL); - mutex_init(&domain->revmap_mutex); domain->ops = ops; domain->host_data = host_data; domain->hwirq_max = hwirq_max; @@ -501,30 +500,30 @@ static bool irq_domain_is_nomap(struct irq_domain *domain) static void irq_domain_clear_mapping(struct irq_domain *domain, irq_hw_number_t hwirq) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], NULL); else radix_tree_delete(&domain->revmap_tree, hwirq); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_set_mapping(struct irq_domain *domain, irq_hw_number_t hwirq, struct irq_data *irq_data) { + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(domain)) return; - mutex_lock(&domain->revmap_mutex); if (hwirq < domain->revmap_size) rcu_assign_pointer(domain->revmap[hwirq], irq_data); else radix_tree_insert(&domain->revmap_tree, hwirq, irq_data); - mutex_unlock(&domain->revmap_mutex); } static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) @@ -1511,11 +1510,12 @@ static void irq_domain_fix_revmap(struct irq_data *d) { void __rcu **slot; + lockdep_assert_held(&irq_domain_mutex); + if (irq_domain_is_nomap(d->domain)) return; /* Fix up the revmap. */ - mutex_lock(&d->domain->revmap_mutex); if (d->hwirq < d->domain->revmap_size) { /* Not using radix tree */ rcu_assign_pointer(d->domain->revmap[d->hwirq], d); @@ -1524,7 +1524,6 @@ static void irq_domain_fix_revmap(struct irq_data *d) if (slot) radix_tree_replace_slot(&d->domain->revmap_tree, slot, d); } - mutex_unlock(&d->domain->revmap_mutex); } /** From patchwork Mon Jan 16 13:50:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203294wrn; Mon, 16 Jan 2023 05:55:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvu1evLm1aWZKd62SJevH/OY7LhDTY8V0vRfbA1tjKpjHTFZdlp/Xjb48sfA5zwYw1wsrR1 X-Received: by 2002:a17:907:ca1d:b0:84d:4e77:6453 with SMTP id uk29-20020a170907ca1d00b0084d4e776453mr25802910ejc.38.1673877344494; Mon, 16 Jan 2023 05:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877344; cv=none; d=google.com; s=arc-20160816; b=pQFdN79CyVaDSQ7lxc1qVIaua/ZaXT//5HCvZW/Bt6l94HZBS3OQ2NmvzbhZrQtStl iMzU3gcXROgAWflL5ChK1X3IumrwgwJBhetcS8hHLSakVxTgmqDs4WLBg+OmTXaeRV0x 60o57rWlCyTzZDbGYwNtG1RInZjaaYo6/2WJOetG30xs9k5AIxadT0dtqJGqCYd/w27I PjOifVJ12NKiA5NnlqteIV3hbSZ2WNxT52usks7c6Vh/JoNbnXqr1MAgm0Y9Maremjwr moKkRZgzZ6yN6DA5PI7riPHeJ39gjzY/P0ZbSmD/0Te1P3GQ8WM6O8prtMmwpT9cyhYR 5H/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rJ0LngDnW2ldwPRHMknnNLUKCBzAlYm+/2EYbVFuC9g=; b=VnCRAtGsRqVQo6MLSiKhzSOqNd02Ko5+UA7/4QJj5vKwEHfl1lBckBRf3y/a9YGPu8 kwb6Jk09awxeKfFjc7uftDzY0lyymFqnNl01xdDYa7dY3phhIH9k2o98BrQk6Z4Ockky TaqPbMshVurX5ZY0xAbzbU+dLEvTUYbtED2/gi3/1u3TR3tD4V+76MvmuPteM1EzgDWB IbEG6AAG/WzJaBVv2HVFWZnZT9BuOBHbCXBrK0Z/pOU0mpiJgpmJe/gRpuFXt6NfUrN+ 7vwPYj+ZXq/LtvQVeIp9D4/UD6L452FA9oSFczYXUfmAg/Pap2ONJkQ0iQp/YXZcFAqX LMYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BB0S7c4B; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn9-20020a1709070d0900b007aed5ffeffbsi19338ejc.78.2023.01.16.05.55.20; Mon, 16 Jan 2023 05:55:44 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BB0S7c4B; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbjAPNvx (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbjAPNus (ORCPT ); Mon, 16 Jan 2023 08:50:48 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E614921978; Mon, 16 Jan 2023 05:50:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 23001CE1160; Mon, 16 Jan 2023 13:50:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B222CC43443; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=Acjdl6EsE3kWgNQwaT/lwb4EHyPJAJutY4r47DlwrFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BB0S7c4BKL1c+LF0TaXpdKTSrjvooPYOjJm0vy/8m09ELpwfW7NKgSjsDwyPf/Hw3 dB3BEcM91ZjUP9YJnVH5D9RzauAPtNR6RA5CZ7li7aOjYIVvTXFTI8FliJMHwUhhff GjDl3La0NWWatzVsJ5HTevYlnNejKrntWFC6bzCauSEDdtjCRhBcSSooALqfpJXnK0 1xpeVOJma5cocRvBG4hSnvDt/UbB+79iLPjDNoeNpdM+Vypa6+Ic7W1nLP0f1nxi4O Zr22yZn1Sdv2NHf5YodowtqMo+CFs5nDCLmbnAIewozKbOuj2Pwq+53QmTGfWAUZeh Z+jWl5XejhwEg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003v0-2e; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 07/19] irqdomain: Look for existing mapping only once Date: Mon, 16 Jan 2023 14:50:32 +0100 Message-Id: <20230116135044.14998-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187610251910814?= X-GMAIL-MSGID: =?utf-8?q?1755187610251910814?= Avoid looking for an existing mapping twice when creating a new mapping using irq_create_fwspec_mapping() by factoring out the actual allocation which is shared with irq_create_mapping_affinity(). Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 60 +++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 248e6acfafbe..894bc6ee6348 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -675,6 +675,34 @@ unsigned int irq_create_direct_mapping(struct irq_domain *domain) EXPORT_SYMBOL_GPL(irq_create_direct_mapping); #endif +static unsigned int __irq_create_mapping_affinity(struct irq_domain *domain, + irq_hw_number_t hwirq, + const struct irq_affinity_desc *affinity) +{ + struct device_node *of_node = irq_domain_get_of_node(domain); + int virq; + + pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); + + /* Allocate a virtual interrupt number */ + virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), + affinity); + if (virq <= 0) { + pr_debug("-> virq allocation failed\n"); + return 0; + } + + if (irq_domain_associate(domain, virq, hwirq)) { + irq_free_desc(virq); + return 0; + } + + pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", + hwirq, of_node_full_name(of_node), virq); + + return virq; +} + /** * irq_create_mapping_affinity() - Map a hardware interrupt into linux irq space * @domain: domain owning this hardware interrupt or NULL for default domain @@ -687,14 +715,11 @@ EXPORT_SYMBOL_GPL(irq_create_direct_mapping); * on the number returned from that call. */ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, - irq_hw_number_t hwirq, - const struct irq_affinity_desc *affinity) + irq_hw_number_t hwirq, + const struct irq_affinity_desc *affinity) { - struct device_node *of_node; int virq; - pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq); - /* Look for default domain if necessary */ if (domain == NULL) domain = irq_default_domain; @@ -702,34 +727,15 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, WARN(1, "%s(, %lx) called with NULL domain\n", __func__, hwirq); return 0; } - pr_debug("-> using domain @%p\n", domain); - - of_node = irq_domain_get_of_node(domain); /* Check if mapping already exists */ virq = irq_find_mapping(domain, hwirq); if (virq) { - pr_debug("-> existing mapping on virq %d\n", virq); + pr_debug("existing mapping on virq %d\n", virq); return virq; } - /* Allocate a virtual interrupt number */ - virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node), - affinity); - if (virq <= 0) { - pr_debug("-> virq allocation failed\n"); - return 0; - } - - if (irq_domain_associate(domain, virq, hwirq)) { - irq_free_desc(virq); - return 0; - } - - pr_debug("irq %lu on domain %s mapped to virtual irq %u\n", - hwirq, of_node_full_name(of_node), virq); - - return virq; + return __irq_create_mapping_affinity(domain, hwirq, affinity); } EXPORT_SYMBOL_GPL(irq_create_mapping_affinity); @@ -834,7 +840,7 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) return 0; } else { /* Create mapping */ - virq = irq_create_mapping(domain, hwirq); + virq = __irq_create_mapping_affinity(domain, hwirq, NULL); if (!virq) return virq; } From patchwork Mon Jan 16 13:50:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44174 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203514wrn; Mon, 16 Jan 2023 05:56:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXsKj9d0+uS5k7ye90XBkCQke5ryY70CWmGe5Ih6YyfVoVlHfDli3IfsdFUxn8QKY72VGNAy X-Received: by 2002:a17:906:3687:b0:86b:914a:571 with SMTP id a7-20020a170906368700b0086b914a0571mr10481192ejc.5.1673877379686; Mon, 16 Jan 2023 05:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877379; cv=none; d=google.com; s=arc-20160816; b=w2QkvOeYiRudCDBi2C4W1+1PZhSNRbx41sD7tG+DHTmZgGaMH1LkHlWIduMF2zotRM JrR39k96jlJQKU6876XH4KQXLPf2jfnr5wtR1kmdVyuJLqvnA/azj+bbEqWFgPF3ktF4 G7KXznHaeCcZEZn8pU2JW29B4OMrwtAYDxeAqzalzRyqJQzzGxtsvWt3A46D+J4OAz5q Ca1S9MHZEClHfW8KIiD4SwKgV09dwM6xSTSj6eaWMROXDeL5V/vD0d3k+470PYWFUYPy aXOy8JOyIuv12mZZ2mN+j6eo4IflMypgELT/ECGTTelKY89zDzhe4v5NJfafGJ9TEdLb CgOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9s8Oq+snk5E2j5zXCKZbvrfIicmMz3lBjArUyISMClE=; b=Kv3SVMd1HF5z8zZ75H0R5cNwUfD8oC8NmWMZxHJBDI/gmV/mvii2vj08j02UGK0Yhr mq2KKhzYSmceKm+5IbPcLCGB2JhdzuwMTp3F0wkbCXqKQgHp10k4yIBHCXwdwLWTUWQP I8NWMzdaiyfx+wIBksfaY41Sa00/EAPnMX4hhzGupcoOkX91UrIt1Y91cS1ybhIU2Ony jWHVn3ADnX4Ea8FVJF1UkG4eQrDlny3wIpQnPtnhmYeRRS0iufEQQ63y0XkCVS5VQ0V5 hiV54cgE7HU0ifj6eAmK9K6zNRjmSoz1dhMCZA10T/mG+M5efVp9F98Qvbd6WorbH+Vn oHzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rb49y6Id; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p34-20020a056402502200b004772b115406si6182124eda.560.2023.01.16.05.55.55; Mon, 16 Jan 2023 05:56:19 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rb49y6Id; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbjAPNwR (ORCPT + 99 others); Mon, 16 Jan 2023 08:52:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231485AbjAPNup (ORCPT ); Mon, 16 Jan 2023 08:50:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6B9021A11; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 99F8BB80F63; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2182C433AC; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877040; bh=2HmrqiLpP1fOhlVzV0RQxKQijAGZZDfEPgi6MiK1HtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rb49y6Id656NJswA3g3hDHkdteg7bL4SCzIxmjys0Ojd5lL4Iib9e89bCTIBEZEu1 VQP3QBxa1T13af8bvR6y6KSWJjjM4MlH/cPuK+wDmMvZQbr7A95livMwIn3cJ7Ecl+ 6iFRTf7k9Ed9zeGGUhErfscwq9yd9SeCMniw3xTv/69Tg3s6Nx8o833O7x7zKfwFJR q7x8V4WHSUtJPNqm2frdkyhln3VQ4VbOms0zTzUTpp2Ektmml0X6lfjEANQyolFGNn 8NiMbEx9k+ef51pofcWr8FMZAW0+KiPpdtgNqEgVacX8CU2/ps0r3+rIWIh817+Hth 1tCiSeIBlzXYw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003v4-5a; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 08/19] irqdomain: Refactor __irq_domain_alloc_irqs() Date: Mon, 16 Jan 2023 14:50:33 +0100 Message-Id: <20230116135044.14998-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187647383770235?= X-GMAIL-MSGID: =?utf-8?q?1755187647383770235?= Refactor __irq_domain_alloc_irqs() so that it can be called internally while holding the irq_domain_mutex. This will be used to fix a shared-interrupt mapping race. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 88 +++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 894bc6ee6348..d6139b0218d4 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1430,40 +1430,12 @@ int irq_domain_alloc_irqs_hierarchy(struct irq_domain *domain, return domain->ops->alloc(domain, irq_base, nr_irqs, arg); } -/** - * __irq_domain_alloc_irqs - Allocate IRQs from domain - * @domain: domain to allocate from - * @irq_base: allocate specified IRQ number if irq_base >= 0 - * @nr_irqs: number of IRQs to allocate - * @node: NUMA node id for memory allocation - * @arg: domain specific argument - * @realloc: IRQ descriptors have already been allocated if true - * @affinity: Optional irq affinity mask for multiqueue devices - * - * Allocate IRQ numbers and initialized all data structures to support - * hierarchy IRQ domains. - * Parameter @realloc is mainly to support legacy IRQs. - * Returns error code or allocated IRQ number - * - * The whole process to setup an IRQ has been split into two steps. - * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ - * descriptor and required hardware resources. The second step, - * irq_domain_activate_irq(), is to program the hardware with preallocated - * resources. In this way, it's easier to rollback when failing to - * allocate resources. - */ -int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, - unsigned int nr_irqs, int node, void *arg, - bool realloc, const struct irq_affinity_desc *affinity) +static int ___irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity) { int i, ret, virq; - if (domain == NULL) { - domain = irq_default_domain; - if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) - return -EINVAL; - } - if (realloc && irq_base >= 0) { virq = irq_base; } else { @@ -1482,24 +1454,18 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, goto out_free_desc; } - mutex_lock(&irq_domain_mutex); ret = irq_domain_alloc_irqs_hierarchy(domain, virq, nr_irqs, arg); - if (ret < 0) { - mutex_unlock(&irq_domain_mutex); + if (ret < 0) goto out_free_irq_data; - } for (i = 0; i < nr_irqs; i++) { ret = irq_domain_trim_hierarchy(virq + i); - if (ret) { - mutex_unlock(&irq_domain_mutex); + if (ret) goto out_free_irq_data; - } } - + for (i = 0; i < nr_irqs; i++) irq_domain_insert_irq(virq + i); - mutex_unlock(&irq_domain_mutex); return virq; @@ -1509,6 +1475,48 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, irq_free_descs(virq, nr_irqs); return ret; } + +/** + * __irq_domain_alloc_irqs - Allocate IRQs from domain + * @domain: domain to allocate from + * @irq_base: allocate specified IRQ number if irq_base >= 0 + * @nr_irqs: number of IRQs to allocate + * @node: NUMA node id for memory allocation + * @arg: domain specific argument + * @realloc: IRQ descriptors have already been allocated if true + * @affinity: Optional irq affinity mask for multiqueue devices + * + * Allocate IRQ numbers and initialized all data structures to support + * hierarchy IRQ domains. + * Parameter @realloc is mainly to support legacy IRQs. + * Returns error code or allocated IRQ number + * + * The whole process to setup an IRQ has been split into two steps. + * The first step, __irq_domain_alloc_irqs(), is to allocate IRQ + * descriptor and required hardware resources. The second step, + * irq_domain_activate_irq(), is to program the hardware with preallocated + * resources. In this way, it's easier to rollback when failing to + * allocate resources. + */ +int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity) +{ + int ret; + + if (domain == NULL) { + domain = irq_default_domain; + if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) + return -EINVAL; + } + + mutex_lock(&irq_domain_mutex); + ret = ___irq_domain_alloc_irqs(domain, irq_base, nr_irqs, node, arg, + realloc, affinity); + mutex_unlock(&irq_domain_mutex); + + return ret; +} EXPORT_SYMBOL_GPL(__irq_domain_alloc_irqs); /* The irq_data was moved, fix the revmap to refer to the new location */ From patchwork Mon Jan 16 13:50:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202679wrn; Mon, 16 Jan 2023 05:53:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXtPvZLXbNtZ3rEc520oZkXCEUxbbIcW6ke7i2wt6Bz1UV20+EsJ1ofCXsSy5PqFXLwbns2n X-Received: by 2002:aa7:da0e:0:b0:49b:58ca:ebbc with SMTP id r14-20020aa7da0e000000b0049b58caebbcmr15350143eds.32.1673877232892; Mon, 16 Jan 2023 05:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877232; cv=none; d=google.com; s=arc-20160816; b=rDyiR+vSpt8pFbM7BGhtJ1A/KV4ulLOGW7mvRPt1qQaZWdPJF6TVN/+XYBcrQoyOBd binkZB/UkQOLPoTe8hhfMKNK4YmlM7uKXKFi96o+Gf507Z8L3W5o/o5ARGPKonVc8aXw px1Z1zDROPRow5nZj/IxRcUxRIedkhTccxEVS7xUx4Z6Gr/fwQ4pUEdASQnUH8loUSyE A82SfqJI6/BcNd+YZE5Ivm4JMv/VA2g0uVHUug6vKO0mPoVqXm+t04kfLU+3vdkkEwU8 mIrJeNXMDSjnD99nyhpZvA3+BoQYfRigro8Yn/1j9Gok7LZBV2TSYIZBElFGwanJ/Khm 5wFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HqWOqjdIVVggfeCcWhyYDFAtfCvoLxTAWvb+cGJDSjs=; b=H1PB62UpXPHODi596AGni8XQ/Y5g8A5RATO1KoAnWqvu7mDVIxJiuULOfrsDO/attd ynCTNogiftuwiriDjCZGvc0y5GqbtaG8uGtHNtsv9FZ9tmwGo+OUX5Cxhv5sEZuxgMP6 pHbUBtBbtVdg1AuKqgK2m4sVkwNzEq/amHFHrspAKxkjrKNpkLCQCRZp675D9fo6B0Xg mlfLzrXs+39DCD2rQgx2tgg1U3hnBEXeJB0UIl2Dcy9RNPdSZe63dvg+2nlS9fDKp0ic HyuCeeZieJAbBNx7NDQMMyx3PZ5wudwE/pN2UiHGGlvEEH7JobIv1qgdgq1nLdB5krtq jpWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oHJeGsTp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y8-20020a056402270800b0048b0ae570f5si6507493edd.501.2023.01.16.05.53.29; Mon, 16 Jan 2023 05:53:52 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oHJeGsTp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231365AbjAPNvM (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbjAPNuo (ORCPT ); Mon, 16 Jan 2023 08:50:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B19021975; Mon, 16 Jan 2023 05:50:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E02EF60FD6; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9645C4331F; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=Ed9Fo75L6ODXzYIZPiGa6hb552YmgO5piG8B7r50/yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHJeGsTpZjhbR8hEi5QwXNAqOZR7SX4mbwM0MegmglOAFViFKlHO7+P0mOBR9ijVP Qr2PmQzKtW9SNjIPeuT1QlM9GFfgPB8iy/vA+QO4zP0Gf/jAnOP7R+4A9jZRnBKOQW WJt4KmINgYXw099WPC30vb0ngHszo+rXTXj/XEMkzEBzF4HHQ8nVk2DDJWx5Hfcgld 1BWWaYmEOee3IFpGN8M1Ttu+qLw2o/xdtuwaRqv5Rjjnpdx7e4w+0U238u5XzrHrQe mKVx0j6LLmUEl60g66ts1hzQUpEFIOeRtXm32y7aL98EJVC+vnTN6YLV/8Kn8HrFCn QqeQpIEBDfzGw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003v7-8t; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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: [PATCH v4 09/19] irqdomain: Fix mapping-creation race Date: Mon, 16 Jan 2023 14:50:34 +0100 Message-Id: <20230116135044.14998-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187493243052203?= X-GMAIL-MSGID: =?utf-8?q?1755187493243052203?= 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. Make sure to hold the irq_domain_mutex when creating mappings so that looking for an existing mapping before creating a new one is done atomically. Fixes: 765230b5f084 ("driver-core: add asynchronous probing support for drivers") Fixes: b62b2cf5759b ("irqdomain: Fix handling of type settings for existing mappings") Link: https://lore.kernel.org/r/YuJXMHoT4ijUxnRb@hovoldconsulting.com Cc: Dmitry Torokhov Cc: Jon Hunter Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 47 ++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index d6139b0218d4..7232947eee3e 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -25,6 +25,9 @@ static DEFINE_MUTEX(irq_domain_mutex); static struct irq_domain *irq_default_domain; +static int ___irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity); static void irq_domain_check_hierarchy(struct irq_domain *domain); struct irqchip_fwid { @@ -692,7 +695,7 @@ static unsigned int __irq_create_mapping_affinity(struct irq_domain *domain, return 0; } - if (irq_domain_associate(domain, virq, hwirq)) { + if (__irq_domain_associate(domain, virq, hwirq)) { irq_free_desc(virq); return 0; } @@ -728,14 +731,20 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, return 0; } + mutex_lock(&irq_domain_mutex); + /* Check if mapping already exists */ virq = irq_find_mapping(domain, hwirq); if (virq) { pr_debug("existing mapping on virq %d\n", virq); - return virq; + goto out; } - return __irq_create_mapping_affinity(domain, hwirq, affinity); + virq = __irq_create_mapping_affinity(domain, hwirq, affinity); +out: + mutex_unlock(&irq_domain_mutex); + + return virq; } EXPORT_SYMBOL_GPL(irq_create_mapping_affinity); @@ -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); @@ -1877,6 +1895,13 @@ void irq_domain_set_info(struct irq_domain *domain, unsigned int virq, irq_set_handler_data(virq, handler_data); } +static int ___irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, + unsigned int nr_irqs, int node, void *arg, + bool realloc, const struct irq_affinity_desc *affinity) +{ + return -EINVAL; +} + static void irq_domain_check_hierarchy(struct irq_domain *domain) { } From patchwork Mon Jan 16 13:50:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44172 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203340wrn; Mon, 16 Jan 2023 05:55:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXtj8TPrmm8SKaiyDDzdEjozqrL/DtyqAmlriPs8xaTXS2aIrUY82pkY905y0yVDumfgKypm X-Received: by 2002:aa7:c1c6:0:b0:49e:210a:65f3 with SMTP id d6-20020aa7c1c6000000b0049e210a65f3mr1609917edp.0.1673877350287; Mon, 16 Jan 2023 05:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877350; cv=none; d=google.com; s=arc-20160816; b=KA5tq7loeFoljXrYmRhB50/4XEGxGxvsRMTK1csweRcmgRKuyRBBOlHSINwLa7uoyQ HGFnhQy353atuiPRPoe7L7yCZyBYHwe949CPTqVH2dPEnJmFtlg85lutO4LpWb/x2BXG BSY5dLyqmw+lyFKXNRY5RaJCBO48EUwzjvDWL+12+DzAH8XkmsDhwBU/dZ669B2aJgMB bWHH4eosL30Bk/bqqGwfMpEn4iEHuNxYBiqY30SrGY6g+GC+B5KcJfsM1CCCtg/rbaPe HqkMUfAB98m6z8NNeb4m6RN2Jc40sKP6rs07RBhW+nIHNZ40Nrde8bZcwqX+c8AcIigN wr7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+0J1Z3wZi9XQ004F8pQojU9aGYUGH8T3gq09tLidKYs=; b=EUtY9oarUAH+iMDSxj/3fZrI0MqIsmKuMuxgIzexJsw43RAzVDD6dQDOZjxuInzdYE dKArIOrMCRFUtlNh+BJYfvX6gTVlB+SNXSj7ornl1uBEHwcULfcVUKG+ncSGqxS/xLBh 3j3V5/3z4dkVasbaHHE1jaaeEcyINKGDOvYTjl1ywdDw+KsvyVpVIDCmeGjSroji6bnd 2J9Bdfhr+gSujtir9QLT8QGduVe2Q6Ft04+fI6WKjcgDiOqKqMtZf75kd2GYxXC+qVM/ JxRIXrGpudTcbGYgE/DM38O1RHkUYdsFe5TkY++ws8z5OreHmWPekQD/P+kasBbTNlut Xh0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pJd1R8RZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a056402518d00b0049e184870a4si3254081edd.286.2023.01.16.05.55.26; Mon, 16 Jan 2023 05:55:50 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pJd1R8RZ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230151AbjAPNwW (ORCPT + 99 others); Mon, 16 Jan 2023 08:52:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231483AbjAPNuo (ORCPT ); Mon, 16 Jan 2023 08:50:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52D3121A0B; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E721860FD7; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF0FDC43327; Mon, 16 Jan 2023 13:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=slBlVmKKVxqS1O4HHOigyS/8bTSWQiItHYPLEGcLTcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pJd1R8RZ22PoYyJifHmA3Qyg04TRQkkwg2rMoVTwmCTyo2JYgb+wjXmvpMXI6LKmp 8QPvyr18NqkhfWcDkBEAXzV5ubCPgzvqE92L/hLlCPFj+vA7xyLySbNdFu55QQoM0A dPuThfItC/7+mjGViTvnvMiPYZsS13BKRrrG1B5a4i+h7PPb7i4vw775G9IY3kf+P2 m7KzhpcF+Ro+ClGx+574wnX9lcu8w2vXy88b92XRLd/tdsmFpA0gXHot55GY0inQu1 ttUl2/uY643dpBoOLfSfaZ+z/d/NfF+klcuEjnJD4eotkAmjbUTt0ANWrNARs2HIfW TVHVqSAePmJhQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003vA-C5; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 10/19] irqdomain: Clean up irq_domain_push/pop_irq() Date: Mon, 16 Jan 2023 14:50:35 +0100 Message-Id: <20230116135044.14998-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187616063919126?= X-GMAIL-MSGID: =?utf-8?q?1755187616063919126?= The irq_domain_push_irq() interface is used to add a new (outmost) level to a hierarchical domain after IRQs have been allocated. Possibly due to differing mental images of hierarchical domains, the names used for the irq_data variables make these functions much harder to understand than what they need to be. Rename the struct irq_data pointer to the data embedded in the descriptor as simply 'irq_data' and refer to the data allocated by this interface as 'parent_irq_data' so that the names reflect how hierarchical domains are implemented. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- kernel/irq/irqdomain.c | 65 +++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 7232947eee3e..6f2b8a1248e1 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1571,8 +1571,8 @@ static void irq_domain_fix_revmap(struct irq_data *d) */ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) { - struct irq_data *child_irq_data; - struct irq_data *root_irq_data = irq_get_irq_data(virq); + struct irq_data *irq_data = irq_get_irq_data(virq); + struct irq_data *parent_irq_data; struct irq_desc *desc; int rv = 0; @@ -1597,45 +1597,44 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) if (WARN_ON(!irq_domain_is_hierarchy(domain))) return -EINVAL; - if (!root_irq_data) + if (!irq_data) return -EINVAL; - if (domain->parent != root_irq_data->domain) + if (domain->parent != irq_data->domain) return -EINVAL; - child_irq_data = kzalloc_node(sizeof(*child_irq_data), GFP_KERNEL, - irq_data_get_node(root_irq_data)); - if (!child_irq_data) + parent_irq_data = kzalloc_node(sizeof(*parent_irq_data), GFP_KERNEL, + irq_data_get_node(irq_data)); + if (!parent_irq_data) return -ENOMEM; mutex_lock(&irq_domain_mutex); /* Copy the original irq_data. */ - *child_irq_data = *root_irq_data; + *parent_irq_data = *irq_data; /* - * Overwrite the root_irq_data, which is embedded in struct - * irq_desc, with values for this domain. + * Overwrite the irq_data, which is embedded in struct irq_desc, with + * values for this domain. */ - root_irq_data->parent_data = child_irq_data; - root_irq_data->domain = domain; - root_irq_data->mask = 0; - root_irq_data->hwirq = 0; - root_irq_data->chip = NULL; - root_irq_data->chip_data = NULL; + irq_data->parent_data = parent_irq_data; + irq_data->domain = domain; + irq_data->mask = 0; + irq_data->hwirq = 0; + irq_data->chip = NULL; + irq_data->chip_data = NULL; /* May (probably does) set hwirq, chip, etc. */ rv = irq_domain_alloc_irqs_hierarchy(domain, virq, 1, arg); if (rv) { /* Restore the original irq_data. */ - *root_irq_data = *child_irq_data; - kfree(child_irq_data); + *irq_data = *parent_irq_data; + kfree(parent_irq_data); goto error; } - irq_domain_fix_revmap(child_irq_data); - irq_domain_set_mapping(domain, root_irq_data->hwirq, root_irq_data); - + irq_domain_fix_revmap(parent_irq_data); + irq_domain_set_mapping(domain, irq_data->hwirq, irq_data); error: mutex_unlock(&irq_domain_mutex); @@ -1653,8 +1652,8 @@ EXPORT_SYMBOL_GPL(irq_domain_push_irq); */ int irq_domain_pop_irq(struct irq_domain *domain, int virq) { - struct irq_data *root_irq_data = irq_get_irq_data(virq); - struct irq_data *child_irq_data; + struct irq_data *irq_data = irq_get_irq_data(virq); + struct irq_data *parent_irq_data; struct irq_data *tmp_irq_data; struct irq_desc *desc; @@ -1676,37 +1675,37 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) if (domain == NULL) return -EINVAL; - if (!root_irq_data) + if (!irq_data) return -EINVAL; tmp_irq_data = irq_domain_get_irq_data(domain, virq); /* We can only "pop" if this domain is at the top of the list */ - if (WARN_ON(root_irq_data != tmp_irq_data)) + if (WARN_ON(irq_data != tmp_irq_data)) return -EINVAL; - if (WARN_ON(root_irq_data->domain != domain)) + if (WARN_ON(irq_data->domain != domain)) return -EINVAL; - child_irq_data = root_irq_data->parent_data; - if (WARN_ON(!child_irq_data)) + parent_irq_data = irq_data->parent_data; + if (WARN_ON(!parent_irq_data)) return -EINVAL; mutex_lock(&irq_domain_mutex); - root_irq_data->parent_data = NULL; + irq_data->parent_data = NULL; - irq_domain_clear_mapping(domain, root_irq_data->hwirq); + irq_domain_clear_mapping(domain, irq_data->hwirq); irq_domain_free_irqs_hierarchy(domain, virq, 1); /* Restore the original irq_data. */ - *root_irq_data = *child_irq_data; + *irq_data = *parent_irq_data; - irq_domain_fix_revmap(root_irq_data); + irq_domain_fix_revmap(irq_data); mutex_unlock(&irq_domain_mutex); - kfree(child_irq_data); + kfree(parent_irq_data); return 0; } From patchwork Mon Jan 16 13:50:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44171 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203316wrn; Mon, 16 Jan 2023 05:55:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWOtKSqZWJctvQbPYnwqV0khAKH69dVlgDFICAQYAlUAB6HUrGH0FvGKT5GuZEygYfSAPW X-Received: by 2002:a17:906:f193:b0:84d:3403:f4f4 with SMTP id gs19-20020a170906f19300b0084d3403f4f4mr28162744ejb.64.1673877345993; Mon, 16 Jan 2023 05:55:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877345; cv=none; d=google.com; s=arc-20160816; b=byLt9A86O85OvjYFUwsBxNkkubSKEWy74IBq70dJIN00IjcIcq6229Ga54plmzG5Sq x/2fihYKD7ecbibo5MNeCEOCGCHc3NqEaHveOqljcylnEDbbD+tCSbUx6foADDSvSSnd lq0aS8W4u2HjW0nItx/vsGaOW28PdL3nJMeWX415WdXD2uTQTTTckIkOeTvyczqR3NL7 bLsIdbykzCWJIkid2h0Nx+xEkd3dMb2jm+N9TboGwIbpznUp6AEh38nHmO03db7PM4hM p6YaM7RBjM/d+B1vJDM8Ij9SvD6rrp9B/rSUS1VvSNPQP4R7tAn9kWDClL1Vg26z3Wmw eWwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Z/ClsNfBkg2pSEDo7D9Er5UKAfTbNSwg5ZQMlU+k9zw=; b=SQ05b95C5q0nchJk338VCLE6sX5DCT+UGecPBfsTzuyxTEfWetXnqHafWnvdO1LWx8 BBf1yrGUxG4EW2ZEr55YbYmBYdAjnulNCmnEKcF17vq1UNiwNfxg9OIFo0XSZPyMbQHO lgwl/r5D2XGHCCmI/oemVeBaGazms5we5o+lF7kpuWqexOcH5sMVwvVoBy1suRtZFUlh zG9pxaEJq+XFkD0iIOJ69TJlEb+wWk5L5+wvBLvL5MkYiBFLim/E9w9nnDX/pfwInWBT pr9ANlouW6axIeE2smqnEOZEC8zkF36a04UM6TFF88/zAHygis+sdgChlFUNX1KsdLeN L4qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iTchXNWY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt2-20020a170907728200b00871dfbabf34si675249ejc.282.2023.01.16.05.55.21; Mon, 16 Jan 2023 05:55:45 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iTchXNWY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229712AbjAPNwH (ORCPT + 99 others); Mon, 16 Jan 2023 08:52:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbjAPNuq (ORCPT ); Mon, 16 Jan 2023 08:50:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CF8B21966; Mon, 16 Jan 2023 05:50:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1FC13B80F97; Mon, 16 Jan 2023 13:50:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B838C43329; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=AK3VCepyLTeOpIFmxwgh5xFJYCJU4/85AqeI5PyR5Sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iTchXNWY+z/sxVHLzD4M9BdaWIAa7SmM3hr6/+6zJyYYXMI2sIrT+/r0hUfT89Npw LaH72M9fgR+oYmIuQYQuQwisq5c4J9r6sQb9RHYhYz+XZaDa1ZLerMd8v1fGI7tOv0 qx6WvR9CvBoci06yw9LLcxtLas/vfUw40VTU6YJ1pdAtvCGQHgp78iMFaxV/YLB1bb Mq4sDq3xphF15PvtMC6HwRHussdS4e6ZR1WgWMgI+qhvgFPg+l1zljkLT1b9p1TLEB f7/83DUqXVmnFnGpQTOIuWQAKR4vDmnB6ezPxzKbPx0AShuc5s8fM5nP1atvhZ8d/d Z0KqzFzrSbEVw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003vD-FM; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 11/19] x86/ioapic: Use irq_domain_create_hierarchy() Date: Mon, 16 Jan 2023 14:50:36 +0100 Message-Id: <20230116135044.14998-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187612169717872?= X-GMAIL-MSGID: =?utf-8?q?1755187612169717872?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- arch/x86/kernel/apic/io_apic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index a868b76cd3d4..9cc4c8e0c3c4 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2364,9 +2364,9 @@ static int mp_irqdomain_create(int ioapic) return -ENODEV; } - ip->irqdomain = irq_domain_create_linear(fn, hwirqs, cfg->ops, - (void *)(long)ioapic); - + ip->irqdomain = irq_domain_create_hierarchy(parent, 0, hwirqs, fn, + cfg->ops, + (void *)(long)ioapic); if (!ip->irqdomain) { /* Release fw handle if it was allocated above */ if (!cfg->dev) @@ -2374,8 +2374,6 @@ static int mp_irqdomain_create(int ioapic) return -ENOMEM; } - ip->irqdomain->parent = parent; - if (cfg->type == IOAPIC_DOMAIN_LEGACY || cfg->type == IOAPIC_DOMAIN_STRICT) ioapic_dynirq_base = max(ioapic_dynirq_base, From patchwork Mon Jan 16 13:50:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44173 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203341wrn; Mon, 16 Jan 2023 05:55:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/aeyyI7QHcGwYyC30SazU9MWgkFg7Ov4KMz4Sz9kYd6Q0g5LJdqMgQ4U6B1IGH6/Y190P X-Received: by 2002:a17:906:944a:b0:7c1:23f2:5b51 with SMTP id z10-20020a170906944a00b007c123f25b51mr11262410ejx.60.1673877350636; Mon, 16 Jan 2023 05:55:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877350; cv=none; d=google.com; s=arc-20160816; b=e2CPeWmJkBo1CbZsMZ5BHhS2shI/d6NIrk3pr8ff6X53w31xw+/SulCmhvGETH6HlR aw8tOjcThdb2YeFH7UZycYhJE0RN3eFT9A2PNqC4DHS5hD8G1oPhw9uBM1tOQxH82Noh oSsm+PQGN1ipo945vd4jeEOLuQOY/VjXKDFnmnJJ++dTqqn6M9ymdDbtW7ugf5dAOdqv vODC7O+fsSdi3wOv6oyHlBSQHREAT44wQShSAF/Yfwmuop3u5OvmN+hU95rooKfS3pZg sOja9SmwaDTcgxy3EoIm6COllVetmx3E/87xbDqdnagI/OtN5KfhNZShCWIRBpf5amgR K6vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sieMFWFq/Se918JBZ5c7BiZBor/2TycoG4dfxt5ArqQ=; b=RspE2ZBfrXFbfXv1mTI/GvSHQM3k9meIhLiaElwZ3BgPInVEm6sXsHzKBZQf3GPSfN Md0pR4nJEO8d6RiK54jiwX9pSDFDpE/wanO8aC8ZvaVlkSK3RC2glRCrrQKoLG2XLlMz ejvoq4GLSRzwLfUJFWHCYnzEorDWUCgzTbv82pXrr/gCNKjV+F4c2kZzzjkpCa1q32fa 8r4ofTtbSKZWBfIDPfq5I9lzQ/F9x+e1+K42KBIj5R/QiIcqt5UWdMg4Bu0tX0NbR5Eu VDhKZ6jZb/ChYgsUxecDlQxX/G1kXhLDaPOwSDPNJH+lJPFQN48Miiu2RL9lC4tdI8dR XSUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="I/MJ4XiE"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vj10-20020a170907d48a00b00870d2ca6b6asi2637830ejc.100.2023.01.16.05.55.26; Mon, 16 Jan 2023 05:55:50 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="I/MJ4XiE"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229701AbjAPNwZ (ORCPT + 99 others); Mon, 16 Jan 2023 08:52:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231458AbjAPNuo (ORCPT ); Mon, 16 Jan 2023 08:50:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5263E2197E; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1A52260FDB; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21CF4C43330; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=ggk54ncazk/OvpoVopO401NRPXtbra5OsVaBMxjoHtE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/MJ4XiEWMNX1n/mFVQna8r9fFJUYXORoumXe4znvqaceuikdzQw77rAnz2v9g8/h OpAH0kyZaZwdf/Q6OBpC8hBpkKEUoyEFj47at1nmrT2LZlA4t3su1m/VcoK3xpyRlu rXfZiBdiU7jtv50ODGMmXKZenXWb2apkKf9U/N05j6VjdALzedKp7oZlnvu+Whi3w0 DyiqnBtAsHkOmcihxbOsIoe9iZKg9jAXMHvvQ7rhHkhzsuieNBV1HkrlTcMRbgpmXM 5OBru3m2h1spMeop4NRWTuh83tHuN21ZH+MVD2vs/hgfiH/S7t6/duY1K5BeMWd0vW SXz0KzsulH7Hw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003vG-ID; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 12/19] x86/apic: Use irq_domain_create_hierarchy() Date: Mon, 16 Jan 2023 14:50:37 +0100 Message-Id: <20230116135044.14998-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187616812861212?= X-GMAIL-MSGID: =?utf-8?q?1755187616812861212?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- arch/x86/platform/uv/uv_irq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/platform/uv/uv_irq.c b/arch/x86/platform/uv/uv_irq.c index 1a536a187d74..ee21d6a36a80 100644 --- a/arch/x86/platform/uv/uv_irq.c +++ b/arch/x86/platform/uv/uv_irq.c @@ -166,10 +166,9 @@ static struct irq_domain *uv_get_irq_domain(void) if (!fn) goto out; - uv_domain = irq_domain_create_tree(fn, &uv_domain_ops, NULL); - if (uv_domain) - uv_domain->parent = x86_vector_domain; - else + uv_domain = irq_domain_create_hierarchy(x86_vector_domain, 0, 0, fn, + &uv_domain_ops, NULL); + if (!uv_domain) irq_domain_free_fwnode(fn); out: mutex_unlock(&uv_lock); From patchwork Mon Jan 16 13:50:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202813wrn; Mon, 16 Jan 2023 05:54:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXt9TPPRXjjb9n2rqrDyOfZdiRuToyJIZRpvYAnvUMjSeHt3JE5V8vVdBSBs+zx15KPM+EJN X-Received: by 2002:a05:6402:5408:b0:482:f518:792d with SMTP id ev8-20020a056402540800b00482f518792dmr72601092edb.28.1673877256808; Mon, 16 Jan 2023 05:54:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877256; cv=none; d=google.com; s=arc-20160816; b=WgiKwWXCmlZKzN1YtNESKHEq9g4pWag7mmJFAlo9M0MT2teLjKUQS75hu0Ty/gCo4t MI8kZ4NOLZK2+e3KVhu0V4WuLrvXuNeCDc1/19RagTumnkjM1l5iF0o6pJdCXFfO+eVp 7v0AuPD3Z9FgVKFS4Pkkl9tUQ1pf9fQ82AAsP3H7L35flvDJDERc+5K0UlRRcOeDfiGu yW2GRi/vhybrmvCZmhB8cmkzYCSYeZ+PHzWHSLATmo+E8UABGjjuSfufRfUmbYNxGQZr b3J4dUOlDR+m+qfXe14yUtsE46N/IrK5q2uoVJmfW8EtQMxVJ3+k7fJl6tSBDoUt3o4W iFGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sXcXjDqzhuYvHM0A0o2DEKqSp4AJPZTfx618RTtvqD0=; b=N9rOau0lmmqNqRM/Y5IuBAzX5N2wl13JcTO/dKjt14kNgS51FbZETa/XsTSoDwbGVQ lnG6tpx6/EEBibx94Z+TrUHgyisA4xDUoHV83Y40Mf5Te8pLPEe/0ktZD77lh+k+bUs7 XklJCGsTsIfBhlNsAViml5WynmI8tkDR9AgI04JPWep7pyUYOXlBkd6Vgo8oyC5mIsIh pAr+sspo0t9WPO5RbLDahQzyfVhUw6dSNurVyl/tMJUsX0ilDKOMR7UY3/6l02WTi/m1 yVL39sRHVJZZAqpJsE7+DlDgwPtDTrHg/6EU48QzuCyEzvh32+ttFz+MI7vb3bXOtEQF 2GRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aoQxzveX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cx26-20020a05640222ba00b0048c7e8f3dcasi27711790edb.483.2023.01.16.05.53.53; Mon, 16 Jan 2023 05:54:16 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aoQxzveX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbjAPNwN (ORCPT + 99 others); Mon, 16 Jan 2023 08:52:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231423AbjAPNup (ORCPT ); Mon, 16 Jan 2023 08:50:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAB1821A10; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6792B60FE4; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F5B1C4332F; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=exIBPyxduIGuUodwt8BZURfkCW3s1wM57ISgdqjT39c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aoQxzveXsm/ZO3tWIHkVG6yOughBTRwFZ4w3sRrr96uAlPlyx7SpR+ZXxXvUOIxHe 7L+qV1iQ2dWU5TH+hcV0tr/8GdtdxBw1Yo6BhAGOIYb/rabVdgtv2aNcMQxzRMTAM0 bbh5rNPE6lCooDhEBQm1NBiGH+qdPEc0AUV5ozjh0aWxeoF20+u9Zc0ZVRKm8nZ691 Ur3XCOM7hzmHdXcraj9O9AX3/ue/9EV4mCGojI6818WYTnt+styKgBm64nnxWgtFC/ daDIz13zqgMzXCIQ1JJHqcysoLXCUbkWc2So86SiCW+EQqY9WdTwv7ljPGLhZkBUCm QmyPMOiGsYLJA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003vI-LQ; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 13/19] irqchip/alpine-msi: Use irq_domain_add_hierarchy() Date: Mon, 16 Jan 2023 14:50:38 +0100 Message-Id: <20230116135044.14998-14-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187518859384868?= X-GMAIL-MSGID: =?utf-8?q?1755187518859384868?= Use the irq_domain_add_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-alpine-msi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-alpine-msi.c b/drivers/irqchip/irq-alpine-msi.c index 5ddb8e578ac6..604459372fdd 100644 --- a/drivers/irqchip/irq-alpine-msi.c +++ b/drivers/irqchip/irq-alpine-msi.c @@ -204,16 +204,14 @@ static int alpine_msix_init_domains(struct alpine_msix_data *priv, return -ENXIO; } - middle_domain = irq_domain_add_tree(NULL, - &alpine_msix_middle_domain_ops, - priv); + middle_domain = irq_domain_add_hierarchy(gic_domain, 0, 0, NULL, + &alpine_msix_middle_domain_ops, + priv); if (!middle_domain) { pr_err("Failed to create the MSIX middle domain\n"); return -ENOMEM; } - middle_domain->parent = gic_domain; - msi_domain = pci_msi_create_irq_domain(of_node_to_fwnode(node), &alpine_msix_domain_info, middle_domain); From patchwork Mon Jan 16 13:50:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44162 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202817wrn; Mon, 16 Jan 2023 05:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXunObYxJ6v62JHQoIBP20sRX/f1z0IFnpL5L0fkCKl3o9isA3Gqs7ycgKyTwr6CiWURH9q7 X-Received: by 2002:a17:907:3e26:b0:7ad:c8d7:4fd9 with SMTP id hp38-20020a1709073e2600b007adc8d74fd9mr105070719ejc.36.1673877257181; Mon, 16 Jan 2023 05:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877257; cv=none; d=google.com; s=arc-20160816; b=aAv0KcNKm9uX8pNlQWjFiVVz0RR0k/sDreHQDre/V1ICCMB+kD80trFBL8e+n26T1Z RgOQfurUEfvcJHqGzvkUSZfr5E4mfATDDGn6v+t9SjO1GFClICiD++5r7TzmSrRLCA3z rD7nE83sC4q/LGnmC+mHjpHkqJbi9fIXKBho4MSJfvMEMHZVgYpQz7uZIKUL9WYLocAH cfdAi4sYFotUDhM47UY0+g+WwxHqH0QgYbIRzYrD6xwdO0B+JSx3BEuxlXG/tkWuaztc iz4jc0gEbNN4+tGzjViJLUSw0ZyctsvRyKQOCOxKux4gmJSUpiPQKGegNaHHy1yf5tr9 tWFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L6yhiZ6LlUbPuFVSIXmDs2SsJmBCeaJlsD2pIr23l74=; b=lOP72KBmP0MpseynRv3q/s/numh/96c10McRHWld7L+OtiaOX+3vnvW/hKP2BCnvvr 86ktqqR/3mq5qFQSlKujHBV/u9x+vjVvX7drB17cFn7x2V5++mkItH+U9n8Hy96r1uCL JE8Wo8y6IECVMg7N0+M4mVmH2cc3f1CYqrV/3XuuntfU31OQ77KKGhqa6s/7AKNSjsPl MEBOe2hLdSxjeJisNF3LjVxsu1CmwqpyNqZgsShvMh6j221Q3R5tSpw0zqe3brqRtoPQ 2febMuycrD4S6IfrNtnt9toTTFPUDkL3YNHmkCxXbQcZDhUqN0+KzHd9l6AW0f6mqwy/ 2OpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zc9+3pnm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb42-20020a170907962a00b00871b82c1f2asi1143686ejc.23.2023.01.16.05.53.53; Mon, 16 Jan 2023 05:54:17 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zc9+3pnm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231521AbjAPNvd (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231534AbjAPNuo (ORCPT ); Mon, 16 Jan 2023 08:50:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7708321963; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1E37D60FDE; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47EE2C4339B; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=xzaP0POiJTvdAArF5s+sRyCE4tI36PeyUYdNU4owoyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zc9+3pnmtbZ6o82DpGuYgW1tMjj2PtHMP9Upu1/umGP0gbfj8u/zRXpbpei3VP4k3 yh66TqL50QoPk7mXgdeNbBCpC13H6fm1Ls7zqggb3rogCRORryH9ZxK2eK3jLw4+GS nCroqQSwrzlbhN+4ZXOmYg61FG/wVxc0HOrPq5HR7Ty1JcuzJF+5atkBtuTnqx09Bj F1OtSt8LptZorWDyyh5Kw/BWMdQ5RifsiBQNdIytp6M67brGBBhO3jIXVhlFAjHi6q 0WnR5b2/IO2kGUl8OwiQXkItmlXHLJU4kpyoqqAG7zt3dMxFYAuM9geuRWMy/TgGoO TNC7j7/KEE6qA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003vL-OK; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 14/19] irqchip/gic-v2m: Use irq_domain_create_hierarchy() Date: Mon, 16 Jan 2023 14:50:39 +0100 Message-Id: <20230116135044.14998-15-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187518353707018?= X-GMAIL-MSGID: =?utf-8?q?1755187518353707018?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-gic-v2m.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index f4d7eeb13951..f1e75b35a52a 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -287,15 +287,14 @@ static __init int gicv2m_allocate_domains(struct irq_domain *parent) if (!v2m) return 0; - inner_domain = irq_domain_create_tree(v2m->fwnode, - &gicv2m_domain_ops, v2m); + inner_domain = irq_domain_create_hierarchy(parent, 0, 0, v2m->fwnode, + &gicv2m_domain_ops, v2m); if (!inner_domain) { pr_err("Failed to create GICv2m domain\n"); return -ENOMEM; } irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS); - inner_domain->parent = parent; pci_domain = pci_msi_create_irq_domain(v2m->fwnode, &gicv2m_msi_domain_info, inner_domain); From patchwork Mon Jan 16 13:50:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44161 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202816wrn; Mon, 16 Jan 2023 05:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3H0j/PraePVtw96Z6PmrbMkzR5RXgVZAU79lue68euIRbfRDcKcEikQYJ8P2JDrU+BG+o X-Received: by 2002:a17:907:9625:b0:7ad:9455:d57d with SMTP id gb37-20020a170907962500b007ad9455d57dmr89438645ejc.74.1673877257184; Mon, 16 Jan 2023 05:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877257; cv=none; d=google.com; s=arc-20160816; b=NCJPe/5FyPYd8Vx6iabsDcQj5uyAPf8LlgZp0oIWp4hLZsgLDQo/x/6c/d4QEAuMIe CntUag8NIl1NJnssF4C0ADE7ixsyAWDw847vGY6JjSDvDwmFMwVJS/+KNlW6ADTjKTzK N8VVaz5dzs26RjuhLYFt5+1f6fnCBigyacdaQNxuYAx9WTXiXX7BVu7IkfuswtzIV/JY h1DFeByoKZNmcrieU0Vkd/9a2c22LBC7WdsdFRuHan3l9OQzQzzgtcyZGefUr4oTDtsx xjwJMdFnIAdAtpIvMRMB/gXiPN7duHH+VggxtEXwtVNVEedfRcjK4UPqr5+Rr+EsGmvg jzEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=09hhy9ylbHeu/SiceC01gZnXJr+aPiYtWbGovWWFSFs=; b=NXmYOvxEU7LM4pdVXKM5VBUPPNE4i3s3yD6RHGTyxP0EV4XQLBgwlrUWwGTz0mXW70 422yoQiMmzr7rtM1dQwAQE+GESb6x0IehVlH7LqtjkiJHBusVuaa04ysU9Ba5G7mftt5 ixvVaKg7hql+gkZZmkg9ZcYwGYNAxdxDkh2PRc5/LayXdeRVIAHR38+EMJRsa7n68ww8 /BzDJ3qNFUS5I5if5APsBouRwzP0DlsIcNJpAyg0Up2vITDGNR0rNwgZtkuPi8ucmJch Ve8RPI9kRAYKNDJO/bW1xJVhZFDT13Wf+hYEYcZXfBpjkwl+NMoqFifMvzg7ovobz/r7 Z0ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EfKk9L9s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f15-20020a0564021e8f00b0048d6ace589esi38698390edf.128.2023.01.16.05.53.53; Mon, 16 Jan 2023 05:54:17 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EfKk9L9s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbjAPNwB (ORCPT + 99 others); Mon, 16 Jan 2023 08:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231548AbjAPNur (ORCPT ); Mon, 16 Jan 2023 08:50:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D8521971; Mon, 16 Jan 2023 05:50:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 36D2DB80F98; Mon, 16 Jan 2023 13:50:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E978C433A0; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=7j3QbaKo3LQZQVKIp6aKOuNy40ktCIOrZ3HeL+Rwf1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EfKk9L9sqpnMZ3+AHb1HMoqZOhQNRwQ/oZkLjU7l3UA9rg17LEbiVel0eSSLhjMC2 zPG81JAv2b1s3VupJKrzR6KNrx0SlI2mJVlrR9cHwWgWsFsRE+qAboOoWXD6Vlr2jJ pdXuNUtXhAtsfzTIJ6fDZhDFxwnsEsixuwaOiy0ihM4Oa8AAeGQtO5TSQQz3rvkP3T mJrVuzeUOIKHwG0EuhhMilUXJWe3ikESXth5vKLBzCjJJj2bOefjqQkeMUPaNQu8Ho cmBc6JyPLCm4u6Mp5q0flNNwB+fo/2enYScFNELZ67OutJgvUTKDkOz2QYFSyudsjK XPSxv9rnDFCnQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003vP-RB; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 15/19] irqchip/gic-v3-its: Use irq_domain_create_hierarchy() Date: Mon, 16 Jan 2023 14:50:40 +0100 Message-Id: <20230116135044.14998-16-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187518767750984?= X-GMAIL-MSGID: =?utf-8?q?1755187518767750984?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Note that the domain host_data was first set to the struct its_node during allocation only to immediately be overwritten with the struct msi_domain_info. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-gic-v3-its.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 973ede0197e3..5634d29b644d 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4909,18 +4909,19 @@ static int its_init_domain(struct fwnode_handle *handle, struct its_node *its) if (!info) return -ENOMEM; - inner_domain = irq_domain_create_tree(handle, &its_domain_ops, its); + info->ops = &its_msi_domain_ops; + info->data = its; + + inner_domain = irq_domain_create_hierarchy(its_parent, + its->msi_domain_flags, 0, + handle, &its_domain_ops, + info); if (!inner_domain) { kfree(info); return -ENOMEM; } - inner_domain->parent = its_parent; irq_domain_update_bus_token(inner_domain, DOMAIN_BUS_NEXUS); - inner_domain->flags |= its->msi_domain_flags; - info->ops = &its_msi_domain_ops; - info->data = its; - inner_domain->host_data = info; return 0; } From patchwork Mon Jan 16 13:50:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44169 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1203277wrn; Mon, 16 Jan 2023 05:55:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXufOstITmRvGV7uDh+cIMZlJdnnNebWf9CxtvQKNGcqbp+PNOtjtjzMnLQvxrkX5Pa+EKIr X-Received: by 2002:a17:906:1150:b0:86c:cbfd:936 with SMTP id i16-20020a170906115000b0086ccbfd0936mr8648020eja.11.1673877340532; Mon, 16 Jan 2023 05:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877340; cv=none; d=google.com; s=arc-20160816; b=GVN/U0KGTO5lwMOVCST34Rito73dBARUHbJsJ9hwNsVS43D1t4BUrOAFEhiWljOH7b fWhlO0bmuGwKaxGJ9MlJSqOBaiy32kqrnkW+0x3odawR96jsNj/k6pHv9MJdoLzEya5k npaJkB+mVTyEpPxCooVad0aJIeWHQouTEq0Phpdg+nrDFMexDmNFkV3cfEixDSZv4NgR OwUbnfBT4r5iiPUOVMk/7mLYHsLQBNLqPPueB8O3nzFX93FaKwjfLaeWtPR0TeJrxA2l KcCtkhtUCswxVuOCiMiNpddNLTjP8m0sc19ecbmz24ns1DSdkVSJMtu7ZBxOx6Nl8vZd GgnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hBlYYTl5Nt5k5NntC7d3zuDMdkqKT93OZIE05iENP04=; b=N3gfq97KFXs+cDvv5il994KgZaKaDcM+xZiMuu9OfuQqq7VNmceBGc7GMrVGZJ1Fro m4OSHkavg8C+yaO9HqhAuKlSOT4hVi5h6kRs3eN4FDjXVyZ+3fqOde7izOOo1AshuXpN RwrWSSBS7syp/7etD8K0SNDNIMumbMfqGH2YfoMfJWLQStbRteyFbnlxlfSgKIIJDa3m zKalSnj/UX4oCWPfv6kw2ZA4zbrZq1hO1g32mrCU7dD7WSJISyAmE/6wbAttzLlEWhcC cRTTMBsjCIVW8oGnCKvbrjZ5w+vUfIYAq/vvUU7I2AdxaW7E9p3ORIEWm5J3639hRnre SaaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jwhs2U9u; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn22-20020a17090794d600b00871a15adeb2si199177ejc.222.2023.01.16.05.55.16; Mon, 16 Jan 2023 05:55:40 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jwhs2U9u; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231592AbjAPNvk (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbjAPNus (ORCPT ); Mon, 16 Jan 2023 08:50:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5AB421A16; Mon, 16 Jan 2023 05:50:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4DDF2B80F9B; Mon, 16 Jan 2023 13:50:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A8FDC4333D; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=AWpbuIZwiPqdwBLRoH8sut1cJ+/Deb137lb+8oUm3Ks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jwhs2U9uyOfPPhn4mjG1861rCP+K6XOfo1RUlUcH3y2A77woSmEaWDtOv3+EJYkIN RUeP+9H8Mom5Axly0fy4klS4ygtYraUWMDptUArzXGhUAcc4t61M6lL2PEshKXehIq i6W+y5NBS2Wdm2NmQcfu/8z64+jvUc0VVMPvApvCDo0Rn+UTm66LzlEI3mhdfQQE0v AVQGhx/RlOojZ/bu99HfGgMiJIu8+MpYnCNpyrLic6Nddt6cMT7rHGJAmC9sY5dC4c +J3wftkLLB0mXW1Z6pnXV+HM9JFJchFBIKQlM/LtHkW5bwggiHntdixQJla8Hg+fTP HwRhKTmpNllMw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt6-0003vS-U5; Mon, 16 Jan 2023 14:51:00 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 16/19] irqchip/gic-v3-mbi: Use irq_domain_create_hierarchy() Date: Mon, 16 Jan 2023 14:50:41 +0100 Message-Id: <20230116135044.14998-17-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187606214633969?= X-GMAIL-MSGID: =?utf-8?q?1755187606214633969?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-gic-v3-mbi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-mbi.c b/drivers/irqchip/irq-gic-v3-mbi.c index e1efdec9e9ac..dbb8b1efda44 100644 --- a/drivers/irqchip/irq-gic-v3-mbi.c +++ b/drivers/irqchip/irq-gic-v3-mbi.c @@ -233,13 +233,12 @@ static int mbi_allocate_domains(struct irq_domain *parent) struct irq_domain *nexus_domain, *pci_domain, *plat_domain; int err; - nexus_domain = irq_domain_create_tree(parent->fwnode, - &mbi_domain_ops, NULL); + nexus_domain = irq_domain_create_hierarchy(parent, 0, 0, parent->fwnode, + &mbi_domain_ops, NULL); if (!nexus_domain) return -ENOMEM; irq_domain_update_bus_token(nexus_domain, DOMAIN_BUS_NEXUS); - nexus_domain->parent = parent; err = mbi_allocate_pci_domain(nexus_domain, &pci_domain); From patchwork Mon Jan 16 13:50:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202820wrn; Mon, 16 Jan 2023 05:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvFHguKrm3SBStkN3TKDqrllPBv+Wvi7O+eTikicUbvgi3OfjmBL8UlC40YcQdTxSwVkeCN X-Received: by 2002:a17:907:1819:b0:870:2aa7:6509 with SMTP id lg25-20020a170907181900b008702aa76509mr5296713ejc.43.1673877257545; Mon, 16 Jan 2023 05:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877257; cv=none; d=google.com; s=arc-20160816; b=WnWmVtgwGSyZbz5M6m/6bZEz6JxqfSkKJH4IXavIpGV6pChkXjhIO0QS6UEgy6/rFt lfVUiG2ho9NIce+YYJ3Ka+s+IZI5g7RcFlkpIoMk77HjxTmToKbdiw/lsYiLnzo8nEEF hedfpJSG0ecru6O7Vwhb7NpoVNUBueKuF82nv3XNL0N1std/vTca87nKjhcrtW/5UEMS TDVwK8delH/XmRMhKQcA4Vly45MDqGUSHEIH6Z9EyM7yO9dwb4Wq919IepLO8YA1xLqg KjYpaSp1rfDJwP267nnmeAQDmObPCfwax/ySdBCYVXwKhXjVidPsiVtD6bujTX1g9I/Q oYiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GnmZhZFvy39ZbB8/E9H6e2bvYOwkrkfJZNFFYfrI2FQ=; b=kUqFDSwNXkK33NWf47U+raMCL2dxnotrjNtVfSs1oaaH8QrfPBGj3+U1E/b9xKvcPv 52GaS9RwvIzIx2mZOxLEfy9uyI+Xgq3uXxPb5nKovzDR0f4mKHoWyqNvmeH2nDVB9YO1 iPJr17Aff/jJ94YD24kgnQbtxQbULBB/AQ4lZHHZ7Zrbn6ddpz0LfdlFbEXXntPzrxeB /CrEnAFUZdfuKVgIFeRktHePwEW13xXuHRMeavtPJp0Cx//X4ZYHqH/KjcoY+oTjgdmF n+Zh6wKOfP4ksytxZmiR3Kz0iek7iLsNm/yLsHSJbwZixE/2H+f1tTTka7MwG/lCgV66 Krzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bbXomJWO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds4-20020a170907724400b0081a9c3ca4bcsi32742980ejc.379.2023.01.16.05.53.53; Mon, 16 Jan 2023 05:54:17 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bbXomJWO; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231223AbjAPNvs (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbjAPNut (ORCPT ); Mon, 16 Jan 2023 08:50:49 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B3F21A17; Mon, 16 Jan 2023 05:50:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 55C99B80F9C; Mon, 16 Jan 2023 13:50:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85430C432C4; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=8DJCpUTNn+l1lULiQCFrqNOTi/kGEEvzvK7CyZ3zKZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bbXomJWO7ZAWnj9f1IHYWsdNOiKPjuldKfB71I8vFaL289g4PgVvZ2CnJhi/ilL2j EOXhxb9aOaf/dRV40UcEh01ip0NTxDdljQGPOQSM35iD7XRJjJGFuoINFi6X4zdW6j /RoXuxAhmDNa/lkHX8DcvSn2YN1k5llWU5hUt78LyQp0IbWQtdV4m9ys6SupTUcfUl K6ziM4uy2P8E9ektMaOQmOMsco5xoEpjNKYPL9Zjgpq6XigjfRnFjdnV7/nASAASTV ei6wiIrQtAXP01c9vD7v+nyrm+9JCHXzPzN+rsArQjOQNiiUGKZ9macMM+jj187Q+7 ScBzZmt+wfq/A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt7-0003vV-0i; Mon, 16 Jan 2023 14:51:01 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 17/19] irqchip/loongson-pch-msi: Use irq_domain_create_hierarchy() Date: Mon, 16 Jan 2023 14:50:42 +0100 Message-Id: <20230116135044.14998-18-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187518939745972?= X-GMAIL-MSGID: =?utf-8?q?1755187518939745972?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-loongson-pch-msi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-loongson-pch-msi.c b/drivers/irqchip/irq-loongson-pch-msi.c index a72ede90ffc6..6e1e1f011bb2 100644 --- a/drivers/irqchip/irq-loongson-pch-msi.c +++ b/drivers/irqchip/irq-loongson-pch-msi.c @@ -163,16 +163,15 @@ static int pch_msi_init_domains(struct pch_msi_data *priv, { struct irq_domain *middle_domain, *msi_domain; - middle_domain = irq_domain_create_linear(domain_handle, - priv->num_irqs, - &pch_msi_middle_domain_ops, - priv); + middle_domain = irq_domain_create_hierarchy(parent, 0, priv->num_irqs, + domain_handle, + &pch_msi_middle_domain_ops, + priv); if (!middle_domain) { pr_err("Failed to create the MSI middle domain\n"); return -ENOMEM; } - middle_domain->parent = parent; irq_domain_update_bus_token(middle_domain, DOMAIN_BUS_NEXUS); msi_domain = pci_msi_create_irq_domain(domain_handle, From patchwork Mon Jan 16 13:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44163 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202818wrn; Mon, 16 Jan 2023 05:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXtePmRDVGoJ0FgsE6knVXLr6IADbZssQvfs/hFWKysEpIzAEbIuVPwZisdNrYs+H4LBqSeK X-Received: by 2002:a17:906:714b:b0:7c0:e98d:b27 with SMTP id z11-20020a170906714b00b007c0e98d0b27mr12836408ejj.58.1673877257299; Mon, 16 Jan 2023 05:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877257; cv=none; d=google.com; s=arc-20160816; b=f/ffWp6QXqMSRk93UGA44wgSbofJ96Yo6rQJ3z3m4hHaQOWL+gZYlrLgAMNi+sPgS2 BaxEwGwC8ZlralZY5CiLy6c7RJEkH/4rP9TGwwm37s0wsWp2Zcyh9QObLId7vCJNpANb KWFQLg7LBl+98tGTVd/NYiyYpX4+GekMpk946sjzye9MY/QqQQ7litspQMV4d5Ac8RJ7 AaMoF9CBlr1hx+KwZ0+6NEpRFwWu5BZW0o8NH2Vg67k0yPThi3xNQTBlKUKpwB1wcWRo KIL3Yu3ZQYwEa1nTTa7XrqwolBT3kZJfh9aX8OCpF+/b+yrk3CGyKUtCpb/OfaMrEBWt 4mOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QAgcHc0KsgxNN6egKVBrPnXpdcEG2tK9d/3SyvW1grE=; b=Gqa+ZdVMsCP2DSkP+F75Tt9Gv3gi4B8WeLb7Mgh9fLbrXH5s6K4mzcvyNkk2wbw2DM dCuE29K34gffkUPnY98JF0aBCXFE0k/e+DsviYep2JjKtYmddGdzoSBiRrrWNzZZQQdZ BeYVeyp4MkkTJ0lbpw0V9REHClZrmiO1qVXa8Q1rRcjfpDlmlAAUXbokUD5Vr8Iu7Ert l0ZpNDP/gA0McOx4LXK1CtCjGQfTlBaWGMd25hlNp64rvwZv8Ht4Eg9ho6zaur5ps2Fs 0jfWOePb2OQj6OC+pL8+7XlhvhjbkSZDVfAQYDgy/kYYjfFrMpy9EN8Ow5KcFkV8kSw0 uJTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lbf7fa2t; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ae2-20020a17090725c200b007c0dcc41dbcsi26246931ejc.821.2023.01.16.05.53.53; Mon, 16 Jan 2023 05:54:17 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lbf7fa2t; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231156AbjAPNv3 (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231543AbjAPNup (ORCPT ); Mon, 16 Jan 2023 08:50:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 777C021A0C; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 47FB560FE1; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B443DC4322E; Mon, 16 Jan 2023 13:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877041; bh=nlxLr7M1e3sPAGKO79refaH63FrFXT94UU3Vpzwqemc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lbf7fa2tZbpeVfBK6+e27SiZIYIPL1Naxz33L0nLt84RxNJ1hoR39PrisqR1X/37R 33TOcM/FZ8iEdZ4mfOYSVj6Wl7wgUscP71KunXbpaLF2ufmxP7zqAFWKoqrN6L1vet T/JwIxIMq+1GBMOWcgof6EKvwiZBKL4ud3N3LJqz9iBHmZ4E8XpXHXrMeWjxOC6GZb 0rLron/ZW1/2GqYdXR/t49omPmZzwfjx7EUnkD82sIDkr7vKx23oWcoPgnZaS50oaM 5PR1it7wREqawHTHchbYwXtlr8kNUPqkotI5Wxf+cSc0izc60QweYgk89cHLmFOkgW Df47QkoVuUghA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt7-0003vX-2z; Mon, 16 Jan 2023 14:51:01 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 18/19] irqchip/mvebu-odmi: Use irq_domain_create_hierarchy() Date: Mon, 16 Jan 2023 14:50:43 +0100 Message-Id: <20230116135044.14998-19-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187518906075774?= X-GMAIL-MSGID: =?utf-8?q?1755187518906075774?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- drivers/irqchip/irq-mvebu-odmi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-mvebu-odmi.c b/drivers/irqchip/irq-mvebu-odmi.c index dc4145abdd6f..108091533e10 100644 --- a/drivers/irqchip/irq-mvebu-odmi.c +++ b/drivers/irqchip/irq-mvebu-odmi.c @@ -161,7 +161,7 @@ static struct msi_domain_info odmi_msi_domain_info = { static int __init mvebu_odmi_init(struct device_node *node, struct device_node *parent) { - struct irq_domain *inner_domain, *plat_domain; + struct irq_domain *parent_domain, *inner_domain, *plat_domain; int ret, i; if (of_property_read_u32(node, "marvell,odmi-frames", &odmis_count)) @@ -197,16 +197,17 @@ static int __init mvebu_odmi_init(struct device_node *node, } } - inner_domain = irq_domain_create_linear(of_node_to_fwnode(node), - odmis_count * NODMIS_PER_FRAME, - &odmi_domain_ops, NULL); + parent_domain = irq_find_host(parent); + + inner_domain = irq_domain_create_hierarchy(parent_domain, 0, + odmis_count * NODMIS_PER_FRAME, + of_node_to_fwnode(node), + &odmi_domain_ops, NULL); if (!inner_domain) { ret = -ENOMEM; goto err_unmap; } - inner_domain->parent = irq_find_host(parent); - plat_domain = platform_msi_create_irq_domain(of_node_to_fwnode(node), &odmi_msi_domain_info, inner_domain); From patchwork Mon Jan 16 13:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 44164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1202815wrn; Mon, 16 Jan 2023 05:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvxqVfJfk5hzwID+QUHVeLL4+6i0xI/yrBA6C+MOusc24vZ9b9pANAKOfx18WR0fmPza77 X-Received: by 2002:a17:906:124c:b0:7c0:d60b:2883 with SMTP id u12-20020a170906124c00b007c0d60b2883mr61739902eja.50.1673877257181; Mon, 16 Jan 2023 05:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673877257; cv=none; d=google.com; s=arc-20160816; b=vQtQsF9VUhVkiUyMkv9GVl76rxaGFQgha15nJlCjJZomHZ02Om30Nh705rIqL34NBv 58MGNda3t17ozCjeEiLIG85JtAfNLldq51drmYn4vaySRyJCsoCwuu0RTMcIFsG5BJ76 JtdKE3nUmA9g8LlVh8PEyhPiW5c/l7wyk+MoIxhRq/qhwDRI9fc8NAg61S/RPZ86x+lB 0xOu+ne/oRWp/t8o/SEWSpl6Fp/3YtmhiTcFxd+MPGEuOVjzBzDSWVWVbAetI3pIKPGX t+oed438pPhXJHFjmA9+GG8FJ3ADeVpkYVIDxMSRHwqtAjo4rwYDuMT3+T1tayUzxOCB 6JkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+0y6gW5mG7sbBcQ8pHRfwB+ejxB0MOL4pwqjyeqdQWc=; b=QFB/x9G/9EiEECPMnweOlwwgjsVkaNtnqiA8OensK+H1Ab5pWxr0ZbMQ1gzUBkFadN sUbH7TRLq/Di+3/9vxwqiKcOoR2hNEZJKdUpuh6ETM5W/cdWScNUuGVSKJomr7a77YwL 0bA9LFlOFwPa0JNMHeFT4sXkzwSUrLop57LdY+bNiusMydtc5TbfZPegfaLmEpXorXlW VGQ5Cn8EgpKZ8KaToyeC72tDreOSMQf28LvaB9Bvmrtz6hIj5sFgu4zTbYNhw8wV/TUL kvlfZJsDN5Lcp+B23u/6Tz8bC9klZof2fT4g5VZcB3EyWZQ9GuLwQ2ThpE64R0IewHgR KMog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pziiGpNm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xb13-20020a170907070d00b0078d3b940ec5si32346506ejb.373.2023.01.16.05.53.53; Mon, 16 Jan 2023 05:54:17 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pziiGpNm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231184AbjAPNvh (ORCPT + 99 others); Mon, 16 Jan 2023 08:51:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231454AbjAPNup (ORCPT ); Mon, 16 Jan 2023 08:50:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAA0D21A0F; Mon, 16 Jan 2023 05:50:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F0A260FE6; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ED5CC4339C; Mon, 16 Jan 2023 13:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673877042; bh=CHsjHqlh8sOEcnUziGGttJ51j1NClOatkbqwQ5xcKxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pziiGpNmWYMO4ElKa8U9ULDlRUp1vp4lHnZX5r/lNxx/KiKH9Wy41kNgwAKRtcCSL 7ny5y7OxduGaV53lUbxVVEqDndg3CA5kvNTbdG8R7/fqZ1RH3JWhaSB5pQEUvLKZ1p pFh/QRvN4mB8IzPwrBu0TPLqueTZ9VRhnfwgnrWJ1oOkBg2ctpaxYk4240jd9QOY9B 2xAP7w9YgBgGVvsq2Rt1v86wq+1V8J4aoIuNZkfC6Dp/FoM0mKLQQQFPb9fbPb9OWl ivYM0K5gSiX8CGG+yMMgJRPp+CJqoO5Uo33hdUlnkgzygxKqAcjUyLlmu9GIuad3ia O3RrDt/z+CbUQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pHPt7-0003va-5v; Mon, 16 Jan 2023 14:51:01 +0100 From: Johan Hovold To: Marc Zyngier , Thomas Gleixner 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 , Hsin-Yi Wang , Mark-PK Tsai Subject: [PATCH v4 19/19] irqdomain: Switch to per-domain locking Date: Mon, 16 Jan 2023 14:50:44 +0100 Message-Id: <20230116135044.14998-20-johan+linaro@kernel.org> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230116135044.14998-1-johan+linaro@kernel.org> References: <20230116135044.14998-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755187518829020702?= X-GMAIL-MSGID: =?utf-8?q?1755187518829020702?= The IRQ domain structures are currently protected by the global irq_domain_mutex. Switch to using more fine-grained per-domain locking, which may potentially speed up parallel probing somewhat. Note that the domain lock of the root domain (innermost domain) must be used for hierarchical domains. For non-hierarchical domain (as for root domains), the new root pointer is set to the domain itself so that domain->root->mutex can be used in shared code paths. Also note that hierarchical domains should be constructed using irq_domain_create_hierarchy() (or irq_domain_add_hierarchy()) to avoid poking at irqdomain internals. As a safeguard, the lockdep assertion in irq_domain_set_mapping() will catch any offenders that fail to set the root domain pointer. Tested-by: Hsin-Yi Wang Tested-by: Mark-PK Tsai Signed-off-by: Johan Hovold --- include/linux/irqdomain.h | 4 +++ kernel/irq/irqdomain.c | 61 +++++++++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 7fd3939328c2..b1b06d75d31a 100644 --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -125,6 +125,8 @@ struct irq_domain_chip_generic; * core code. * @flags: Per irq_domain flags * @mapcount: The number of mapped interrupts + * @mutex: Domain lock, hierarhical domains use root domain's lock + * @root: Pointer to root domain, or containing structure if non-hierarchical * * Optional elements: * @fwnode: Pointer to firmware node associated with the irq_domain. Pretty easy @@ -152,6 +154,8 @@ struct irq_domain { void *host_data; unsigned int flags; unsigned int mapcount; + struct mutex mutex; + struct irq_domain *root; /* Optional data */ struct fwnode_handle *fwnode; diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 6f2b8a1248e1..77c31b89740d 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -226,6 +226,17 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s domain->revmap_size = size; + /* + * Hierarchical domains use the domain lock of the root domain + * (innermost domain). + * + * For non-hierarchical domains (as for root domains), the root + * pointer is set to the domain itself so that domain->root->mutex + * can be used in shared code paths. + */ + mutex_init(&domain->mutex); + domain->root = domain; + irq_domain_check_hierarchy(domain); mutex_lock(&irq_domain_mutex); @@ -503,7 +514,7 @@ static bool irq_domain_is_nomap(struct irq_domain *domain) static void irq_domain_clear_mapping(struct irq_domain *domain, irq_hw_number_t hwirq) { - lockdep_assert_held(&irq_domain_mutex); + lockdep_assert_held(&domain->root->mutex); if (irq_domain_is_nomap(domain)) return; @@ -518,7 +529,11 @@ static void irq_domain_set_mapping(struct irq_domain *domain, irq_hw_number_t hwirq, struct irq_data *irq_data) { - lockdep_assert_held(&irq_domain_mutex); + /* + * This also makes sure that all domains point to the same root when + * called from irq_domain_insert_irq() for each domain in a hierarchy. + */ + lockdep_assert_held(&domain->root->mutex); if (irq_domain_is_nomap(domain)) return; @@ -540,7 +555,7 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) hwirq = irq_data->hwirq; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->mutex); irq_set_status_flags(irq, IRQ_NOREQUEST); @@ -562,7 +577,7 @@ static void irq_domain_disassociate(struct irq_domain *domain, unsigned int irq) /* Clear reverse map for this hwirq */ irq_domain_clear_mapping(domain, hwirq); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->mutex); } static int __irq_domain_associate(struct irq_domain *domain, unsigned int virq, @@ -612,9 +627,9 @@ int irq_domain_associate(struct irq_domain *domain, unsigned int virq, { int ret; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->mutex); ret = __irq_domain_associate(domain, virq, hwirq); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->mutex); return ret; } @@ -731,7 +746,7 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, return 0; } - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->mutex); /* Check if mapping already exists */ virq = irq_find_mapping(domain, hwirq); @@ -742,7 +757,7 @@ unsigned int irq_create_mapping_affinity(struct irq_domain *domain, virq = __irq_create_mapping_affinity(domain, hwirq, affinity); out: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->mutex); return virq; } @@ -811,7 +826,7 @@ 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); + mutex_lock(&domain->root->mutex); /* * If we've already configured this interrupt, @@ -864,11 +879,11 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) /* Store trigger type */ irqd_set_trigger_type(irq_data, type); out: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return virq; err: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return 0; } @@ -1132,6 +1147,7 @@ struct irq_domain *irq_domain_create_hierarchy(struct irq_domain *parent, else domain = irq_domain_create_tree(fwnode, ops, host_data); if (domain) { + domain->root = parent->root; domain->parent = parent; domain->flags |= flags; } @@ -1528,10 +1544,10 @@ int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base, return -EINVAL; } - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); ret = ___irq_domain_alloc_irqs(domain, irq_base, nr_irqs, node, arg, realloc, affinity); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return ret; } @@ -1542,7 +1558,7 @@ static void irq_domain_fix_revmap(struct irq_data *d) { void __rcu **slot; - lockdep_assert_held(&irq_domain_mutex); + lockdep_assert_held(&d->domain->root->mutex); if (irq_domain_is_nomap(d->domain)) return; @@ -1608,7 +1624,7 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) if (!parent_irq_data) return -ENOMEM; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); /* Copy the original irq_data. */ *parent_irq_data = *irq_data; @@ -1636,7 +1652,7 @@ int irq_domain_push_irq(struct irq_domain *domain, int virq, void *arg) irq_domain_fix_revmap(parent_irq_data); irq_domain_set_mapping(domain, irq_data->hwirq, irq_data); error: - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); return rv; } @@ -1691,7 +1707,7 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) if (WARN_ON(!parent_irq_data)) return -EINVAL; - mutex_lock(&irq_domain_mutex); + mutex_lock(&domain->root->mutex); irq_data->parent_data = NULL; @@ -1703,7 +1719,7 @@ int irq_domain_pop_irq(struct irq_domain *domain, int virq) irq_domain_fix_revmap(irq_data); - mutex_unlock(&irq_domain_mutex); + mutex_unlock(&domain->root->mutex); kfree(parent_irq_data); @@ -1719,17 +1735,20 @@ EXPORT_SYMBOL_GPL(irq_domain_pop_irq); void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs) { struct irq_data *data = irq_get_irq_data(virq); + struct irq_domain *domain; int i; if (WARN(!data || !data->domain || !data->domain->ops->free, "NULL pointer, cannot free irq\n")) return; - mutex_lock(&irq_domain_mutex); + domain = data->domain; + + mutex_lock(&domain->root->mutex); for (i = 0; i < nr_irqs; i++) irq_domain_remove_irq(virq + i); - irq_domain_free_irqs_hierarchy(data->domain, virq, nr_irqs); - mutex_unlock(&irq_domain_mutex); + irq_domain_free_irqs_hierarchy(domain, virq, nr_irqs); + mutex_unlock(&domain->root->mutex); irq_domain_free_irq_data(virq, nr_irqs); irq_free_descs(virq, nr_irqs);