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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20A8FC433EF for ; Mon, 20 Dec 2021 11:56:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232212AbhLTL4B (ORCPT ); Mon, 20 Dec 2021 06:56:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232119AbhLTL4A (ORCPT ); Mon, 20 Dec 2021 06:56:00 -0500 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A925EC061574; Mon, 20 Dec 2021 03:56:00 -0800 (PST) Received: by mail-yb1-xb30.google.com with SMTP id y68so28053050ybe.1; Mon, 20 Dec 2021 03:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5/crEyEqm9JXUuy5rjWxQ+CMQQRqWO7tHqYVFHQvrBs=; b=mXrhHqYHkn5WA7ONhl0448/qRonQDH308gWLxvXXjOj5BwqAJ5ce7EKjpyzKs/C2xu acpRVM+USp+1N0Tx8VhwuySoFbC9axrKCU7f5sk1h781KOrvwHIt7XsRGNOYHcdHtxNr 8xGRDvTpZu1JccymjbSsD3rDkwZi3nHVWkIjKduwU1GDJZ8a7vQaxL9pM73AJ9LGY31T WWjcmZ3nfgdLz4N+c5MU3Sgc72NQ9f8Or2TtAJKd1DP4iqWDAk9nVWBXD5AUqDMd0qie swl7tZrd/LMJrFBh9CaoyjVSlcr5pLRaf/YqIYq++3Wv3jj4cwr7QjMeAuz3myO2R52f McuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5/crEyEqm9JXUuy5rjWxQ+CMQQRqWO7tHqYVFHQvrBs=; b=w99VnqXRQoK91BhE4tUN29Qmd0iFmp1GiaE/nOeT8UHhY1Jgje+tTObNAg7YyQnrj/ vOmCJ+ViJOy8d1mXf2LqUfQ+Ohu1Le6g0f3VIA12j/F1l92p5d8kWd/bUM+ykMWXslkY 00lZyHW7iwa6AmowB9Bhkju0ugWTyscB/BPHduAyS6zK4Ge2hfHT3Q7fKHjj2wY8cYpY cu8JklXk0wzPWdGnDs1dVh2aTnOBVBjPzsKuZfIEEAL6bmLtfFFFMZR14XHZl7S/F9v7 mhpgRwPUXVsjO3MRFcPHc98YKj+vV4SI/SKFNKWu1uAXL04FotFg+b7PHr7OzLk1NqE+ LZ6g== X-Gm-Message-State: AOAM531lwXTFpc/27utsF+fsFzsxoKeBha62qIUjHA6m6z1u4pyXrQQX 4Z4Kqx8a9DzwbI4/A3XDR2Bitm6R4aoBod5lEmE= X-Google-Smtp-Source: ABdhPJysWqs3UIISqCAQj4ffQ5qMe9Bpl2EXfUC7zH6b93AKzhohiEKwF4Ewph//Iz3ChGcjfDKCLckgOCL2PP+4gd8= X-Received: by 2002:a25:84c1:: with SMTP id x1mr22282261ybm.690.1640001359897; Mon, 20 Dec 2021 03:55:59 -0800 (PST) MIME-Version: 1.0 References: <20211218165258.16716-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20211218165258.16716-3-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Mon, 20 Dec 2021 11:55:33 +0000 Message-ID: Subject: Re: [PATCH 2/3] i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt To: Geert Uytterhoeven Cc: Lad Prabhakar , Rob Herring , Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list , Chris Brandt , Wolfram Sang , Linux I2C , linux-rpi-kernel , Linux ARM , Linux Kernel Mailing List , Linux-Renesas , Linux-sh list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Hi Geert, Thank you for the review. On Mon, Dec 20, 2021 at 10:18 AM Geert Uytterhoeven wrote: > > Hi Prabhakar, > > On Sat, Dec 18, 2021 at 5:59 PM Lad Prabhakar > wrote: > > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static > > allocation of IRQ resources in DT core code, this causes an issue > > when using hierarchical interrupt domains using "interrupts" property > > in the node as this bypasses the hierarchical setup and messes up the > > irq chaining. > > Thanks for your patch! > > > In preparation for removal of static setup of IRQ resource from DT core > > code use platform_get_irq_optional() for DT users only. > > Why only for DT users? > Plenty of driver code shared by Renesas ARM (DT-based) on SuperH > (non-DT) SoCs already uses platform_get_irq_optional(), so I expect > that to work for both. > For the non DT users the IRQ resource is passed as a range [0] and not a single interrupt so I went with this approach. Is there a way I'm missing where we could still use platform_get_irq_xyz() variants for such cases? > > Signed-off-by: Lad Prabhakar > > > --- a/drivers/i2c/busses/i2c-sh_mobile.c > > +++ b/drivers/i2c/busses/i2c-sh_mobile.c > > @@ -830,20 +830,41 @@ static void sh_mobile_i2c_release_dma(struct sh_mobile_i2c_data *pd) > > > > static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, struct sh_mobile_i2c_data *pd) > > { > > - struct resource *res; > > - resource_size_t n; > > + struct device_node *np = dev_of_node(&dev->dev); > > int k = 0, ret; > > > > - while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { > > - for (n = res->start; n <= res->end; n++) { > > - ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr, > > - 0, dev_name(&dev->dev), pd); > > + if (!np) { > > + struct resource *res; > > + resource_size_t n; > > + > > + while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { > > + for (n = res->start; n <= res->end; n++) { > > + ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr, > > + 0, dev_name(&dev->dev), pd); > > + if (ret) { > > + dev_err(&dev->dev, "cannot request IRQ %pa\n", &n); > > + return ret; > > + } > > + } > > + k++; > > + } > > + } else { > > + int irq; > > + > > + do { > > + irq = platform_get_irq_optional(dev, k); > > Check for irq == -ENXIO first, to simplify the checks below? > OK. > > + if (irq <= 0 && irq != -ENXIO) > > + return irq ? irq : -ENXIO; > > Can irq == 0 really happen? > > All SuperH users of the "i2c-sh_mobile" platform device use an > evt2irq() value that is non-zero. > > I might have missed something, but it seems the only user of IRQ 0 on > SuperH is smsc911x Ethernet in arch/sh/boards/board-apsh4a3a.c and > arch/sh/boards/board-apsh4ad0a.c, which use evt2irq(0x200). > I'll keep that in mind if the Ethernet driver falls in the convection patch changes. > These should have been seeing the "0 is an invalid IRQ number" > warning splat since it was introduced in commit a85a6c86c25be2d2 > ("driver core: platform: Clarify that IRQ 0 is invalid"). Or not: > the rare users may not have upgraded their kernels beyond v5.8 yet... > Might be users have not updated their kernels. [0] https://elixir.bootlin.com/linux/v5.16-rc6/source/arch/sh/kernel/cpu/sh4a/setup-sh7724.c#L454 Cheers, Prabhakar > > + if (irq == -ENXIO) > > + break; > > + ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr, > > + 0, dev_name(&dev->dev), pd); > > if (ret) { > > - dev_err(&dev->dev, "cannot request IRQ %pa\n", &n); > > + dev_err(&dev->dev, "cannot request IRQ %d\n", irq); > > return ret; > > } > > - } > > - k++; > > + k++; > > + } while (irq); > > } > > > > return k > 0 ? 0 : -ENOENT; > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id CC7CAC433F5 for ; Mon, 20 Dec 2021 11:58:44 +0000 (UTC) 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=5rgTY5G1wgsXvp9ZTkrey0GFB7iSlllJds9wQD913OY=; b=Baol9JrtQ0Ncwv FVvAoyoPEZNaUM0z9/Dh7fTWKxGeN6ssiZJ8JBufW3XzKfCTCP0pRCl7oOFUiJk16roe4J2x3b1/v ZmG48Evh8iZtMyvqDORhlhBBNqd+S/PU3sK0BgW/lbWWm9JrCP3eBU5CPOHshKbnMOIxAjmBKKQ/e kUQDpXxVDUQ8saY/F7sFxdC5/jZMD8aJDfEigNayeE07JbxhbFPJRndr/XeQO0vszvMsjwJzeY0+/ 3+Yu7gjwJ0tIuYkD4pbDy6Wgx4FQ3w3izPqZhJuOVUvgD2JDvLHQTFONnKXYpIUxhHCAbRaq7UgmV R0iA0kbiTriUu1FTLwiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzHI3-0028eU-Ar; Mon, 20 Dec 2021 11:57:16 +0000 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzHGr-00283n-N9; Mon, 20 Dec 2021 11:56:03 +0000 Received: by mail-yb1-xb2d.google.com with SMTP id e136so27959383ybc.4; Mon, 20 Dec 2021 03:56:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5/crEyEqm9JXUuy5rjWxQ+CMQQRqWO7tHqYVFHQvrBs=; b=mXrhHqYHkn5WA7ONhl0448/qRonQDH308gWLxvXXjOj5BwqAJ5ce7EKjpyzKs/C2xu acpRVM+USp+1N0Tx8VhwuySoFbC9axrKCU7f5sk1h781KOrvwHIt7XsRGNOYHcdHtxNr 8xGRDvTpZu1JccymjbSsD3rDkwZi3nHVWkIjKduwU1GDJZ8a7vQaxL9pM73AJ9LGY31T WWjcmZ3nfgdLz4N+c5MU3Sgc72NQ9f8Or2TtAJKd1DP4iqWDAk9nVWBXD5AUqDMd0qie swl7tZrd/LMJrFBh9CaoyjVSlcr5pLRaf/YqIYq++3Wv3jj4cwr7QjMeAuz3myO2R52f McuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5/crEyEqm9JXUuy5rjWxQ+CMQQRqWO7tHqYVFHQvrBs=; b=xl0JDgYbky08toRl0S88CUAKB67Nt7+Na9XML/vO9rkRlQXCqZurO8gbIp8+7/Vk/8 UGGv8XrVjFObkzo0rwMeRNCuvOnZNyb+oNtqAsgITuJRIbdxICwmFQkeaoYaOQs5uLCZ XPqrk4stjyjKJ/1QntN2jUR4zkJ0LmTyxYCHTGjJ3gzptrD34SeMFKhWG1pIvEkxC+8M 2By4J82C0GxK1eAd1XdaYydzDulDtq/JetxBu6JToVz3FM/t1T/u47BnPlHH4Nw4dMEa 4OIighsRkH2pBSkeKAmzEqvpfYCcUQqujeuI1KMHQS2Rgf3ftXARTTa/2+4NPL2Zk1Cz G6lw== X-Gm-Message-State: AOAM531LIUjImcDI3xpvft57u+FexZKPArN9JIRNsgaSQgoWC1sT8IjS VT+egUsS2SD4r5qY14YljReJxtoPhcVR44Wqt7w= X-Google-Smtp-Source: ABdhPJysWqs3UIISqCAQj4ffQ5qMe9Bpl2EXfUC7zH6b93AKzhohiEKwF4Ewph//Iz3ChGcjfDKCLckgOCL2PP+4gd8= X-Received: by 2002:a25:84c1:: with SMTP id x1mr22282261ybm.690.1640001359897; Mon, 20 Dec 2021 03:55:59 -0800 (PST) MIME-Version: 1.0 References: <20211218165258.16716-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20211218165258.16716-3-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Mon, 20 Dec 2021 11:55:33 +0000 Message-ID: Subject: Re: [PATCH 2/3] i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt To: Geert Uytterhoeven Cc: Lad Prabhakar , Rob Herring , Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list , Chris Brandt , Wolfram Sang , Linux I2C , linux-rpi-kernel , Linux ARM , Linux Kernel Mailing List , Linux-Renesas , Linux-sh list X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211220_035601_845175_59CCB4D5 X-CRM114-Status: GOOD ( 39.46 ) 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 Hi Geert, Thank you for the review. On Mon, Dec 20, 2021 at 10:18 AM Geert Uytterhoeven wrote: > > Hi Prabhakar, > > On Sat, Dec 18, 2021 at 5:59 PM Lad Prabhakar > wrote: > > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static > > allocation of IRQ resources in DT core code, this causes an issue > > when using hierarchical interrupt domains using "interrupts" property > > in the node as this bypasses the hierarchical setup and messes up the > > irq chaining. > > Thanks for your patch! > > > In preparation for removal of static setup of IRQ resource from DT core > > code use platform_get_irq_optional() for DT users only. > > Why only for DT users? > Plenty of driver code shared by Renesas ARM (DT-based) on SuperH > (non-DT) SoCs already uses platform_get_irq_optional(), so I expect > that to work for both. > For the non DT users the IRQ resource is passed as a range [0] and not a single interrupt so I went with this approach. Is there a way I'm missing where we could still use platform_get_irq_xyz() variants for such cases? > > Signed-off-by: Lad Prabhakar > > > --- a/drivers/i2c/busses/i2c-sh_mobile.c > > +++ b/drivers/i2c/busses/i2c-sh_mobile.c > > @@ -830,20 +830,41 @@ static void sh_mobile_i2c_release_dma(struct sh_mobile_i2c_data *pd) > > > > static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, struct sh_mobile_i2c_data *pd) > > { > > - struct resource *res; > > - resource_size_t n; > > + struct device_node *np = dev_of_node(&dev->dev); > > int k = 0, ret; > > > > - while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { > > - for (n = res->start; n <= res->end; n++) { > > - ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr, > > - 0, dev_name(&dev->dev), pd); > > + if (!np) { > > + struct resource *res; > > + resource_size_t n; > > + > > + while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { > > + for (n = res->start; n <= res->end; n++) { > > + ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr, > > + 0, dev_name(&dev->dev), pd); > > + if (ret) { > > + dev_err(&dev->dev, "cannot request IRQ %pa\n", &n); > > + return ret; > > + } > > + } > > + k++; > > + } > > + } else { > > + int irq; > > + > > + do { > > + irq = platform_get_irq_optional(dev, k); > > Check for irq == -ENXIO first, to simplify the checks below? > OK. > > + if (irq <= 0 && irq != -ENXIO) > > + return irq ? irq : -ENXIO; > > Can irq == 0 really happen? > > All SuperH users of the "i2c-sh_mobile" platform device use an > evt2irq() value that is non-zero. > > I might have missed something, but it seems the only user of IRQ 0 on > SuperH is smsc911x Ethernet in arch/sh/boards/board-apsh4a3a.c and > arch/sh/boards/board-apsh4ad0a.c, which use evt2irq(0x200). > I'll keep that in mind if the Ethernet driver falls in the convection patch changes. > These should have been seeing the "0 is an invalid IRQ number" > warning splat since it was introduced in commit a85a6c86c25be2d2 > ("driver core: platform: Clarify that IRQ 0 is invalid"). Or not: > the rare users may not have upgraded their kernels beyond v5.8 yet... > Might be users have not updated their kernels. [0] https://elixir.bootlin.com/linux/v5.16-rc6/source/arch/sh/kernel/cpu/sh4a/setup-sh7724.c#L454 Cheers, Prabhakar > > + if (irq == -ENXIO) > > + break; > > + ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr, > > + 0, dev_name(&dev->dev), pd); > > if (ret) { > > - dev_err(&dev->dev, "cannot request IRQ %pa\n", &n); > > + dev_err(&dev->dev, "cannot request IRQ %d\n", irq); > > return ret; > > } > > - } > > - k++; > > + k++; > > + } while (irq); > > } > > > > return k > 0 ? 0 : -ENOENT; > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel