Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp105747pxb; Mon, 16 Aug 2021 00:44:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeFLH1AdLrATeAp803XlvsRVqHxyoYQuEDxbGJH1lMe1kG68J34oLZNrj+yT3S9iXy+fb1 X-Received: by 2002:a05:6638:1b6:: with SMTP id b22mr14354440jaq.122.1629099867763; Mon, 16 Aug 2021 00:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629099867; cv=none; d=google.com; s=arc-20160816; b=z0YhSXg2w/ZXcxJLFzMVjMo/LyM9ZVITXbI8AYBuC6+uhpAyPhMSMOa25ciEOtEnuz P7HBeHpkXdMiX3bR1Qu4maDKyD+JPYh/50ecQQQYxwfl71c62Tqk+rK80qyPEyt5ABba HFICnezMT/cSghSR3N++RNYRXj1HCWuRvOt3sZ+1RKcfUn5JzmweypCS/brILeL6D0jp 3+IyCpz7O394avZ8ZNxEPqfkeErBnkNocnH6X8JhiaKT5b29nxKqwmJ3Mqpwot147F5o MezMQX4ScS5dbQfcEbwrBOSuSeiEX3/tCI9gyeYDnGiI0C6rhcJqXouB8uMQDzk0KZxp T51Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ekxxRBUg/5MlM9EvXSag8jh0s/ufeg9UQlS77H9dDI0=; b=F1Vw1fQj/96wWjMPHgvy0EyPhODZu7CeDUrAxXUqaaA6JIH2Xbvomjc/sgWAkcPs0b Dtd+wL2wTGQUu/AZPV2ZaVT376a2Lmq65Wiweps0YQwC/Yu5CORQrOs0HrgTBkH9lCFJ kTEf4TsQxi2tfxI7hf0Y0BnXAkqph0SOTVxhJp2Vosc3YL8eYGEttes1vCuwBo2dXZfB ImV9V5Ywka3CYtjUiX/lv9G2QxqRSjnVX1r63o0zttpZRwqBBarNZxMmCTIO46nW1iLO juoWsXWL4wWeWASk1dHnLcC5taoqZeVf7799GIo6M2N6c4j8p9E3ZqMLADqZVU4FHuWa HhOg== 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 13si12384012jan.43.2021.08.16.00.44.16; Mon, 16 Aug 2021 00:44:27 -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 S234385AbhHPHny (ORCPT + 99 others); Mon, 16 Aug 2021 03:43:54 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:13328 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234329AbhHPHnu (ORCPT ); Mon, 16 Aug 2021 03:43:50 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Gp5k82SPNz86l8; Mon, 16 Aug 2021 15:43:12 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 16 Aug 2021 15:43:14 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) 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; Mon, 16 Aug 2021 15:43:13 +0800 From: Kefeng Wang To: , Rob Herring , "Frank Rowand" CC: , Russell King , "Linus Walleij" , , Kefeng Wang , Ruizhe Lin Subject: [PATCH 3/3] amba: Properly handle device probe without IRQ domain Date: Mon, 16 Aug 2021 15:46:19 +0800 Message-ID: <20210816074619.177383-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210816074619.177383-1-wangkefeng.wang@huawei.com> References: <20210816074619.177383-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] 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 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; + ret = request_resource(parent, &dev->res); if (ret) goto err_out; diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 74afbb7a4f5e..32d5ff8df747 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -222,7 +222,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node, { struct amba_device *dev; const void *prop; - int i, ret; + int ret; pr_debug("Creating amba device %pOF\n", node); @@ -253,10 +253,6 @@ static struct amba_device *of_amba_device_create(struct device_node *node, if (prop) dev->periphid = of_read_ulong(prop, 1); - /* Decode the IRQs and address ranges */ - for (i = 0; i < AMBA_NR_IRQS; i++) - dev->irq[i] = irq_of_parse_and_map(node, i); - ret = of_address_to_resource(node, 0, &dev->res); if (ret) { pr_err("amba: of_address_to_resource() failed (%d) for %pOF\n", -- 2.26.2