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: <20220115181422.0b622b69@jic23-huawei>
Date:   Sat, 15 Jan 2022 18:14:22 +0000
From:   Jonathan Cameron <jic23@...nel.org>
To:     Oleksij Rempel <o.rempel@...gutronix.de>
Cc:     devicetree@...r.kernel.org, Lars-Peter Clausen <lars@...afoo.de>,
        linux-iio@...r.kernel.org,
        Robin van der Gracht <robin@...tonic.nl>,
        linux-kernel@...r.kernel.org,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        David Jander <david@...tonic.nl>
Subject: Re: [PATCH v1 1/1] iio: adc: tsc2046: rework the trigger state
 machine

...

> > >  
> > > -static enum hrtimer_restart tsc2046_adc_trig_more(struct hrtimer *hrtimer)
> > > +static enum hrtimer_restart tsc2046_adc_timer(struct hrtimer *hrtimer)
> > >  {
> > >  	struct tsc2046_adc_priv *priv = container_of(hrtimer,
> > >  						     struct tsc2046_adc_priv,
> > >  						     trig_timer);
> > >  	unsigned long flags;
> > >  
> > > -	spin_lock_irqsave(&priv->trig_lock, flags);
> > > -
> > > -	disable_irq_nosync(priv->spi->irq);
> > > -
> > > -	priv->trig_more_count++;
> > > -	iio_trigger_poll(priv->trig);
> > > -
> > > -	spin_unlock_irqrestore(&priv->trig_lock, flags);
> > > +	spin_lock_irqsave(&priv->state_lock, flags);
> > > +	switch (priv->state) {
> > > +	case TSC2046_STATE_ENABLE_IRQ_POLL:
> > > +		/*
> > > +		 * IRQ handler called iio_trigger_poll() to sample ADC.
> > > +		 * Here we
> > > +		 * - re-enable IRQs
> > > +		 * - start hrtimer for timeout if no IRQ will occur
> > > +		 */
> > > +		priv->state = TSC2046_STATE_POLL;
> > > +		enable_irq(priv->spi->irq);  
> > 
> > I comment on this below, but I'm not sure why you don't move the enable_irq()
> > here out of this timer function and then have the first entry of the timer
> > go directly to TSC2046_STATE_POLL after a longer initial wait.  
> 
> Hm... yes. You are right.
> 
> > It's been a long time since I looked at this, so perhaps I'm missing the
> > point.  What you have here works as far as I can see, it just seems to push
> > more than necessary into the state machine.  
> 
> The IRQ line is a level shifter connected to one of channels muxed to the core
> ADC. If we switch internal muxer to different channel, the IRQ line will
> change the state.
> 
> So, we need a trigger which:
> - do not triggers if we do ADC readings.
> - keeps triggering as long as we have some state changes on the IRQ line
> - trigger only with specific rate
> - still triggers for some amount of time after last interrupt event was
>   detected. Current implementation is doing only one extra read.
Ah.. Good explanation, I get the point now :)

Jonathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ