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] [day] [month] [year] [list]
Message-ID: <87tubphwqa.fsf@waldekranz.com>
Date:   Wed, 23 Mar 2022 09:57:49 +0100
From:   Tobias Waldekranz <tobias@...dekranz.com>
To:     Guenter Roeck <linux@...ck-us.net>,
        Wim Van Sebroeck <wim@...ux-watchdog.org>
Cc:     linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] watchdog: gpio_wdt: Support GPO lines with the toggle
 algorithm

On Tue, Mar 22, 2022 at 17:04, Guenter Roeck <linux@...ck-us.net> wrote:
> On 3/22/22 15:29, Tobias Waldekranz wrote:
>> Support using GPO lines (i.e. GPIOs that are output-only) with
>> gpio_wdt using the "toggle" algorithm.
>> 
>> Since its inception, gpio_wdt has configured its GPIO line as an input
>> when using the "toggle" algorithm, even though it is used as an output
>> when kicking. This needlessly barred hardware with output-only pins
>> from using the driver.
>> 
>> Signed-off-by: Tobias Waldekranz <tobias@...dekranz.com>
>> ---
>> 
>> Hi,
>> 
>> This patch has been in our downstream tree for a long time. We need it
>> because our kick GPIO can't be used as an input.
>> 
>> What I really can't figure out is why the driver would request the pin
>> as in input, when it's always going to end up being used as an output
>> anyway.
>> 
>> So I thought I'd send it upstream in the hopes of either getting it
>> merged, or an explanation as to why it is needed.
>> 
>
> I _think_ the assumption / idea was that "toggle" implies that the output
> is connected to a pull-up resistor and that the pin either floats or is
> pulled down to ground, causing the signal to toggle. I don't know if/how
> that works in practice, though.

Ah I see. Yeah I'm not sure it has the intended effect. AFAIK, that type
of connection should be specified using the GPIOD_OUT_LOW_OPEN_DRAIN
flag, no?

Beyond that though, it seems unnecessary for the driver to impose that
restriction. If an open drain configuration is required on the GPIO,
then I think that should be specified via the device tree. Looking at
some code, gpiod_configure_flags seems to support this:

	if (lflags & GPIO_OPEN_DRAIN)
		set_bit(FLAG_OPEN_DRAIN, &desc->flags);
	else if (dflags & GPIOD_FLAGS_BIT_OPEN_DRAIN) {
		/*
		 * This enforces open drain mode from the consumer side.
		 * This is necessary for some busses like I2C, but the lookup
		 * should *REALLY* have specified them as open drain in the
		 * first place, so print a little warning here.
		 */
		set_bit(FLAG_OPEN_DRAIN, &desc->flags);
		gpiod_warn(desc,
			   "enforced open drain please flag it properly in DT/ACPI DSDT/board file\n");
	}

In other words, a DT node like this...

	&watchdog {
		compatible = "linux,wdt-gpio";
        	gpios = <&my-gpio 42 GPIO_ACTIVE_HIGH>;
	};

...the GPIO will behave like it does with the "level" algo today. If an
open-drain config is required, using this binding...

	&watchdog {
		compatible = "linux,wdt-gpio";
        	gpios = <&my-gpio 42 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
	};

...will give you that.

In other words, with this patch applied, the setup of the GPIO is
completely deferred to the device tree. In the general case, my guess is
that who ever wrote that has a better chance of specifying the correct
flags.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ