Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp323420pxb; Wed, 20 Oct 2021 23:36:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpA+XHaFbAxNj42rdBHxahSotoC8PlDiJ3l2mrsjz3+nT7ebyw9unVET6MEVmDc1cc6Hbz X-Received: by 2002:aa7:d944:: with SMTP id l4mr5325219eds.325.1634798192107; Wed, 20 Oct 2021 23:36:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634798192; cv=none; d=google.com; s=arc-20160816; b=qp4ZFR35O7b9KIN1C5nBeUQWCX+kkMPk09lHgn2/BRfFyCY3gxXEmRLtWnupjJRR1L GMXv5LtxyqdGognxeOrXhfT63yzCAJDfIfevbE2OHNtUqfIDloVY5Jc5UrcD6Xu/1Zgt eEEzNk9QnkVgPEDWcw2hcxHUkfTzOu4iqYj8DU5PLUmbUc0UFIUwEJfVbtRRVjTTtCcE FDRdft3ISUmW54/M2MrU4wJvkJA97H+kx4Qa6t1vgCTIerEoK+5g4xNiNboqxd2N7Z3H eEIqUCN9iAY3o4PQbc81QiENiu9SGJ85VnIthW4u4RBhoISpDWgsnV77MFFOkEw/RadW 4ezQ== 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=LTwQtDBSrl9BJaqXMsiFgCWWZSracugIENQCM3ntZxY=; b=j9F4/BwhLBsgchxsR3p6fKtCtcycN3IynpmIk/OgVqfb5YsBpGXR4MmxBfDSDxDvCZ yk1NwUf17B11WOhIDOyMt95jJlkKjJE1g2edTdcqWoT3CzyX7R2mjY8YRdk79H64lyea 5KgHDBdJeFze9C7voMtOlZxG+mHbr/6oW9Tx0a2sUzM6EE8x1jrZZOzMMso/Ow4wZEzD 4vkHLHq/sBuEd5NbtT/cT3zy9BTEbfpi05igpvb4vDDNNX1URVZjofKCXGkii+zD2HUr yjxaAfrjzf9sCDsTAS+uyj1rlYd7UV/XPnpVEW+SIus61WEkNz6bEKzTzAPAMcA/vMbO E9Mw== 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 v5si8473602edi.595.2021.10.20.23.35.46; Wed, 20 Oct 2021 23:36:32 -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 S231154AbhJUGfT (ORCPT + 99 others); Thu, 21 Oct 2021 02:35:19 -0400 Received: from muru.com ([72.249.23.125]:46880 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231443AbhJUGfP (ORCPT ); Thu, 21 Oct 2021 02:35:15 -0400 Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 3197480C1; Thu, 21 Oct 2021 06:33:30 +0000 (UTC) Date: Thu, 21 Oct 2021 09:32:55 +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 1/4] serial: core: Add wakeup() and start_pending_tx() for power management Message-ID: References: <20211015112626.35359-1-tony@atomide.com> <20211015112626.35359-2-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 Hi, * Johan Hovold [211018 07:09]: > On Fri, Oct 15, 2021 at 02:26:23PM +0300, Tony Lindgren wrote: > > @@ -1067,6 +1116,11 @@ uart_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) > > if (!uport) > > goto out; > > > > + if (uart_port_wakeup(uport) < 0) { > > + ret = -EAGAIN; > > + goto out; > > + } > > ...this isn't right. You should just resume the device synchronously > here and not return some random error to user space, which it is > unlikely to even handle. OK I'll check what we can already wake synchronously :) > Now this may require moving more of the runtime PM into serial core, > where it should have been added in the first place, due to a lot of the > serial callbacks being called with the port spin lock held. Yup.. So the good news is that Andy already has the generic serial layer runtime PM changes in his WIP tree. I'll take a look if we can already add some of that without bringing in all the other dependencies. > The current implementation is just broken. Take uart_dtr_rts(), for > example, nothing makes sure that the device is active before accessing > the modem control registers there. You're currently just relying on > luck and pm_runtime_irq_safe() (which you are now trying to remove). Yeah agreed, it's broken. It is usable for at least two limited cases though, which are a serial port console with PM, and bluetooth with PM. The serial port console typically only has RX and TX lines connected, and the bluetooth typically uses out-of-band GPIO pins for wakeups. To enable the serial port PM in general, we need to make sure it is enabled only for applications where it can be used. So it needs to be enabled from the user space as we do for the serial console, or enabled from the consumer device driver for things like bluetooth. Sure the TX should work in all other cases too.. > > + > > + if (uart_port_wakeup(uport) < 0) > > + goto out; > > + > > uart_port_dtr_rts(uport, raise); > > +out: > > uart_port_deref(uport); > > } > > Heh, here you do try to do something about dtr_rts(), but you can't just > ignore the request and wish for the best in case the device is > suspended. :) There needs to be a synchronous resume here too. Well for the current use cases the port should be already awake at this point :) But yeah, for the TX path we should be able to handle all the cases. Regards, Tony