From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50043.outbound.protection.outlook.com [40.107.5.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E24D221CEB0F9 for ; Mon, 18 Sep 2017 20:01:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Xl9wxh2bAIUTJXCpSRVTa7DUqHV5iMIUQ25vQtyiGMw=; b=HuSpJLfqZ/gkMso1Hbt1xojH+YMALH7drx0/wvOTDDASIOimMa/4gmAWy8hu+8moSlWkTaltmVCBJ7LvWyPYMvmxcUP095hidkX4JIy6RqXibMRFua5LyQcRhWSw3TYfdITJ/rZ/U+q4v6/Ig+DmG/zxsOpqwkRdbwcM/al6rh4= Received: from AM0PR0402MB3940.eurprd04.prod.outlook.com (52.133.40.140) by AM0PR0402MB3620.eurprd04.prod.outlook.com (52.133.46.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Tue, 19 Sep 2017 03:05:01 +0000 Received: from AM0PR0402MB3940.eurprd04.prod.outlook.com ([fe80::d0d3:8e74:b9b0:d4af]) by AM0PR0402MB3940.eurprd04.prod.outlook.com ([fe80::d0d3:8e74:b9b0:d4af%13]) with mapi id 15.20.0056.016; Tue, 19 Sep 2017 03:05:01 +0000 From: Pankaj Bansal To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Laszlo Ersek (lersek@redhat.com)" Thread-Topic: [edk2] [PATCH v2] MdeModulePkg/SerialDxe: Fix not able to change serial attributes Thread-Index: AQHTMFGDorijtN0Ab0upgeqMcPWvBaK6bH2AgAEZtYCAAAB7QA== Date: Tue, 19 Sep 2017 03:05:01 +0000 Message-ID: References: <1505720565-28495-1-git-send-email-pankaj.bansal@nxp.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B970A8B@shsmsx102.ccr.corp.intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103B972E6E@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103B972E6E@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=pankaj.bansal@nxp.com; x-originating-ip: [122.177.215.231] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR0402MB3620; 6:J5RMizMuxi2Yy+JIkhJAg8eZZDF8Z412n6p9GczmRLp4ekNapXQEhK6AYqw/Fs7eKco5t3cu2sYI1WUW0y3rEMMLEBJvCP69ZT+9evjr7uK7rVLc5VTIJtTjlBdbj5ofnsoBoajAE8su/FGbOT+rkR2/qpNPzLUwC25Z4STgbNSS99u2/ZUwBXuJ8B2OvQYm0ubLKaxaA6GkYOkNijTuw0Zb3pR5Npbi3BuTluQQfv3QjuwgW9BMeANXORdAb+gHqrGBSlIwNM8q1Q+xsM9bN8i3HhcnNCce8GhyJUpGR0+G787XzJk73KpGsncgn3LmI5CqEU6OrevlIo7KZORWtA==; 5:k9Izjun2yXSp7cjrKGl+4HMWNPP9MbdJ1pnTByp6obf1qgPljmdnquBNu6W2jzxAFGUpY1HSUiYbdcIn4Pa0NdpkCpyMICa7p01tcIWTQ49kpzHmjbLwI6YgR8PHR1BwLHAlhiQuw5ZrJcz9mMZuIQ==; 24:Ep5LaV65dHI5CZ2LqA3fS10aDPRr8BN5IF5996bJPc05Jg3lCQ1r42GlfxTg5AzxRdVbVYpLIKX0/3XzKeGqt3FQCCApWl8H1xIjhwiN9Ww=; 7:31l6QWhprTcAiETnsxdFrOSvhvez0aP1WWdpR/G4O9mOXytJVsAIlfn3u9Jx0nGBs+rg7sROznFuG6pebDU+qNY//EAttJBhLaN8+dvIa37d2LsOEiLt0MNhFENv2xSTkXNkJ4PoxAh6ggImX8muzBeE4B6Ds3BW70bc40MYUdL57WAtUB5DO17fPH0dnAjatirfjVrOcWqbRKEjYNSpNqeVngbE6pnfpiQq6MaTBnA= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 7a87b6ac-a4ad-45a4-3c8f-08d4ff0b3815 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM0PR0402MB3620; x-ms-traffictypediagnostic: AM0PR0402MB3620: x-exchange-antispam-report-test: UriScan:(185117386973197)(162533806227266)(228905959029699); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123558100)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM0PR0402MB3620; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM0PR0402MB3620; x-forefront-prvs: 04359FAD81 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(6009001)(39860400002)(376002)(346002)(13464003)(189002)(199003)(51914003)(377454003)(93886005)(53936002)(55016002)(99286003)(6436002)(7736002)(66066001)(478600001)(8936002)(4326008)(6306002)(9686003)(2950100002)(33656002)(110136005)(229853002)(105586002)(106356001)(966005)(5660300001)(189998001)(76176999)(81166006)(81156014)(305945005)(102836003)(6116002)(3846002)(8676002)(50986999)(316002)(2501003)(101416001)(53546010)(54356999)(7696004)(6506006)(97736004)(2900100001)(74316002)(86362001)(5250100002)(3660700001)(25786009)(2906002)(3280700002)(6246003)(68736007)(14454004)(44824005)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0402MB3620; H:AM0PR0402MB3940.eurprd04.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Sep 2017 03:05:01.4221 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3620 Subject: Re: [PATCH v2] MdeModulePkg/SerialDxe: Fix not able to change serial attributes 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: Tue, 19 Sep 2017 03:02:00 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Zeng, Thanks for suggestion. I agree, that this looks nicer and gives more details. Please push the patch with comment updates and signatures as you have menti= oned. Thanks & Regards, Pankaj Bansal -----Original Message----- From: Zeng, Star [mailto:star.zeng@intel.com]=20 Sent: Tuesday, September 19, 2017 8:30 AM To: Pankaj Bansal ; edk2-devel@lists.01.org Cc: Zeng, Star ; Laszlo Ersek (lersek@redhat.com) Subject: RE: [edk2] [PATCH v2] MdeModulePkg/SerialDxe: Fix not able to chan= ge serial attributes Pankaj, Thanks for your explanation at https://lists.01.org/pipermail/edk2-devel/20= 17-September/014832.html about the execute flow to reproduce the issue. How about also include the explanation to the commit log like below? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Issue : When try to change serial attributes using sermode command, the def= ault values are set with the execute flow as below. The sermode command calls SerialSetAttributes, which sets H/W attributes of= Serial device. After that the SerialIo protocol is reinstalled, which caus= es MdeModulePkg/Universal/Console/TerminalDxe and MdeModulePkg/Universal/Console/ConPlatformDxe drivers' bindings to stop= and then start. This in turn calls SerialReset, which undoes changes of Se= rialSetAttributes. Cause : The SerialReset command resets the attributes' values to default. Fix : Serial Reset command should set the attributes which have been change= d by user after calling SerialSetAttributes. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Another minor comment, how about update "COM port" to be "Serial Port" in t= he change? If you agree with above comments, you do not need to send an update patch a= nd I will help push the patch with the updates I comment above and Reviewed= -by: Star Zeng , and of course Regression-tested-by: L= aszlo Ersek . Thanks, Star -----Original Message----- From: Zeng, Star Sent: Monday, September 18, 2017 6:12 PM To: Pankaj Bansal ; edk2-devel@lists.01.org Cc: Zeng, Star Subject: RE: [edk2] [PATCH v2] MdeModulePkg/SerialDxe: Fix not able to chan= ge serial attributes Pankaj, Thanks for the update. I raised a question in the V1 patch review, could you help kindly provide t= he feedback? "how you reproduce the issue by sermode command as I see sermode command on= ly calls SerialIo->SetAttributes() but not SerialIo->Reset()" Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Pank= aj Bansal Sent: Monday, September 18, 2017 3:43 PM To: edk2-devel@lists.01.org Cc: Pankaj Bansal Subject: [edk2] [PATCH v2] MdeModulePkg/SerialDxe: Fix not able to change s= erial attributes Issue : When try to change serial attributes using sermode command, the def= ault values are set Cause : The SerialReset command resets the attributes' = values to default Fix : Serial Reset command should set the attributes whic= h have been changed by user after calling SerialSetAttributes. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Pankaj Bansal --- Changes in v2: - Modified Patch description MdeModulePkg/Universal/SerialDxe/SerialIo.c | 66 ++++++++-----------------= ---- 1 file changed, 18 insertions(+), 48 deletions(-) diff --git a/MdeModulePkg/Universal/SerialDxe/SerialIo.c b/MdeModulePkg/Uni= versal/SerialDxe/SerialIo.c index 43d33db..dc7e13a 100644 --- a/MdeModulePkg/Universal/SerialDxe/SerialIo.c +++ b/MdeModulePkg/Universal/SerialDxe/SerialIo.c @@ -220,7 +220,6 @@ SerialReset ( ) { EFI_STATUS Status; - EFI_TPL Tpl; =20 Status =3D SerialPortInitialize (); if (EFI_ERROR (Status)) { @@ -228,49 +227,17 @@ SerialReset ( } =20 // - // Set the Serial I/O mode and update the device path - // - - Tpl =3D gBS->RaiseTPL (TPL_NOTIFY); - - // - // Set the Serial I/O mode - // - This->Mode->ReceiveFifoDepth =3D PcdGet16 (PcdUartDefaultReceiveFifoDep= th); - This->Mode->Timeout =3D 1000 * 1000; - This->Mode->BaudRate =3D PcdGet64 (PcdUartDefaultBaudRate); - This->Mode->DataBits =3D (UINT32) PcdGet8 (PcdUartDefaultDataBi= ts); - This->Mode->Parity =3D (UINT32) PcdGet8 (PcdUartDefaultParity= ); - This->Mode->StopBits =3D (UINT32) PcdGet8 (PcdUartDefaultStopBi= ts); - - // - // Check if the device path has actually changed - // - if (mSerialDevicePath.Uart.BaudRate =3D=3D This->Mode->BaudRate && - mSerialDevicePath.Uart.DataBits =3D=3D (UINT8) This->Mode->DataBits = && - mSerialDevicePath.Uart.Parity =3D=3D (UINT8) This->Mode->Parity && - mSerialDevicePath.Uart.StopBits =3D=3D (UINT8) This->Mode->StopBits - ) { - gBS->RestoreTPL (Tpl); - return EFI_SUCCESS; - } - - // - // Update the device path + // Go set the current attributes // - mSerialDevicePath.Uart.BaudRate =3D This->Mode->BaudRate; - mSerialDevicePath.Uart.DataBits =3D (UINT8) This->Mode->DataBits; - mSerialDevicePath.Uart.Parity =3D (UINT8) This->Mode->Parity; - mSerialDevicePath.Uart.StopBits =3D (UINT8) This->Mode->StopBits; - - Status =3D gBS->ReinstallProtocolInterface ( - mSerialHandle, - &gEfiDevicePathProtocolGuid, - &mSerialDevicePath, - &mSerialDevicePath - ); - - gBS->RestoreTPL (Tpl); + Status =3D This->SetAttributes ( + This, + This->Mode->BaudRate, + This->Mode->ReceiveFifoDepth, + This->Mode->Timeout, + (EFI_PARITY_TYPE) This->Mode->Parity, + (UINT8) This->Mode->DataBits, + (EFI_STOP_BITS_TYPE) This->Mode->StopBits + ); =20 return Status; } @@ -513,11 +480,6 @@ SerialDxeInitialize ( { EFI_STATUS Status; =20 - Status =3D SerialPortInitialize (); - if (EFI_ERROR (Status)) { - return Status; - } - mSerialIoMode.BaudRate =3D PcdGet64 (PcdUartDefaultBaudRate); mSerialIoMode.DataBits =3D (UINT32) PcdGet8 (PcdUartDefaultDataBits); mSerialIoMode.Parity =3D (UINT32) PcdGet8 (PcdUartDefaultParity); @@ -529,6 +491,14 @@ SerialDxeInitialize ( mSerialDevicePath.Uart.StopBits =3D PcdGet8 (PcdUartDefaultStopBits); =20 // + // Issue a reset to initialize the COM port // Status =3D=20 + mSerialIoTemplate.Reset (&mSerialIoTemplate); if (EFI_ERROR (Status))=20 + { + return Status; + } + + // // Make a new handle with Serial IO protocol and its device path on it. // Status =3D gBS->InstallMultipleProtocolInterfaces ( -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel