Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4521870rwb; Mon, 21 Nov 2022 08:33:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6GyiIrCXhpFfPt6N/2KvoHaHfO7PX2URxop72OK9JGe8vYUJkwsEEg8X94vsihyX+EuFef X-Received: by 2002:a17:90b:3e8b:b0:1fb:825c:af8a with SMTP id rj11-20020a17090b3e8b00b001fb825caf8amr26661243pjb.104.1669048429196; Mon, 21 Nov 2022 08:33:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669048429; cv=none; d=google.com; s=arc-20160816; b=hcToIhCnznXoxy293Ht9VmGjcBb/W6sTpVIDNxlvpC1i8pkbb9dxwEw9993IGpDr12 0TB33vMmUBo8LHuTlvzQrPUjyWLgwPS6heXShRwrcyz/nvR+Ht2kLYyi6ZfQZmzoSqXh VrSQDz5lPvnAT8kxVzqV79oP5w4cipvE1u9RKOhrb3VHGTvcQckFP/RAkY9+nsVPAKLL yz8vRbLWf+p8RiqtubAmh3T+e3jBRBC4ysbcvJCS4NLG7Fas6i6zggC3fqQewXS0Xeb3 uP09B2wzsPuMyog3FhpuXxZjwtS7MnNY8UT5PtDEhhE//67ffMmgrTN28ekuI8xuf1yh RY6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=MqSNqTk6zSn2/CxqHu1Zk5vIICcROEec5cXqFROUsAQ=; b=jVXFsFtdzUE0SaO9YRG5ME6FQ4aaNDPp1T4qcXE+ZKh673X1OYsDi9OPsISTe3c4e8 TpJgjU7sfXCHBOLWAvTvvjNIXRPfOhnC+JwqXawh19dGxL3YcI6w7a0vXWACnsN5kai0 LvyI5tdfdg/g/dWpI6PhEviK014lk52zjKoW0+lA4k1Bn/1g68DsMn+XhBZxx+MxQbaN JfRd/ph3C5mbjGKrZlLvvTFjgquZFjV+oTHcth4WywlaHsSBpT/wIUAi6kCeNRuH5qeO 3/5fvQ+VmUYNerEDJqY4BIner8ORuoVIh384LQX/AvlAANw/LOuFRgiPd8M8Kb0TPVsA 3ERg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MED9eLTL; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi5-20020a17090b4b4500b0020d887ded6esi12913945pjb.120.2022.11.21.08.33.37; Mon, 21 Nov 2022 08:33: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=@linutronix.de header.s=2020 header.b=MED9eLTL; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbiKUOtT (ORCPT + 91 others); Mon, 21 Nov 2022 09:49:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232401AbiKUOr6 (ORCPT ); Mon, 21 Nov 2022 09:47:58 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4E74D32B6; Mon, 21 Nov 2022 06:41:57 -0800 (PST) Message-ID: <20221121140049.491212443@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1669041592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=MqSNqTk6zSn2/CxqHu1Zk5vIICcROEec5cXqFROUsAQ=; b=MED9eLTLCMaP9JjgxDdnM9Qe91gAN0co/FhD3zsKDk9NXRDOHiuAGTbgsIe36YcEteUfzQ kEMf1EH6oY52gflGi8LX0nB7hW73PWpue4PDsBbCOM9d7zxAUlVKEizRi0OnHpkCHIEA3W DjMqfnm7IkBYxEA8RUfxd0BzaPZRJnplGWLPOgt/UJQTob7mWUMopMESTaZmmYnL8N1kE5 QSFlG2iLpZxFD7IpRLOya2HausK3SPiWj7dybx49JBRRKp2ER96ARqx+UqMmYoOOGgna0M z/+JZPqZv+Pa0+5IdVSLPsBO7/PSMgi0qK5SQPEKmVHdlI7iI2lkwtuuqVPG6g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1669041592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=MqSNqTk6zSn2/CxqHu1Zk5vIICcROEec5cXqFROUsAQ=; b=Anqh6ewUZl0pXlAdjbqMgriIRD+DnvrtfkV6fSyBs6v4TKr+4HPdCWXH4A/aracjdB1JgF Ja2c16USH0yTsGDw== From: Thomas Gleixner To: LKML Cc: Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Ammar Faizi , Robin Murphy , Lorenzo Pieralisi , Nishanth Menon , Tero Kristo , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, Vinod Koul , Sinan Kaya , Andy Gross , Bjorn Andersson , Mark Rutland , Shameerali Kolothum Thodi , Zenghui Yu , Shawn Guo , Sascha Hauer , Fabio Estevam Subject: [patch V2 19/40] genirq/msi: Split msi_domain_alloc_irq_at() References: <20221121135653.208611233@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Mon, 21 Nov 2022 15:39:52 +0100 (CET) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 In preparation for providing a special allocation function for wired interrupt which are connected to a wire to MSI bridge, split the inner workings of msi_domain_alloc_irq_at() out into a helper function so the code can be shared. No functional change. Signed-off-by: Thomas Gleixner --- kernel/irq/msi.c | 76 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 33 deletions(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1465,34 +1465,10 @@ int msi_domain_alloc_irqs_all_locked(str return msi_domain_alloc_locked(dev, &ctrl); } -/** - * msi_domain_alloc_irq_at - Allocate an interrupt from a MSI interrupt domain at - * a given index - or at the next free index - * - * @dev: Pointer to device struct of the device for which the interrupts - * are allocated - * @domid: Id of the interrupt domain to operate on - * @index: Index for allocation. If @index == %MSI_ANY_INDEX the allocation - * uses the next free index. - * @affdesc: Optional pointer to an interrupt affinity descriptor structure - * @icookie: Optional pointer to a domain specific per instance cookie. If - * non-NULL the content of the cookie is stored in msi_desc::data. - * Must be NULL for MSI-X allocations - * - * This requires a MSI interrupt domain which lets the core code manage the - * MSI descriptors. - * - * Return: struct msi_map - * - * On success msi_map::index contains the allocated index number and - * msi_map::virq the corresponding Linux interrupt number - * - * On failure msi_map::index contains the error code and msi_map::virq - * is %0. - */ -struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, unsigned int index, - const struct irq_affinity_desc *affdesc, - union msi_instance_cookie *icookie) +static struct msi_map __msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, + unsigned int index, + const struct irq_affinity_desc *affdesc, + union msi_instance_cookie *icookie) { struct msi_ctrl ctrl = { .domid = domid, .nirqs = 1, }; struct msi_domain_info *info; @@ -1501,17 +1477,16 @@ struct msi_map msi_domain_alloc_irq_at(s struct msi_desc *desc; int ret; - msi_lock_descs(dev); domain = msi_get_device_domain(dev, domid); if (!domain) { map.index = -ENODEV; - goto unlock; + return map; } desc = msi_alloc_desc(dev, 1, affdesc); if (!desc) { map.index = -ENOMEM; - goto unlock; + return map; } if (icookie) @@ -1520,7 +1495,7 @@ struct msi_map msi_domain_alloc_irq_at(s ret = msi_insert_desc(dev, desc, domid, index); if (ret) { map.index = ret; - goto unlock; + return map; } ctrl.first = ctrl.last = desc->msi_index; @@ -1534,7 +1509,42 @@ struct msi_map msi_domain_alloc_irq_at(s map.index = desc->msi_index; map.virq = desc->irq; } -unlock: + return map; +} + +/** + * msi_domain_alloc_irq_at - Allocate an interrupt from a MSI interrupt domain at + * a given index - or at the next free index + * + * @dev: Pointer to device struct of the device for which the interrupts + * are allocated + * @domid: Id of the interrupt domain to operate on + * @index: Index for allocation. If @index == %MSI_ANY_INDEX the allocation + * uses the next free index. + * @affdesc: Optional pointer to an interrupt affinity descriptor structure + * @icookie: Optional pointer to a domain specific per instance cookie. If + * non-NULL the content of the cookie is stored in msi_desc::data. + * Must be NULL for MSI-X allocations + * + * This requires a MSI interrupt domain which lets the core code manage the + * MSI descriptors. + * + * Return: struct msi_map + * + * On success msi_map::index contains the allocated index number and + * msi_map::virq the corresponding Linux interrupt number + * + * On failure msi_map::index contains the error code and msi_map::virq + * is %0. + */ +struct msi_map msi_domain_alloc_irq_at(struct device *dev, unsigned int domid, unsigned int index, + const struct irq_affinity_desc *affdesc, + union msi_instance_cookie *icookie) +{ + struct msi_map map; + + msi_lock_descs(dev); + map = __msi_domain_alloc_irq_at(dev, domid, index, affdesc, icookie); msi_unlock_descs(dev); return map; }