From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81872C432BE for ; Tue, 24 Aug 2021 20:08:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6643561262 for ; Tue, 24 Aug 2021 20:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234780AbhHXUJm (ORCPT ); Tue, 24 Aug 2021 16:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbhHXUJl (ORCPT ); Tue, 24 Aug 2021 16:09:41 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86522C061757 for ; Tue, 24 Aug 2021 13:08:56 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id z128so43313820ybc.10 for ; Tue, 24 Aug 2021 13:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F5e1UqcNeXqqqIbmlY1mNsIR9q95Ez+3wFDl23ZZGpQ=; b=fv/JThfp9GEwMkn3x96ddxImdAStoVrVpBe3DWTUXk6sFz4QCo0OUFahDIkOLE3RPP gkpoUWwEXKelZvoGpnr7YHFnxdbGst9bePhlAJzGfkajcC3jfXw5XWDIdeej8K8U/erm DFiXWSOb0/0WX9msgvIdxU9V5mnkmCkO3fsDcmEpDgpyErWxMbE/XA92ibk4NuPrgN7b eaHCb7jGiQjmw/w2xWw01p6sAypRclXZS62q2oF4xPGCaykvZae3j9Sqb5OdfXH+PqAm q6gu/6FFjLG6FBkgmyzx6TO/kefEIEJ13zgmifhEqEt0DGJ2/+JDISYZ3L39g/wdFOaV YlJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F5e1UqcNeXqqqIbmlY1mNsIR9q95Ez+3wFDl23ZZGpQ=; b=Z1F1kVeWeWSNDuenQr//gW8FU7nvc7CRALcm1v5v1G+D0OJ0W9IHsOcVlGfKbJXiRA x0aE+iEYideRa94RgLwGCKjE8Ahr+QG2/tueSzXH4iZVPv11W6YwDEeRo+9hO74lVkkb qpdw4P0Gk3k5MKplJBnqQElJWIwGct38A6EvSIosdV3eMa6mYAqJt/v8LFhxlT6P3cXK 97pv545C9axYszEyNipZfsiRHrpY7T+hzuWCe0VppYyQFwE9uS04btCROzOa5SQpnfvY xf8J8UCvx1GaKcAzArxB2/mtI4KyFZtorcHlKgBDmjnKSa00E172eqKVJsb4wzdweYfq 8U8w== X-Gm-Message-State: AOAM5303+1P3KxGrPrk0Fr1jZcX5Ewi+1up04Lx02CAjbZ0a4sBriLUw YlzokkhEiDY6twUsatgTJcTUAtZtYeOOavt+Xb7sqg== X-Google-Smtp-Source: ABdhPJwAmvFlzL4gm2+wLFJNEj2whFnulqk+m/QHIiUlkmaKbJTK9+lzObJYqW8RHttpf1rQDlni1pTfhEm/Ax+BeC0= X-Received: by 2002:a25:d2c8:: with SMTP id j191mr7322236ybg.412.1629835735586; Tue, 24 Aug 2021 13:08:55 -0700 (PDT) MIME-Version: 1.0 References: <20210816074619.177383-1-wangkefeng.wang@huawei.com> <20210816074619.177383-4-wangkefeng.wang@huawei.com> In-Reply-To: From: Saravana Kannan Date: Tue, 24 Aug 2021 13:08:19 -0700 Message-ID: Subject: Re: [PATCH 3/3] amba: Properly handle device probe without IRQ domain To: Rob Herring Cc: Kefeng Wang , "linux-kernel@vger.kernel.org" , Frank Rowand , devicetree@vger.kernel.org, Russell King , Linus Walleij , linux-arm-kernel , Ruizhe Lin Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -Saravana > > 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 > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00B8AC4338F for ; Tue, 24 Aug 2021 20:11:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA75C61040 for ; Tue, 24 Aug 2021 20:11:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BA75C61040 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=m9HxNVynaelV4NpytRrauNygXzCtvIudqiXjpj9M5c0=; b=GVxOoM+924Hx+A rR68kxB2oupAbdorzRPs9X5ToYk9OW6UO5HOTtjrfRWNoq/KEuihSepJwLzAQCaQi4L6g8MngeLuV 6jsGL03X0nM4KErhKujhSNRKZmz7a9XwzAKGU1vx4e4mpIsvZASpwYQhfggnfpV9eKwSP3JapkBbg n3yfGYkx4JD7jsSWXnhk8faWJWkDHhlUZBC+2SQkvwclJLZqYnJbnsCOWTXn9T1Ovs8JyVOWrycht ib2+mcJ5PZKaLm4LDrzBs5W+9Gan+RIl9hN7AW6Cd+L7F1qz8I/Bn9xx3wcKI0rQyrTEL0NB6pG74 XGNIxWsqJWE0HQg8f2lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIcjI-004cHH-2k; Tue, 24 Aug 2021 20:09:04 +0000 Received: from mail-yb1-xb32.google.com ([2607:f8b0:4864:20::b32]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIcjC-004cFG-DV for linux-arm-kernel@lists.infradead.org; Tue, 24 Aug 2021 20:09:00 +0000 Received: by mail-yb1-xb32.google.com with SMTP id n126so30038845ybf.6 for ; Tue, 24 Aug 2021 13:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F5e1UqcNeXqqqIbmlY1mNsIR9q95Ez+3wFDl23ZZGpQ=; b=fv/JThfp9GEwMkn3x96ddxImdAStoVrVpBe3DWTUXk6sFz4QCo0OUFahDIkOLE3RPP gkpoUWwEXKelZvoGpnr7YHFnxdbGst9bePhlAJzGfkajcC3jfXw5XWDIdeej8K8U/erm DFiXWSOb0/0WX9msgvIdxU9V5mnkmCkO3fsDcmEpDgpyErWxMbE/XA92ibk4NuPrgN7b eaHCb7jGiQjmw/w2xWw01p6sAypRclXZS62q2oF4xPGCaykvZae3j9Sqb5OdfXH+PqAm q6gu/6FFjLG6FBkgmyzx6TO/kefEIEJ13zgmifhEqEt0DGJ2/+JDISYZ3L39g/wdFOaV YlJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=F5e1UqcNeXqqqIbmlY1mNsIR9q95Ez+3wFDl23ZZGpQ=; b=DySiVzdK9n/1pNCyEPbjToJEDzeMPC/eYvdxOaty99SNCjHvItwl/xSshoxRq8TCU5 AqEGrnOudOMjUftVFWX4oCEaq4h6seNm0U5fIYIhjalFRvGd6jXQyx6vR6Wgxx1wX4zl lflyyFuJynohoSvb6NIILve5zDoRtpAYtieGUp8YdOIEkx1JReZ1s5SiZtMLnlxQC2Sp phw0Vj41VIYGZ0F663U0L2E7sxjGsGR2mnU3VcbTeosVVOOxz1Z1SIL9rmeXEZdm8CU4 w9G0jrPQWi0IzyivnRdRBEVGvGQW83bYvLFXlUNRl+Q6vqa+6LGSsc0UScctcP2+x9oO 3dAw== X-Gm-Message-State: AOAM5336TQ61Cbae6wZUHgZfTEZD02yLjrlYr9sUjpFVNiHRLm192fo0 ElpZc1pGMQY+UJX9nABhW5kWNnddwoAzAjA5BZ9LTg== X-Google-Smtp-Source: ABdhPJwAmvFlzL4gm2+wLFJNEj2whFnulqk+m/QHIiUlkmaKbJTK9+lzObJYqW8RHttpf1rQDlni1pTfhEm/Ax+BeC0= X-Received: by 2002:a25:d2c8:: with SMTP id j191mr7322236ybg.412.1629835735586; Tue, 24 Aug 2021 13:08:55 -0700 (PDT) MIME-Version: 1.0 References: <20210816074619.177383-1-wangkefeng.wang@huawei.com> <20210816074619.177383-4-wangkefeng.wang@huawei.com> In-Reply-To: From: Saravana Kannan Date: Tue, 24 Aug 2021 13:08:19 -0700 Message-ID: Subject: Re: [PATCH 3/3] amba: Properly handle device probe without IRQ domain To: Rob Herring Cc: Kefeng Wang , "linux-kernel@vger.kernel.org" , Frank Rowand , devicetree@vger.kernel.org, Russell King , Linus Walleij , linux-arm-kernel , Ruizhe Lin X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210824_130858_623567_2339910C X-CRM114-Status: GOOD ( 37.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. -Saravana > > 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 > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel