Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2102963rwd; Fri, 19 May 2023 00:37:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NBK3eeFXQ86ZY1cGcS4Snp8xNWLk3v2+pYnnAgu8uaH0i0CFwK9B3eIzsByKbAArQtkiw X-Received: by 2002:a17:903:41c4:b0:1ac:3fe0:d6ad with SMTP id u4-20020a17090341c400b001ac3fe0d6admr1944936ple.65.1684481846434; Fri, 19 May 2023 00:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684481846; cv=none; d=google.com; s=arc-20160816; b=Jl0KqSfV9RG5Q/BBX0pasmOI7AwN+yUpDAvRAoY3G6f8uerD5VmkbPCZB3CK9URTyA wQT5oPB7t/vQbnB18FBSsRQXlAlMX47PTYkPfEpxOTOpk6HHMa0AqhjBRhcAjtLVpeMQ KtBnMTIx3SINb8I/6vAaEgNWEnLbB6fZ/SyWkXttlVdh7Ml3A252163A9rxCJI48zSxb dqn2hidaWQUfMQDEO2SpM5jsErgYmTbfjNJ/5rGzbyeB7mQyZ+++7jtNaisCcaWlmemI lZqEL8OUDmlZlxhvm+vgaEpUt+r/7CEqxqHuFpqTkBDgEsYOGCAJ2tX7p9nahdkeyB4m G/pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UbOI2BswfJZla5qXGK39angeaoacnpzerdSxrcRJE4E=; b=CkbUndJj+9vUev79rdhTGiz5SCnvOJteNIzI46NYUa4XSphsbjxjPBtSuLF09bfacy qhA2qV+laT4sqbpOkBq1dM2Tzd7fYJzyDUGzPHy14/ik5OJOQ3bI0fGX9pQyeKUzGf2+ HaJ4YZcgiB3su1cT/zStFBdSCNLsaM2axmz44tT7TWcMRwAAftZGIpC4GuD6/h6mpW0x mqC+YucuuW3Ia95hoDY+rOHvz4K8souhjVk8+mbRr+vUVfx9cF3zczyOKHiEAWruopZ9 OBpKAMBmdFYkpeOd1fxapa+eCaWGJAA0+N4gUYUbf2pU+EftSVqyhbH453USkRj+m/+U KDAw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a170902b10100b001ac34fed041si2878788plr.475.2023.05.19.00.37.10; Fri, 19 May 2023 00:37:26 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229769AbjESHRP (ORCPT + 99 others); Fri, 19 May 2023 03:17:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbjESHRN (ORCPT ); Fri, 19 May 2023 03:17:13 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 654DBE7F for ; Fri, 19 May 2023 00:17:11 -0700 (PDT) Received: from moin.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::7b] helo=bjornoya.blackshift.org) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pzuM3-0007xp-KD; Fri, 19 May 2023 09:16:47 +0200 Received: from pengutronix.de (unknown [172.20.34.65]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id 942241C837F; Fri, 19 May 2023 07:16:43 +0000 (UTC) Date: Fri, 19 May 2023 09:16:43 +0200 From: Marc Kleine-Budde To: Judith Mendez Cc: Chandrasekar Ramakrishnan , linux-can@vger.kernel.org, Wolfgang Grandegger , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Schuyler Patton , Tero Kristo , Rob Herring , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Oliver Hartkopp , Conor Dooley Subject: Re: [PATCH v6 2/2] can: m_can: Add hrtimer to generate software interrupt Message-ID: <20230519-morbidity-directory-dbe704584aa3-mkl@pengutronix.de> References: <20230518193613.15185-1-jm@ti.com> <20230518193613.15185-3-jm@ti.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="iuo7eibl3agbzuu3" Content-Disposition: inline In-Reply-To: <20230518193613.15185-3-jm@ti.com> X-SA-Exim-Connect-IP: 2a0a:edc0:0:b01:1d::7b X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 --iuo7eibl3agbzuu3 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 18.05.2023 14:36:13, Judith Mendez wrote: > Add an hrtimer to MCAN class device. Each MCAN will have its own > hrtimer instantiated if there is no hardware interrupt found and > poll-interval property is defined in device tree M_CAN node. >=20 > The hrtimer 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. >=20 > Signed-off-by: Judith Mendez [...] > diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_c= an/m_can_platform.c > index 94dc82644113..3e60cebd9d12 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/ > =20 > +#include > #include > #include > =20 > @@ -96,12 +97,40 @@ static int m_can_plat_probe(struct platform_device *p= dev) > goto probe_fail; > =20 > addr =3D devm_platform_ioremap_resource_byname(pdev, "m_can"); > - irq =3D platform_get_irq_byname(pdev, "int0"); > - if (IS_ERR(addr) || irq < 0) { > - ret =3D -EINVAL; > + if (IS_ERR(addr)) { > + ret =3D PTR_ERR(addr); > goto probe_fail; > } > =20 As we don't use an explicit "poll-interval" anymore, this needs some cleanup. The flow should be (pseudo code, error handling omitted): if (device_property_present("interrupts") { platform_get_irq_byname(); polling =3D false; } else { hrtimer_init(); polling =3D true; } > + irq =3D platform_get_irq_byname_optional(pdev, "int0"); Remove the "_optional" and.... > + if (irq =3D=3D -EPROBE_DEFER) { > + ret =3D -EPROBE_DEFER; > + goto probe_fail; > + } > + > + if (device_property_present(mcan_class->dev, "interrupts") || > + device_property_present(mcan_class->dev, "interrupt-names")) > + mcan_class->polling =3D false; =2E..move the platform_get_irq_byname() here > + else > + mcan_class->polling =3D true; > + > + if (!mcan_class->polling && irq < 0) { > + ret =3D -ENXIO; > + dev_err_probe(mcan_class->dev, ret, "IRQ int0 not found, polling not a= ctivated\n"); > + goto probe_fail; > + } Remove this check. > + > + if (mcan_class->polling) { > + if (irq > 0) { > + mcan_class->polling =3D false; > + dev_info(mcan_class->dev, "Polling enabled, using hardware IRQ\n"); Remove this. > + } else { > + dev_dbg(mcan_class->dev, "Polling enabled, initialize hrtimer"); > + hrtimer_init(&mcan_class->hrtimer, CLOCK_MONOTONIC, > + HRTIMER_MODE_REL_PINNED); move this backwards, where you set "polling =3D true" > + } > + } > + > /* message ram could be shared */ > res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram= "); > if (!res) { > --=20 > 2.17.1 Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung N=C3=BCrnberg | Phone: +49-5121-206917-129 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 | --iuo7eibl3agbzuu3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEDs2BvajyNKlf9TJQvlAcSiqKBOgFAmRnIlgACgkQvlAcSiqK BOgXywf/RpAXV/U1zHDPBijDrYbooi5qG+9apga4pa83AeVAmCSFEvc4HdppRD9a 44eyG2UYRZER6Yotk3qLMev4Pawss2VbjbxAgxUvb7cTqkxEw7EppC8updsbneww 4NsVsG0IJ+6J68R73+FZ0ero9kcKXbHWvqTz/xEWFfEGll+S89W5lRpybDzDUoa4 f0ggPvpHbvKMSQWRwTh3EtTY59Ym9QYaQ/ZdEGKG1W/yPN4McVLFUwrcoi3xI/oV V9Qf5kf36sZ3z32MqMCtQaqKLaCiuL3LVsx98rkDH/k0Wb8JjSCt/3Y7KtU1tg5g NyKk4mhSR+pxCNUwBVWiGGhc4Asgsw== =W8BC -----END PGP SIGNATURE----- --iuo7eibl3agbzuu3--