Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6060122yba; Tue, 14 May 2019 00:36:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOkDTzL0Cc7KXNxfu4p9lKH3GAciZECYNTg030FyrTceLwHL0/QCCl27Ta2RNytApEF6zl X-Received: by 2002:a65:448b:: with SMTP id l11mr35928628pgq.185.1557819382402; Tue, 14 May 2019 00:36:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557819382; cv=none; d=google.com; s=arc-20160816; b=jjXYLFMlSLz+mUXX5NvPkbewMby4oy3BD23/b0vJrV1/TFQlosbjUltgmW/jvduQaC eCr6Rp9TaQRqrfBhuTeThJJnkrJOCVDwweTIvx1U6NBHMt/Q0bcSfr67oYKTFlrvBTIO Jh+BDhGCFtIWwYopeH0kmmoH1oNQCJ1DIo47ZKWw02SehI4xolspHxb8UtHiKtKWiMQP pc145nlP/uCszrY3sAeKWIJsjSBenVwG7fLQuFuM3vxM94kwYjyq7osYDtVWcJVqGiXl 1JxVZXgJ0grkBpjhYMVv8iZBeGBD+/DRhJbs6oSUdRtJeW79i9r3OHKaiIqN7CbcTTnP J1tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ypxcL+Y2IvMWn09TLf/QK34oXMbYOcjJzriH87EFApU=; b=KNyveaLuBhxRaHXP6BL0s085xPphnz65tVTD+H8Qb8Z6j7WeUm3ePm1wAtlTKYCy3U Ip6yiwh1rE27NuaWxqPbte+ClxuQckZZ8pJyFHvV0cpXIybJBYJ9rqL180DnT/gyRs0+ sQ6cIqGT1MbWw/S7W4WUvs3eDbltaZRlMlvVVky6BqBr6iLfjeU50fuITRj6UXv+N0ph Nch0LwBlTVAAjCDY0gA0yV7+AyTaGECDMWy86+wFKj5e+8JNZ9GdwOmMMaaTKEr+Ft5v WA5+/iylsKgJy5LvFPhURBn6aXbqnnwrlYysTyAYjm/d2+grvAmjmAWSK5JDM7T5khGh OnTQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67si19386585pfg.177.2019.05.14.00.35.54; Tue, 14 May 2019 00:36:22 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726434AbfENHfE (ORCPT + 99 others); Tue, 14 May 2019 03:35:04 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:40583 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbfENHfD (ORCPT ); Tue, 14 May 2019 03:35:03 -0400 Received: by mail-lf1-f67.google.com with SMTP id h13so11026733lfc.7; Tue, 14 May 2019 00:35:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ypxcL+Y2IvMWn09TLf/QK34oXMbYOcjJzriH87EFApU=; b=Zt61CVWfeJRKPEEh7jwVW2RaAhOUVD+pyubobdEXvlsLpnyJIzpjHRZVneaQCRYw+g ADDd+MfAL3U8ndjB0hm6Y0v5tA5QN25XqRTPwWINJ4IO4puLYVsIVoJqxt/+drxFEQsY 0uJ9s3Y61qocUec1imklZbCixKguZl2btNcn23AWHFXLR1cOhQzWrO8xE6pY0HBh/5oR 5CEMw4jq224OF9p/4dm9Q9Jxh3++dL0VlvW2YlEeHupQp3mWHcqque8KeFLhimhrugCu G3Li4vI8Q+YwOM+x0hxtu3In1aL2IrQE8+rKFJf2PBUM2usvIlFXL+V2ZaUxr9zKqxfY 3Lhg== X-Gm-Message-State: APjAAAVTJ7Pj5LP2aHEeb6MPC7FELGPhIWATlwFWAy9JgD29F7S3vPfN j7txJAHUViX/puic4ya1rSk= X-Received: by 2002:a19:2d1a:: with SMTP id k26mr16477193lfj.104.1557819301422; Tue, 14 May 2019 00:35:01 -0700 (PDT) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id m5sm3625700lfb.47.2019.05.14.00.35.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 00:35:00 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1hQRxh-0001Dz-9k; Tue, 14 May 2019 09:34:57 +0200 Date: Tue, 14 May 2019 09:34:57 +0200 From: Johan Hovold To: Lanqing Liu , Rob Herring , Greg Kroah-Hartman Cc: baolin.wang@unisoc.com, baolin.wang@linaro.org, jslaby@suse.com, lanqing.liu@unisoc.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, chunyan.zhang@unisoc.com, orson.zhai@unisoc.com, zhang.lyra@gmail.com Subject: Re: [PATCH] tty: serial_core: Fix the incorrect configuration of baud rate and data length at the console serial port resume Message-ID: <20190514073457.GI9651@localhost> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 mode, > userspace needs to close the console, which means the uport->cons->cflag > 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 configure > the baud rate and data length of the serial port according to its own cflag > when resuming the console port. At this time, the cflag is 0, which will > 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") Judging from a quick look it seems the xmit buf, which is released in that function may now be leaking too. > To fix this, assigning the TTY->termios.c_cflag value to uport->cons->cflag > before the userspace closes this console serial port. It will ensure that > 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. Johan