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=192.55.52.43; helo=mga05.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 E3A86221EA0A5 for ; Thu, 7 Dec 2017 17:58:32 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 18:03:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,375,1508828400"; d="scan'208";a="11574480" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 07 Dec 2017 18:03:06 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 7 Dec 2017 18:03:05 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 7 Dec 2017 18:03:05 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.93]) with mapi id 14.03.0319.002; Fri, 8 Dec 2017 10:03:03 +0800 From: "Wu, Hao A" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [PATCH] MdeModulePkg/ScsiDisk: Return EFI_NO_MEDIA when no media presents Thread-Index: AQHTb0GGrWlXSkVfGk6AQKhwbWdzVaM4sq5A Date: Fri, 8 Dec 2017 02:03:02 +0000 Message-ID: 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: Fri, 08 Dec 2017 01:58:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu 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 >=20 > 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. >=20 > 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(-) >=20 > 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 =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 @@ ScsiDiskWriteBlocks ( > 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 @@ ScsiDiskReadBlocksEx ( > 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 @@ ScsiDiskWriteBlocksEx ( > 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 @@ ScsiDiskFlushBlocksEx ( > 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