Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp88616pxb; Tue, 24 Aug 2021 21:07:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxN+NRknvW/cYf3a2AxUKVn2ehu6nJ99ghbSMonxuE9PGwJUkaplhSZ/pU93yziVL5b3u1U X-Received: by 2002:a17:907:9152:: with SMTP id l18mr44231029ejs.190.1629864446038; Tue, 24 Aug 2021 21:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629864446; cv=none; d=google.com; s=arc-20160816; b=i6URYtK46Wu2wFfitUzjBcDma/n5I8eit5S1d2nQb1KZyRvV4dftsl8PPXpGpAj2Kx 0+cD1a+YkDK4piSPwNQpCjNF/yubpLx/hD8mMzFIqGdpuVjVNFxO+Hb4QHGR4S+UdByC LCqCLpZ2bP5Pqc6Tfdur1kvWLhtiL6VbLtKH9giJaMOONuN1qysz6RC4dkcxJj1UlyOr QPi1QhB5CLATGX2HFStpbIrrwpDIBH+9E4RYbkCXAhfA8PVOcnb+AMws8DyeqnoWUuLv 51KIlVNIPG3ibRIM7yzkyD+qQflc768yhui951VgpYU3BsdvcgGrppuUlcUX0ZIrBN0S c7pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=Ot5BeAXBddKTf8qnDZFX3CzOBLSXdCp/KHviQ9dPy6U=; b=tiRIsf/OttvIbMk5BvxDAaHzdrINJ8pV6Zxjj6UlSp5pA2ncHHhp5o6wNVNvR+xOAs 5HCzmMZIxHZ6sfna0mZwRsRRCQMhjbXrX/jhoozZ0u8NFIIP0KlGD1VhaR6VFtY8Xxk1 S134j79evEXR40BpwYG2tvCasP1FS5HpX4UOYknMbbm+3/6trk/WRcwgMLQdC8/B67j7 t2fOTJjWaPSxyLzkYoiOkROy/0yqCfISwfNucddu9OihBZQvOsILVIMXroK06b1iyrbB rnu4TGhsal/vfd5fDo+B+EZa2KkVnKR4G+F9+arHBUUyG6rgsqRhouYdpk3MpT20CNoB s7QA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si20102409ejy.465.2021.08.24.21.07.02; Tue, 24 Aug 2021 21:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229464AbhHYEGC (ORCPT + 99 others); Wed, 25 Aug 2021 00:06:02 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:14412 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbhHYEGB (ORCPT ); Wed, 25 Aug 2021 00:06:01 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GvXN50KX5zbdcY; Wed, 25 Aug 2021 12:01:25 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 25 Aug 2021 12:05:14 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 25 Aug 2021 12:05:14 +0800 Subject: Re: [PATCH 3/3] amba: Properly handle device probe without IRQ domain To: Saravana Kannan , Rob Herring CC: "linux-kernel@vger.kernel.org" , "Frank Rowand" , , Russell King , Linus Walleij , linux-arm-kernel , Ruizhe Lin , References: <20210816074619.177383-1-wangkefeng.wang@huawei.com> <20210816074619.177383-4-wangkefeng.wang@huawei.com> From: Kefeng Wang Message-ID: Date: Wed, 25 Aug 2021 12:05:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/8/25 4:08, Saravana Kannan wrote: > On Tue, Aug 24, 2021 at 1:05 PM Rob Herring wrote: >> +Saravana >> >> Saravana mentioned to me there may be some issues with this one... >> >> >> On Mon, Aug 16, 2021 at 2:43 AM Kefeng Wang wrote: >>> of_amba_device_create() uses irq_of_parse_and_map() to translate >>> a DT interrupt specification into a Linux virtual interrupt number. >>> >>> But it doesn't properly handle the case where the interrupt controller >>> is not yet available, eg, when pl011 interrupt is connected to MBIGEN >>> interrupt controller, because the mbigen initialization is too late, >>> which will lead to no IRQ due to no IRQ domain found, log is shown below, >>> "irq: no irq domain found for uart0 !" >>> >>> use of_irq_get() to return -EPROBE_DEFER as above, and in the function >>> amba_device_try_add()/amba_device_add(), it will properly handle in such >>> case, also return 0 in other fail cases to be consistent as before. >>> >>> Cc: Russell King >>> Cc: Rob Herring >>> Cc: Frank Rowand >>> Reported-by: Ruizhe Lin >>> Signed-off-by: Kefeng Wang >>> --- >>> drivers/amba/bus.c | 27 +++++++++++++++++++++++++++ >>> drivers/of/platform.c | 6 +----- >>> 2 files changed, 28 insertions(+), 5 deletions(-) >>> >>> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c >>> index 36f2f42c8014..720aa6cdd402 100644 >>> --- a/drivers/amba/bus.c >>> +++ b/drivers/amba/bus.c >>> @@ -19,6 +19,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> >>> #include >>> >>> @@ -371,12 +372,38 @@ static void amba_device_release(struct device *dev) >>> kfree(d); >>> } >>> >>> +static int of_amba_device_decode_irq(struct amba_device *dev) >>> +{ >>> + struct device_node *node = dev->dev.of_node; >>> + int i, irq = 0; >>> + >>> + if (IS_ENABLED(CONFIG_OF_IRQ) && node) { >>> + /* Decode the IRQs and address ranges */ >>> + for (i = 0; i < AMBA_NR_IRQS; i++) { >>> + irq = of_irq_get(node, i); >>> + if (irq < 0) { >>> + if (irq == -EPROBE_DEFER) >>> + return irq; >>> + irq = 0; >>> + } >>> + >>> + dev->irq[i] = irq; >>> + } >>> + } >>> + >>> + return 0; >>> +} >>> + >>> static int amba_device_try_add(struct amba_device *dev, struct resource *parent) >>> { >>> u32 size; >>> void __iomem *tmp; >>> int i, ret; >>> >>> + ret = of_amba_device_decode_irq(dev); >>> + if (ret) >>> + goto err_out; >>> + > Similar to other resources the AMBA bus "gets" for the device, I think > this should be moved into amba_probe() and not here. There's no reason > to delay the addition of the device (and loading its module) because > the IRQ isn't ready yet. The following code in the amba_device_try_add() will be called, it uses irq[0] and irq[1], so I put of_amba_device_decode_irq() into amba_device_try_add(). 470 if (dev->irq[0]) 471 ret = device_create_file(&dev->dev, &dev_attr_irq0); 472 if (ret == 0 && dev->irq[1]) 473 ret = device_create_file(&dev->dev, &dev_attr_irq1); 474 if (ret == 0) 475 return ret; of_amba_device_decode_irq() in amba_device_try_add() won't lead to issue, only delay the device add, right? If make it into amba_probe(), the above code should be moved too, could we make a new patch to move both of them, or don't move them?