From patchwork Thu Oct 5 07:56:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 148759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp345547vqb; Thu, 5 Oct 2023 07:41:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH81atGEjJyH+v+EA0BvLXWwtox+j6aYaTeMwZdlSwnEd7dDOLhwqg1AxX0DAgHLfRAKhHp X-Received: by 2002:a05:6a21:a599:b0:153:39d9:56f8 with SMTP id gd25-20020a056a21a59900b0015339d956f8mr2320719pzc.15.1696516883745; Thu, 05 Oct 2023 07:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696516883; cv=none; d=google.com; s=arc-20160816; b=VmAsNfRx/8cTlQHWiDbsRA04IywRTvtwY6CmiDFf4x+sfWdoNunPmFsstbQFPWvm2Q rY11aAWL9p+nq52/w53Jop89QxlzpsgvV1OTgzTsrDT2Nl6JYIh3IpWB9c6ORS58/SAe phCVypjK14QrJycRvjFNjMiRILCcRQ+7O+VZmovWLc0wG3AgzXbUSHTl9MI2Oig+jqy6 lE155FqjnMAq85pFA3V75UoUQ8gertLi1SSbOHRSCDy18TZW7467iWITzdDVRxAurOzv oLHhq2WpgXjTO0oFVUthgVEne1i9GVCXf4tHnYppndq5JPU/6vk5G9v/gvfUk9Bk9DaV s0oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=YgdliScY+7H6Y+egGa8GySiooIxBE1QqOkR/5GcCLGE=; fh=c4gVgLWzq4YXSbk13qVtfs8jByfTd5K+WpAMXcU2Rzg=; b=GZZmIhEpZ4s/7rMI7TiQc8EYXP5o0TBZgZQQVfF11f7Y04gibTLqnvJNOxAtV8coNv k+GHQ2+7Hah2HQCJ7bWnSfkij5N1Cfd2HI2X8jn3sD8vVbVnnGvriQZYIdyCWSDVqZNv y34OAVwzCHy0UT7p7zsJA9Asdx+ef+Axyz+D2QykkUGJZ6I7gVYUY72X1dHF0V5Y0wKG 5lbBldDEZFa+hT5jxAYXplvX4OtM8vb+UpvtX89D3Yi52/vUBO0H41IEsKb5o8fZqXTF N50GaKjUlnJXkLqH7AxxGedQouewASssM5MwpHuPrJs8OmurlaKsZ66s/nhqHxtctqKM suyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bx29-20020a056a02051d00b00588d84b1217si1836495pgb.415.2023.10.05.07.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A34858373A36; Thu, 5 Oct 2023 07:40:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236726AbjJEOg5 (ORCPT + 19 others); Thu, 5 Oct 2023 10:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236150AbjJEOej (ORCPT ); Thu, 5 Oct 2023 10:34:39 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 17C3A4233; Thu, 5 Oct 2023 06:53:03 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 51FE280A0; Thu, 5 Oct 2023 07:56:47 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko Cc: Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Maximilian Luz Subject: [PATCH] serial: core: Fix checks for tx runtime PM state Date: Thu, 5 Oct 2023 10:56:42 +0300 Message-ID: <20231005075644.25936-1-tony@atomide.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:40:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778926579092321131 X-GMAIL-MSGID: 1778926887698888528 Maximilian reported that surface_serial_hub serdev tx does not work during system suspend. During system suspend, runtime PM gets disabled in __device_suspend_late(), and tx is unable to wake-up the serial core port device that we use to check if tx is safe to start. Johan summarized the regression noting that serdev tx no longer always works as earlier when the serdev device is runtime PM active. The serdev device and the serial core controller devices are siblings of the serial port hardware device. The runtime PM usage count from serdev device does not propagate to the serial core device siblings, it only propagates to the parent. In addition to the tx issue for suspend, testing for the serial core port device can cause an unnecessary delay in enabling tx while waiting for the serial core port device to wake-up. The serial core port device wake-up is only needed to flush pending tx when the serial port hardware device was in runtime PM suspended state. To fix the regression, we need to check the runtime PM state of the parent serial port hardware device for tx instead of the serial core port device. As the serial port device drivers may or may not implement runtime PM, we need to also add a check for pm_runtime_enabled(). Reported-by: Maximilian Luz Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM") Signed-off-by: Tony Lindgren Tested-by: Maximilian Luz --- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -156,7 +156,7 @@ static void __uart_start(struct uart_state *state) * enabled, serial_port_runtime_resume() calls start_tx() again * after enabling the device. */ - if (pm_runtime_active(&port_dev->dev)) + if (!pm_runtime_enabled(port->dev) || pm_runtime_active(port->dev)) port->ops->start_tx(port); pm_runtime_mark_last_busy(&port_dev->dev); pm_runtime_put_autosuspend(&port_dev->dev);