Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp449699rwb; Mon, 26 Sep 2022 00:45:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4m2gaPxpr6J7wrmK/TEHMJQiuus+28rBwhShUAtPVlJQ8eakgaAkG3hcpTI+TLpOtyp0wW X-Received: by 2002:a05:6402:3587:b0:451:30ca:c067 with SMTP id y7-20020a056402358700b0045130cac067mr21361844edc.195.1664178329536; Mon, 26 Sep 2022 00:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664178329; cv=none; d=google.com; s=arc-20160816; b=KESI57rEPpcuweEMhbBfd+Bb5ZnxIEAszfLZspoyEjPs8yV4OS80cG9kdQ/lLDjdvq ya28tNRfnKpxtXnKDLIm2YH5uDHXarL69SgrSv6EXrtPVtQR7gakStIZlS0oceQwCuhf qmbRyq0SI+eWY/HESANScVKRbYLoT8vAykYT+Di0HYdu//Pnps3p/ZXugBovNTzKtYdK DRNbSSpYBWUWcJ93tv7k9ddi+B4WW/BerfnA5guqvLjctVRPJSAiVxKv53+mJckZZHB9 Hp4qAU6MuuYE5h+srCvdUXXM9f6WOCkYZaLV7hJb81FILh7tbBcBuujpdH4XJsATL2c6 2Dtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=ioYGPRvwOzTPXX99j4J/86pZ+x1+n0p+8AnOz//0Jhc=; b=fnMrcqBJgiA132XOngWRg/QC4KBI9Om4dsT8FYic9DPM2b+HeFfnBEP7kVqPEeRlqK tVz2DmQ/YSsGuRztuZ7JBg4uwYXxqSzjOYZwGyVrYqa7eFqp5P8msCoy53kZuy8XkdIz ejXXaBdbfHT5rwpZbHnyaumIpFu1da+sN+DHU8KhnMYExVInRcsF0sYDl9+HWe36MZk5 dpJvt96iUH62WbB/IF7Mwac6ErmDgNtnS+QUskK4Ifl40ZSFjptVmlO2jU7/fMRph3L8 oz1aUWBvSVttj/7jb4rD8FDHRIIwpcgm1dMkcJhOOBx9exRqUzRd8XjIuLLukwUdjIy9 bn3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a056402274200b00453f51948e6si17271255edd.153.2022.09.26.00.45.04; Mon, 26 Sep 2022 00:45:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbiIZHQz (ORCPT + 99 others); Mon, 26 Sep 2022 03:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234043AbiIZHQv (ORCPT ); Mon, 26 Sep 2022 03:16:51 -0400 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E55532052; Mon, 26 Sep 2022 00:16:46 -0700 (PDT) Received: by mail-wr1-f46.google.com with SMTP id bq9so8740469wrb.4; Mon, 26 Sep 2022 00:16:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=ioYGPRvwOzTPXX99j4J/86pZ+x1+n0p+8AnOz//0Jhc=; b=oaXmMK7zWNr/X2XgflIbyeGIUvEvSyxF0uMyTxiCcDBXg4QqC2ZrgHKmtpYSgeDbOG MRSySzK3ru2WA21EeskQfK5/ynq7a+ToEcJFd+iKMq7vtgXzp9ngH90DzJvZtmOgl4uZ jQsw2knzf+NYdKPjQZMSuXROCbDVjSPzJVrNoYHxqep2EkYrVEINU/xMfHLm3sRBX13g 6BFbkdg+Jv9R1Dan5HyxXy3f9Ycd2VH7u4RUHxYBVsitpdbjvF77uOmO2/Az/JHbum0g OWfnCSODOb1GAHYJMOgIFZrjqZDrBmBUa1xBfj/L2Fp19uRHmNLqAdKJGfzrS+oc0hA4 XmPQ== X-Gm-Message-State: ACrzQf1qOe8z7Y8DuBRTQEffeFYr2rGsI0ZJggtCcyz5T+XhG6crfxYn pa7ng2CoTV/TjR5kcx1lPg++dMjaUME= X-Received: by 2002:a5d:47cc:0:b0:22c:86fe:ad94 with SMTP id o12-20020a5d47cc000000b0022c86fead94mr9236407wrc.599.1664176604539; Mon, 26 Sep 2022 00:16:44 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id g11-20020a05600c310b00b003b4fe03c881sm10532225wmo.48.2022.09.26.00.16.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 00:16:44 -0700 (PDT) Message-ID: Date: Mon, 26 Sep 2022 09:16:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: [PATCH] serial: 8250: Fix restoring termios speed after suspend To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Greg Kroah-Hartman Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220924104324.4035-1-pali@kernel.org> Content-Language: en-US From: Jiri Slaby In-Reply-To: <20220924104324.4035-1-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24. 09. 22, 12:43, Pali Rohár wrote: > Since commit edc6afc54968 ("tty: switch to ktermios and new framework") > termios speed is no longer stored only in c_cflag member but also in new > additional c_ispeed and c_ospeed members. If BOTHER flag is set in c_cflag > then termios speed is stored only in these new members. > > Since commit 027b57170bf8 ("serial: core: Fix initializing and restoring > termios speed") termios speed is available also in struct console. > > So properly restore also c_ispeed and c_ospeed members after suspend to fix > restoring termios speed which is not represented by Bnnn constant. > > Fixes: 4516d50aabed ("serial: 8250: Use canary to restart console after suspend") > Signed-off-by: Pali Rohár > --- > drivers/tty/serial/8250/8250_port.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c > index 39b35a61958c..441f317c55af 100644 > --- a/drivers/tty/serial/8250/8250_port.c > +++ b/drivers/tty/serial/8250/8250_port.c > @@ -3314,8 +3314,13 @@ static void serial8250_console_restore(struct uart_8250_port *up) > unsigned int baud, quot, frac = 0; > > termios.c_cflag = port->cons->cflag; > - if (port->state->port.tty && termios.c_cflag == 0) > + termios.c_ispeed = port->cons->ispeed; > + termios.c_ospeed = port->cons->ospeed; > + if (port->state->port.tty && termios.c_cflag == 0) { I don't currently know how safe it is to assume port->state->port.tty cannot change between the test above and the dereferences below. In anyway, you should cache it as it is used 4 times now. It would make the code definitely more readable. > termios.c_cflag = port->state->port.tty->termios.c_cflag; > + termios.c_ispeed = port->state->port.tty->termios.c_ispeed; > + termios.c_ospeed = port->state->port.tty->termios.c_ospeed; > + } > > baud = serial8250_get_baud_rate(port, &termios, NULL); > quot = serial8250_get_divisor(port, baud, &frac); -- js suse labs