linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] nfc: pn544: Fix occasional HW initialization failure
@ 2020-02-19 15:01 Dmitry Osipenko
  2020-02-19 19:11 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Osipenko @ 2020-02-19 15:01 UTC (permalink / raw)
  To: David S. Miller, Samuel Ortiz, David Heidelberg; +Cc: netdev, linux-kernel

The PN544 driver checks the "enable" polarity during of driver's probe and
it's doing that by turning ON and OFF NFC with different polarities until
enabling succeeds. It takes some time for the hardware to power-down, and
thus, to deassert the IRQ that is raised by turning ON the hardware.
Since the delay after last power-down of the polarity-checking process is
missed in the code, the interrupt may trigger immediately after installing
the IRQ handler (right after the checking is done), which results in IRQ
handler trying to touch the disabled HW and ends with marking NFC as
'DEAD' during of the driver's probe:

  pn544_hci_i2c 1-002a: NFC: nfc_en polarity : active high
  pn544_hci_i2c 1-002a: NFC: invalid len byte
  shdlc: llc_shdlc_recv_frame: NULL Frame -> link is dead

This patch fixes the occasional NFC initialization failure on Nexus 7
device.

Cc: <stable@vger.kernel.org>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/nfc/pn544/i2c.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 720c89d6066e..4ac8cb262559 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -225,6 +225,7 @@ static void pn544_hci_i2c_platform_init(struct pn544_i2c_phy *phy)
 
 out:
 	gpiod_set_value_cansleep(phy->gpiod_en, !phy->en_polarity);
+	usleep_range(10000, 15000);
 }
 
 static void pn544_hci_i2c_enable_mode(struct pn544_i2c_phy *phy, int run_mode)
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] nfc: pn544: Fix occasional HW initialization failure
  2020-02-19 15:01 [PATCH v1] nfc: pn544: Fix occasional HW initialization failure Dmitry Osipenko
@ 2020-02-19 19:11 ` David Miller
  2020-02-19 21:41   ` Dmitry Osipenko
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2020-02-19 19:11 UTC (permalink / raw)
  To: digetx; +Cc: sameo, david, netdev, linux-kernel

From: Dmitry Osipenko <digetx@gmail.com>
Date: Wed, 19 Feb 2020 18:01:22 +0300

> The PN544 driver checks the "enable" polarity during of driver's probe and
> it's doing that by turning ON and OFF NFC with different polarities until
> enabling succeeds. It takes some time for the hardware to power-down, and
> thus, to deassert the IRQ that is raised by turning ON the hardware.
> Since the delay after last power-down of the polarity-checking process is
> missed in the code, the interrupt may trigger immediately after installing
> the IRQ handler (right after the checking is done), which results in IRQ
> handler trying to touch the disabled HW and ends with marking NFC as
> 'DEAD' during of the driver's probe:
> 
>   pn544_hci_i2c 1-002a: NFC: nfc_en polarity : active high
>   pn544_hci_i2c 1-002a: NFC: invalid len byte
>   shdlc: llc_shdlc_recv_frame: NULL Frame -> link is dead
> 
> This patch fixes the occasional NFC initialization failure on Nexus 7
> device.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] nfc: pn544: Fix occasional HW initialization failure
  2020-02-19 19:11 ` David Miller
@ 2020-02-19 21:41   ` Dmitry Osipenko
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Osipenko @ 2020-02-19 21:41 UTC (permalink / raw)
  To: David Miller; +Cc: sameo, david, netdev, linux-kernel

19.02.2020 22:11, David Miller пишет:
> From: Dmitry Osipenko <digetx@gmail.com>
> Date: Wed, 19 Feb 2020 18:01:22 +0300
> 
>> The PN544 driver checks the "enable" polarity during of driver's probe and
>> it's doing that by turning ON and OFF NFC with different polarities until
>> enabling succeeds. It takes some time for the hardware to power-down, and
>> thus, to deassert the IRQ that is raised by turning ON the hardware.
>> Since the delay after last power-down of the polarity-checking process is
>> missed in the code, the interrupt may trigger immediately after installing
>> the IRQ handler (right after the checking is done), which results in IRQ
>> handler trying to touch the disabled HW and ends with marking NFC as
>> 'DEAD' during of the driver's probe:
>>
>>   pn544_hci_i2c 1-002a: NFC: nfc_en polarity : active high
>>   pn544_hci_i2c 1-002a: NFC: invalid len byte
>>   shdlc: llc_shdlc_recv_frame: NULL Frame -> link is dead
>>
>> This patch fixes the occasional NFC initialization failure on Nexus 7
>> device.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> 
> Applied and queued up for -stable, thanks.
> 

Awesome, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-19 21:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 15:01 [PATCH v1] nfc: pn544: Fix occasional HW initialization failure Dmitry Osipenko
2020-02-19 19:11 ` David Miller
2020-02-19 21:41   ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).