Skip to contentSkip to conversation

scsi: sr: Fix some cdroms automatically ejected when booting into the system

PATCH In review jinxiaobo 2 participants 3 messages Apr 27, 2022 – May 5, 2022 SCSI

lore
Share & tools
lore

jinxiaobo

author
#0 lore raw

PATCH 1/1 scsi: sr: Fix some cdroms automatically ejected when booting into the system

sr_get_events() has been called before udev starts when SCSI CDROM is built-in and AHCI SATA is bulit-in,so sr events propagated to user space are not handled.
if both is loadable, udev will handle sr events, some cdroms may eject. We need call sr_get_events() once before device_add_disk() to keep the same result, whether both are built-in or loadable.

---
 drivers/scsi/sr.c | 1 +
 1 file changed, 1 insertion(+)
drivers/scsi/sr.c +1 -0
index cbd92891a762..043b3ab72d7a 100644
@@ -676,6 +676,7 @@ static int sr_probe(struct device *dev)
 	set_capacity(disk, cd->capacity);
 	disk->private_data = cd;
 
+	sr_get_events(sdev);
 	if (register_cdrom(disk, &cd->cdi))
 		goto fail_minor;
 
Signature · 1 line
2.20.1
#1 lore raw

Hi jinxiaobo!

Quoted 6 lines

sr_get_events() has been called before udev starts when SCSI CDROM is built-in and AHCI SATA is bulit-in,so sr events propagated to user space are not handled. if both is loadable, udev will handle sr events, some cdroms may eject. We need call sr_get_events() once before device_add_disk() to keep the same result, whether both are built-in or loadable.

I am not sure how calling sr_get_events() and throwing away the result ensures that events get propagated to udev. Isn't this just changing timing slightly?

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
author
#2 lore raw

Hi Martin K. Petersen!

As things stand, we cannot guarantee that all events will be propagated
to udev. So I think, we don't need to ensure that all events are received by udev, we only need to ensure that events after sr probe can be received by udev and actively discard events before sr probe.

Quoted 18 lines

Hi jinxiaobo!

Quoted 6 lines

sr_get_events() has been called before udev starts when SCSI CDROM is built-in and AHCI SATA is bulit-in,so sr events propagated to user space are not handled. if both is loadable, udev will handle sr events, some cdroms may eject. We need call sr_get_events() once before device_add_disk() to keep the same result, whether both are built-in or loadable.

I am not sure how calling sr_get_events() and throwing away the result ensures that events get propagated to udev. Isn't this just changing timing slightly?

--
Martin K. Petersen Oracle Linux Engineering