Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2600880pxb; Tue, 21 Sep 2021 03:38:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2fssMF76Qr5xz1ESC3inu041gEdyS9jQizn799akJTpMUg2TkqJ99QjBS2+g2qGNIiX+L X-Received: by 2002:a17:906:ece4:: with SMTP id qt4mr34167345ejb.250.1632220705990; Tue, 21 Sep 2021 03:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632220705; cv=none; d=google.com; s=arc-20160816; b=sNzbIXDvlIk89A+nb9HCAGDgGZ3AL8nkkpgu+o0D1y51ZhKMnNSSkFtim9/Fi+LawE WI8iwFTqg8tdYAhTyVaV3KsiOz5Bo0Qc5IHI8b1ehgbm3Gt26NBYJFVch7b3KBkwSn21 egQWSmNyknKn1Vl19fFx33GsszfY4Cy2eS0p7hJjRrHaqwuJh7oFvSOdkzapOYmkUi/k LIABDtmtUhzyULwNjTyYenbzjM8/ZxF76FYGZH2CypPL9oXj6ad4UAk0vYbudCyWvKqr I41inKqA4XYMEIf/CBI6LefFiwqeZ539ahX9atJhv4jeGicmSquL7gEnfEy7QHpt3U5j JrWw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sXw48U6vsgzH29tqtCvvbD3SUJUsZZYK5vJUgKlAYc0=; b=Q4GEj9JhydH3MiYMJu3oH1UwP+AbzBt+MdBMrIgtxa5hVj2QCkwAwLEnlLIa5lZntJ 3qdzUzEY0YYc1fS/JlijX5Jy5GcSTInIDVoO+/UU/79ReiJ1eordnfnCdiNKKyTD+UCy bPbNjVVHPr1iVKMwL1qlGAZw5oedb0vcwiicA/zG5t6D7iEyQZvo0b/NLCunMjsHJbeO NktXm5ua5IZ3gu1+vizFQ9T64/rrhS4sR0lw74vH2gfSRqAAgMnXdLjOSLxrZMZ3RJe6 0paXCZbn8eNBhrJbLuuwToyp9g7k7MjEoZqtjUFQOYp3uZXrwS/vk9DqYTNyKL97RH31 oL3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si15103122ejt.376.2021.09.21.03.38.02; Tue, 21 Sep 2021 03:38:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232012AbhIUKfh (ORCPT + 99 others); Tue, 21 Sep 2021 06:35:37 -0400 Received: from muru.com ([72.249.23.125]:35542 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbhIUKfa (ORCPT ); Tue, 21 Sep 2021 06:35:30 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 118A38127; Tue, 21 Sep 2021 10:34:27 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman Cc: Andy Shevchenko , Jiri Slaby , Johan Hovold , Vignesh Raghavendra , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] serial: 8250: Implement prep_tx for power management Date: Tue, 21 Sep 2021 13:33:44 +0300 Message-Id: <20210921103346.64824-5-tony@atomide.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210921103346.64824-1-tony@atomide.com> References: <20210921103346.64824-1-tony@atomide.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can use the prep_tx() call to wake up an idle serial port. This allows ust to remove the depedency to pm_runtime_irq_safe() for 8250_omap driver in the following patches. Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_port.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c @@ -1650,6 +1650,29 @@ static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t) return HRTIMER_NORESTART; } +static int serial8250_prep_tx(struct uart_port *port) +{ + struct uart_8250_port *up = up_to_u8250p(port); + struct device *dev = up->port.dev; + int err; + + if (!(up->capabilities & UART_CAP_RPM)) + return 0; + + if (!pm_runtime_suspended(dev)) { + pm_runtime_mark_last_busy(dev); + return 0; + } + + err = pm_request_resume(dev); + if (err < 0) { + dev_warn(dev, "prep_tx wakeup failed: %d\n", err); + return err; + } + + return -EINPROGRESS; +} + static void serial8250_start_tx(struct uart_port *port) { struct uart_8250_port *up = up_to_u8250p(port); @@ -3227,6 +3250,7 @@ static const struct uart_ops serial8250_pops = { .set_mctrl = serial8250_set_mctrl, .get_mctrl = serial8250_get_mctrl, .stop_tx = serial8250_stop_tx, + .prep_tx = serial8250_prep_tx, .start_tx = serial8250_start_tx, .throttle = serial8250_throttle, .unthrottle = serial8250_unthrottle, -- 2.33.0