From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Star Zeng <star.zeng@intel.com>, Hao A Wu <hao.a.wu@intel.com>
Subject: [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents
Date: Thu, 7 Dec 2017 17:55:03 +0800 [thread overview]
Message-ID: <20171207095503.20652-1-ruiyu.ni@intel.com> (raw)
Current code always return EFI_MEDIA_CHANGED no matter the media
is removed from CD/DVD drive or the media is changed.
It doesn't strictly follow the UEFI Spec.
Update code to return EFI_NO_MEDIA when media is removed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 41 ++++++++++++++++++++--------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index 2289f20152..6a0a193556 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -568,6 +568,7 @@ ScsiDiskReadBlocks (
MediaChange = FALSE;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
+ Media = ScsiDiskDevice->BlkIo.Media;
if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
@@ -598,14 +599,17 @@ ScsiDiskReadBlocks (
&ScsiDiskDevice->EraseBlock
);
}
- Status = EFI_MEDIA_CHANGED;
+ if (Media->MediaPresent) {
+ Status = EFI_MEDIA_CHANGED;
+ } else {
+ Status = EFI_NO_MEDIA;
+ }
goto Done;
}
}
//
// Get the intrinsic block size
//
- Media = ScsiDiskDevice->BlkIo.Media;
BlockSize = Media->BlockSize;
NumberOfBlocks = BufferSize / BlockSize;
@@ -700,6 +704,7 @@ ScsiDiskWriteBlocks (
MediaChange = FALSE;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (This);
+ Media = ScsiDiskDevice->BlkIo.Media;
if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
@@ -730,14 +735,17 @@ ScsiDiskWriteBlocks (
&ScsiDiskDevice->EraseBlock
);
}
- Status = EFI_MEDIA_CHANGED;
+ if (Media->MediaPresent) {
+ Status = EFI_MEDIA_CHANGED;
+ } else {
+ Status = EFI_NO_MEDIA;
+ }
goto Done;
}
}
//
// Get the intrinsic block size
//
- Media = ScsiDiskDevice->BlkIo.Media;
BlockSize = Media->BlockSize;
NumberOfBlocks = BufferSize / BlockSize;
@@ -922,6 +930,7 @@ ScsiDiskReadBlocksEx (
MediaChange = FALSE;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
+ Media = ScsiDiskDevice->BlkIo.Media;
if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
@@ -952,14 +961,17 @@ ScsiDiskReadBlocksEx (
&ScsiDiskDevice->EraseBlock
);
}
- Status = EFI_MEDIA_CHANGED;
+ if (Media->MediaPresent) {
+ Status = EFI_MEDIA_CHANGED;
+ } else {
+ Status = EFI_NO_MEDIA;
+ }
goto Done;
}
}
//
// Get the intrinsic block size
//
- Media = ScsiDiskDevice->BlkIo2.Media;
BlockSize = Media->BlockSize;
NumberOfBlocks = BufferSize / BlockSize;
@@ -1081,6 +1093,7 @@ ScsiDiskWriteBlocksEx (
MediaChange = FALSE;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
+ Media = ScsiDiskDevice->BlkIo.Media;
if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
@@ -1111,14 +1124,17 @@ ScsiDiskWriteBlocksEx (
&ScsiDiskDevice->EraseBlock
);
}
- Status = EFI_MEDIA_CHANGED;
+ if (Media->MediaPresent) {
+ Status = EFI_MEDIA_CHANGED;
+ } else {
+ Status = EFI_NO_MEDIA;
+ }
goto Done;
}
}
//
// Get the intrinsic block size
//
- Media = ScsiDiskDevice->BlkIo2.Media;
BlockSize = Media->BlockSize;
NumberOfBlocks = BufferSize / BlockSize;
@@ -1230,6 +1246,7 @@ ScsiDiskFlushBlocksEx (
MediaChange = FALSE;
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO2 (This);
+ Media = ScsiDiskDevice->BlkIo.Media;
if (!IS_DEVICE_FIXED(ScsiDiskDevice)) {
@@ -1260,13 +1277,15 @@ ScsiDiskFlushBlocksEx (
&ScsiDiskDevice->EraseBlock
);
}
- Status = EFI_MEDIA_CHANGED;
+ if (Media->MediaPresent) {
+ Status = EFI_MEDIA_CHANGED;
+ } else {
+ Status = EFI_NO_MEDIA;
+ }
goto Done;
}
}
- Media = ScsiDiskDevice->BlkIo2.Media;
-
if (!(Media->MediaPresent)) {
Status = EFI_NO_MEDIA;
goto Done;
--
2.15.0.gvfs.1.preview.4
next reply other threads:[~2017-12-07 9:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 9:55 Ruiyu Ni [this message]
2017-12-08 2:03 ` [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents Wu, Hao A
2017-12-11 1:19 ` Zeng, Star
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-list 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=20171207095503.20652-1-ruiyu.ni@intel.com \
--to=devel@edk2.groups.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