Repository navigation
nfc: stop polling before taking the device down on an rfkill block - #71
Conversation
|
Thanks, this is a real bug, and it is the Pixel 7 Pro's bug too. I read the fix through against the two rfkill fixes already in our 7.3-rc6 base (1ab526d97a57 and d2492688bb9f): no new lock is taken under Two things before I merge it:
For upstream: And the kernel release ( |
00ffd49 to
cd8588a
Compare
|
Thanks for reading it against the rfkill fixes. Pushed, rebased on today's
checkpatch --strict only notes that it can't see be055b2f89b5, since our tree's base is squashed; it's the 2013 commit in mainline. Understood on the order: this one lands after omarchy-mobile #78. |
|
Thanks, that's everything I asked for. The code is unchanged (the same One change on my side about the order. Since this afternoon, CONTRIBUTING asks that a change which alters the Pixel 7 Pro on purpose runs on that phone before it merges, not after, and this one does: the tile's "Off" will now close the ST54J with a poll running. So the plan is: I merge your omarchy-mobile #78 first, put this commit on my phone's kernel, run one block/unblock cycle of the tile, and merge this right after if it behaves. Nothing more needed from you. |
nfc_rfkill_set_block() calls nfc_dev_down(), which refuses a device that
is polling or has an active target with -EBUSY, and the return value is
ignored. Userspace such as neard keeps a poll loop running whenever the
adapter is powered, so blocking NFC through rfkill left the radio on and
polling.
Deactivate the active target and stop polling first, then take the
device down. This stays in the rfkill path rather than in
nfc_dev_down(): when userspace asks for DEV_DOWN itself, the -EBUSY
tells it to stop its own poll first, while an rfkill block has no one
to tell.
After a stop from here, genl_data.poll_req_portid still names the
process that started the poll. Its later STOP_POLL returns -EINVAL at
the !dev->polling check and its next START_POLL sets the id again, so
nothing breaks.
On a Pixel 9a (ST54L on nxp-nci, 7.3.0-rc6-omamobile-tegu-s2mpg15-m1,
net/nfc/core.c as in this patch) with neard polling, `rfkill block nfc`
left the controller interrupting about 14 times a second; with this
change the interrupts stop and nfctool reports the device unpowered.
Fixes: be055b2f89b5 ("NFC: RFKILL support")
Cc: stable@vger.kernel.org
Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com>
cd8588a to
d58a46b
Compare
|
A short status, since this has been waiting on me since the 27th. Nothing is needed from you. The commit is unchanged, and so is the For the record, my Pixel 7 Pro NFC series (draft #146) touches the same file, but only |
|
Ran it on my Pixel 7 Pro tonight ( |
The shell's NFC tile switches NFC through rfkill, but on the palmtop it did nothing.
nfc_rfkill_set_block()callsnfc_dev_down(), and that returns -EBUSY while the device polls or has an active target, which is always with neard running. The error was ignored, so the radio kept polling.This change deactivates the target and stops the poll first, then takes the device down.
Tested on the palmtop (ST54L on nxp-nci, neard polling): before,
rfkill block nfcleft about 14 interrupts a second; with this nfc.ko the interrupts stop and nfctool reports the device unpowered. Unblocking and powering it again through neard brings polling back, over three cycles. The userspace side, which tells neard, is omarchy-mobile's omamobile-shell 0.2.29.checkpatch --strict is clean and core.o builds with W=1.