Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1873414pxb; Fri, 24 Sep 2021 14:05:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5nJqo8WBuFAUJYIn408V0oVyJX3/AVVuEJRtdL/+5vfkoHA+pB7UxinimDsuims1hhTQD X-Received: by 2002:a05:6402:222b:: with SMTP id cr11mr7565310edb.392.1632517518421; Fri, 24 Sep 2021 14:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632517518; cv=none; d=google.com; s=arc-20160816; b=CeoJg79HIJl0LMRGS3iWqHvzf2L1fw9aVWILkOzsA5TXDL31M8XA+anztLN3R5pCFq u3QjZ8if+Kvnl3V9bUVXgtEN6sC5igma78J6krtSz/owQHJTNOwWdw0lGOgnGeaMoo7P NwFa0Otogk8NUIE3F/CGoJMCV1AS7wLmS0vwa75XGCFeT4kWDQ8gAPYNkU6HLsnM5p9t pm/3nCxjZCLEivfwg6q9sPcQ2FmJR1TcG6QRK8OCnDuyUYKN5IeoRccvWDQrjEPCgrQ0 mRBth6jenFeMfppfKGFlbNBC1e7kApWFKAdNougoQQ1YYm6n5yi/YxvUPfLCLB2FpqAQ AkrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=1tJ0V/nQa21in49jAQ513c6PWARkXEaCelzHCHVkvwM=; b=i0sKLDR152N0CiOFnAWeb+aiM2Qto6dSEyHiBgRMSlMav+3qUCN7uiuIM90FcsAww8 mst3KQXrqtGd1mweZiP51xmmtA27BgoxeLYQp5k7FqCic9YiUc0JOsFv4T8yHQZdctL0 j/Qho5DlPUdA2bNMRISwdEIfYo3Ulhtx4qk6QC2YAidKeus4L8WZHHdna88BT6jsKYNU 5LFTBpgYkuvUgpm1ZmlPbZETSxKRa8xHD15K1pBMoabXm5r6TkT/DkOfRYSCeRrwl9jJ oHxNGbr82cBUPo4O8rBVm9+ixOI3RQwEAWHD1vwlsLZ6Wfgrx9sDX9cLRCxTAa6/9BBA mgzQ== 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 e16si4015811ejm.243.2021.09.24.14.04.54; Fri, 24 Sep 2021 14:05:18 -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 S1347017AbhIXPRs (ORCPT + 99 others); Fri, 24 Sep 2021 11:17:48 -0400 Received: from muru.com ([72.249.23.125]:36942 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346962AbhIXPRq (ORCPT ); Fri, 24 Sep 2021 11:17:46 -0400 Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id C9FB380EE; Fri, 24 Sep 2021 15:16:40 +0000 (UTC) Date: Fri, 24 Sep 2021 18:16:10 +0300 From: Tony Lindgren To: Johan Hovold Cc: Greg Kroah-Hartman , Andy Shevchenko , Jiri Slaby , Vignesh Raghavendra , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/6] serial: 8250: Implement prep_tx for power management Message-ID: References: <20210921103346.64824-1-tony@atomide.com> <20210921103346.64824-5-tony@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Johan Hovold [210924 14:44]: > On Thu, Sep 23, 2021 at 06:05:36PM +0300, Tony Lindgren wrote: > > * Johan Hovold [210923 12:50]: > > > On Tue, Sep 21, 2021 at 01:33:44PM +0300, Tony Lindgren wrote: > > > > +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; > > > > + } > > > > > > How is this supposed to work without a runtime PM usage-counter > > > increment? What's to prevent the port from suspending again while it's > > > transmitting? > > > > Hmm yeah we should at pm_runtime_get() and pm_runtime_put() to write() > > unless serial8250_rpm_get() and serial8250_rpm_put() are doing it. > > If you do the put after just buffering the data it doesn't really solve > anything. Right, sounds like we currently rely on the autosuspend_timeout there. > > Or pair prep with finish and deal with the usage count there. > > Problem is where to call it from. How do you tell the device is done > transmitting? And how should we deal with flow control? Etc. Maybe if the device driver needs to call uart_start() also from runtime PM idle function and if no data allow suspend. Then if there is more data, uart_write() calls uart_start() again, device wakes up and so on. Regards, Tony