public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents
@ 2017-12-07  9:55 Ruiyu Ni
  2017-12-08  2:03 ` Wu, Hao A
  2017-12-11  1:19 ` Zeng, Star
  0 siblings, 2 replies; 3+ messages in thread
From: Ruiyu Ni @ 2017-12-07  9:55 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Hao A Wu

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2017-12-08  2:03 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Zeng, Star

Reviewed-by: Hao Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Thursday, December 07, 2017 5:55 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star; Wu, Hao A
> Subject: [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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Zeng, Star @ 2017-12-11  1:19 UTC (permalink / raw)
  To: Ni, Ruiyu, edk2-devel@lists.01.org; +Cc: Wu, Hao A, Zeng, Star

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-11  1:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox