Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp643030ybb; Wed, 25 Mar 2020 06:58:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vta+RtsG3NE6L+n/NPItCJ7rGYGU0uvTrg3t/Mmolz0Gsq2LeXJ89hgaLnegHzGZknwo6qr X-Received: by 2002:aca:c3c1:: with SMTP id t184mr2581511oif.113.1585144706496; Wed, 25 Mar 2020 06:58:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585144706; cv=none; d=google.com; s=arc-20160816; b=HmXCgemD/VMsScriXJejaambrmtAq7rJAeH/yMFLggnPpMp0Ed6lxVk7URscKUmMOj O1yrtIvklIn/yGAvsPJRyb+GoahbG6mA6VZVsNVclLXxE9Ojv5Mul+GNmZQUMIfPGT8u OcroQgCRCIa3AncleNZw3YB8QWKSEI47PmvU8yJNjrPgLMKJL3mzb3PnmgJHUexPjWvC BqCEFij1yNnXNjMtT1a00etwpYpGQhv6rOQIl6/w6zrNSsf/FlMiV/xjT+J1/ebJspoU q8wgAlse250Czb2djNo4K5Pkpw3/PZEOMmto7eNCMZPZcYniOrN95HG7rPN1Uvlz0YOB GLpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=8APkf79GBh4IqM9WbXUT1BDdYZ+0I50DUa6/FK/uQbY=; b=IyoeMgv05k/DtJH9FOGJW9sQMH53POb8K3fmksFvXOqUQOqxM+VKWBLLkll+TmTBCv A0wuH1BVtKsZEFdwHTtyRR4wpCn14PuMGo/BcwVncQy566VspYIJNnXtHlhiAdLwwUVx Rqi1KgRUYxhM7qn4HB7QJie2N8JzKxsDxt97K+rAoqNyvY8j3+iyhNCov3uYu2OrpOxG okhvIUt3tyLOu/neqmuVZq8H5DZQO9NgfisQtSIhvScwW8brXe7sNgrV8jxAAtCdoSqy KbDTi1i2kJjroAKbhSYl7Dh93dOkerJ3qzLJKaSYanNZWAtUFrw9TSyUdwrfpIxyqe2c XxUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k9bzfTUS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22si7966553oto.237.2020.03.25.06.58.13; Wed, 25 Mar 2020 06:58:26 -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; dkim=pass header.i=@kernel.org header.s=default header.b=k9bzfTUS; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727464AbgCYN5x (ORCPT + 99 others); Wed, 25 Mar 2020 09:57:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:36646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbgCYN5x (ORCPT ); Wed, 25 Mar 2020 09:57:53 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B197120663; Wed, 25 Mar 2020 13:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585144671; bh=Et7ilZ2iSNQe0WMJIlJXaPolWCo3ZKQ1yz30y5NgNiw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=k9bzfTUSkpjYxwgvTeSMSaOOMZXZxAf9pHh5DGqgYBahSk0Ehk3wBG+WXY4UMhVDF E7w5492eBVdcqAVJh90ysSmZA6+5DBZ89aWQTVJ8q6cnOtWjONh53ltODaWm3T0Np3 2cT4tUQrmIcapRvaBLgKaBpkOACx502pU73rVudM= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jH6XV-00Faf6-Up; Wed, 25 Mar 2020 13:57:50 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 25 Mar 2020 13:57:49 +0000 From: Marc Zyngier To: Jiaxun Yang Cc: Thomas Bogendoerfer , linux-mips@vger.kernel.org, Huacai Chen , Thomas Gleixner , Jason Cooper , Rob Herring , Mark Rutland , Mauro Carvalho Chehab , "David S. Miller" , Greg Kroah-Hartman , Jonathan Cameron , Andy Shevchenko , Allison Randal , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v8 06/11] irqchip: mips-cpu: Convert to simple domain In-Reply-To: References: <20200325035537.156911-1-jiaxun.yang@flygoat.com> <20200325035537.156911-7-jiaxun.yang@flygoat.com> <20200325123742.GA9911@alpha.franken.de> Message-ID: <5eb9ce9ea665ee32da40779f00fc9b37@kernel.org> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/1.3.10 X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: jiaxun.yang@flygoat.com, tsbogend@alpha.franken.de, linux-mips@vger.kernel.org, chenhc@lemote.com, tglx@linutronix.de, jason@lakedaemon.net, robh+dt@kernel.org, mark.rutland@arm.com, mchehab+samsung@kernel.org, davem@davemloft.net, gregkh@linuxfoundation.org, Jonathan.Cameron@huawei.com, andriy.shevchenko@linux.intel.com, allison@lohutok.net, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-03-25 13:07, Jiaxun Yang wrote: > 于 2020年3月25日 GMT+08:00 下午9:00:01, Marc Zyngier 写到: >> On 2020-03-25 12:37, Thomas Bogendoerfer wrote: >>> On Wed, Mar 25, 2020 at 11:54:59AM +0800, Jiaxun Yang wrote: >>>> The old code is using legacy domain to setup irq_domain for CPU >>>> interrupts >>>> which requires irq_desc to be preallocated. >>>> >>>> However, when MIPS_CPU_IRQ_BASE >= 16, irq_desc for CPU IRQs may end >> >>>> up >>>> unallocated and lead to incorrect behavior. >>>> >>>> Thus we convert the legacy domain to simple domain which can >> allocate >>>> irq_desc during initialization. >>>> >>>> Signed-off-by: Jiaxun Yang >>>> Co-developed-by: Huacai Chen >>>> Signed-off-by: Huacai Chen >>>> Reviewed-by: Marc Zyngier >>>> --- >>>> drivers/irqchip/irq-mips-cpu.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/irqchip/irq-mips-cpu.c >>>> b/drivers/irqchip/irq-mips-cpu.c >>>> index 95d4fd8f7a96..c3cf7fa76424 100644 >>>> --- a/drivers/irqchip/irq-mips-cpu.c >>>> +++ b/drivers/irqchip/irq-mips-cpu.c >>>> @@ -251,7 +251,7 @@ static void __init __mips_cpu_irq_init(struct >>>> device_node *of_node) >>>> clear_c0_status(ST0_IM); >>>> clear_c0_cause(CAUSEF_IP); >>>> >>>> - irq_domain = irq_domain_add_legacy(of_node, 8, MIPS_CPU_IRQ_BASE, >> 0, >>>> + irq_domain = irq_domain_add_simple(of_node, 8, MIPS_CPU_IRQ_BASE, >>>> &mips_cpu_intc_irq_domain_ops, >>>> NULL); >>> >>> this breaks at least IP30 and guess it will break every platform >> where >>> MIPS_CPU_IRQ_BASE == 0. add_legacy will always do >>> irq_domain_associate_many(), >>> while add_simple doesn't do it, if first_irq == 0. >>> >>> Marc, what is the reason not doing it all the time ? What's the >> correct >>> way here to work with irq_domain_add_simple() in this case ? >> >> On a fully DT-ified platform, using non-legacy irqdomains, virtual >> interrupts >> are allocated as a "random" number, depending on the order of >> allocation, >> and on demand. >> >> The first_irq hack in irq_domain_add_simple() is just a way to still >> allocate >> descriptors upfront (and I wish we could drop it...). >> >> If you have legacy code that "knows" about the relationship between >> Linux's >> virtual interrupt and the hwirq (that is only meaningful to the >> interrupt >> controller), you're screwed, and need to stick to the legacy >> irqdomain. >> >> It feels like the MIPS code is squarely in the latter case, so I guess >> this >> patch is probably the wrong thing to do for this architecture. > > So probably we can use legacy domain when MIPS IRQ BASE is in the > range of legacy IRQ > and switch to simple domain when it's not in that range? No, see below. > Here in Loongson systems IRQ 0-15 is occupied by I8259 so I did this > hack. Well, if you have to consider which Linux IRQ gets assigned, then your platform is definitely not ready for non-legacy irqdomains. Just stick to legacy for now until you have removed all the code that knows the hwirq mapping. M. -- Jazz is not dead. It just smells funny...