From nobody Wed Dec 17 17:27:08 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E41BC6BB29 for ; Mon, 6 May 2024 13:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000596; cv=none; b=Rm7RzKQSe15fmlOCtsQs3zzoQWA3f/satflnGMNFKhSNJNpW0+dvvWn67j63qQDUf3AOYC+7U/F4bURZXgI4e/+22yGDL9m+yiCpXXsN3i+44Zd3kHSuk2FsWYcbinxgU8nwB2iyr314AOLORho88S5vWzCYP7A7fFkvDLXURYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000596; c=relaxed/simple; bh=y9pKMTSpROuW5uGr7WjodDH4J07+axt2U3SLIM1IjUQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EcntnTlequTjAtCKMqaqNker7B8++5DOSNKCEGpMQxDZx66Dr9QoVRtEjjVpXoakifaC1X+kJEttpI23Ej210uNpEcoGA1JQUy79/NTS8+pgSYDsOT1/uGyy8C+2owOeD0C3KdOD9oIV32innS+DL6iKkOpvGUVmXrpXO6HKMCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VY1lC0J7PzcdVt for ; Mon, 6 May 2024 21:01:59 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id 3E41D140134 for ; Mon, 6 May 2024 21:03:09 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 6 May 2024 21:03:08 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 1/5] genirq/irqdomain: Clean up for irq_create_fwspec_mapping() Date: Mon, 6 May 2024 21:02:19 +0800 Message-ID: <20240506130223.317265-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506130223.317265-1-ruanjinjie@huawei.com> References: <20240506130223.317265-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) Content-Type: text/plain; charset="utf-8" In irq_create_fwspec_mapping(), if the hwirq in domain extracted from fwspec has virq mapping, check the trigger type if they are consistent, which is a relatively independent function that can be extracted into a helper function irq_check_trigger_type(), which will make irq_create_fwspec_mapping() function more readable. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 60 ++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index aadc8891cc16..baa53a9e0cd1 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -789,6 +789,38 @@ void of_phandle_args_to_fwspec(struct device_node *np,= const u32 *args, } EXPORT_SYMBOL_GPL(of_phandle_args_to_fwspec); =20 +static inline int irq_check_trigger_type(struct irq_fwspec *fwspec, + int virq, irq_hw_number_t hwirq, + unsigned int type) +{ + struct irq_data *irq_data; + + /* + * If the trigger type is not specified or matches the + * current trigger type then we are done so return the + * interrupt number. + */ + if (type =3D=3D IRQ_TYPE_NONE || type =3D=3D irq_get_trigger_type(virq)) + return 0; + + /* + * If the trigger type has not been set yet, then set + * it now and return the interrupt number. + */ + if (irq_get_trigger_type(virq) =3D=3D IRQ_TYPE_NONE) { + irq_data =3D irq_get_irq_data(virq); + if (!irq_data) + return -EINVAL; + + irqd_set_trigger_type(irq_data, type); + return 0; + } + + pr_warn("type mismatch, failed to map hwirq-%lu for %s!\n", + hwirq, of_node_full_name(to_of_node(fwspec->fwnode))); + return -EINVAL; +} + unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) { struct irq_domain *domain; @@ -829,32 +861,8 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwsp= ec *fwspec) */ virq =3D irq_find_mapping(domain, hwirq); if (virq) { - /* - * If the trigger type is not specified or matches the - * current trigger type then we are done so return the - * interrupt number. - */ - if (type =3D=3D IRQ_TYPE_NONE || type =3D=3D irq_get_trigger_type(virq)) - goto out; - - /* - * If the trigger type has not been set yet, then set - * it now and return the interrupt number. - */ - if (irq_get_trigger_type(virq) =3D=3D IRQ_TYPE_NONE) { - irq_data =3D irq_get_irq_data(virq); - if (!irq_data) { - virq =3D 0; - goto out; - } - - irqd_set_trigger_type(irq_data, type); - goto out; - } - - pr_warn("type mismatch, failed to map hwirq-%lu for %s!\n", - hwirq, of_node_full_name(to_of_node(fwspec->fwnode))); - virq =3D 0; + if (irq_check_trigger_type(fwspec, virq, hwirq, type)) + virq =3D 0; goto out; } =20 --=20 2.34.1 From nobody Wed Dec 17 17:27:08 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABF945FB9A for ; Mon, 6 May 2024 13:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000595; cv=none; b=fpPj7EUj8saxVMKuLagyvMciwoVw8YAz5MbEDtBIR9DEJaaV7LNOCI/G2khPJNFnHRgCZ+na0Q+4NSNloCgbfA+6wUR4w4gSh+mx3nax/n3757FVCnEMX+Q/OYgwfaBRrF5q6hJPkxDALNpiI640OXG75nUv+IJwLN3id84ohT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000595; c=relaxed/simple; bh=CQyVq+F6jzKSnAUtUnQ3X91KAzPVmn25oCVUP0vkPKY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BvKehR/ffYeRkWZgLfaUB2tUQ65xHi/Bv+abhCAlFzVCrZrewe/Ohg5a7XMLD/IVs4Q/Zu2uvjfa3PTw89sneigl4+h7mf29d7vN2etx7N9+hxgPznKUlaCKjMpkuNA0EC/P0TU0RxVOxEQvTssWmO5Z9WYN7sGHCG3a3mYl1GY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VY1hB1Yrczcnyt for ; Mon, 6 May 2024 20:59:22 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id 0C92D140158 for ; Mon, 6 May 2024 21:03:10 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 6 May 2024 21:03:09 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 2/5] genirq/irqdomain: Simplify the checks for irq_default_domain Date: Mon, 6 May 2024 21:02:20 +0800 Message-ID: <20240506130223.317265-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506130223.317265-1-ruanjinjie@huawei.com> References: <20240506130223.317265-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) Content-Type: text/plain; charset="utf-8" Use ternary to check whether assign irq_default_domain, which can simplify the code. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index baa53a9e0cd1..42bdbd04bc3c 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -661,8 +661,7 @@ unsigned int irq_create_direct_mapping(struct irq_domai= n *domain) struct device_node *of_node; unsigned int virq; =20 - if (domain =3D=3D NULL) - domain =3D irq_default_domain; + domain =3D domain ? : irq_default_domain; =20 of_node =3D irq_domain_get_of_node(domain); virq =3D irq_alloc_desc_from(1, of_node_to_nid(of_node)); @@ -734,8 +733,7 @@ unsigned int irq_create_mapping_affinity(struct irq_dom= ain *domain, int virq; =20 /* Look for default domain if necessary */ - if (domain =3D=3D NULL) - domain =3D irq_default_domain; + domain =3D domain ? : irq_default_domain; if (domain =3D=3D NULL) { WARN(1, "%s(, %lx) called with NULL domain\n", __func__, hwirq); return 0; @@ -953,8 +951,7 @@ struct irq_desc *__irq_resolve_mapping(struct irq_domai= n *domain, struct irq_data *data; =20 /* Look for default domain if necessary */ - if (domain =3D=3D NULL) - domain =3D irq_default_domain; + domain =3D domain ? : irq_default_domain; if (domain =3D=3D NULL) return desc; =20 @@ -1554,11 +1551,9 @@ int __irq_domain_alloc_irqs(struct irq_domain *domai= n, int irq_base, { int ret; =20 - if (domain =3D=3D NULL) { - domain =3D irq_default_domain; - if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) - return -EINVAL; - } + domain =3D domain ? : irq_default_domain; + if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n")) + return -EINVAL; =20 mutex_lock(&domain->root->mutex); ret =3D irq_domain_alloc_irqs_locked(domain, irq_base, nr_irqs, node, arg, @@ -1962,11 +1957,9 @@ static int irq_domain_debug_show(struct seq_file *m,= void *p) struct irq_domain *d =3D m->private; =20 /* Default domain? Might be NULL */ - if (!d) { - if (!irq_default_domain) - return 0; - d =3D irq_default_domain; - } + d =3D d ? : irq_default_domain; + if (!d) + return 0; irq_domain_debug_show_one(m, d, 0); return 0; } --=20 2.34.1 From nobody Wed Dec 17 17:27:08 2025 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10D5E6D1BB for ; Mon, 6 May 2024 13:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000597; cv=none; b=Ev3Fsfd42ht7QkECYBFwjfXst/h6KXag0cS8gEXErD64gDMR5Mtjz3galSpCBG+R22743NanLo4IMfE+yS3P80nvNYgGt/2TezT/D8DpTorSzBXfviXQUa5tTrKkxMN7k/ZXQVfRWSDC5Ll/vLb2O+FiECO9zhrzbXqCQ2Vu3a0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000597; c=relaxed/simple; bh=SWCL/GgvDvSAFp81ExaUX0cbPTexrcab9TT6aTWubmw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X4Oc0TugVfx9rYBTeuCX+q/XVfE39e7UnzzGvar1sYY8aokHI4fyNLz3ONPFiFVgACne7DHfNfqT6ZOBWmNiYxrRfUc4l1v6kXsm0OZBc+NqXgT9M5eL8lBE26ir3gqvs1A+ieNm5gX5MUgI/V+aycTgNmU7dHOD7NzXIbCv1Lw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VY1lH5v0mz1xmgr for ; Mon, 6 May 2024 21:02:03 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id C10761A016C for ; Mon, 6 May 2024 21:03:10 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 6 May 2024 21:03:10 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 3/5] genirq/irqdomain: Clean code for irq_create_direct_mapping() Date: Mon, 6 May 2024 21:02:21 +0800 Message-ID: <20240506130223.317265-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506130223.317265-1-ruanjinjie@huawei.com> References: <20240506130223.317265-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) Content-Type: text/plain; charset="utf-8" Add "out" goto label for irq_domain_update_bus_token(), and "out_free_desc" goto label for irq_create_direct_mapping(), which can simplify the code. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 42bdbd04bc3c..6d8a368c677b 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -317,10 +317,8 @@ void irq_domain_update_bus_token(struct irq_domain *do= main, domain->bus_token =3D bus_token; =20 name =3D kasprintf(GFP_KERNEL, "%s-%d", domain->name, bus_token); - if (!name) { - mutex_unlock(&irq_domain_mutex); - return; - } + if (!name) + goto out; =20 debugfs_remove_domain_dir(domain); =20 @@ -332,6 +330,7 @@ void irq_domain_update_bus_token(struct irq_domain *dom= ain, domain->name =3D name; debugfs_add_domain_dir(domain); =20 +out: mutex_unlock(&irq_domain_mutex); } EXPORT_SYMBOL_GPL(irq_domain_update_bus_token); @@ -672,17 +671,18 @@ unsigned int irq_create_direct_mapping(struct irq_dom= ain *domain) if (virq >=3D domain->hwirq_max) { pr_err("ERROR: no free irqs available below %lu maximum\n", domain->hwirq_max); - irq_free_desc(virq); - return 0; + goto out_free_desc; } pr_debug("create_direct obtained virq %d\n", virq); =20 - if (irq_domain_associate(domain, virq, virq)) { - irq_free_desc(virq); - return 0; - } + if (irq_domain_associate(domain, virq, virq)) + goto out_free_desc; =20 return virq; + +out_free_desc: + irq_free_desc(virq); + return 0; } EXPORT_SYMBOL_GPL(irq_create_direct_mapping); #endif --=20 2.34.1 From nobody Wed Dec 17 17:27:08 2025 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6050B77F08 for ; Mon, 6 May 2024 13:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; cv=none; b=CiBFh7kH18T2ZmRsn4A8SYTBIyqy/28A86rSCDIJRzdhxBG3XWu5a1IWTaUzJeTm/4XFNoCdZMfwixo18Zxrptlts4RM+GR3Cijsg76w925VjpOC9ymAmYE6jQYybVFzk79lvI9OSYq1ExRBtnz1xwAOeVeyV5F3SX1Sx/JGKMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; c=relaxed/simple; bh=uuxg5U4k/MG1J3jogr6OvT/NI4ZO8YphByPzlme47Wg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ajylu0GMLaJdD8J+tQ+gD7Gkqzhl4Pzgvmx8dIvYv9HIX5PW4tV2Ojbn5hdH7vfB1ioLUWDl3bD/fjYl5jd5AjJcvdQiuECDiL+k+HS8rkmz0/LhLvSLchXI1f1WY31uaZN8glVsclNGjr+OIPW+SdgQVFkzTzMA3ET1fRprduw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4VY1jS0mCtzNw6L for ; Mon, 6 May 2024 21:00:28 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id B882418007D for ; Mon, 6 May 2024 21:03:12 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 6 May 2024 21:03:12 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 4/5] genirq/irqdomain: Simplify the checks for irq_domain_push/pop_irq() Date: Mon, 6 May 2024 21:02:22 +0800 Message-ID: <20240506130223.317265-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506130223.317265-1-ruanjinjie@huawei.com> References: <20240506130223.317265-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) Content-Type: text/plain; charset="utf-8" Since whether desc is NULL or domain is NULL or irq_data is NULL, it returns -EINVAL, check them together in irq_domain_push/pop_irq(). And whether the irq domain is not hierarchy or it's parent domain is not consistent, it returns -EINVAL, check them together too. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 6d8a368c677b..2ef53697d877 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -1613,21 +1613,14 @@ int irq_domain_push_irq(struct irq_domain *domain, = int virq, void *arg) * to deadlock, so we just do a simple check before starting. */ desc =3D irq_to_desc(virq); - if (!desc) + if (!desc || !domain || !irq_data) return -EINVAL; + if (WARN_ON(desc->action)) return -EBUSY; =20 - if (domain =3D=3D NULL) - return -EINVAL; - - if (WARN_ON(!irq_domain_is_hierarchy(domain))) - return -EINVAL; - - if (!irq_data) - return -EINVAL; - - if (domain->parent !=3D irq_data->domain) + if (WARN_ON(!irq_domain_is_hierarchy(domain)) || + domain->parent !=3D irq_data->domain) return -EINVAL; =20 parent_irq_data =3D kzalloc_node(sizeof(*parent_irq_data), GFP_KERNEL, @@ -1694,17 +1687,11 @@ int irq_domain_pop_irq(struct irq_domain *domain, i= nt virq) * deadlock, so we just do a simple check before starting. */ desc =3D irq_to_desc(virq); - if (!desc) + if (!desc || !domain || !irq_data) return -EINVAL; if (WARN_ON(desc->action)) return -EBUSY; =20 - if (domain =3D=3D NULL) - return -EINVAL; - - if (!irq_data) - return -EINVAL; - tmp_irq_data =3D irq_domain_get_irq_data(domain, virq); =20 /* We can only "pop" if this domain is at the top of the list */ --=20 2.34.1 From nobody Wed Dec 17 17:27:08 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCE6378C60 for ; Mon, 6 May 2024 13:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; cv=none; b=Uxf53VKgkFbx9qyqXpEOyd8R7f2NbprJ5PeC4sPyeHygCloZTZc4AVIStSKEXttvpBZGt5ipk4HpWcXsd7S3otS/bH+bbb5gmIwJ+rVSqkcLOimcmTBQhIbFV/y+4zNbFB+hNt/JnojR4aM10/1T9GPn2o+QkTNJNvYLNl12y6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715000598; c=relaxed/simple; bh=+ulLU4slP0ZpFDa6qvL8fvK6SU8hdStisvDrncOSz4Y=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JetqGsM3gPCC+ThQotl/PCiddmpchN105ZmK/YN9oxR1HR1G6wYNBzsBwHIA+iUj1v1vVHy0VYjkg7CZtIMvnBJy2Y28xnAE9cIVXH+9CUokiG62UEVGm6BBSz3Fg9kLmlviTXVqy5lSvWs1cGycKp8Hssh87+beq6yGb2jU0eQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VY1hF6TMTzcp0d for ; Mon, 6 May 2024 20:59:25 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id B6F59180065 for ; Mon, 6 May 2024 21:03:13 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 6 May 2024 21:03:13 +0800 From: Jinjie Ruan To: , CC: Subject: [PATCH 5/5] genirq/irqdomain: Clean up for irq_domain_xlate_* Date: Mon, 6 May 2024 21:02:23 +0800 Message-ID: <20240506130223.317265-6-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240506130223.317265-1-ruanjinjie@huawei.com> References: <20240506130223.317265-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) Content-Type: text/plain; charset="utf-8" As irq_domain_xlate_onecell() and irq_domain_xlate_onetwocell() have almost the same logic, introduce irq_domain_xlate_common() to do it and use a new xlate_type enum variable to distinguish them. Signed-off-by: Jinjie Ruan --- kernel/irq/irqdomain.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c index 2ef53697d877..4dd53d76f7ef 100644 --- a/kernel/irq/irqdomain.c +++ b/kernel/irq/irqdomain.c @@ -985,6 +985,29 @@ struct irq_desc *__irq_resolve_mapping(struct irq_doma= in *domain, } EXPORT_SYMBOL_GPL(__irq_resolve_mapping); =20 +enum xlate_type { + ONE_CELL =3D 0, + ONE_TWO_CELL, +}; + +static inline int irq_domain_xlate_common(const u32 *intspec, + unsigned int intsize, + unsigned long *out_hwirq, + unsigned int *out_type, + enum xlate_type type) +{ + if (WARN_ON(intsize < 1)) + return -EINVAL; + + *out_hwirq =3D intspec[0]; + *out_type =3D IRQ_TYPE_NONE; + + if (type =3D=3D ONE_TWO_CELL && intsize > 1) + *out_type =3D intspec[1] & IRQ_TYPE_SENSE_MASK; + + return 0; +} + /** * irq_domain_xlate_onecell() - Generic xlate for direct one cell bindings * @@ -995,11 +1018,8 @@ int irq_domain_xlate_onecell(struct irq_domain *d, st= ruct device_node *ctrlr, const u32 *intspec, unsigned int intsize, unsigned long *out_hwirq, unsigned int *out_type) { - if (WARN_ON(intsize < 1)) - return -EINVAL; - *out_hwirq =3D intspec[0]; - *out_type =3D IRQ_TYPE_NONE; - return 0; + return irq_domain_xlate_common(intspec, intsize, out_hwirq, + out_type, ONE_CELL); } EXPORT_SYMBOL_GPL(irq_domain_xlate_onecell); =20 @@ -1037,14 +1057,8 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, const u32 *intspec, unsigned int intsize, unsigned long *out_hwirq, unsigned int *out_type) { - if (WARN_ON(intsize < 1)) - return -EINVAL; - *out_hwirq =3D intspec[0]; - if (intsize > 1) - *out_type =3D intspec[1] & IRQ_TYPE_SENSE_MASK; - else - *out_type =3D IRQ_TYPE_NONE; - return 0; + return irq_domain_xlate_common(intspec, intsize, out_hwirq, + out_type, ONE_TWO_CELL); } EXPORT_SYMBOL_GPL(irq_domain_xlate_onetwocell); =20 --=20 2.34.1