Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4951371imm; Tue, 18 Sep 2018 01:44:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbopRwaHEXxsqq5ex3CTyz4rIHX0sS6wgoYSOI6uQ8S4gWnlFmxyJNRbB1kZHdKZL2pjKCX X-Received: by 2002:a63:1516:: with SMTP id v22-v6mr26908004pgl.150.1537260264961; Tue, 18 Sep 2018 01:44:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537260264; cv=none; d=google.com; s=arc-20160816; b=m/zJJcr0GjoJ2DPP5j6f/GeUWGJ+F/Yy86PWpBLvhLzdE8ktFjj28N1q8gNf4iARe9 8Wc3bVI/1rnnmNNxxUQCZ9BMom5gsSyPKHXtI7gT83FSJjT7U5pqzrIF5R9mbQexeDRW 5hwdn6u95xuO3mZUv+vG2fD00MW9fIwPqAR1OHgl/j9op3i9RncNpvBRjLb9zfaaTpe2 Qzlxbuw4hbI4S3VqqVCUCSkYWgnhh01Qn3s0FZUu9NIa3HBPh2LwuS9v4K33frKQ1xMU zv51RnDlheRvI9jgHjI3v7ZnXeqpEIGbYiAvBEr61iJa/TWCExTCz43SfoMbR5MLuMJI QbXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=se2VUtFBDzYRubuWGp+QcJ6Ez6UF0gI1mEOGR5U2nr4=; b=drn4DRSUpBrtZX3S4/Nhw1aOT4D0H05TxfDZ46z611rLz4yiJXoXBfq5R1hEhXdWSW +qlW3W++/NUzilFb9eMNwMaJCBm0g/Bjiu11fHosBhQDmbP0gtX3lI3+qURCv9s7OZWo 9P0X/nQpIjZmtG1COJvGVZ5ChhxKBLNAW0rjz73kBfIVKlpqFwYNn2XHx/Hc5EBM/Ghj fLNHB/grw3vS5GMMdMjJvXygJgQkBuKghwclgDSMwcoVgI0vFAHDbxsApc+lZyEjgbJd bNa1VwnnLgicJeAov2ErtxosxjnbOhBcy7Y367uOncW8cxr3OGYhbqFCwxNcfuhUcWtN bPsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j61-v6si16822237plb.49.2018.09.18.01.44.08; Tue, 18 Sep 2018 01:44:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729419AbeIROPi (ORCPT + 99 others); Tue, 18 Sep 2018 10:15:38 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:36448 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729129AbeIROPi (ORCPT ); Tue, 18 Sep 2018 10:15:38 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07437684|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03302;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=7;RT=7;SR=0;TI=SMTPD_---.CsM55JJ_1537260211; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:SMTPD_---.CsM55JJ_1537260211) by smtp.aliyun-inc.com(10.147.40.7); Tue, 18 Sep 2018 16:43:32 +0800 Date: Tue, 18 Sep 2018 16:43:31 +0800 From: Guo Ren To: Marc Zyngier Cc: tglx@linutronix.de, jason@lakedaemon.net, robh+dt@kernel.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH V5 1/3] irqchip: add C-SKY irqchip drivers Message-ID: <20180918084331.GA10950@guoren> References: <86in35mfas.wl-marc.zyngier@arm.com> <20180917020928.GA22452@guoren-Inspiron-7460> <86tvmoz22k.wl-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86tvmoz22k.wl-marc.zyngier@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 17, 2018 at 02:27:31PM +0100, Marc Zyngier wrote: > On Mon, 17 Sep 2018 03:09:29 +0100, > Guo Ren wrote: > > [...] > > > > > + > > > > + irq_set_default_host(root_domain); > > > > > > Please drop this. There is no reason to use this on any modern, DT > > > based architecture. Ok. > > Please let me keep this and in my arch/csky/kernel/smp.c: > > > > void __init setup_smp_ipi(void) > > { > > ... > > irq_create_mapping(NULL, IPI_IRQ); > > rc = request_percpu_irq(IPI_IRQ, handle_ipi, "IPI Interrupt", &ipi_dummy_dev); > > This looks quite wrong. Reading the code at > https://lkml.org/lkml/2018/9/12/674, it really looks like you're > assuming that IPI_IRQ will be mapped to a Linux IRQ with the same > number. Nothing could be farther from the truth. Yes, you are right. I should use irq_create_mapping() return value as the arg for request_percpu_irq. It's a stupid bug, thoug it happens to work. > The Linux IRQ is returned as the result of irq_create_mapping, which > you're ignoring. You'd be better off creating this mapping from the > irqchip code, and expose the resulting Linux IRQ to oyu SMP code by > any mean of your choice (such as moving the send_ipi_message into the > irqchip code as well). Ok, see my diff below, is that OK? --- a/drivers/irqchip/irq-csky-mpintc.c +++ b/drivers/irqchip/irq-csky-mpintc.c @@ -16,6 +16,7 @@ #include #include +static struct irq_domain *root_domain; static void __iomem *INTCG_base; static void __iomem *INTCL_base; @@ -46,7 +47,7 @@ static void csky_mpintc_handler(struct pt_regs *regs) void __iomem *reg_base = this_cpu_read(intcl_reg); do { - handle_domain_irq(NULL, + handle_domain_irq(root_domain, readl_relaxed(reg_base + INTCL_RDYIR), regs); } while (readl_relaxed(reg_base + INTCL_HPPIR) & BIT(31)); @@ -139,13 +140,17 @@ static void csky_mpintc_send_ipi(const unsigned long *mask, unsigned long irq) */ writel_relaxed((*mask) << 8 | irq, reg_base + INTCL_SIGR); } + +static int csky_mpintc_ipi_irq_mapping(void) +{ + return irq_create_mapping(root_domain, IPI_IRQ); +} #endif /* C-SKY multi processor interrupt controller */ static int __init csky_mpintc_init(struct device_node *node, struct device_node *parent) { - struct irq_domain *root_domain; unsigned int cpu, nr_irq; int ret; @@ -172,8 +177,6 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) if (!root_domain) return -ENXIO; - irq_set_default_host(root_domain); - /* for every cpu */ for_each_present_cpu(cpu) { per_cpu(intcl_reg, cpu) = INTCL_base + (INTCL_SIZE * cpu); @@ -184,6 +187,8 @@ csky_mpintc_init(struct device_node *node, struct device_node *parent) #ifdef CONFIG_SMP set_send_ipi(&csky_mpintc_send_ipi); + + set_ipi_irq_mapping(&csky_mpintc_ipi_irq_mapping); #endif return 0; diff --git a/arch/csky/include/asm/smp.h b/arch/csky/include/asm/smp.h index 9a53abf..fed3a5a 100644 --- a/arch/csky/include/asm/smp.h +++ b/arch/csky/include/asm/smp.h @@ -7,6 +7,8 @@ #ifdef CONFIG_SMP +#define IPI_IRQ 15 + void __init setup_smp(void); void __init setup_smp_ipi(void); @@ -19,6 +21,8 @@ void arch_send_call_function_single_ipi(int cpu); void __init set_send_ipi(void (*func)(const unsigned long *, unsigned long)); +void __init set_ipi_irq_mapping(int (*func)(void)); + #define raw_smp_processor_id() (current_thread_info()->cpu) #endif /* CONFIG_SMP */ diff --git a/arch/csky/kernel/smp.c b/arch/csky/kernel/smp.c index 522c73f..f8343f6 100644 --- a/arch/csky/kernel/smp.c +++ b/arch/csky/kernel/smp.c @@ -20,8 +20,6 @@ #include #include -#define IPI_IRQ 15 - static struct { unsigned long bits ____cacheline_aligned; } ipi_data[NR_CPUS] __cacheline_aligned; @@ -121,13 +119,23 @@ void __init enable_smp_ipi(void) enable_percpu_irq(IPI_IRQ, 0); } +static int (*arch_ipi_irq_mapping)(void) = NULL; + +void __init set_ipi_irq_mapping(int (*func)(void)) +{ + if (arch_ipi_irq_mapping) + return; + + arch_ipi_irq_mapping = func; +} + void __init setup_smp_ipi(void) { - int rc; + int rc, irq; - irq_create_mapping(NULL, IPI_IRQ); + irq = arch_ipi_irq_mapping(); - rc = request_percpu_irq(IPI_IRQ, handle_ipi, "IPI Interrupt", &ipi_dummy_dev); + rc = request_percpu_irq(irq, handle_ipi, "IPI Interrupt", &ipi_dummy_dev); if (rc) panic("%s IRQ request failed\n", __func__);