Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31010110rwd; Thu, 6 Jul 2023 14:15:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlH7nxUTF03IyIoA6muyVJK+rGi6scKQQ3qwi9SV4TUn56QnI6h8r15X23cbBhvLT+OWXEaR X-Received: by 2002:a05:6a20:918e:b0:106:9266:4448 with SMTP id v14-20020a056a20918e00b0010692664448mr5151342pzd.16.1688678103144; Thu, 06 Jul 2023 14:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688678103; cv=none; d=google.com; s=arc-20160816; b=tqqKl462f8LZuFW9kSarXDoj9NHya0m1yCfFo7aB2YcMQ3LrPvZHu63jl81ZEcipmW 1M7N/EQy43HHe4JoQOZre6wrnfIJ5xcRz0j311QpT6fUrpjUp1g7LW3Sg6AdhSH+OITw UpTEvuPK8sTgXRNgJ0zlnqJpoPK8n9phKczi4QPeCwoqUXULnKUHamWrmwBu6VCTx29w YXwk2V1/f14JHfbNT4lDBaUpgaImpYJoIAhcX/JM+e0WeaC1h2Ejwsmro7Qh1F4hULJ2 z6TKLiG3S+S8WI+5Hx5zFiTmvGYzj6VFnE87v8bZcp+5nBMbhnUcNu/gBYjWyPqcz9rt EBpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=n1W53TeQDe5JDCf7UtyqlAcHmKtsABgVqfo1mFuklQc=; fh=aRWwJCDqQJPwwGgR1pXPI5k54a8IEb0O8AVOofG0yCQ=; b=LvqEwoWbxyHoUOMmSwm1u9e6aNXIg/jUkCv6cXcu5yPzXQnneV2l+3O4rCjiAobKev yr3maMgNI2Tn+ORwCONTdnu+ot37FZhkbVYFzTU3YVrvpYPLGd2gKrC9ps8zciq/3RZn 5cBjD3WE1gcTL0iQ9tofdKwey1e/G7LGkkc9Us7huy3U3mXE1V6saHxPrhE9tQB3enSu 7cnWK+ZtXUSgXgwEkETZFA+06t2+kHjGysNG4hhcN7G/OLq+/dgRFX/yIGS/ndF1uObs icBnRUzZdZhrj3H9QegmLc1LXp5nhqZoGLA+WffLIVkgs8ogd2qZTelh80o0NWu2PkKb IGfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xTREQGBc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cj24-20020a056a00299800b0063b356e36fesi2217054pfb.372.2023.07.06.14.14.51; Thu, 06 Jul 2023 14:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xTREQGBc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232480AbjGFVNW (ORCPT + 99 others); Thu, 6 Jul 2023 17:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbjGFVNV (ORCPT ); Thu, 6 Jul 2023 17:13:21 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B08919A7; Thu, 6 Jul 2023 14:13:19 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 366LCiYc031415; Thu, 6 Jul 2023 16:12:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1688677964; bh=n1W53TeQDe5JDCf7UtyqlAcHmKtsABgVqfo1mFuklQc=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=xTREQGBcMBf3NLvztHSFWf8W8ieUtzsm3JJMAO+L9NTMlBIzMwpRkB+Z7QHKwil1R 2ptXWyL/9WUHfr9DUMHPtUoRtPtqMRuLKud6HSdR3PGMApF/7Axfy+iUZeclJkjaR8 2rkXK40iuyiOVacKm5VkV/UBVpIauPVDu+gMlQ9Y= Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 366LCiob031221 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 6 Jul 2023 16:12:44 -0500 Received: from DLEE110.ent.ti.com (157.170.170.21) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Thu, 6 Jul 2023 16:12:43 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE110.ent.ti.com (157.170.170.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Thu, 6 Jul 2023 16:12:43 -0500 Received: from [128.247.81.105] (ileaxei01-snat.itg.ti.com [10.180.69.5]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 366LChjb027967; Thu, 6 Jul 2023 16:12:43 -0500 Message-ID: Date: Thu, 6 Jul 2023 16:12:43 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 2/2] can: m_can: Add hrtimer to generate software interrupt Content-Language: en-US To: Francesco Dolcini CC: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , , Schuyler Patton , Tero Kristo , Rob Herring , Krzysztof Kozlowski , , Oliver Hartkopp , Simon Horman References: <20230705195356.866774-1-jm@ti.com> <20230705195356.866774-3-jm@ti.com> <20230706-unstopped-skedaddle-7168f2b12189-mkl@pengutronix.de> <0ba17779-9cd9-6cb2-a79c-6b14b73a42db@ti.com> From: Judith Mendez In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 7/6/23 3:21 PM, Francesco Dolcini wrote: > On Thu, Jul 06, 2023 at 10:20:59AM -0500, Judith Mendez wrote: >> Hi Marc >> >> On 7/6/23 2:25 AM, Marc Kleine-Budde wrote: >>> On 05.07.2023 14:53:56, Judith Mendez wrote: >>>> Introduce timer polling method to MCAN since some SoCs may not >>>> have M_CAN interrupt routed to A53 Linux and do not have >>>> interrupt property in device tree M_CAN node. >>>> >>>> On AM62x SoC, MCANs on MCU domain do not have hardware interrupt >>>> routed to A53 Linux, instead they will use timer polling method. >>>> >>>> Add an hrtimer to MCAN class device. Each MCAN will have its own >>>> hrtimer instantiated if there is no hardware interrupt found in >>>> device tree M_CAN node. The timer will generate a software >>>> interrupt every 1 ms. In hrtimer callback, we check if there is >>>> a transaction pending by reading a register, then process by >>>> calling the isr if there is. >>>> >>>> Tested-by: Hiago De Franco # Toradex Verdin AM62 >>>> Reviewed-by: Tony Lindgren >>>> Signed-off-by: Judith Mendez >>>> --- > > ... > >>>> diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c >>>> index 94dc82644113..76d11ce38220 100644 >>>> --- a/drivers/net/can/m_can/m_can_platform.c >>>> +++ b/drivers/net/can/m_can/m_can_platform.c >>>> @@ -5,6 +5,7 @@ >>>> // >>>> // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/ >>>> +#include >>>> #include >>>> #include >>>> @@ -96,12 +97,28 @@ static int m_can_plat_probe(struct platform_device *pdev) >>>> goto probe_fail; >>> >>> Please set "irq" to 0 during declaration. >> >> During declaration of irq, it is already set to 0: >> >> int irq, ret = 0; > > The initialization here applies only to ret. > > int irq = 0, ret = 0; Understood, thanks! > >>>> addr = devm_platform_ioremap_resource_byname(pdev, "m_can"); >>>> - irq = platform_get_irq_byname(pdev, "int0"); >>>> - if (IS_ERR(addr) || irq < 0) { >>>> - ret = -EINVAL; >>>> + if (IS_ERR(addr)) { >>>> + ret = PTR_ERR(addr); >>>> goto probe_fail; >>>> } >>>> + if (device_property_present(mcan_class->dev, "interrupts") || >>>> + device_property_present(mcan_class->dev, "interrupt-names")) { >>>> + irq = platform_get_irq_byname(pdev, "int0"); >>>> + if (irq == -EPROBE_DEFER) { >>>> + ret = -EPROBE_DEFER; >>>> + goto probe_fail; >>>> + } >>>> + if (irq < 0) { >>>> + ret = -EINVAL; >>> >>> Please return the original error value. >> >> The original value returned is -EINVAL: >> >> - if (IS_ERR(addr) || irq < 0) { >> - ret = -EINVAL; >> >> Perhaps I am missing something here? > > if (irq < 0) { > ret = irq; > ... > } > > And you can also get rid of the explicit test for -EPROBE_DEFER this > way simplifying the code. I misunderstood, thanks!! ~ Judith