From patchwork Fri Dec 9 14:01:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31758 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp794751wrr; Fri, 9 Dec 2022 06:07:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4MZ92NaM29JfDC8Oe5orlA3k23qkhdDgrUeBcKVqYTKUIV40E4DunMQsEEKI3oMrWC7a4X X-Received: by 2002:a05:6a00:796:b0:577:3523:bd23 with SMTP id g22-20020a056a00079600b005773523bd23mr6270242pfu.27.1670594820906; Fri, 09 Dec 2022 06:07:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594820; cv=none; d=google.com; s=arc-20160816; b=sYqR8g5BgkkUZKEe2CcOmCXcjGoo2zjFa3mFWW8f3Sp0Ao1/9QpFCIovLS5znGkxGt jXIVdc6b2TymGo/Arsd+9p6l/5fhofRMjrF4g/6WH2XzzCv0K4zEnmPjiXniPa/mVeU9 s/y8wI8Gyc7gd1i4kyexHy6GHGFbPhp7zRlDW0QnOe80+LprXyN6z65kRvcIfRUtOzsD 96oDMunnc4BoGhsY/30z+QfpCsRC5QFaAoiJQXkqxjKea42heQav6HrEZ2MT/Dk/ZgFn uLLXQuvy73iVycRBVzIK7Ma3Njww48yBGO/QKjg3vN/8S0sp+aEVywEh8lcnVppvuQIz zKlA== 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=cfpn2uEv/U9rQisqF9KvtRm3pdOi4ugASYEUzdAKdno=; b=Had1YPHsLXXN5ERmgekiMSAWnE2kIBi2SGe1tpPOFlubHyPfmDZ5P6qjqYYjX7gjl1 p/mbN4tUH+2yfp+EudCq3a4l2YqAbCaMam1McHRkfOFBksY0M/rZ/swSXdXU64VLU0z4 9/t1Bm8CvEEL80c4I48m9IktqlWA7ZW/8/O3GbFTnQF/qFgjjkbqZnzNdI68Da6h07aD +dB7yYRYnpbu58CrZrX+SI6X+McU0NudZYzboIGQ3ZnaIDkNqCJGQIxNoXteiuiGNNfk VfLqqVLIhBr1da596G5D9HZKVOX6ezXmuCDdVx0WopmUKWwwcMzuokUDAEk3YVbNbAvo Tqjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nSaWAlAU; 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 k8-20020a056a00168800b0056bffcfc30csi1786744pfc.249.2022.12.09.06.06.38; Fri, 09 Dec 2022 06:07:00 -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=nSaWAlAU; 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 S229982AbiLIOFY (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbiLIOFQ (ORCPT ); Fri, 9 Dec 2022 09:05:16 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A229975BC2; Fri, 9 Dec 2022 06:05:14 -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 F408562253; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CC5AC433D2; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=SjCpvljZm9XNVxL3XT6AlbBdKw5R8JeaSMnpPTwki1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nSaWAlAUrqEG5ELDFmUcCWJPu5CdS+h5m0QCJd8D1jkUxpD1G0JIVdf98aHAE5jSS 4xcm5Y55UxqCaqkWKa1VD8XoV6lT4PICg4nL75h4zYyjRuBV3z5evo0gXQVbGBJXvv IMAY1rMNgetBFtaxQohto8eRNKsqc6HobhtXWDqlCt4LhgTEPJTca+UtoTlfljiOGo nTHEV39C9ACQWgg2XCivAoqu+6UpJoOaWSUJBZ97VfV9EGjbNLCq/2xcUhykx8IzWW v7w2vmkA1YIoyDL7cnJtXGQCxvX3CvqiKbNiJms4JkSfhsI9P56O9wb6GHW4vdhN6G 2qND3lMvL9kpQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000RP-6n; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 01/19] irqdomain: Drop bogus fwspec-mapping error handling Date: Fri, 9 Dec 2022 15:01:32 +0100 Message-Id: <20221209140150.1453-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745634806816126?= X-GMAIL-MSGID: =?utf-8?q?1751745634806816126?= 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(). 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 Fri Dec 9 14:01:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31756 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp794615wrr; Fri, 9 Dec 2022 06:06:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6q6fEmph12ImjkfyCSt7rvFZM9o5dMDOHlOtMmsm16xBbQCTNodsbp3hUOd1VVY7YuvWv8 X-Received: by 2002:aa7:858a:0:b0:56e:705e:3608 with SMTP id w10-20020aa7858a000000b0056e705e3608mr5342872pfn.31.1670594809058; Fri, 09 Dec 2022 06:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594809; cv=none; d=google.com; s=arc-20160816; b=bDBjgwpaL6JlsCGZQxmZFydo7osOfLqrUpM9jnObykbl+tw55zUk95Uyje534LIiqb +5x19lLMS/3h6w6sDif2be1V04mN/mbicVkJV40gUI1ndhZVdQYx/qxT1vBeNQQTlQ4U 74oPFWZAiXLEO3sS9ZUjuhVzOjPXP4ej1z5TSYMD80OF8f+sfHrCMjP5KOarnPtISXIa uNxL8s/7A7WRHu+AagazmS88FTL3W4w5/MuUYf/nIAlxWzB+2vRdDijVNBOqrj9DGgaa +uAMlMoL1jHJ/u+oNgmdB2kWwDyP5dgQ6gWTFDdlbfJDfHwdTbuiC9juT9p342bjcGts 18sA== 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=s4/ZtNgD94wBCnDtH6rUcAaL0L1ocdWfdSs2GB5k+9U=; b=K8WDKRrhvXppXUNIQnlKXT44JyLfeNzKqOAmsSBdBzUTa1a9qWLh6MHA7Uvy6JueJ4 y3fWDRvlN5PeBSCCODXMJmy2iqhfgHd4bwvrdgjcIETTT8inRExBKedYhVtCKMuP/Cek hpGKmf2QBj1Z5uyqhfIg1jRelysD3rVbCOGAq/VerauqjHnCTUo+L5qczXcRO2ZRPazZ hjt/pdWBW6zN98OLrOspmc9fseGSZJZR8JSZ6ekyqp3A+MzoYgoLA44lhvIQyGvc8kFQ Fktj0dJMGY/Ud5vVfWyG1Yj5XqO4IISbf/wlx5mXlngjDKr1FauIJpn6h1zaZMMSvFqP 2yMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TtPqP036; 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 e7-20020a056a001a8700b00574250bd73dsi1790055pfv.321.2022.12.09.06.06.25; Fri, 09 Dec 2022 06:06:49 -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=TtPqP036; 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 S230074AbiLIOFm (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbiLIOFT (ORCPT ); Fri, 9 Dec 2022 09:05:19 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 496E678686; Fri, 9 Dec 2022 06:05:16 -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 B3185B82880; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FE20C433F2; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=N1BLDRjjNKEXoxfIcTMF9Q00bHff3r4yykAh+872CX4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TtPqP036tkrcpv8Bt8ZY85ddGfPygznR0oI4wrG4ml4cOxlh6GVIgC5zOR8M9UJjh Uh9O2pzEW7CpDacllUilQyJnITlv2eyNBoQN1j0hw+49TBfYAoMKTzggSQVSkG7p4b T9cehDQjtLS2DQTRdBEy5zRBVLsirgEKLn8emPyVRIS/0zEWbYxJW7lCNfQO/VMoI6 yAC9rNvM6NGAP2CcipblH0bRWIegOw9ze3sAVakaSO3wSe4iCsZaMOfl6AWoQ7q7kM mQU2FNCRbCIjg4YF8g4WPIYIwV36kZ3orKASqrvbFDDlQb15WEizOxfA3appk0sg5R hFHPmeEi/25gA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000RR-9J; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 02/19] irqdomain: Drop dead domain-name assignment Date: Fri, 9 Dec 2022 15:01:33 +0100 Message-Id: <20221209140150.1453-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745622751393557?= X-GMAIL-MSGID: =?utf-8?q?1751745622751393557?= 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. 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 Fri Dec 9 14:01:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795346wrr; Fri, 9 Dec 2022 06:07:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf76F/UauvJKEFsjPEj/R6V4+bWkO8+yapXXaAUovHS6Vfxly6qMqV01QpyrNhdcD562y6zz X-Received: by 2002:a17:902:efc2:b0:189:76ef:e112 with SMTP id ja2-20020a170902efc200b0018976efe112mr5587559plb.41.1670594877415; Fri, 09 Dec 2022 06:07:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594877; cv=none; d=google.com; s=arc-20160816; b=CQToAld7OKCBDU0EbjFrKUH4rQqkf80kN5JLkFUkGOgD3pmEiaIkIj5cG4Bf/vQ86n v8BgfYsuImx0OGnOdZbUNVtq9Wy8ahugziGvWetVcsuGA5B70xkjRJ2mpUP++dD2ztt3 m4q3ODYwy93n5WD1CKHVNm4IxScEzjoJ8QR22aFyHSmgLyjelsoetJdThYS0HkMrSlsa QvrT/EtFcCF//j7kVeKI6chlLx5rr5sy/Q8Nh9DHaixCXAS/MvL5o/2HDq++yCpkrm6d AYTwtVJHX4nA1iofK2OVh6aeBgbQOOaLYmlu679mtW6j0dUJIrKfkPdWiMcBOUrQg5FL Mwwg== 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=KXI4/2gvWo3JgagVv9QzrshOOsooeMjvWeQoQPWHWvY=; b=fJWjzDpIXE/+5CEtcXp68XpIESBEQZlf2LeP5bK4EvvdKiogZ0BSJqR1QDfNoTltUt EOr9KkYjY0ut/Chz2YFqnkuF+g+hJS/lqWue0Uq9zR3EcngTExOEFhoLhThzsprSTJeM PqO964wEWrhMvPVbxDbXh92x8j36Riy4ul1ZqJdgBR39dm5cIjHvujnURDXlmULiSjxc /MatGrx/kGUD6FW30zHzxa+gkU8xXKgg1JJlKCi4VL/8OfAc2l9qmAVkmS+JoOp77oX3 5Zi125ZqC+zsJka3TdKTO2cRfrDFJBpMraBRGvuYvoKTMIZo5ouAS1KvjEg60OqTBU5v EiQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oUW10l3c; 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 g64-20020a636b43000000b00478d5e8c51asi1596612pgc.281.2022.12.09.06.07.42; Fri, 09 Dec 2022 06:07:57 -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=oUW10l3c; 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 S229731AbiLIOFp (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbiLIOFT (ORCPT ); Fri, 9 Dec 2022 09:05:19 -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 B925278697; Fri, 9 Dec 2022 06:05:16 -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 56E77B8287A; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78FADC433A8; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=62Hsw3IDekfs4Ib+zf3Eg7ZV2PJkMIizx7ANGAPQ61c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oUW10l3cUR5KCjF/GgIMN/DD1OxWuDSXZVQ9RNkRUS/Asgqsh1VdeRrLQSK3pynpz XKWY39K9d7/kdxFvjgrK7M9ooqQe5hrXWOw26WLX3M64Bax7q7qGNgLtAb/j6oX5s4 ljnvHXGKiuEPWUJAF2Tds8yM4sscPbl9lPIwfVJAavmMFGq1pnTEFxdngmrlFv/eiY Oh7LAZIABdXx46wqT5m71kfss0mEX1nDulIyEYtm9tsp4kuPYOuxGe5nOX6iibIvuC HMM48lcKLBtgPRwyPlT8iscJlNYXSUZURGu7TzkXaY3YT6FrR8kLkNAmn9mr2W905j 6ve63l3AI9GDA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000RT-CB; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 03/19] irqdomain: Drop leftover brackets Date: Fri, 9 Dec 2022 15:01:34 +0100 Message-Id: <20221209140150.1453-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745694145582899?= X-GMAIL-MSGID: =?utf-8?q?1751745694145582899?= Drop some unnecessary brackets that were left in place when the corresponding code was updated. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795404wrr; Fri, 9 Dec 2022 06:08:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7VlqsbpaBMasVOTirHZDPyDSjesEIhJVywcBFFLAKvIC0DhjrHn5I+4fb330DZNEGa9/66 X-Received: by 2002:a17:903:189:b0:18c:1bc5:bd58 with SMTP id z9-20020a170903018900b0018c1bc5bd58mr6596030plg.9.1670594883673; Fri, 09 Dec 2022 06:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594883; cv=none; d=google.com; s=arc-20160816; b=pRkws2KvKseyx0XJhaNRnVWC4cj5YK6XG54KZHX6lSaeA41KTTO66oxtIhhi9fE+vx JG2cbuBzrqe9Bec6r4c3IQmqdTDkK7AbSW2x17GuWL+fFtuXvZ4+cYlX0/9DgTNu8HLW lDof3EMqrXRA0DBG3e7YzHDhZyhxy0YlCaQXxEm24xIiDQBgfpXqNUBmfVx9TBnSk01z YeQnVrThwmevETu7YoKMhTA8pezyzOD6F3d8SQi7ea1fm44gEZ+/dUSOEyKvBg3xGhVt 2c6teLBraZ3oqPXLefWu1frKohBFSb9hmzdUg/wvUq0FKqxCDZcLojUc/OcaVVG/LzHv VjJA== 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=JdXwRbltF2/ckQVe508m84L4WBTteZ31VKrtUR/Yb7I=; b=CxwJg645g1WUTAyPyey4uIgk5/in99Eu7qjwatWJbf3t57oc0HlHIGgyfXFxSxqedV D1qdqTuQZg5BoDFckj0apITZKSa7Egzhgcloo9JwcF7YTLlYqgw6Y6aE/RnrjADziG3C Xlyzhr3RSNj082+KH468THLJTwViRKKPOYaLM4lLUu8KIdrCDNFivR57MntyccEsH7HM WuTObcpaTdsPjplzGRkpLgwittEwkoJoBXMDKZuNEDPz0lBeAbA+VRUMMyyjPyvXcwSc icApr5HEzFiyhwNQiSy5FVhRmWgqAHyMu+F5FtWH1o9nT0t7VTosv5nnXW6UlqeM6JBe k7Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qMh5hmBZ; 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 i19-20020a170902e49300b0018c166e2304si1509747ple.299.2022.12.09.06.07.45; Fri, 09 Dec 2022 06:08:03 -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=qMh5hmBZ; 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 S230063AbiLIOFj (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229914AbiLIOFS (ORCPT ); Fri, 9 Dec 2022 09:05:18 -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 497B97868B; Fri, 9 Dec 2022 06:05:16 -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 E5910B82879; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78F51C433A7; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=niOEf+y/CPs0Wgq9no1nSEQwpCfRmMUIj1MEHaqp6o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qMh5hmBZHRacWKxQ3PhjUYbyvKsBDG6k/6Ha4xNVKmoF0sgZWrXE30p010cv9xPbX U7mmlRkKAIpZMC/0ZhNFREAmOwYAuOedHoVxcEpAcqnQ6jvlqQVp/QXeBohqLpsu7L AGYEeDPju+UkCyuAeZGdkWg8VPRbtbrN7P4V24oCGQ2PjPBJGD0o/AqlI+izZeNe3z njngGonkfbj8pebR4ZOOqF4knVeISyx6YUQMUZvjxiKcxdtAw4W3HT8i9X637hlbDW Vg8I5CGt/E3fGd2kQOllmkhzVuWUVJJj9al7te1/JqBBgfG/Zai7rPTtPybMIUv7U0 29QVlwJLrQBBQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000RV-F7; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 04/19] irqdomain: Fix association race Date: Fri, 9 Dec 2022 15:01:35 +0100 Message-Id: <20221209140150.1453-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745700699788970?= X-GMAIL-MSGID: =?utf-8?q?1751745700699788970?= 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()") 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 Fri Dec 9 14:01:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp794302wrr; Fri, 9 Dec 2022 06:06:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf654yEa9xvES7JbFUuJf1n0wuax5c+g8SkEXEetNrGM0tqlde3+MA5/suKxIDEeSkWdPxRO X-Received: by 2002:a05:6a20:2aa4:b0:a5:2a8f:4328 with SMTP id v36-20020a056a202aa400b000a52a8f4328mr11668134pzh.23.1670594781155; Fri, 09 Dec 2022 06:06:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594781; cv=none; d=google.com; s=arc-20160816; b=he+C9MShICGId6OBzbWIsxyhzfusDk8AYeuRZ9n36LQhT0CqlkzvLG1+yz/LtCu6YI /NYf1K5ATXl50sYnA0jMZpuJg4PwYpxPzd0A3Qdi93n6H4909oCdN9TeynAt7ZHYH8XP jUHHQhNI/u9bJUUTuOAf36w2DczATOe2xHepByuvAXFNHtI3JDTBicBMwZ+zR9tyGu9o 6sjpYuM/2inEBA1M9y4iVXmju7S1noBBjEEfe5w6SYlFAE82pmFNlZwllothk7cw2LfO IqYfscS732rT7AOzc8EnxMVMorDad+XYAQGopA8ueBlzB0BQtAn7uSnG5HO3CI07orRW dWsw== 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=4WadEyHKseQUVT0rB9PWSL7cW80vRQIVKerL5ejOPSM=; b=tk6Svx9UDSYZbsOwoBJSMDxQ53P4tVLVOT2QYT4ShJ7L4hHh56aj8zkCIS94MfO+Ef tGUDy+6SmdwuTdD385eZW3JKb3s6He8W5hSs9SbzK9lLgI/O6i4aJsfrB81W4f16B2NV f0BUuzhkJaWvSeRIRDsuFt0AJeXRPEqCIoSsaDog3/yHcTXzFBNFDZHhT08luggJfWlo 5bHFuAFdCatQCgQ5/LVv3uk4hyYWkuE0mBh0Izd34XSJAgT7s4t+tqizY48L9OthaE1/ T50YZPnY2roBfeIbKqhtHwKH/0yvh6xufGHDYHKlHvWv2ZUFqTdRlEYb3bbf7/6I710S Pg7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=apXAddBP; 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 z37-20020a630a65000000b004751c9dcf62si1502338pgk.509.2022.12.09.06.05.53; Fri, 09 Dec 2022 06:06:21 -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=apXAddBP; 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 S229965AbiLIOFV (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbiLIOFQ (ORCPT ); Fri, 9 Dec 2022 09:05:16 -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 A23C97721E; Fri, 9 Dec 2022 06:05:14 -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 1ED8162268; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78CA4C433A4; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=qRyAyv7DCxYIOlxXXpgDgiVYhhrQXHLZUca0t02tYg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=apXAddBPyF6ckd0fDxOBEFwwBJ2g70bsaR1CLhiYv+piyP9cSESieLYxOYZxSrJvW m1dHEWfEiXxuRJyQXw8FpL00gTyyam2gdB3keU9cyqNIGIKWwTKrxE0/e0OiTbahoQ h31gMUBYiyEplfhe1FdMbzi4e1F0ELhItaHiJ5/1tdHOqjl9wBm+vkXNIAaI3CiJjG weMap5GGQzy1lCDTA6rQx4w5/ILV9iqO6kWfr9pfi1f5CyOrIeD6QyiqmlTrwImOhd n3H524YFaH8qYx5qu3hAm8KRGhGIxOBNbJBEIeio4awfyrwuyJcYmvSOefJot3OYLV +vEGZ+Lxh0bFA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000RZ-Hc; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 05/19] irqdomain: Fix disassociation race Date: Fri, 9 Dec 2022 15:01:36 +0100 Message-Id: <20221209140150.1453-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745593266484753?= X-GMAIL-MSGID: =?utf-8?q?1751745593266484753?= 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") 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 Fri Dec 9 14:01:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31754 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp794498wrr; Fri, 9 Dec 2022 06:06:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6JULuu6VAT2DtrTEEHWEZRru9EYEayFmoh0s2J9PtQ3Xr7uAy4UbJby/tj+/COPUWvQxAQ X-Received: by 2002:a17:90b:4fc2:b0:219:f9d9:c82e with SMTP id qa2-20020a17090b4fc200b00219f9d9c82emr5983492pjb.42.1670594796389; Fri, 09 Dec 2022 06:06:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594796; cv=none; d=google.com; s=arc-20160816; b=EwZSVdQRNCJww0aeSs95XS3bUZ+mLVzu8EdC/IjP/3mf2joahdJbtBMCmuSheKDLad VWuIRPX5t2iwJA2rrb1CFBeJRBFpwFr0IdzBih4dwxznM6DNeBHxwID2E6OIfB5cQCi9 RsS+zWoOXgfpA9JzLGlKn3sqXrWjCy7AQ+obPHX3Hm2CdXM9NopQcgox2oQc5LykyI1l YIzdZ3ZmppKt0svXrIBpXLsFgQ3CBwp5ZXGj5WunVAjxNlS0txKFko1IHAhSPOePoc9c ODsJxicqxv/Qtg+oFQFTQAJ9XtDhXjen5h3leLgY2Z1ErTGNwkWpR8tXg001P7+bzodI cEoQ== 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=ftcIPpS9dnwX3FOCuGr8qp7lSyWNA2Hj6+qZ6hUSo6g=; b=g5K6Id3KF6Glbbd6oIycnusSDnFkVFvKCsoaXH88QwU5yrZWQKB9muQJ1ad81nbNIp pFacwSDg0f+amaLUYpH6pYLbo7VR7Q9sNlBGnjVUnNNChuGPAo37kjyFyKWWKJ4FWAOE IG4/l1kJASWWsArEBQ+hlENavgj7Jvh5XE9sDefKEaLiI8iOf7vVy2eCBeLGoMQuskLH O4Uwv4hLXl0RWvvVNeNRms2dRJNV9SXNzMRUQfXdGaBzcOsqAqNlhF1BIzNNUloq1Hd3 UzIZ9llQhZlXE6CxyNNdbxTvG9rOxW5esCVswLu3EVgC9mumfB02JZyZoNUniZE5Fk07 bdlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mjFT4DQ8; 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 p15-20020a17090a74cf00b002193068fe94si2169778pjl.37.2022.12.09.06.06.10; Fri, 09 Dec 2022 06:06:36 -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=mjFT4DQ8; 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 S230019AbiLIOF2 (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbiLIOFR (ORCPT ); Fri, 9 Dec 2022 09:05:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10A6E77229; Fri, 9 Dec 2022 06:05:15 -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 95C3962269; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CBE8C433AA; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=25WzgH8MXrRT4j0vWI1/G7WvfbKjDj7LuhqI1OtgHDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mjFT4DQ8z9ZlKuB/SCMNZRZ/RzrAZgiOOrJ0PfRUJaVRThztlaUcCpQPOu4kqduKI gyxKZjq/e81Mu8CIHXWLq5xUKKGKb6JyuIJBw/BylQS0Rpr25Rl3TOUYd2YtZajdd5 /WC7iKD80xZ7YxL4zrOzLMKnC9D7Ht+/pt5o/OBx4dZavApxI8yvOky/JU4yNe2Zhx Bj6cCE12Jif+aEbiNW9BRmMocaSxG2Dfyfe3YM4tV/JdJouLMRwajSrkkIQrqvPIpo iDinKaUbIMvf9pkyu2PeDD5xjNlU9HxV06/rZ2hAcYBptCO30KGgY3pOYVwhez79pw kvPrnTrp/85Lw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000Rc-Kt; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 06/19] irqdomain: Drop revmap mutex Date: Fri, 9 Dec 2022 15:01:37 +0100 Message-Id: <20221209140150.1453-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745608962295134?= X-GMAIL-MSGID: =?utf-8?q?1751745608962295134?= 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. 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 a372086750ca..16399de00b48 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 Fri Dec 9 14:01:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp794505wrr; Fri, 9 Dec 2022 06:06:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5HEz12ImGxaLVq8d+SGxTG9JU6aFZ3jTiIH5GDQmydyPquxITzBHui3uVypZqKcAT9oY/n X-Received: by 2002:a05:6a20:c18d:b0:9d:efbe:a11b with SMTP id bg13-20020a056a20c18d00b0009defbea11bmr7643665pzb.43.1670594797540; Fri, 09 Dec 2022 06:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594797; cv=none; d=google.com; s=arc-20160816; b=hwzdHc5FiAV5x3QyVmpcrNHnTiT1Fry1FCihz5MpfRQ3dOavbuQYpGDCBoR423ppqu jt+MwPVjSQSdaAr4dKMfX3/U7j6pbbL3EPsHpLvMBvYJTv0/4JhSgKuz+2JmnJL9b37b 3LzumJqCG4m20TADAxuClUgtmtTVDw6ml7PJL53JLlhSuq8NELP2VPtvqxX1NgEN3WvR 7p3OdX31+PfrAre0D989/2/T13WM3a1unbI6lHgRHguxSzyDZlZbRMoURPsae0wW0dZ3 2VppJP+HkP5jaXMVUFm/JvnUv2oQQF+Al1wDFppazMg4JvlK0O06b0u7mTFmEGD5b9n5 82Yg== 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=DtZzKYhE9ZSYQsC3O9iDREX3KPksRZt95W4w53P55Zk=; b=jUy/yeA0w7wBHmT0xFXZATnfvHkHT/OZkWltWiB1JjvpcThAoWHIzc0gOMkgAS68YC BNUmWTpucgX4fVQz0SROPuTwEim7m8JGPxcxhWA6o/nZuxCd4DdLx7W7oVvf06z148IM hwm0fvneY90SMiK+9B6SDVM+XtINxT+A3z2aSd93mwWs2pBE75vwSacucnqlnyHABfOS Hk2aPF2lrcWlb7BL2YINJrfullT2eTySjt93rVcr2MrF6KFS1siCzN22kqw2AI3tmO+s Yfr/m5J22TqY7KDlo9BpA14HoVpEFK1AI9VeFq5LDPBMMWmIJ1f53Awfk9YsVGLlCP+F G09g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lesnMst8; 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 w70-20020a628249000000b0056e0ac0f382si1861462pfd.233.2022.12.09.06.06.16; Fri, 09 Dec 2022 06:06: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=lesnMst8; 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 S230044AbiLIOFb (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbiLIOFR (ORCPT ); Fri, 9 Dec 2022 09:05:17 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 210387682B; Fri, 9 Dec 2022 06:05:15 -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 AFD346226F; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84661C433AC; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=1UsTmUxkh2RO4JtVXWdoi0GSvnFbd1ZBNIWS//6pOwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lesnMst8ZMnQFRl6LMW0T4LFSGmVlDGTS8EafxqYjlGQsJC81FBUeJt8WMsuJ/TDz r+PPCTtfBNWzTB76qamYg8zRlBxoDn9bsJBFIGPAPFH5f2qLUSRFh7kAtaDtV1GDG0 I4WhkZGYz1CsaMtfC5SLmZczWBFUpSZwSMAtwpcbR/t3PwfJFmEQlpdNpniL7KID4q PBpQi8zys3EBMtQ6wc+5PCp2ZMy++T49fhpcgZ0VufYyx5xmKB0uvGN9h0lmXYy+Dn GlTZEe23TEc+tqeqb7YzcTjZJMROSQ7XmL/VwUuZfzmeDwyIvO4u/egCcM1fTWeqvd kC+qduj1gftsA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000Rg-Nl; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 07/19] irqdomain: Look for existing mapping only once Date: Fri, 9 Dec 2022 15:01:38 +0100 Message-Id: <20221209140150.1453-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745610009939631?= X-GMAIL-MSGID: =?utf-8?q?1751745610009939631?= 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(). 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 Fri Dec 9 14:01:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795037wrr; Fri, 9 Dec 2022 06:07:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf6UL4kW2tpLOGo/3XBpJFEtOC5D8yjs6C2rK540YvgSt3NoIGznLezbvuuWPglkG9i/9YeF X-Received: by 2002:a17:902:7081:b0:189:907b:7cc1 with SMTP id z1-20020a170902708100b00189907b7cc1mr5712362plk.51.1670594849281; Fri, 09 Dec 2022 06:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594849; cv=none; d=google.com; s=arc-20160816; b=GKHcwgRuQYZjOaL26FzD/pc49B+n10s/8hQUDrFxPnmoprCN/T6a7o6CasmNd0+d8z kkEJa/vu7imx+E2EwDhnlZb0YlRn7WoG6V1qMnxXlce1uMVVpRBwG8yCpxQErp6WSRfQ YXZcrU9DlEIN8p93Up0Tac87DDnEcrDRFoDFk+V7pfPLWKkdLCL2GYdrw3ZeGgwqWGbE Z0Y7NKEadSj2b0xeuPrtZsYp8/NzcsdNwS+C9sFCof4SlwngiFYQyaoNkm0Suc776TCU QWgtcp7MBocUW0MMzxBM91EXJcRdbQlWDs4YtEbPSU7mUXZyu5xmU63TPkK3xi3CVR5V /wtQ== 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=mMoakzuisq8sfWECDfM55I1jMZJ3dswF/ljH/Dw99T0=; b=SAdPGqgfTgHBnOH97RgU72rnB8UY0fZUp+7Yw2DPCWNaMD45tFzQNXhzUVW2HHwLfS WWHrSikGkV9KyQJdK0VhSpFpu2mWcb7w2D2BiqagjgcvpZgvZ6gvJKUK/Xf+XU6zyTvh EZSCBRWUcXD2gwxIayYGHp5c4kY7t6+HF2TSZmI2q2U7ovfj+L25oorlT2olQ4gKG/Bx HwgKOFxmZmtkor9a95vmbu7J68XODDcKRaz/nOHVgGXoAfiehoSkrBmCaapT/g59MY7g BZDxKiGo+zawq/cZienJ3DtErdIVSFVpIdae6LuLHAZW62sDSVy2sI3kTKeU1ZuY9hsb e9Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RPRB6Xwy; 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 n1-20020a170902f60100b001897390a9fdsi1675373plg.541.2022.12.09.06.07.12; Fri, 09 Dec 2022 06:07:29 -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=RPRB6Xwy; 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 S230134AbiLIOF6 (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229942AbiLIOFU (ORCPT ); Fri, 9 Dec 2022 09:05:20 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B937F7869B; Fri, 9 Dec 2022 06:05:16 -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 662F7B82884; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4141C43324; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=lHmq3B91dsrvn0iV4+ZnPYLRzHPArBilZTdSdeuIYww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RPRB6XwyWPCrk8NYr8tPhVSW4ycG+ZuiOob0VpN0c7XhIQ5ezg/uf497ovusn8T38 gCL9SrqF35c9X5WSUqMkzpnypDWlvXnstszZCDWodj9WLgXEqgkRwrGtbqEvjx9rB/ NPtqIpWK5fY1+nttim5qJ9D36XtdRTLkAsmZu9B9Fr2uzy4z5ShflHqXiot00NEbZM DGzGpAIdbhiEmallyO/2LITF3ae37tn7GzEsHqST9jEQRE9WZA8jbgJbLQPN/vu8mP /Vxjhw9zF+a9cNzrVvQ+Sig3IbpzH3Oaro5Fh7rRetaThsVwkG0hut7jf4apQQzq5s /cSsAS9RnmVyQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000Rj-R9; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 08/19] irqdomain: Refactor __irq_domain_alloc_irqs() Date: Fri, 9 Dec 2022 15:01:39 +0100 Message-Id: <20221209140150.1453-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745664163417878?= X-GMAIL-MSGID: =?utf-8?q?1751745664163417878?= Refactor __irq_domain_alloc_irqs() so that it can can be called internally while holding the irq_domain_mutex. This will be used to fix a shared-interrupt mapping race. 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 Fri Dec 9 14:01:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795306wrr; Fri, 9 Dec 2022 06:07:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf7BFpKGAI/K9i01lry94RlBxkPGoM5OhHKtWfGcHo+hxjSIAacJJ2DA+uYMYhZ5gMK9ywtl X-Received: by 2002:aa7:9555:0:b0:576:c9a1:ec35 with SMTP id w21-20020aa79555000000b00576c9a1ec35mr7350226pfq.17.1670594874269; Fri, 09 Dec 2022 06:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594874; cv=none; d=google.com; s=arc-20160816; b=ZdVgJf+CucZVT19tOp8Y5mktAOEVAyjBbAfwym6xiflVf5/m0RlzQyJR5i0MMeWZzf ubpPvISpWfu5q0i8Dtv61gAOKLZt49lN1ArsXMki2YHhEpk3x+Wtfeish3KgRF5OV91/ dBixQDz1NAwDj/NfFo5Vjca0/WUnvjDSE8B3Uw97FjaW4wJwP7PeO2zOesW8BWU1QwHc 3oXixD8mDg4lMFQysnU/122weexrRFbrCAace1n3oUQ6MSikEk93QHV78wI+dmcXQl2x Rz5kzpwhUs4LUojVqxXbPdFkdhA97LjgvNQYJ6ddv+3ZN1liU8L1QnyoVqAByBWe643J XEJw== 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=D98X2LxC6bEzSYRltVk/c+FDztTlnpxw3RTb1PCtF4w=; b=Pm//wYhehRkenCc7PAcW8Jkgxj5e+46w6tSS7MELQNgpBRyJMYyMMDNaMfml5wqSxK OW6nzLNkFqeiBkydO1ozy7aVtf2ls+KkXGFXZvgbR8sXgrwsE/MDSGYxGcQ6h/EuXXLO m93MfH23aPxSim6RrDXyP2kPI6l+h0KlQYJmkOSvyr09FFPL3gMpSUd7Hfn7ZP49M4GI e82rZAU99c4ROPsS6x5bG4WZ4Nwvfsy68rw9XGCZt3NwUjTq/bnZPITpXJ1aGfbx2iSw R8QmbqkjrpBUyuv+cvyWVspkmh1jsELAGv/Umz0CfHoVI7YiNbyFKW7DkjiOVgf2HWok BfYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hXF3sBDM; 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 a11-20020a056a000c8b00b00571a5c5eaa5si1915948pfv.150.2022.12.09.06.07.40; Fri, 09 Dec 2022 06:07:54 -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=hXF3sBDM; 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 S230057AbiLIOFf (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbiLIOFR (ORCPT ); Fri, 9 Dec 2022 09:05:17 -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 2FB367722C; Fri, 9 Dec 2022 06:05:15 -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 C28CE62270; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B410BC43322; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=TMyLqWF3g4BsvWN/vPIOrQXHZItfyvQpoJNh+QahnCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hXF3sBDMaTy2y9hAwRc40/AkC5aUSb78OM0u4aKmhoYp5Qy0aGxoKWhRUqzRio/3y ON8IwOiMehMqprgc0pLH3BmaZV9mhTD3K0Mxczv+7V2o3pzBzhUFM+73LWnhUKkUbS QIr/hVdZ5/v9+LMRq2X4h1sT36/vzh0+NBsJaqVcGCTleI4s6F+mhVj0es6GaZXxwF 31W0aik7quS84VpvU1l78bdo26WSmlP+qu78XWc5UtOa6oPPVl9o+XMgzpHj2vf2eV 5gDHYleGO0V4x4b7PPDAh2P22j8ty1wPtAPAt99AB3daJvII3vYynBE83MYD08ZOOZ BGkwWHqbtZcpg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0I-0000Rm-Ud; Fri, 09 Dec 2022 15:05:30 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 09/19] irqdomain: Fix mapping-creation race Date: Fri, 9 Dec 2022 15:01:40 +0100 Message-Id: <20221209140150.1453-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745690779524234?= X-GMAIL-MSGID: =?utf-8?q?1751745690779524234?= 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") Cc: Dmitry Torokhov Cc: Jon Hunter Link: https://lore.kernel.org/r/YuJXMHoT4ijUxnRb@hovoldconsulting.com 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 Fri Dec 9 14:01:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795688wrr; Fri, 9 Dec 2022 06:08:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7DJTCur+OmDM1xeKG+0wOEFiQ0h9B+QKe71cRFk5CXZXDFzI5O8FoqvyQ9r7CyOcqCkAbE X-Received: by 2002:a05:6a20:6f06:b0:a2:e391:f8f3 with SMTP id gt6-20020a056a206f0600b000a2e391f8f3mr6897411pzb.34.1670594911948; Fri, 09 Dec 2022 06:08:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594911; cv=none; d=google.com; s=arc-20160816; b=hwYBWCoYN4VpX7JGPpJDxcMsHlr+CVNuh/CqB90KqcSotZMfhz1Fa5Et8Ls30qMG1R 5Uek29ZWuRuGA27/cRWLwkOp/9Wcgz3VleDHK6cIlyJNr8VCnCmiFInI4xGxOHnloZ6R LeQNca/Aw1iOc8FFnrFmAReHJhiAvoofVnK6nJOXh4yWVQxtlKGlrWRPAvCpu3O4N5kM M48dTFYaOZk71SfrJ7iG7eJCfYlCD7Xr/JFRk4VWBdY4cj/Cri9OZXrQ9Vsu3u03I56e qkT7rz89WpA+k/WJzqNlBgus5ofSV4qOeMd9Dr4cGWiwSQtt2J/Hq4nfFANCnAz8RS1o sL+w== 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=HY98ER5wylNvGJb8LiSDKkJHDekI/BolkpLmVwke0iA=; b=v+UjNg4XWKKfBNpRLIYpO9ThJzUIHx9r07NsMGNCyG2VoxKaK/L/OYSSHYMfRmoi0I dr2Njudmrf2rIrep0T3+92/fh8sq9ajXvOPPkgGAkVCLJD0gf9WlQFtrBrSOYllb4IfT l5Dcb0f8mLO2hB2g7S6aF1td0AMu+HEb8Ovt8b1PCEIOOqe8ZAZ/KaKx+sNhSnpua4b3 2EvdSaCQ9iXl/lBmshljbHcmpDaTqzz+1eg2qsSPIv/2PEVwNf4VSs6pk128dBdoIbVQ oMNTN6faEe6+Oe0/4ThranWb/ZyFY6Z9Fb8nQkjQaKGMcF7OX9Lg0vB+lhRc2FpBlQdR R7Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VKfmdud8; 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 v11-20020aa799cb000000b0056d480f7b92si1702413pfi.378.2022.12.09.06.08.17; Fri, 09 Dec 2022 06:08:31 -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=VKfmdud8; 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 S230148AbiLIOGG (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229947AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0774977209; Fri, 9 Dec 2022 06:05:16 -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 3206862277; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9572C4332B; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=oPl4pvwV1ibYKGzWqPE8Z/9v5b9TU2RoMS/4leBXqsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VKfmdud8A78pJzExYNYQ+U4s3u8OKfVXagECsOzWHPXy66/hT0yis1zPJ5bTEJwkf 2TESlFeolRO7vpH0WOyJMkk8sAelvUHhlQO1sAHQXs5T9fpSjE83hgDCOciThGTXRe ht/FDTPHI4NWTkn9AGNi8YcGcAF/HTLYotvk/fj/fx8R2K/JnTnsZi1CsW8b4RAgQx SX+/rbaGDuMlw1Te7sM12DSA/1p54pRAYqpeIAhhrdMeAuZ2i9uuKOw/xN/hFqLpZC YYrDjw3kP8pMZ1yrdqn2w+tBGSbHZ2lDiUdJMSODa46qWfH7wmrOpPMNRjomDPr6Vk EMlo4QMH46JXA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000Rp-21; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 10/19] irqdomain: Clean up irq_domain_push/pop_irq() Date: Fri, 9 Dec 2022 15:01:41 +0100 Message-Id: <20221209140150.1453-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745730437480484?= X-GMAIL-MSGID: =?utf-8?q?1751745730437480484?= 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. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795487wrr; Fri, 9 Dec 2022 06:08:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf50gDS1+2MDMJGfgmjHuA1JVRsKtSq1hBLhlT+pjbnb+Ioul/q7cBSnBKV8un/Lueg52gXL X-Received: by 2002:a05:6a00:2189:b0:56d:59f0:d291 with SMTP id h9-20020a056a00218900b0056d59f0d291mr6604380pfi.18.1670594890792; Fri, 09 Dec 2022 06:08:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594890; cv=none; d=google.com; s=arc-20160816; b=dNTuqmSvx34L1PDAlwFEyWsXHBELZyIKC1rCwMtI69fABCUfcBqM0QrFJM/6U8jdyt WKYR62LiOdiRu+E+rS52FchofaMepkwdkfZGj6uMUcPI8J50jhIdTtl59DvyyqrWHehJ n32+woeb9FMCuaU+N9U4YhApkW9mulVQ3hH/kQ4BdfmAKD65MUN0DOSmPVjJVaLtL94d 1tCj3tIo7JqkEvoy1L/9Ld69Afgr4wtTK4HU5Zz1uAdtEEvx8X4L17YAcTz+XvT7eg6t AlP3PZlABTlVaokLG3IDWCOFz3suzxszYE9srWPQ8D5MZlwNwhFvInKRm2nG6V3e1WS4 YIuA== 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=NlOQ29Q54riMu3mdOTcCHirFG8hK7BzJCn4n9g8qcoM=; b=H6RhNekfBn6TLHswEkqvI+XEo5kVBodWRzogQmAgFO1Ez0b00qrMlGkmRfarUGCw9b Sk1KxUFjBtuEOTIzE8qFVvW/WMu7oDJfY+liGuazdl5veGrU2LTV5fD+DqMRYkFDvtGr MhuB9vEQcakiCnPP8mjImezHhTHhsIhxZM/IgV+Xx1+oO6j+k5SpZqBZnTIERZxYhuzz 75u9GyLxzRhp2w7lmLmgM2W6QOTgyTqnul7HYFVWiqT6RB4WomxwdM08fagclspg1H+e g0K7i6qfhvjyvhRsvshUtSLLZkM5Xlx/gZO2qMXyjdc+RWmfrgneAsi0X8MYjn3CU9yi dvhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kt/0JpLZ"; 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 h3-20020a056a00230300b00560bdd654ffsi1848444pfh.314.2022.12.09.06.07.55; Fri, 09 Dec 2022 06:08:10 -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="kt/0JpLZ"; 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 S229968AbiLIOF4 (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbiLIOFT (ORCPT ); Fri, 9 Dec 2022 09:05:19 -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 0766D75BCA; Fri, 9 Dec 2022 06:05:16 -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 DEB426226A; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D964CC4332C; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594713; bh=WgkN5Je4cNOPVZ/hkI2lCqO1EkpEAYkIqXZpsz/aHt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kt/0JpLZVVFNgMrMfpluMRkkS1efDFdyD9NG2ZAWI0Yy86pZT9zhcPVjSD6Q5JhQC VOhYIkAxut3lwd51nXIxbqzhfnpeeOraosktgApMH6WlqmkxwkGBA45z8IlaLPjz5F /7OsANSOCDKqf6/C0788t7x6G/3JNYbCsRtXsFXd3q9N6dOdlRfcOhyRCsDtpdZpRY 596PPCham19J1eMFCGq3Xd7G8daWN9xx9UI3vLCYwKDmnx528mpZvoGzMSgBQWhvOI KQNBEB3XnMIPDhOs9rx//GTKhS8q15YLJl8NktAiHzRTPSqaJhDl0AXmIEpl/gGbDa ubTCupgoJr0qg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000Rs-5E; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 11/19] x86/ioapic: Use irq_domain_create_hierarchy() Date: Fri, 9 Dec 2022 15:01:42 +0100 Message-Id: <20221209140150.1453-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745708320872376?= X-GMAIL-MSGID: =?utf-8?q?1751745708320872376?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795212wrr; Fri, 9 Dec 2022 06:07:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ECEJwZmXJ4JdZYvPr8H7UzhhTZTyjBPYbZePDq7fb4fetJsrE6MzosTe5+fueetUKeemN X-Received: by 2002:a05:6a21:108f:b0:9e:ae77:aad7 with SMTP id nl15-20020a056a21108f00b0009eae77aad7mr5640185pzb.29.1670594865633; Fri, 09 Dec 2022 06:07:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594865; cv=none; d=google.com; s=arc-20160816; b=ss0QRd3czkAtk0/h87r4IQIK/rP+BszmlHHT9JSL0MJ6PHmnBuVaSJgXCEa35FlG2F NhKxbNLjGhW/O8drm375is2al+tjuqbgiqLKh/JTgJMk6e8YVeBg8U/PjQBpWwi2yHPA ivrNS5j3IGPQEEzP3+6nIPsZtVCMSL88FaOqVBKGqEBBaEzHleCB9Ih2EPoRsEdueMql E2zBnOsvzsuJVxNGAK5j8IUM+er5YKLnQOgUw1Ot5Uq5ukI1wxlETfCsbq2KGtNi2kxN TWut/hiEncfe23TONW6Sy0TBlz56QTl4OhhZh3D385CUY5H7K7i1VLDlkngFRqbaWWie 6WSA== 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=DWeG1268g6v4b8wuSax0W2FlWgBUonuvP/aVevr+xC0=; b=U2vs0B8DfBUPEf3j3uB0lpN9Xu0drkRzO96OdWCvsqzvk9kvK661E+Cl5AeOe7mqqY UfgcKVLCThcXxTGCEfJ2+J1/ViuOvg7S+QE91w+s5NM6t25/5d5m1U/XZWLDaes2Xw+x mXPtXgZC5IKToq09k6b3rjcTNH7qC/q/aaC5MCbxmZ5WQHO4T1aYEykjvEnELkpETIGd pYLFaSUgl0RuX+UAvN5/RPPPF7ZIUH59t6pPuT5W40ILs3NBpU3RfGavQ1WTHA0aJIlr LehvdDOaMQuO6qMS6c0oGFHHgxSNpPqAHeGPCkBV6+43VWQSfNKPAlySe4LK0H+2GeqC fCMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ek8MZqQK; 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 k62-20020a638441000000b004789f4ef89fsi1519687pgd.875.2022.12.09.06.07.30; Fri, 09 Dec 2022 06:07: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=Ek8MZqQK; 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 S230018AbiLIOGZ (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -0500 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA967720A; Fri, 9 Dec 2022 06:05:18 -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 7090ACE289D; Fri, 9 Dec 2022 14:05:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 025F3C43332; Fri, 9 Dec 2022 14:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=6gyDnOh8vPJma4ZvWV3odrUEiz4K7dnpkJYUU+2k8Ko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ek8MZqQKLsJ2LM5eTC6LlMFwRDP9T77FoT9Unw5x0i8TZozYTJDlgE5dX9OYlJHLc fBVnwf6BIAwxVgSKs3qB/zWQdbukgQ/7haodw9cswsTecqC3DzFYWhW7tLKLKmnx9X eswae/iOsywzrd85JzubZr0kZ2YR0QLa86l8DW2Fgr3oKPcaT0cGd+5ySQy+4cPl8V o5tUk3iMxqfJtiQRguut9wsTvQ7ELUH1Nrw57f+xm8cUaNkekwQy+iHBJ22/vGAcaX +Hd1y9+od+wFDSIvXyPVRJHyaAESxqMRuf8lViOsI6sWcSWVTr/V1cqaedM+7FkvKv DfQIUSAXNMN0A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000Rv-8T; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 12/19] x86/apic: Use irq_domain_create_hierarchy() Date: Fri, 9 Dec 2022 15:01:43 +0100 Message-Id: <20221209140150.1453-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745681672723067?= X-GMAIL-MSGID: =?utf-8?q?1751745681672723067?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795099wrr; Fri, 9 Dec 2022 06:07:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf76xZMEapHKQstGULtDeFkhBopSN9raa42gSfFhPiJloaEe1XgzydF8zVaVHrZpB4+Wi4ld X-Received: by 2002:a17:90a:b382:b0:21a:3fc:e10d with SMTP id e2-20020a17090ab38200b0021a03fce10dmr5737788pjr.6.1670594854044; Fri, 09 Dec 2022 06:07:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594854; cv=none; d=google.com; s=arc-20160816; b=X9668pZVa0eWxzxzLFi/WNgqLgCWZHM4yH7VtBXUFOpAQf0+z7C4dul0niknQceMQ4 odMVvXb3oE2UhXxsNqHBRb3sD6CrZ9BnRK+USE8H+GY8XUAdi8gm1iGxBVxCeHk8qQfd VM0wv0LdCSBovst1aYhLi97BbighD7U0sMXvMUlsnw+p+BarNXwB7xN4gQpsFSNpNTu1 a0wvrX8r1ISEuca0Lg7WvCYMpYVmb+T8SjPnHoLGAthKfHXErGXq8SXI5PRvzoADc977 zCwqUEi/6DHlDHxHktTobhCUe475+NIFwE6ybV1Ko7IGNH9ehDHoq/IIuTQetQiqQpL7 Xf0A== 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=VI7n3F8eClzrikLhAyXzOCzZi37Qm+6qhrk4FWjzz2k=; b=QRZHkI5ZzG1did19dCxV30sO5AW5vFZVUBBa5kikVetQpWyhJPWjp1dRxSossaEO56 z5IYK0bRNLvCCHbZMCjRrIKA4uH8vXRw/T0zXmMGaiDpfYFuLdn39tIJaIhNnYr+o9An ypVQMq+QYVHyF453LeDhF7ErEWaMSFGVky/exEf8Zxu7HvQQrEURhB2w3ciOg39XI+Gl HG8AJdjj/soUTWyyE2A+4zoyAnswi9FYtt5WX4P6LNUcGS339n2ueMJFWhktrMl/Jbpm WLLJsxaFdHQV201tIYlw5IQglJvCL0r3v5rKAvLVLLkP+Ph8yAfJYXaj//VawM/nAunk LFEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LQH/23aQ"; 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 a21-20020a63e855000000b00476759b8788si1603844pgk.861.2022.12.09.06.07.20; Fri, 09 Dec 2022 06:07:34 -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="LQH/23aQ"; 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 S229847AbiLIOGR (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73EDB7683F; Fri, 9 Dec 2022 06:05:17 -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 603476227D; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20BDEC433D2; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=9AtJSfDyD2LZYkx9jto+1enajKmHrHjk2oxsdGhfsTI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LQH/23aQv5CuTQY+WSVZhYoXYYPKe6yGP1JpGCGS4WwGIs95UD34/oFrns8IfdXbb kjRAvMWLf3p5JqVYlg10HwURYxs7WqpDpqDM5cK2SGKIrxzHrv1v+C6g0N340RjwSw 2eLqhphBx0Pww1X072puzRf/Ag9/cpnverpYZS444l2SEsNGj70hDSF3MgQhNYF83k r0aIP18jRdwkwi+9SRwUDPoeEbCscYT2eW0fWFVqLej9t5pHUkPUzqiQHl0KsIe9kR gEdFN0uxhpNhLBIrhQKvvGmOTyOH6TSY9b5gRuxSNk538JAR6veJDICDg0zoLfCPoM oN3icrx9blW0g== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000Ry-Bh; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 13/19] irqchip/alpine-msi: Use irq_domain_add_hierarchy() Date: Fri, 9 Dec 2022 15:01:44 +0100 Message-Id: <20221209140150.1453-14-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745669721835276?= X-GMAIL-MSGID: =?utf-8?q?1751745669721835276?= Use the irq_domain_add_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31757 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp794623wrr; Fri, 9 Dec 2022 06:06:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ioVkBk0vIm5tlWZV4GDss9jOJ9RnPL8TsTqyAMFiDih/Q/9885ucYR2QzpsAh9J9YqsjB X-Received: by 2002:a17:90a:6506:b0:214:222:6ed3 with SMTP id i6-20020a17090a650600b0021402226ed3mr6313307pjj.43.1670594809654; Fri, 09 Dec 2022 06:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594809; cv=none; d=google.com; s=arc-20160816; b=X+OqSUYP5P6jFz7u2DiXu/HPOKprG3E6oX2RslxnHpMfVoHWBTPp3RHE4CuaJFONdT nF2CuNCGR876PstDreSOX/n5ZsgaYGWnUlqhciJQMSRVlAxsjeSG8bx/OmfKQ7BXH4tu cuw7/8m0HGQmo+EfogYmr2jN3CLOs8nEpV4yFZ23wOh0QCIxN5ufpgMqlP2TATpDP3pF F8gzjGfzdZi0TRGI8adbHzu5EjfI0fGzab+tS13hCAkHaoLNRBIOV5loK0xiw3/RkGIn XAq/izDlxYLNW18tfLCabd4CRJMAHWBFYqn8ALd0n/w0++rgi4FbzPE5rFt6W8Macb9M Ke9w== 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=kcEXQ8fWmo5QKc8dQsC1MbPmOVMpdGM/QMWk6N5iHf0=; b=Lb7+ZJStUz5EOEnJ/IyQBrBzRX/0hS76NJnt8oQOUydiYfy5e9PAtHDguHZP9NirG1 0+dL2rI9Vn4B4oXeEmK7O1PtjEa6ZqPazeCTlIma5Oka4IK/4NjFww+7Gjq8QfwIpd8w tLAG/nPQ0eG6LaXsKf/SjEUZoHpGcTPiHiOYg5k6Ozb2J/qAgwvZzgAREI/ThVSftghu 5roOaJfmJs+bouBCcYA15JyLKzaTeJcuzTjFJ+E/tuHU6kUSM4V4A7zadpT+0xMIqrWZ htL+i4yInSfLDmzoKQ4e3viocayi9SRT2Cll/4ZEtXLKcEBE2qFP0D6RmIPNM6ICPpUm B8CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BFDsvV4J; 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 28-20020a17090a001c00b0020a95eb3d4fsi1638939pja.128.2022.12.09.06.06.30; Fri, 09 Dec 2022 06:06:49 -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=BFDsvV4J; 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 S230111AbiLIOFv (ORCPT + 99 others); Fri, 9 Dec 2022 09:05:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbiLIOFT (ORCPT ); Fri, 9 Dec 2022 09:05:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 076FD76828; Fri, 9 Dec 2022 06:05:16 -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 EFDE062273; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3025DC43335; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=ZKlz/YPbyRCy6KkXCyyH1Wjmy+f6XTvrp78tKhH71kY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BFDsvV4JYL8Ufghpt0gvE1GAPsID7hham9gDxCAssbxD3BSmwFSu70uNDmc8A4KbX aR01ktHPCbycG/+w58ceoDDD6kKLgN+CAmJb6XoZq+ycC3q3lWubq6iOc8RnaQ1SoR 8u8SOsRcqTQsETEw4p5j9ZayGV+LmsgThr04Bg9SGvIiQLcIptkFZADYUP/y2TSNC8 lX6F+EbVLGujT6fVX0X1+AU79BqwnKVSUZDwMfYsp7C0IiaSsTnCvquFznxpOvu/gg UbAHQlvJfFLzabTGFGPE3Bs36RCjY7BMhTsU/v3Q6DGW5J2ePx7pd0dGr4AVipCNyu tff9fLn0RHH4A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000S1-Ee; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 14/19] irqchip/gic-v2m: Use irq_domain_create_hierarchy() Date: Fri, 9 Dec 2022 15:01:45 +0100 Message-Id: <20221209140150.1453-15-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745623129574965?= X-GMAIL-MSGID: =?utf-8?q?1751745623129574965?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795894wrr; Fri, 9 Dec 2022 06:08:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf7TwiLliDBuleEF50rGC2FBJaxqearl9vGSaUT+BF6Vq11/iy8kpEYM+mGufrgU+wM1mt+4 X-Received: by 2002:a05:6a20:9f03:b0:a3:960e:7d0a with SMTP id mk3-20020a056a209f0300b000a3960e7d0amr7435911pzb.58.1670594932103; Fri, 09 Dec 2022 06:08:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594932; cv=none; d=google.com; s=arc-20160816; b=Al/9OSrO8wHDxWYIgDAmpEbk/26c+gQsclHD7uIcBQkX+CfkD5R3o+dmM3URT79Siw wQ9VAuupY6DkC/q481Lp4IRpvOth07JtTRTQ9VdRWoEZpJL39G5xqIGZcUJER31Cn5se qE64NyDRN8mqKo66DWIPTAtnpzrINjjiYn3oWWqgvIzKWCsYRkeUa19sQqB/0c+U8Ht5 lFUTRa3eNQrmEelGwPjZuEzpF136BxubDire/xvqud86jgv7sa4sXPAzLFP5Pn+c6bm/ N8jldmGT5qafV5MaAaoVKN6QxuhivPyQZZVyp/RnRF1xSqnJXvyOIJQR5XYDyGdr2FZf wD3w== 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=B61zXv09Q9TRJZQ2Jw4n5bsIyzKlZyxMbWSXxIzRwnA=; b=d9dKr4k2r/sLqTgKroBaQ8QkISG8fELaWolmPWSNBIK/3IN5UrAt1lEoJwjoN6HlSx +rcz7qdSzQS/RiGPCH58Atj7S7IAfxkvDsxr6oi59kty42DDQM8DOzBXGITxtd58xwDl A3XUELLS2gg/uNEKwkGnx5MwrhctOQ1RihCmpFdhbechM+fFNlFc8oOKF2wI6kimgJ9P 4sr99UnsrRZ9U/3zSh51c6DNf5teiSgsTE039GF7YExi6cZeMle4PCsM8CU5DUEGPMtg RBG6bIHVvWFQ3lwK/Y24an7wPehM1hRrAitvBOd7fy+ZgBNgDQEq2Pig6iFHjSHfoPII /Yzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BpiDKarN; 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 x5-20020a654145000000b00477ff64b022si1592346pgp.19.2022.12.09.06.08.37; Fri, 09 Dec 2022 06:08: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=BpiDKarN; 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 S229488AbiLIOG3 (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -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 E57EF76158; Fri, 9 Dec 2022 06:05:19 -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 06F03B82888; Fri, 9 Dec 2022 14:05:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39586C43336; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=UP2+AxwTenj8IrLgN7iAfjLcXLHT12juB5rPhe2Zwxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BpiDKarNH9X0K6qACc5wCbNpoj3PrvLBH3ImpbDVxAxxji2VVF4P849xUehHurjyX t/kNzu4eYQt+hcnRpVw/dzMaltG99Z277c3qMosBOIHyxJNhppT/gnExeOPO5PKg6Y YSddxp4S+zfGSnuYnWT7LUyRzLcEjju4Mjr7PjLEKYM2/TQAPqUysd+44AuqKUe/oV N6eGq6TqROl5p/7FDNCrvnWWbp3qa2e2ExaNC2Ptb5qd3EAMJvwBVtRuJ9sGi86DBs hIFXZ5zNcVYmc9br2fVUYWoHw3M8SOI1VvlAbHPk3cFYRer2PeolbfSauun3/Ci2x5 StOGXJZ8dldiQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000S4-Hq; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 15/19] irqchip/gic-v3-its: Use irq_domain_create_hierarchy() Date: Fri, 9 Dec 2022 15:01:46 +0100 Message-Id: <20221209140150.1453-16-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745751182227470?= X-GMAIL-MSGID: =?utf-8?q?1751745751182227470?= 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. 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 Fri Dec 9 14:01:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795038wrr; Fri, 9 Dec 2022 06:07:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5x7YY+tl7ye+iKuDj2XZevecuPnLQxTuUOuFDHk4h17nozUM6SBh7xMsyYlSGwhwO2hWTF X-Received: by 2002:a05:6a20:bc9d:b0:a7:187a:7b0a with SMTP id fx29-20020a056a20bc9d00b000a7187a7b0amr7787376pzb.42.1670594849347; Fri, 09 Dec 2022 06:07:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594849; cv=none; d=google.com; s=arc-20160816; b=mBQ6KhFqDda7ZD1tJnZV12/uep0jj25cl4sNHb6HjKqAnh+TdV75ceg0r3MVHy7Kep IO2H7WPLKJaNZEkdkDN3v3dYZfz8WruAcD+zVVfrWZXwkq1ccvpK00xDh47oMvmoFP29 JCKWOFUTo7bOlfA1IaPGwn6K6KVAm8mr2fZPgr847sBkyT0KeVGT9bmQGsW1i94j6XQK A5nczVSDZ7wYaD6SOifn56hORRwL22eD0/52J08BLpPabnXlE0VUctif8gpHoG/sRETo sMtmtnZYcnCou1VdiNExm9HbQszDIz8h8+RvPaGFYNfAaXmKMYzsHIgj4tIZbsQxNhij j6uQ== 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=Xo1QoGD/8nidNxlNAHUR5Zc5MFBAeUJyXXYMPVP2KSM=; b=jxi8ygRqQWkYVLfLZ1kIzhdQMYu++NZWs7P5tD7TRPrWY4Vo6dgUbLQ+GWmVT3MJ5t Yu07Vz6ImST4iji248OkTyDlr3vn7lOfsu78nbsNFYH9pjeQLX1rc2oXesUw9qNixK8i OTrWngVRCyOYJDT0ky3ROkVbkJPujxtDpiznr0kX/7PaoMIy4FpuqVWsp2yJJX4x+yq3 IB64RDgrth8Sygtx4WDerQTxfQsKYdll5/zs2athSwJYE5Dm9dYzRQ8mR8lieDwpmQYc zaQs6hmtMqJTn3jlMvJJLW7knqvDq7JU6FpEhnwkeZ3pOSJuPgulZKe8w6x18IkYLtWe Bnww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mnf9JEUD; 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 s62-20020a635e41000000b00478e541eb23si1606896pgb.745.2022.12.09.06.07.13; Fri, 09 Dec 2022 06:07:29 -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=Mnf9JEUD; 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 S230152AbiLIOGM (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229948AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -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 6AFDD7616D; Fri, 9 Dec 2022 06:05:17 -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 6395F6227E; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D30CC4333B; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=1R69EjNecFlegnni2yXQZM+277REaHNNTHY/K11udy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mnf9JEUD7JHMYGBYApLf75+mZmAgrtsrYJ02sdm8UKC2Sf9WiJgIm5/9s58scqcLB iMtYck+IjZHQ5NGdTeNIiuJmq3Ddep6kGCG41Gs/xqAKBavdghFv838rjjAeEhNPIc sIvb9Iea8qtCGCdJNHMyAKMcVdsw5vLT1BvE2KC5o0q16uJRIeuvQY0R2Rk5qClBx1 2G+qwGLcc78nH8cD+NXIR9d1vIvzGqZk6E7N6W4bBb6F4pCELIgbRmNirC7MizYes4 0RrKS9vJeFfKyuIQnaUo2mBhmMC5AcRArr+t8fATrWgBEKxPZuZsCwpSJ4hEJLgBwO xnQDtiWmGSYcA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000S7-KN; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 16/19] irqchip/gic-v3-mbi: Use irq_domain_create_hierarchy() Date: Fri, 9 Dec 2022 15:01:47 +0100 Message-Id: <20221209140150.1453-17-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745664774095854?= X-GMAIL-MSGID: =?utf-8?q?1751745664774095854?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795863wrr; Fri, 9 Dec 2022 06:08:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6c3pSqtAEyztfMpU5qu23MW4fSmXNLl75RJGuXiXNaJAsVKku/ZiNbMU+lsQtKuOs8hnqs X-Received: by 2002:a05:6a00:88c:b0:56b:f51d:820a with SMTP id q12-20020a056a00088c00b0056bf51d820amr7338766pfj.7.1670594926926; Fri, 09 Dec 2022 06:08:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594926; cv=none; d=google.com; s=arc-20160816; b=QyjWmuwY1Mu7Zbi3Ot4l8FOgDF75V1+p0cF6KjAeSy1E2SZtHgQsiBCpf0hDUwTCIX 6gUktFi29UwbuaMuInV/dDQuCLyePKVXXRgICdvPOpERPnwD4gpMwtXMWTQ+6zJ33lP1 XuRaRUyfcPsXJQCnjdWRPaglyy/FwYf96D5JZfMoCvXtas8EAxksKe5c6hrqjk06Bnz8 7e+vgQK1+J8XRYLVrBEph2z5ew+6DUDyU3s+L93gt2MNbrAfxazVjsyg6Um1vC4Fa/nG OsqPEajIDuu91d9CEcmwoFJeSEbO9JlJHI39ZYk7C+Tv7ybryGvaTtIbj6HRl9W6HZHQ wEIg== 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=1E2U45qA8GMGqDEw3uygGu4V0CmHBUDj8JwaZvgmTo8=; b=hPnnL3T/vnyxy9h/2oVcJP1lgYMH3JTghUSB5TuyQYpsSmCQipmP+j9rr3Hlio2xQa elWptabXQYpRPoIplkA1bCjVj7bLP7vPDTQ3Rcv474Bvly2yMPVCyElIBSZRY8tqRzhT t3huU7Z/sNTfXS+fggbwdDqnz8GQ6Csz6f8Qq3pIilX5Hu3BNU1X9rrhO5tP3CHyJcAL zA3TSdMe1Vwkm/hVee/n5vS+eVZ2bNzPBmB3udcL7JZAHoneBn73aGnyfRSTJr5VSadN ADROD6v4Q1XDINk8IR6IRVVNbUTUDYFJSflAMJidReJogLgTAA9Y3pkzrfXOrPeflevU bGKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I9U1EWXH; 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 u141-20020a627993000000b0057576b1c933si1667934pfc.340.2022.12.09.06.08.31; Fri, 09 Dec 2022 06:08:46 -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=I9U1EWXH; 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 S230003AbiLIOGW (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCC97869E; Fri, 9 Dec 2022 06:05:17 -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 7972762284; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71032C432C6; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=4RPPmHlyjmlFUoLHUFxMf8HvCeMtaA+C0YRncoYi5r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9U1EWXH4g5czfiJcl1sznKHcybwXhDHSvBNWqKAoKXukqvbk9CcBWG6iNGfjlgsu zDW5xeYGQe2Z6XJmQXKV2lG7bkPVFqR10B/YTiDFu+wL3blgNxOYtlxgkkSXPBZA4V NDOHRvSCTENf4pJ0802Q0WI51jPP8l5IdCI7KFftI/9WBagQZziZAaILSb8B8XvQ6I eYq3s3TwJwJRGUC0ZbZ3phmicN64cDLZfjnoJGtmY8ZmZzqRBo4IDPP2GTSGSUaQNA Pooze409PSzu4gDkgEIa3EYs+BWgusMT1PdLk9xUqhqIdBYVdq6Ku9Q4BPRar0NVEi IUBq3zuqxbTWQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000SA-Nb; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 17/19] irqchip/loongson-pch-msi: Use irq_domain_create_hierarchy() Date: Fri, 9 Dec 2022 15:01:48 +0100 Message-Id: <20221209140150.1453-18-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745745829827736?= X-GMAIL-MSGID: =?utf-8?q?1751745745829827736?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795219wrr; Fri, 9 Dec 2022 06:07:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7jWNV5a+wi9/1wP5pZRDB9+UgsQBPpB+AqQie9PWZjJMZfrqPrH3nZ7H5pNAESRIIeQrP9 X-Received: by 2002:a62:18c6:0:b0:575:fdb6:8e55 with SMTP id 189-20020a6218c6000000b00575fdb68e55mr5470758pfy.7.1670594866051; Fri, 09 Dec 2022 06:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594866; cv=none; d=google.com; s=arc-20160816; b=sSfWGHQd2rvzjtWNH6yVbnnr3s66DFA0p9+b+igSKsZhtcnZcFmbcWQr+yOV9+8sHv WsaYQTf6LaR8QLdEEYXlH/40b76+ayDd1kEEFYD87ggXY5sN7iePV6eGK9VMaJmg3afk /5PYVJWd2BJJZcZUYmAAJiLM1BO7zv0cAn7WQqcv6cT97lq9E3eyTUbvcrUWtri2yFlm swEvaHbPGElkD1dGIwOUCmt7MVF0Ys4hbJ4miEQ7GBEIuR2wUI1OjGsgqD3uVKsaaNjr qOGANoN3OgLkf4jZYt+s+sCiBTFXLHC3n3ZDm764JUJgyXIXCou3PDWqkJQ/HHepYO// oJYQ== 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=hx9oSguu0EFl0P+a2HocVZ43pPDMXuJPdjEMGmJgOWs=; b=eC5YIFvyq6g3bLLvnT4g+gjTD4hf8XpVDi4YUSiaMnIk9YuyUOOAHiYLQ75/PDMzi8 jGndRYGrW0tV1gxbnRA9k9QG6us4972U/qtdDOX+QG0iASZ5YzPJIxV5sdlHBEcD6ZtQ TWQM0NUucUCnLdC+yW+ZCDzN+LAcU6PskLqiaKUFHgYoibwfvO+czKuRE0oPlUnl7p4k bEPboihGVMacKQ0660qumnI4u7/FwqJC6OO12k2sprKQy2jHZKesoytZifIx/QCrVhxy 3yCW/oQtfrmvePKrOlkVi0CSLBC9Vv8je4uEn55ByElp3IPDoN5eRz3GisAmpImmEh/v BuPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vBPCGJ3y; 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 c14-20020a056a00008e00b0056bbdb48fcdsi1728816pfj.118.2022.12.09.06.07.30; Fri, 09 Dec 2022 06:07:46 -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=vBPCGJ3y; 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 S230193AbiLIOGc (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbiLIOFV (ORCPT ); Fri, 9 Dec 2022 09:05:21 -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 DD1A176143; Fri, 9 Dec 2022 06:05:19 -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 26115B8288B; Fri, 9 Dec 2022 14:05:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86F9DC432C7; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=VZG0mIrnpRYSLmP6v+aPSsXqssZN+JxVOB0YXZxJtgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBPCGJ3ydqDKIQkyQiwvx3XBhQ8eYOJI6wjL7rjJduxKvPdzdS5X9EDTcy8k6PxC5 r2hMYtQ9BPJ38yd40f/xppo09a5tY54ooaCwgv7bHH17qds/lSpnelHcNAThBeuhz/ BrjSw3OEW9PtnBWPMuErakJhKSnTpv80Bhu0T8z2VQr2n8I3BcENT58IDq8oT3n6n1 tTRDCz/w4Ra6GZ99RJmFy8Jv1kiZqdKtmbldZW9z01mSQohFyIF2INRmpczT8jgrZz Z0gTo7WjVwGW5u9NI6AhHt2Jgp4Dh0CnSQTmD8OJ6yRG7UYz6t6F6Ux+of7yFXakxf EI6muweRqyVcg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000SD-QA; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 18/19] irqchip/mvebu-odmi: Use irq_domain_create_hierarchy() Date: Fri, 9 Dec 2022 15:01:49 +0100 Message-Id: <20221209140150.1453-19-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745681879229381?= X-GMAIL-MSGID: =?utf-8?q?1751745681879229381?= Use the irq_domain_create_hierarchy() helper to create the hierarchical domain, which both serves as documentation and avoids poking at irqdomain internals. Signed-off-by: Johan Hovold Reviewed-by: Philippe Mathieu-Daudé --- 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 Fri Dec 9 14:01:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 31759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp795011wrr; Fri, 9 Dec 2022 06:07:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4tlXiDZvZITUP1//LQd6QK7Z8Rp6LXJeN9XVvtvex5vwngq7pLUpqPeIL4xmjU6z4sBUcH X-Received: by 2002:a62:e519:0:b0:575:bf29:d1e0 with SMTP id n25-20020a62e519000000b00575bf29d1e0mr6097063pff.26.1670594846960; Fri, 09 Dec 2022 06:07:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670594846; cv=none; d=google.com; s=arc-20160816; b=pQozsWRrAaQ3h4sXjfn69Lh3o6mLsmJEqVmQDQh5jd0N5I4jB1B4h+szp5GU1XwzSU 9D1h++MDBBQz27zE9VllgKigMsnUPvWlED3z9DcB5966SfSpJfvtIs+s2s4NGHca7BTK mMUZBiv1/R6V7wFYEQInmrKiup/ILjNLq6nNOSDbvSEfLedsd5+dtErdYFguqjFZperG ptaK0v1by7wynrhVLTNcwiKu5yum5G2YixvICK8BPrCFmK3K61sDottzQa+tP0gHXzG3 hR6/+8o/NE1nA5vNvIHrbISaGIkKwAI8MC6ots8YWCRLMTn81o2ESjNAEWIrbdEKBvWa BMww== 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=lMqX6jviS25+9cyCHOT0yKch5BPh+rV2mxWHuOBH/E0=; b=XpGshJzz8ExIzXrFGk+oSH+rYnw3G2lnA4dzz8g0cmin4mJ1BgXYbJuaI+lulEZ/pJ 8uDFakP5W1nml20l8GoS8bJxz1Ok5uoWE6arIqL/6afuz9aRSK1EGWUFXn4u8cWMpgNX zknOas8R1sgeyyDz9CkfQVjj+tEosdJAAiAEFOED4zIjSiXxGlMlwnXFKDxsXZ+M5+0/ 4xEssaJzSEDHgbESQNXDqMYQ+UU9PKGmCjINhka0oFV7QL+BwzZuXXaOwje0DXzoq4Ty yJZllfPNpWtFkPsDgHUwTmBeTdUPETTT8AdkGi1EtQOHZSHPPMSsZfmAbelLFPHPnNoK dElA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DzsRaw4w; 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 c15-20020aa7880f000000b005775394c99fsi1804874pfo.52.2022.12.09.06.07.12; Fri, 09 Dec 2022 06:07:26 -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=DzsRaw4w; 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 S230139AbiLIOGB (ORCPT + 99 others); Fri, 9 Dec 2022 09:06:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbiLIOFU (ORCPT ); Fri, 9 Dec 2022 09:05:20 -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 075D473F69; Fri, 9 Dec 2022 06:05:16 -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 18EE362275; Fri, 9 Dec 2022 14:05:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A37EFC433F1; Fri, 9 Dec 2022 14:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670594714; bh=Vr1RWEE1BLL3F5ODipwAjwleNPdE5gnPm2mw3W0gbGQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzsRaw4wb2Khse5EZuyLvwhozm4UKC6pAm6PodJFWnWXqIY2vIqI4cSbO+bcuQA0w 6mmTvv7Hgz9bwJhJbDPPtyi8oQLGdeFB3WZh4lZXvURZq53QUY7jzMa7K0kEtwVjGO 8zRT9wdLd5cMpvYSbELaa3pZJ/5QQJe/nx6695C/EmvdwmHuHRbO/JH0axDFI3aisK Y/S2J3HgcQ/lZ32vCRTLbBSu0hKr0IElmOwNkkboTWMJClv9SIj7vgBukvKaKbI7bt NuIe87GrS6Kbv++RUtf2Ps53UltTalh4qxbmQXWyW2/r7M+/fx1/KU1Mr+8PMMaBCi bPlNFlVv+wrPw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p3e0J-0000SG-T5; Fri, 09 Dec 2022 15:05:31 +0100 From: Johan Hovold To: Marc Zyngier Cc: Thomas Gleixner , 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 Subject: [PATCH v3 19/19] irqdomain: Switch to per-domain locking Date: Fri, 9 Dec 2022 15:01:50 +0100 Message-Id: <20221209140150.1453-20-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221209140150.1453-1-johan+linaro@kernel.org> References: <20221209140150.1453-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?1751745662325824968?= X-GMAIL-MSGID: =?utf-8?q?1751745662325824968?= 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. Signed-off-by: Johan Hovold --- include/linux/irqdomain.h | 4 ++++ kernel/irq/irqdomain.c | 48 ++++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h index 16399de00b48..cad47737a052 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..3faea8b66120 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -217,6 +217,7 @@ 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->mutex); domain->ops = ops; domain->host_data = host_data; domain->hwirq_max = hwirq_max; @@ -227,6 +228,7 @@ struct irq_domain *__irq_domain_add(struct fwnode_handle *fwnode, unsigned int s domain->revmap_size = size; irq_domain_check_hierarchy(domain); + domain->root = domain; mutex_lock(&irq_domain_mutex); debugfs_add_domain_dir(domain); @@ -503,7 +505,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 +520,7 @@ 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); + lockdep_assert_held(&domain->root->mutex); if (irq_domain_is_nomap(domain)) return; @@ -540,7 +542,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 +564,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 +614,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 +733,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 +744,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 +813,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 +866,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 +1134,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 +1531,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 +1545,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 +1611,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 +1639,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 +1694,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 +1706,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 +1722,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);