lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3859166d-fc78-f42d-1553-282e4140325a@ti.com>
Date:   Mon, 22 May 2023 10:17:38 -0500
From:   Judith Mendez <jm@...com>
To:     Marc Kleine-Budde <mkl@...gutronix.de>
CC:     Chandrasekar Ramakrishnan <rcsekar@...sung.com>,
        <linux-can@...r.kernel.org>,
        Wolfgang Grandegger <wg@...ndegger.com>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, <netdev@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, Schuyler Patton <spatton@...com>,
        Tero Kristo <kristo@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <devicetree@...r.kernel.org>,
        Oliver Hartkopp <socketcan@...tkopp.net>,
        Conor Dooley <conor+dt@...nel.org>
Subject: Re: [PATCH v6 2/2] can: m_can: Add hrtimer to generate software
 interrupt

Hello Marc,

On 5/19/23 2:16 AM, Marc Kleine-Budde wrote:
> 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.
>>
>> 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.
>>
>> Signed-off-by: Judith Mendez <jm@...com>
> 
> [...]

Missed this poll-interval, thanks.

> 
>> 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.

> 
>> +	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 (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?

> 
>> +		} 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 = true"

ok,
> 
>> +		}
>> +	}
>> +
>>   	/* message ram could be shared */
>>   	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram");
>>   	if (!res) {
>> -- 
>> 2.17.1

- judith

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ