Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp342280yba; Wed, 15 May 2019 02:16:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqypD4ACpO1fsUOjgtX0C+bEz7xFRpD2P5Aa/MLoWSPGKUiNCDijFY326FKOxtIWvjIqMRxI X-Received: by 2002:a63:1701:: with SMTP id x1mr42899442pgl.153.1557911808984; Wed, 15 May 2019 02:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557911808; cv=none; d=google.com; s=arc-20160816; b=Lyb+KEcgG7szjw/JLDvCulSSn/ssbjdTJl6y3K+fC2+g/muBGE886BG+CjsAAPWNGS 8LtXK8rJivPTbxGuuSTaPHakCyuK+A7XaQYQLqijkcNBXfzsmbqltH7Pde+t5Wg3xXoa isTd2e/7gYy1/22Z5XS2hfLJcWtwzdl9a4TL+I6SgExy1iVqiD8pUAurvXJX1qBrP0V9 96vCy3p5CQbtNdvQpLOQmLiXSg4GlIOxYD0Z2xLo1tI1vtdS5QEQwTe/Xe1+Igoc7Pv5 C+i0kY+Yo8nNAp84TNp9yY/ssA5WD4jCAVW7jqoV6bhc4969JHGMhqGURj8gFho2DVQF V4Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8l+XsAWtzDO+iVF8T+43qDNahyoPM+IYYP74fL9auB0=; b=RzZ97Y/+UI2dB2ih5dt6jqroBK2CC7GkWe6DiTgFhe1bp3jjLYaBW4KymWiBv3tNHY vm6EDAjx28y/33YDkQkhuHeAVb77lngW/AKFAOizghxmIXUOiuaOlA9WixeNFUmFLdJ6 hfdFDRy8ag3K9WnqEvm8FabTyzSy2UPtWpLoMtB+v1f0I5JGUg9GKL1TJf7o+ZeMADdR UPXAWk+Z9zytvD98rCmJTE/wltdl+6Pnr8+np8bIHJ9GYtm1tW6iDzRNMa6FZxi7drgu DvDjVGdmWS5IszvjP5BUcOqNB6S/ZLNGHl8ZDseDPdp4kpt7JOyG6uwgY/5GDf8JPPTP CIFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p+UZ57l1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si1360668pgh.393.2019.05.15.02.16.34; Wed, 15 May 2019 02:16:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p+UZ57l1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbfEOJP3 (ORCPT + 99 others); Wed, 15 May 2019 05:15:29 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:34258 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbfEOJP3 (ORCPT ); Wed, 15 May 2019 05:15:29 -0400 Received: by mail-oi1-f195.google.com with SMTP id v10so1309701oib.1; Wed, 15 May 2019 02:15:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8l+XsAWtzDO+iVF8T+43qDNahyoPM+IYYP74fL9auB0=; b=p+UZ57l126N1SmeVU3MI6F+D8dLYxvuEP2cSlhSnFkK2cWvQzhBrKHTv/XXifW9cJp n9xvtEVQnB8G8b1fE36eBGkSIkJvqTUjsDQ1j2kXyW5IGKrrGuT0TLiA/Sm/yLAs6xM9 HYVfVeWmueaGTSKGcYzDKlQaf98U4NXxkLZEe7NNsx8x+1pafuZeH3Cx1is+pub2tv0A 3cHcEfTyE+jmGNmTpLq0sNKUo3bKIiZkR65Dh+LwGE3jCSEs4X1I1JFjROZ1BvXQ16Pj tr1zzZ0HqoUurxgMJbwXDi5lvJ88/oBP0H0Y1/RolqAMPOOhmNwOJzG6XvKGvyMuX8t2 IG9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=8l+XsAWtzDO+iVF8T+43qDNahyoPM+IYYP74fL9auB0=; b=EvfFmmn+I81iuFRlnM4FzcDDvNwiKk3u0M7ijxZZFRapWdz95thJRzREtE4QNL02qZ nYMPBr5U5nD3c/aweIbKAGZEAgtD0r7qIBqbIDB7wffIyca+luYlYso8wkmxu997boDL LJTRIoBrVCOdO6WdINWooTx3wODWnQcxPwWJ2EW+yn1Mnk+Rc0zT077psWeD62hY6ovw Zsz20CT/pHUWHjnDtoldm51oW94lOWjPdcHQTP8KcY6BVxxfYooFfNokxHV1whLsuKAU RU6svvO6pqgNEyeDxxL+lfQlm5oWeLqDGpVpgOCtaeFdpmkjMGQnWqni2OLJNkVPhIIl G1Gg== X-Gm-Message-State: APjAAAXbwbEKts34RFG9yty7F+NMDtonnyUsEWGjm7o4B72ByKhZQ6Rv hpRO3LX9Yb6ffGI9H+jnNfI4ZZUHXnsI0ju8s5k= X-Received: by 2002:aca:df09:: with SMTP id w9mr5504644oig.94.1557911728083; Wed, 15 May 2019 02:15:28 -0700 (PDT) MIME-Version: 1.0 References: <20190514073457.GI9651@localhost> In-Reply-To: <20190514073457.GI9651@localhost> From: hhome liu Date: Wed, 15 May 2019 17:15:16 +0800 Message-ID: Subject: Re: [PATCH] tty: serial_core: Fix the incorrect configuration of baud rate and data length at the console serial port resume To: Johan Hovold Cc: Rob Herring , Greg Kroah-Hartman , baolin.wang@unisoc.com, Baolin Wang , jslaby@suse.com, =?UTF-8?B?5YiY5bKa5riFIChMYW5xaW5nIExpdSk=?= , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, chunyan.zhang@unisoc.com, orson.zhai@unisoc.com, zhang.lyra@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Johan Hovold =E4=BA=8E2019=E5=B9=B45=E6=9C=8814=E6=97=A5= =E5=91=A8=E4=BA=8C =E4=B8=8B=E5=8D=883:35=E5=86=99=E9=81=93=EF=BC=9A > > On Thu, May 09, 2019 at 01:42:39PM +0800, Lanqing Liu wrote: > > When userspace opens a serial port for console, uart_port_startup() > > is called. This function assigns the uport->cons->cflag value to > > TTY->termios.c_cflag, then it is cleared to 0. When the user space > > closes this serial port, the TTY structure will be released, and at > > this time uport->cons->cflag has also been cleared. > > > > On the Spreadtrum platform, in some special scenarios, like charging mo= de, > > userspace needs to close the console, which means the uport->cons->cfla= g > > has also been cleared. But printing logs is still needed in the kernel.= So > > when system enters suspend and resume, the console needs to be configur= e > > the baud rate and data length of the serial port according to its own c= flag > > when resuming the console port. At this time, the cflag is 0, which wil= l > > cause serial port to produce configuration errors that do not meet user > > expectations. > > This is actually yet another regression due to 761ed4a94582 ("tty: > serial_core: convert uart_close to use tty_port_close") which > incidentally removed the call to uart_shutdown() where the cflag was > being saved precisely to avoid the problem you're describing: > > ae84db9661ca ("serial: core: Preserve termios c_cflag for console= resume") Yes, agree with you. > > Judging from a quick look it seems the xmit buf, which is released in > that function may now be leaking too. We haven't found this issue before, but we can try to reproduce it on our platform. > > > To fix this, assigning the TTY->termios.c_cflag value to uport->cons->c= flag > > before the userspace closes this console serial port. It will ensure th= at > > the correct cflag value can be gotten when the console serial port was > > resumed. > > Not sure this is the right fix, but I don't have time to look at this > right now. OK. Thanks for your comments.