mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josef Schlehofer <pepe.schlehofer@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Hyunwoo Kim <v4bel@theori.io>,
	Josef Schlehofer <pepe.schlehofer@gmail.com>
Subject: [PATCH 0/6] media: az6007/drxk/dvb-core: cope with a tuner unplugged while in use
Date: Wed, 23 Sep 2026 02:14:04 +0200	[thread overview]
Message-ID: <20260923001410.30297-1-pepe.schlehofer@gmail.com> (raw)

Unplugging an az6007 based tuner (here a TechniSat CableStar Combo HD
CI with a CAM inserted) while it is in use can leave parts of the DVB
stack stuck on the disconnected device.

In particular:

- drxk keeps accessing the device after unplug and hides the resulting
  errors from userspace.
- The CA thread can get stuck polling a removed CAM slot and prevent
  the disconnect from completing.
- Applications that wait on or poll the DVB devices are neither woken
  up nor told that the device is gone, so the disconnect can wait
  indefinitely for them to close the devices.

This series fixes these issues by:

- treating an unreadable CAM slot status as no CAM,
- propagating -ENODEV from az6007 to drxk and stopping further device
  access,
- waking up the users of the demux, dvr and CA devices and returning
  -ENODEV to them, so they can handle the device removal.

Tested on Linux 6.18.44 on a Turris 1.x (PowerPC P2020, two CPUs,
non-preemptible):

- tvheadend with CAM enabled, idle, scanning and streaming,
- unplugging the tuner or the whole USB hub,
- unbinding the driver through sysfs,
- blocking reads on dvr0 and demux0.

In all tested cases the disconnect completed and blocked userspace
operations returned -ENODEV.

Some pre-existing cases where the release waits for users that are
not woken up remain. The unlocked user count check in
dvb_ca_en50221_release() and dvb_dmxdev_release() also still races
with a concurrent close(), and patches 5 and 6 make that race easier
to hit.

Josef Schlehofer (6):
  media: az6007: fix CAM status polling after disconnect
  media: az6007: propagate USB errors from I2C transfers
  media: drxk: stop retrying after disconnect
  media: drxk: stop accessing a disconnected device
  media: dvb-core: dmxdev: wake up readers on release
  media: dvb-core: wake up CA users on release

 drivers/media/dvb-core/dmxdev.c         | 31 ++++++++++++++--
 drivers/media/dvb-core/dvb_ca_en50221.c | 24 ++++++++++++-
 drivers/media/dvb-frontends/drxk_hard.c | 48 +++++++++++++++++++------
 drivers/media/dvb-frontends/drxk_hard.h |  2 +-
 drivers/media/usb/dvb-usb-v2/az6007.c   | 23 ++++++------
 5 files changed, 104 insertions(+), 24 deletions(-)


base-commit: df2908090cda368b01ff43709f51890076c56157
-- 
2.54.0 (Apple Git-157)


             reply	other threads:[~2026-09-23  0:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  0:14 Josef Schlehofer [this message]
2026-09-23  0:14 ` [PATCH 1/6] media: az6007: fix CAM status polling after disconnect Josef Schlehofer
2026-09-23  0:14 ` [PATCH 2/6] media: az6007: propagate USB errors from I2C transfers Josef Schlehofer
2026-09-23  0:14 ` [PATCH 3/6] media: drxk: stop retrying after disconnect Josef Schlehofer
2026-09-23  0:14 ` [PATCH 4/6] media: drxk: stop accessing a disconnected device Josef Schlehofer
2026-09-23  0:14 ` [PATCH 5/6] media: dvb-core: dmxdev: wake up readers on release Josef Schlehofer
2026-09-23  0:14 ` [PATCH 6/6] media: dvb-core: wake up CA users " Josef Schlehofer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260923001410.30297-1-pepe.schlehofer@gmail.com \
    --to=pepe.schlehofer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=v4bel@theori.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®