From: "Zeng, Star" <star.zeng@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wu, Hao A" <hao.a.wu@intel.com>, "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents
Date: Mon, 11 Dec 2017 01:19:28 +0000 [thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9C1DB4@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <20171207095503.20652-1-ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiyu Ni
Sent: Thursday, December 7, 2017 5:55 PM
To: edk2-devel@lists.01.org
Cc: Wu, Hao A <hao.a.wu@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: [edk2] [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents
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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
prev parent reply other threads:[~2017-12-11 1:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 9:55 [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents Ruiyu Ni
2017-12-08 2:03 ` Wu, Hao A
2017-12-11 1:19 ` Zeng, Star [this message]
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=0C09AFA07DD0434D9E2A0C6AEB0483103B9C1DB4@shsmsx102.ccr.corp.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