Message ID | 20231219095158.285408-1-maobibo@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-4983-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1825980dyi; Tue, 19 Dec 2023 01:52:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4ZrK7Lf5wFXePNouyxE8kR1ozpAYtZwL1YlOV7d66RhikbCtN7uBwCs4Iq1cL/a9c6rJT X-Received: by 2002:a50:8718:0:b0:552:ff5d:a8dd with SMTP id i24-20020a508718000000b00552ff5da8ddmr1714938edb.28.1702979545353; Tue, 19 Dec 2023 01:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702979545; cv=none; d=google.com; s=arc-20160816; b=SiHmb5OXYJY2P+lM3cP3ybEVnF1QBupXnzfkel36OVvJIAEhtuvE/LhzJ6EQgV1e5W TePC6t0e4IjtnbH4IltfpzM0v1UtYj2kf/nlawafjB5HWUN+A3pR9UByyCofbuMvhBR0 BiYXx78haKrgtmPt7aJP3MR6J4UGys54a0EEARsjOlu51M2U88Kj12hsNYDGZB1UM3Sz 7F3IKpQCGkBNkwtq+Dc92SrGcf1LfxaL/x6z4cnEUIkWMhfQVMEL11tAiOr73MMkPsen ymbhYRYdYBsro9t1kpF9iZEUWUqbzcDBiEPUmlO+FZS3i7s+9gukhXI5BHjeHu95rNc0 fxXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=ZFypWzhX9wyAnRhCRuwRyNvJVF1gAJgxGNxfIwFTKfI=; fh=D85EK2jxNpa3kv/X6jYXYF0pTJVrDh31i5DODxrhleo=; b=UqJdKDSL62vP0dbZ2ZGWbjgBVOmH8NdZEBowepwpmtTx5ivpOHCmTjQnKmVsIH2Gor +Zi9MHNfdtLndIcwGXldxSylV5egD7t8xzsUkVH8wGIhW/HhNlNubhrduhBkLk0rl9OF GImc9Sdp9uhHjmxgufuug5EHUooIQ6hGFSrotBqk9On4TyKX0I9lxf1VTv16f74bUQe/ mL9AxkX1JkSyp4xiI7J6rAglpjftzeEra6382x3Olz4aPVg9KLEpaQZIksScP1ZGdRyF KdLyrzlUQH0rC4szfzqjALcV6E5gIpvuaN3LEJZ/zYS43uELo208WxlVweGUm/YiqMSu +wyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4983-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4983-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id de27-20020a056402309b00b005529bfab6a6si4226966edb.3.2023.12.19.01.52.25 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 01:52:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4983-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4983-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4983-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EE5931F2326C for <ouuuleilei@gmail.com>; Tue, 19 Dec 2023 09:52:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E93A1429B; Tue, 19 Dec 2023 09:52:07 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE22314267; Tue, 19 Dec 2023 09:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxE_C_Z4FlrJECAA--.13018S3; Tue, 19 Dec 2023 17:51:59 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxD+W+Z4FlvBkAAA--.798S2; Tue, 19 Dec 2023 17:51:59 +0800 (CST) From: Bibo Mao <maobibo@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Marc Zyngier <maz@kernel.org> Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jianmin Lv <lvjianmin@loongson.cn> Subject: [PATCH] irqchip/loongson-eiointc: Refine irq affinity setting during resume Date: Tue, 19 Dec 2023 17:51:58 +0800 Message-Id: <20231219095158.285408-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8AxD+W+Z4FlvBkAAA--.798S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxZw1UJrWDXw1xXw45ZrWfXrc_yoW5Xr4kpF W3A3Z0yrW5JFyUXryakr4DX34avFn5X3y7KFZxWay7ZFs8J3WDKF4FyF1vvFW0kry7JF12 vF45Xr18ua15C3XCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07URa0PUUUUU= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785703479564711735 X-GMAIL-MSGID: 1785703479564711735 |
Series |
irqchip/loongson-eiointc: Refine irq affinity setting during resume
|
|
Commit Message
maobibo
Dec. 19, 2023, 9:51 a.m. UTC
During suspend and resume, other CPUs are removed and IRQs are migrated
to CPU0. So it is not necessary to restore irq affinity for eiointc.
Also there is some optimization for function eiointc_irq_dispatch,
in genral there are 256 IRQs supported for eiointc. When irq happens,
eiointc irq handler reads the bitmap and find pending irqs. There are
4 times of consecutive iocsr_read64 operations for the total 256 bits,
indeed in most scenario pending value is zero in 3 times, and not zero
in one time. Here zero checking is added to avoid some useless
operations sush as clearing hw ISR.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
---
drivers/irqchip/irq-loongson-eiointc.c | 29 +++++++++++---------------
1 file changed, 12 insertions(+), 17 deletions(-)
Comments
+ irqchip maintainer Thomas. Jianmin, Could you give some feedback about this patch since you are author about this patch? By searching code of all hw irqchip drivers, there is no affinity restoring during s3/s4. Regards Bibo Mao On 2023/12/19 下午5:51, Bibo Mao wrote: > During suspend and resume, other CPUs are removed and IRQs are migrated > to CPU0. So it is not necessary to restore irq affinity for eiointc. > > Also there is some optimization for function eiointc_irq_dispatch, > in genral there are 256 IRQs supported for eiointc. When irq happens, > eiointc irq handler reads the bitmap and find pending irqs. There are > 4 times of consecutive iocsr_read64 operations for the total 256 bits, > indeed in most scenario pending value is zero in 3 times, and not zero > in one time. Here zero checking is added to avoid some useless > operations sush as clearing hw ISR. > > Signed-off-by: Bibo Mao <maobibo@loongson.cn> > --- > drivers/irqchip/irq-loongson-eiointc.c | 29 +++++++++++--------------- > 1 file changed, 12 insertions(+), 17 deletions(-) > > diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c > index 1623cd779175..b01be85b8ebc 100644 > --- a/drivers/irqchip/irq-loongson-eiointc.c > +++ b/drivers/irqchip/irq-loongson-eiointc.c > @@ -198,6 +198,17 @@ static void eiointc_irq_dispatch(struct irq_desc *desc) > > for (i = 0; i < eiointc_priv[0]->vec_count / VEC_COUNT_PER_REG; i++) { > pending = iocsr_read64(EIOINTC_REG_ISR + (i << 3)); > + > + /* > + * Get pending eiointc irq from bitmap status, there are 4 times > + * consecutive iocsr_read64 operations for 256 IRQs. > + * > + * In most scenario value of pending is 0 if no multiple IRQs > + * happen at the same time > + */ > + if (!pending) > + continue; > + > iocsr_write64(pending, EIOINTC_REG_ISR + (i << 3)); > while (pending) { > int bit = __ffs(pending); > @@ -241,7 +252,7 @@ static int eiointc_domain_alloc(struct irq_domain *domain, unsigned int virq, > int ret; > unsigned int i, type; > unsigned long hwirq = 0; > - struct eiointc *priv = domain->host_data; > + struct eiointc_priv *priv = domain->host_data; > > ret = irq_domain_translate_onecell(domain, arg, &hwirq, &type); > if (ret) > @@ -304,23 +315,7 @@ static int eiointc_suspend(void) > > static void eiointc_resume(void) > { > - int i, j; > - struct irq_desc *desc; > - struct irq_data *irq_data; > - > eiointc_router_init(0); > - > - for (i = 0; i < nr_pics; i++) { > - for (j = 0; j < eiointc_priv[0]->vec_count; j++) { > - desc = irq_resolve_mapping(eiointc_priv[i]->eiointc_domain, j); > - if (desc && desc->handle_irq && desc->handle_irq != handle_bad_irq) { > - raw_spin_lock(&desc->lock); > - irq_data = irq_domain_get_irq_data(eiointc_priv[i]->eiointc_domain, irq_desc_get_irq(desc)); > - eiointc_set_irq_affinity(irq_data, irq_data->common->affinity, 0); > - raw_spin_unlock(&desc->lock); > - } > - } > - } > } > > static struct syscore_ops eiointc_syscore_ops = { >
> -----Original Messages----- > From: maobibo <maobibo@loongson.cn> > Send time:Thursday, 01/04/2024 15:53:51 > To: "Huacai Chen" <chenhuacai@kernel.org>, "Jiaxun Yang" <jiaxun.yang@flygoat.com>, "Thomas Gleixner" <tglx@linutronix.de> > Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, "Jianmin Lv" <lvjianmin@loongson.cn> > Subject: Re: [PATCH] irqchip/loongson-eiointc: Refine irq affinity setting during resume > > + irqchip maintainer Thomas. > > Jianmin, > > Could you give some feedback about this patch since you are author about > this patch? By searching code of all hw irqchip drivers, there is no > affinity restoring during s3/s4. > > Regards > Bibo Mao > Hi, bibo I looked into the patch, IMO, the change here in your patch is reasonable. The original restoring code here is aimed to restore irq routing registers from its' affinity, but it seems that the affinity may be changed during cpu offline, so we should not use it this way. Moreover, the affinity of each irq will be set to boot cpu after all of non-boot cpus are offline before suspend callback, so it seems that affinity restoring is not needed. > On 2023/12/19 下午5:51, Bibo Mao wrote: > > During suspend and resume, other CPUs are removed and IRQs are migrated > > to CPU0. So it is not necessary to restore irq affinity for eiointc. > > > > Also there is some optimization for function eiointc_irq_dispatch, > > in genral there are 256 IRQs supported for eiointc. When irq happens, > > eiointc irq handler reads the bitmap and find pending irqs. There are > > 4 times of consecutive iocsr_read64 operations for the total 256 bits, > > indeed in most scenario pending value is zero in 3 times, and not zero > > in one time. Here zero checking is added to avoid some useless > > operations sush as clearing hw ISR. > > > > Signed-off-by: Bibo Mao <maobibo@loongson.cn> > > --- > > drivers/irqchip/irq-loongson-eiointc.c | 29 +++++++++++--------------- > > 1 file changed, 12 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c > > index 1623cd779175..b01be85b8ebc 100644 > > --- a/drivers/irqchip/irq-loongson-eiointc.c > > +++ b/drivers/irqchip/irq-loongson-eiointc.c > > @@ -198,6 +198,17 @@ static void eiointc_irq_dispatch(struct irq_desc *desc) > > > > for (i = 0; i < eiointc_priv[0]->vec_count / VEC_COUNT_PER_REG; i++) { > > pending = iocsr_read64(EIOINTC_REG_ISR + (i << 3)); > > + > > + /* > > + * Get pending eiointc irq from bitmap status, there are 4 times > > + * consecutive iocsr_read64 operations for 256 IRQs. > > + * > > + * In most scenario value of pending is 0 if no multiple IRQs > > + * happen at the same time > > + */ > > + if (!pending) > > + continue; > > + > > iocsr_write64(pending, EIOINTC_REG_ISR + (i << 3)); > > while (pending) { > > int bit = __ffs(pending); > > @@ -241,7 +252,7 @@ static int eiointc_domain_alloc(struct irq_domain *domain, unsigned int virq, > > int ret; > > unsigned int i, type; > > unsigned long hwirq = 0; > > - struct eiointc *priv = domain->host_data; > > + struct eiointc_priv *priv = domain->host_data; > > > > ret = irq_domain_translate_onecell(domain, arg, &hwirq, &type); > > if (ret) > > @@ -304,23 +315,7 @@ static int eiointc_suspend(void) > > > > static void eiointc_resume(void) > > { > > - int i, j; > > - struct irq_desc *desc; > > - struct irq_data *irq_data; > > - > > eiointc_router_init(0); > > - > > - for (i = 0; i < nr_pics; i++) { > > - for (j = 0; j < eiointc_priv[0]->vec_count; j++) { > > - desc = irq_resolve_mapping(eiointc_priv[i]->eiointc_domain, j); > > - if (desc && desc->handle_irq && desc->handle_irq != handle_bad_irq) { > > - raw_spin_lock(&desc->lock); > > - irq_data = irq_domain_get_irq_data(eiointc_priv[i]->eiointc_domain, irq_desc_get_irq(desc)); > > - eiointc_set_irq_affinity(irq_data, irq_data->common->affinity, 0); > > - raw_spin_unlock(&desc->lock); > > - } > > - } > > - } > > } > > > > static struct syscore_ops eiointc_syscore_ops = { > > 本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。 This email and its attachments contain confidential information from Loongson Technology , which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this email in error, please notify the sender by phone or email immediately and delete it.
diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c index 1623cd779175..b01be85b8ebc 100644 --- a/drivers/irqchip/irq-loongson-eiointc.c +++ b/drivers/irqchip/irq-loongson-eiointc.c @@ -198,6 +198,17 @@ static void eiointc_irq_dispatch(struct irq_desc *desc) for (i = 0; i < eiointc_priv[0]->vec_count / VEC_COUNT_PER_REG; i++) { pending = iocsr_read64(EIOINTC_REG_ISR + (i << 3)); + + /* + * Get pending eiointc irq from bitmap status, there are 4 times + * consecutive iocsr_read64 operations for 256 IRQs. + * + * In most scenario value of pending is 0 if no multiple IRQs + * happen at the same time + */ + if (!pending) + continue; + iocsr_write64(pending, EIOINTC_REG_ISR + (i << 3)); while (pending) { int bit = __ffs(pending); @@ -241,7 +252,7 @@ static int eiointc_domain_alloc(struct irq_domain *domain, unsigned int virq, int ret; unsigned int i, type; unsigned long hwirq = 0; - struct eiointc *priv = domain->host_data; + struct eiointc_priv *priv = domain->host_data; ret = irq_domain_translate_onecell(domain, arg, &hwirq, &type); if (ret) @@ -304,23 +315,7 @@ static int eiointc_suspend(void) static void eiointc_resume(void) { - int i, j; - struct irq_desc *desc; - struct irq_data *irq_data; - eiointc_router_init(0); - - for (i = 0; i < nr_pics; i++) { - for (j = 0; j < eiointc_priv[0]->vec_count; j++) { - desc = irq_resolve_mapping(eiointc_priv[i]->eiointc_domain, j); - if (desc && desc->handle_irq && desc->handle_irq != handle_bad_irq) { - raw_spin_lock(&desc->lock); - irq_data = irq_domain_get_irq_data(eiointc_priv[i]->eiointc_domain, irq_desc_get_irq(desc)); - eiointc_set_irq_affinity(irq_data, irq_data->common->affinity, 0); - raw_spin_unlock(&desc->lock); - } - } - } } static struct syscore_ops eiointc_syscore_ops = {