Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2012654pxb; Fri, 24 Sep 2021 17:57:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyGvOl3ynbigxnTCPLa9MNMmN/lgQsJrGEOLv+3UBhyHcX44hiT0s/1M/0lzr6QXYLmRLh X-Received: by 2002:a17:907:1b02:: with SMTP id mp2mr14821035ejc.196.1632531440202; Fri, 24 Sep 2021 17:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632531440; cv=none; d=google.com; s=arc-20160816; b=JbsOtzyTAsq9nBxFm2c2TPeZQbwHtrCjck8NojYXJVzxyB2jRwMHn0ScFWVrACA6Zw 0gBNRmJR706gM/vw3/iv59EIxgVMQs00PjMZrPiWp8GLVSdnRUcpihBcC8eOjL8VsCwB 4krDVixfEH4IkMG+eVXkkvqu0ASTREQXIDkYbIl1Yva8nBo509fTus9jukr41axkmNlb 4GHq+BCh+MObVBJCrLNtJjOHnkp07YR+aqmVopdcSujw5mqsYl2bqba3OxcVwHcRoOde J2EYYB4Nj5Tc3TWGGSx0VqZU7rACSMeonbIJD/07XNVhdFkYSy0Lw8kIREmL/8tJhQbu ArTA== 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=P9vx6MLQapU6u3pHJtOfjk+2eYblKwEkq9dyiqZ6jr8=; b=QKKr76mW/3a3zgmaEY6Qn0F1A1ug1xL4Kow+xRlQaf8KeZCFBmaJsmOtIrN7PT1r2k 3ow5Ypm9Mgo6ymwCKPgHILOQngWdLtrOpZSCTBPE7e27HTuYxtqf8joAZqW/oSGqzo9O HFWwddW41Eb1OloFeyZHsqcmkh6b++TPi5ZBy/puKEIQ6KUdiyBIUrb+3t/l4WgluARb 66nK14bEMwlLdr2i3n/4UXWr9HoJmMtfcdsuuxZfj5MYFIQ0z02FBCJpsXaJNGqcepi2 we8P4pHaaqkgDVpLM+9zMUxv3oip9lA3xEtOd6MKnEI2o5PLVra6RVcY70ncNGg+YgP+ dpVg== 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 y11si14876959edj.62.2021.09.24.17.56.56; Fri, 24 Sep 2021 17:57:20 -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 S1346984AbhIXPKy (ORCPT + 99 others); Fri, 24 Sep 2021 11:10:54 -0400 Received: from muru.com ([72.249.23.125]:36928 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346962AbhIXPKy (ORCPT ); Fri, 24 Sep 2021 11:10:54 -0400 Received: from localhost (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id 967E880EE; Fri, 24 Sep 2021 15:09:48 +0000 (UTC) Date: Fri, 24 Sep 2021 18:09:18 +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 3/6] serial: core: Add new prep_tx for power management Message-ID: References: <20210921103346.64824-1-tony@atomide.com> <20210921103346.64824-4-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:38]: > On Thu, Sep 23, 2021 at 06:02:27PM +0300, Tony Lindgren wrote: > > * Johan Hovold [210923 12:46]: > > > On Tue, Sep 21, 2021 at 01:33:43PM +0300, Tony Lindgren wrote: > > > > If the serial driver implements PM runtime with autosuspend, the port may > > > > be powered off for TX. To wake up the port, let's add new prep_tx() call > > > > for serial drivers to implement as needed. We call it from serial > > > > write_room() and write() functions. If the serial port is not enabled, > > > > we just return 0. > > > > > > This isn't right. If there's room in the driver buffer, there's no > > > reason to not accept those characters. > > > > Maybe. We might get away with returning zero bytes written in write(). > > But to me it seems better to stop things early when write is known > > to not succeed. > > But you shouldn't return zero from write() either. If there's room in > the write buffer we accept the data. And then waking up the serial port takes several tens of ms and the buffer is full and we still need to deal with it :) But yeah I see your point for the write buffer. > > > It's the drivers responsibility to resume writing when write() is > > > called and that me need to be done in a runtime resume callback in case > > > the device is suspended. > > > > I think we currently need to return zero bytes written from write() > > when the serial port is not usable. > > > > I don't think we can return a fake number of bytes written from write(). > > It's not a fake number. It's similar to if you have a port that is > stalled due to flow control. We buffer the data and continue writing > when the other end is ready to accept more. OK. So based on what you suggested earlier I'll take a look at moving the wake-up to __uart_start(), then have the device driver runtime PM resume call uart_start() again. Looks like uart_start() is a void function anyways.. If you have some better ideas there, please let me know. > > > No need to be patching line disciplines for this. > > > > Do you see issues with handling the errors in line disciplines? > > It's just conceptually wrong to push retrying up the stack, possible all > the way to user space in case of non-blocking opens, just because the > device isn't already runtime active. Yes, I don't see a way around that currently. Maybe if we start making use of uart_tx_stopped() or something similar that could be simplified. And we'll be still hit these line discipline error handling cases anyways depending on how long the serial port wake up takes. Regards, Tony