mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Judith Mendez <jm@ti.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
	<linux-can@vger.kernel.org>,
	Wolfgang Grandegger <wg@grandegger.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Schuyler Patton <spatton@ti.com>, Tero Kristo <kristo@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Conor Dooley <conor+dt@kernel.org>
Subject: Re: [PATCH v6 2/2] can: m_can: Add hrtimer to generate software interrupt
Date: Mon, 22 May 2023 14:00:04 -0500	[thread overview]
Message-ID: <31925752-8028-98fc-b6a4-9b8fe8a3ce0b@ti.com> (raw)
In-Reply-To: <20230522-manhunt-smooth-442d9d864f04-mkl@pengutronix.de>

Hello,

On 5/22/23 1:37 PM, Marc Kleine-Budde wrote:
> On 22.05.2023 10:17:38, Judith Mendez wrote:
>>>> diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/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/
>>>> +#include <linux/hrtimer.h>
>>>>    #include <linux/phy/phy.h>
>>>>    #include <linux/platform_device.h>
>>>> @@ -96,12 +97,40 @@ static int m_can_plat_probe(struct platform_device *pdev)
>>>>    		goto probe_fail;
>>>>    	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;
>>>>    	}
>>>
>>> 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 = false;
>>> } else {
>>>           hrtimer_init();
>>>           polling = true;
>>> }
>>
>> Ok.
>>
>>>
>>>> +	irq = platform_get_irq_byname_optional(pdev, "int0");
>>>
>>> Remove the "_optional" and....
>>
>> On V2, you asked to add the _optional?.....
>>
>>>   	irq = platform_get_irq_byname(pdev, "int0");
>>
>> use platform_get_irq_byname_optional(), it doesn't print an error
>> message.
> 
> ACK - I said that back in v2, when there was "poll-interval". But now we
> don't use "poll-interval" anymore, but test if interrupt properties are
> present.
> 
> See again pseudo-code I posted in my last mail:
> 
> | if (device_property_present("interrupts") {
> |          platform_get_irq_byname();
> 
> If this throws an error, it's fatal, bail out.
> 
> |          polling = false;
> | } else {
> |          hrtimer_init();
> |          polling = true;
> | }
> 

Ok, will add this then..


>>
>>>
>>>> +	if (irq == -EPROBE_DEFER) {
>>>> +		ret = -EPROBE_DEFER;
>>>> +		goto probe_fail;
>>>> +	}
>>>> +
>>>> +	if (device_property_present(mcan_class->dev, "interrupts") ||
>>>> +	    device_property_present(mcan_class->dev, "interrupt-names"))
>>>> +		mcan_class->polling = false;
>>>
>>> ...move the platform_get_irq_byname() here
>>
>> ok,
>>
>>>
>>>> +	else
>>>> +		mcan_class->polling = true;
>>>> +
>>>> +	if (!mcan_class->polling && irq < 0) {
>>>> +		ret = -ENXIO;
>>>> +		dev_err_probe(mcan_class->dev, ret, "IRQ int0 not found, polling not activated\n");
>>>> +		goto probe_fail;
>>>> +	}
>>>
>>> Remove this check.
>>
>> Should we not go to 'probe fail' if polling is not activated and irq is not
>> found?
> 
> If an interrupt property is present in the DT, we use it - if request
> IRQ fails, something is broken and we've already bailed out. See above.
> If there is no interrupt property we use polling.

Got it, thanks.

>>
>>>
>>>> +
>>>> +	if (mcan_class->polling) {
>>>> +		if (irq > 0) {
>>>> +			mcan_class->polling = false;
>>>> +			dev_info(mcan_class->dev, "Polling enabled, using hardware IRQ\n");
>>>
>>> Remove this.
>>
>> Remove the dev_info?
> 
> ACK, this is not possible anymore - we cannot have polling enabled and
> HW IRQs configured.

Sounds good, will submit a v7 with these cleanup changes.

regards,
Judith

      reply	other threads:[~2023-05-22 19:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 19:36 [PATCH v6 0/2] Enable multiple MCAN on AM62x Judith Mendez
2023-05-18 19:36 ` [PATCH v6 1/2] dt-bindings: net: can: Remove interrupt properties for MCAN Judith Mendez
2023-05-18 19:36 ` [PATCH v6 2/2] can: m_can: Add hrtimer to generate software interrupt Judith Mendez
2023-05-19  7:16   ` Marc Kleine-Budde
2023-05-22 15:17     ` Judith Mendez
2023-05-22 18:37       ` Marc Kleine-Budde
2023-05-22 19:00         ` Judith Mendez [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31925752-8028-98fc-b6a4-9b8fe8a3ce0b@ti.com \
    --to=jm@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=kristo@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rcsekar@samsung.com \
    --cc=robh+dt@kernel.org \
    --cc=socketcan@hartkopp.net \
    --cc=spatton@ti.com \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®