Bug 248368 - devd MEDIACHANGE events are delivered unreliably for /dev/cdX devices
Summary: devd MEDIACHANGE events are delivered unreliably for /dev/cdX devices
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-30 14:17 UTC by Gleb Popov
Modified: 2020-08-02 00:17 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gleb Popov freebsd_committer 2020-07-30 14:17:31 UTC
1. VirtualBox

On a VirtualBox VM with a CD-ROM device attached I run:

# cat /var/run/devd.pipe | grep cd

While it runs, I insert and then eject an ISO image to/from the drive. This yields MEDIACHANGE event only during **ejection**:

!system=DEVFS subsystem=CDEV type=MEDIACHANGE cdev=cd0
!system=GEOM subsystem=DEV type=MEDIACHANGE cdev=cd0

2. Real hardware

The same test done on real computer and DVD-ROM drive results in MEDIACHANGE events emitted during **insertion** only, and not on ejection.

Additionally, devd log is spammed with following errors, not sure if relevant:

!system=CAM subsystem=periph type=error device=cd0 serial="K1KH3TA2730" cam_status="0xcc" scsi_status=2 scsi_sense="71 02 3a 02" CDB="00 00 00 00 00 00 "
Comment 1 PauAmma 2020-08-02 00:17:46 UTC
Duplicating.

1. VirtualBox 5.2.44

% uname -a
FreeBSD FreeBSD-bug-248402 12.1-RELEASE-p7 FreeBSD 12.1-RELEASE-p7 GENERIC  amd64
% sudo cat /var/run/devd.pipe | grep cd
Password:
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " <--- Inserting .iso image at that point, messages stop.
<--- After a minute or so, remove .iso image, messages as follows:
!system=DEVFS subsystem=CDEV type=MEDIACHANGE cdev=cd0
!system=GEOM subsystem=DEV type=MEDIACHANGE cdev=cd0
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="1e 00 00 00 01 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="25 00 00 00 00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="1e 00 00 00 01 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="25 00 00 00 00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="1e 00 00 00 01 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="25 00 00 00 00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="1e 00 00 00 01 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="25 00 00 00 00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="VB2-01700376" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 " 
^C

2. Bare metal (Lenovo Z50-70)
% uname -a
FreeBSD gadfly 12.1-RELEASE-p7 FreeBSD 12.1-RELEASE-p7 GENERIC  amd64
% sudo cat /var/run/devd.pipe | grep cd
Password:
<--- upon opening the empty caddy
!system=CAM subsystem=periph type=error device=cd0 serial="KYME48F3455" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 02" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="KYME48F3455" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 02" CDB="00 00 00 00 00 00 " 
<--- upon closing the caddy with a DVD-R in it
!system=CAM subsystem=periph type=error device=cd0 serial="KYME48F3455" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 04 01" CDB="00 00 00 00 00 00 " 
!system=DEVFS subsystem=CDEV type=MEDIACHANGE cdev=cd0
!system=GEOM subsystem=DEV type=MEDIACHANGE cdev=cd0
!system=CAM subsystem=periph type=error device=cd0 serial="KYME48F3455" cam_status="0xcc" scsi_status=2 scsi_sense="70 06 28 00" CDB="00 00 00 00 00 00 " 
!system=DEVFS subsystem=CDEV type=CREATE cdev=iso9660/12_1_RELEASE_AMD64_CD
!system=GEOM subsystem=DEV type=CREATE cdev=iso9660/12_1_RELEASE_AMD64_CD
!system=DEVFS subsystem=CDEV type=DESTROY cdev=iso9660/12_1_RELEASE_AMD64_CD
!system=GEOM subsystem=DEV type=DESTROY cdev=iso9660/12_1_RELEASE_AMD64_CD
<--- upon opening the caddy again
!system=CAM subsystem=periph type=error device=cd0 serial="KYME48F3455" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 02" CDB="00 00 00 00 00 00 "
<--- upon closing the emptied caddy
!system=CAM subsystem=periph type=error device=cd0 serial="KYME48F3455" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 04 01" CDB="00 00 00 00 00 00 " 
!system=CAM subsystem=periph type=error device=cd0 serial="KYME48F3455" cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 01" CDB="00 00 00 00 00 00 "