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 02B7FC433F5 for ; Mon, 20 Dec 2021 11:55:01 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p8J3Dm12iWTcf7exp/AkGv4cfgJIrsfz8oEQORcNYCc=; b=P4cHNfL283bM51 I6Z0qzB5UnwGMes1DV9lLAVWT74BULV4ArHBEIDwzKi/hXvnlJ/fO+1a4ILL24uMr+jzRMxaZIc7P 1uvWWmTmBKEJyLYWqtfsUQY0OSXHKqZYAQE4xSLGsux+GMV2dJvxIovL7USt4AFdHhCcUmbn0ylsz 4GQTjtYf8f0nArP9/DJMGhTZar3reNu78eGtJaolMi+f31V1UxY8qdmzWvICNitpJwwH2B4Xj6dIp jgaCYTnADvisKpt+9VrmOht7BTiOvtFjpGf21aPR/5SEgcGt/7ySJv6DOCd+xBp4YIB9B46RpGd/8 KNyGDLlVYgq1EfJXQv+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzHEc-00277j-6U; Mon, 20 Dec 2021 11:53:42 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mzHEY-00275h-7W; Mon, 20 Dec 2021 11:53:39 +0000 Received: by mail-lf1-x135.google.com with SMTP id k21so2936491lfu.0; Mon, 20 Dec 2021 03:53:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=26xwnj5Rc4PxUxWQ0D4wRedOgH4U0TnIyB5Pyr5ElXM=; b=puS2aGCNbSMFjhnD38Y8XSMXeVjdv5GML2E0GBnEjRppvkzbEgR0Tro45eqcyQJrhu BHBH1cfwa/nWE/fuxBIWrmlkMvXBdrAmQtxCdsNWDWC42WdDQ5HY1+LZc4jM4RVcL1pv HS64ocU6jjBlRGziB8kzJUbU0zBPlsw1jHxSFFgiBCm+oImX1h8Vt5DxZXmF/DkbTxao m4k2dFmai2Yf1o9nL8etwhFpEXaKr02wR8BXo9PW3WrfAWROklN6BUaPNno/S1EjQ1EI i+ICSCKkbCB3/TuES4c0o4zrQHaa+G91qzCErZ0KzWl6O9OxQbx7BNMaUU+CsL9u5f0Z B5jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=26xwnj5Rc4PxUxWQ0D4wRedOgH4U0TnIyB5Pyr5ElXM=; b=0hEtnVNZNEBo+xJomoCOrQ5//ZiysIWpLIcItercedejP1htuW01DCenvY1dv/7vzt j5Clk9Lf3Ql07OgguEp0SpWcoEN0hMXaMtB8s0ppshGIkmJe3hEtzx7iRwr9HKGfKkM8 adXFZYDBkQIpLP/hkXNXcPUijCI02c6ekC+3LNwThvx+OnZojcwVjIOws7QrwOLctd3E LPLcfsdYc2ZpL2z+vvhqahjIOgcpvpSpLA9UvilXL8gV21Q46AhxXm5XCjuSPvLfsTS8 4Sbp0T/H4uoc2zb2hKhAgPWqVSziWS8wENk8VhUXLF9kFKsRT/daHrhWQwIH03EyIJiV GnaA== X-Gm-Message-State: AOAM531tM39ekl0IXOZzQATiVImOITbh0vn2gD68CNUltdhDHZORNNoZ 0XTnj5JI91OpiLj5CRQXkhg= X-Google-Smtp-Source: ABdhPJzvCk2woxK/Bccuz0lcve5nuC7UjZgBk2V0xbwweezLib7eEYvCugQEhe0cBGr2KRpO6gA+QA== X-Received: by 2002:a05:6512:ea2:: with SMTP id bi34mr15866909lfb.12.1640001215406; Mon, 20 Dec 2021 03:53:35 -0800 (PST) Received: from [192.168.1.100] ([31.173.82.33]) by smtp.gmail.com with ESMTPSA id g26sm945488lfb.158.2021.12.20.03.53.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Dec 2021 03:53:34 -0800 (PST) Message-ID: <042a2183-3f04-088c-1861-656de870337d@gmail.com> Date: Mon, 20 Dec 2021 14:53:27 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH 2/3] i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt Content-Language: en-US To: Geert Uytterhoeven , Lad Prabhakar Cc: 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 , Prabhakar , Linux-sh list References: <20211218165258.16716-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20211218165258.16716-3-prabhakar.mahadev-lad.rj@bp.renesas.com> From: Sergei Shtylyov Organization: Brain-dead Software In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211220_035338_312333_4C231D96 X-CRM114-Status: GOOD ( 30.25 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 20.12.2021 13:17, Geert Uytterhoeven 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. > >> 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? > >> + if (irq <= 0 && irq != -ENXIO) >> + return irq ? irq : -ENXIO; > > Can irq == 0 really happen? Doesn't matter much in this case -- devm_request_irq() happily takes IRQ0. :-) > 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). > 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: Warning or no warning, 0 is still returned. :-/ My attempt to put an end to this has stuck waiting a review from the IRQ people... > the rare users may not have upgraded their kernels beyond v5.8 yet... > >> + 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