Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp382289pxb; Wed, 25 Aug 2021 05:38:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIPSkmKaZLVRTuIc7BU6dER0gqesdKZmR8GdbO/cjLm9Ye8CKfqWIxhrFQTrwzl+rCfduu X-Received: by 2002:aa7:d95a:: with SMTP id l26mr12584994eds.305.1629895090735; Wed, 25 Aug 2021 05:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629895090; cv=none; d=google.com; s=arc-20160816; b=muEYJr4H5fYki3SXRJDJqfWs85uDreAN4qmf1Y/r1adsjLDS4AL47RTsy6gxyefDxu 6DkhPJd7f6DMvVplPp3TGrFU8HxelrYvWYGsVAzrkXYQvgxJ2L6kxItN6iX81PoPQDDO B4hUo2FnqI/5PP8px7oEUjkszbRwjTPe6HOFj+C0WHjy6tZijmuOXOyyCMpo+87ZKvQz 0XH7ebnehUaF0bPXNQYOeEqQbbTYnABPvlfC2JnrjsfsKUU72aB8EzWJBjjoeeZF719U cvFBwdcPFhx02lbu7fFwAIKb5DRbHMEIeZNYaffNmfPVEcTU0yh+pNd10BhgFgiyg6if HpyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KoRMFmsYKLYGCVkd8lCprOsByHqtPBGwvnIgAHDe8t0=; b=HDxks2QVvBDXUcLFFQGo0WcIFz/L8gpQiqtsZIEI51AAF0+aUUe522gX0jrA7sxKId kIDxnGx8pChh5p9L2/OQdHYPVEV6wnfuQHrJ9Xe5h2QWlvn8r4a63J0arzCM2WQPJ5+8 jKT99bWjnI/Nj9cCpYqfGN9BmS+9GC3MnEanfr2kMw+kjdaPKTOxDhf6X1GvbM3yvF4Y c8bzyyUSIRYOBuRf+BuqUMBMU/EAJR4FFJrMox30y7olzrxObWqraaF8gH4VESJ7Y4Xq +VG/gOs+K3Uhc/SKAdmOuNNSrbNOMLBOt2mQPifTsyMfeTRw5Ji/36oHq1SYo7Zia2bL T05w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ptaaKz6B; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw25si12920683edb.390.2021.08.25.05.37.46; Wed, 25 Aug 2021 05:38:10 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ptaaKz6B; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240886AbhHYMek (ORCPT + 99 others); Wed, 25 Aug 2021 08:34:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:40324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240864AbhHYMej (ORCPT ); Wed, 25 Aug 2021 08:34:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 96DC261184; Wed, 25 Aug 2021 12:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629894833; bh=qrESRDAEVzdBOBV/LmDq/fGG6ZFyDzbuKD741OD8lw8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ptaaKz6BM9sC8AF20cxv7ay0tp6xTyNsiqtL2al4Vfzn5R+ZpYOzYOA1xvXnZIzYv PK+FJmuXp6S3mHqbiW2UKQq6mAI2X8nyGt/HfhWPtyoTfmjANXs7zRq2qa4ZK9R00a 2GeLpDdA1fYdEBma/psBZD4Vpv/wfkgjqrgTLUCITNmWf9Oxby2bMf5JhgfhTFCFUf YiiPXUeOLv2Sv2hvGK2Pz4oSisNhom7rLCUthmjn6Fd56XJpAfaMUfktEi+uer9p5n lViqpSR/iT8mLu6A5dsUDndWcW36EM/rO8SqPM5nBHRvYaZPpsOKtrUy10JY7idyE6 /3fn8EfzOk/3g== Received: by mail-ed1-f46.google.com with SMTP id q3so36753667edt.5; Wed, 25 Aug 2021 05:33:53 -0700 (PDT) X-Gm-Message-State: AOAM530zSDlSjn0+Gtpqi8tvzNtBCXLK104Yj6Atbz9mByARJFqx9oLZ /YJ7J7NLVzk//Y3EOaBsUL7fb90M0bgMcLpEmg== X-Received: by 2002:aa7:cb19:: with SMTP id s25mr49263006edt.194.1629894832158; Wed, 25 Aug 2021 05:33:52 -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: Rob Herring Date: Wed, 25 Aug 2021 07:33:40 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] amba: Properly handle device probe without IRQ domain To: Kefeng Wang Cc: Saravana Kannan , "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 11:05 PM Kefeng Wang wrote: > > > 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; I wonder if we could just remove these. Why does userspace need them in the first place? It's only an ABI if someone notices. Looking at the history, AMBA bus was added in 2003 with just 'irq' and then changed (ABI break) in 2004 to 'irq0' and 'irq1'. Rob [1] https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git/log/arch/arm/common/amba.c