From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4C2E020352ABD for ; Sun, 10 Dec 2017 17:14:54 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2017 17:19:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,391,1508828400"; d="scan'208";a="396235" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga002.fm.intel.com with ESMTP; 10 Dec 2017 17:19:30 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sun, 10 Dec 2017 17:19:30 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Mon, 11 Dec 2017 09:19:29 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" , "Zeng, Star" Thread-Topic: [edk2] [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents Thread-Index: AQHTb0F/wSLSXV1FskujFSQ0braoU6M9XZMQ Date: Mon, 11 Dec 2017 01:19:28 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103B9C1DB4@shsmsx102.ccr.corp.intel.com> References: <20171207095503.20652-1-ruiyu.ni@intel.com> In-Reply-To: <20171207095503.20652-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2017 01:14:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ruiy= u Ni Sent: Thursday, December 7, 2017 5:55 PM To: edk2-devel@lists.01.org Cc: Wu, Hao A ; Zeng, Star 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 Cc: Star Zeng Cc: Hao A Wu --- 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/Bu= s/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 =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -598,14 +599,17 @@ ScsiDiskReadBlocks ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -700,6 +704,7 @@ ScsiDisk= WriteBlocks ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -730,14 +735,17 @@ ScsiDiskWriteBlocks ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -922,6 +930,7 @@ ScsiDisk= ReadBlocksEx ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -952,14 +961,17 @@ ScsiDiskReadBlocksEx ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo2.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -1081,6 +1093,7 @@ ScsiDi= skWriteBlocksEx ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -1111,14 +1124,17 @@ ScsiDiskWriteBlocksEx ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } // // Get the intrinsic block size // - Media =3D ScsiDiskDevice->BlkIo2.Media; BlockSize =3D Media->BlockSize; =20 NumberOfBlocks =3D BufferSize / BlockSize; @@ -1230,6 +1246,7 @@ ScsiDi= skFlushBlocksEx ( MediaChange =3D FALSE; OldTpl =3D gBS->RaiseTPL (TPL_CALLBACK); ScsiDiskDevice =3D SCSI_DISK_DEV_FROM_BLKIO2 (This); + Media =3D ScsiDiskDevice->BlkIo.Media; =20 if (!IS_DEVICE_FIXED(ScsiDiskDevice)) { =20 @@ -1260,13 +1277,15 @@ ScsiDiskFlushBlocksEx ( &ScsiDiskDevice->EraseBlock ); } - Status =3D EFI_MEDIA_CHANGED; + if (Media->MediaPresent) { + Status =3D EFI_MEDIA_CHANGED; + } else { + Status =3D EFI_NO_MEDIA; + } goto Done; } } =20 - Media =3D ScsiDiskDevice->BlkIo2.Media; - if (!(Media->MediaPresent)) { Status =3D 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