Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1582152pxb; Fri, 24 Sep 2021 07:40:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzx8UV+wuVTqMDqZx2y9RKuQMwY3QMnKi4LCmPp6UogavKpr7liVsniY1tqfybmiNlPoP72 X-Received: by 2002:a17:906:5e43:: with SMTP id b3mr11519270eju.424.1632494429435; Fri, 24 Sep 2021 07:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632494429; cv=none; d=google.com; s=arc-20160816; b=n5pDjDpp8dcJ/8YM7R5QQ6h/Ja/VYv/krpUXyx/2g61O99Ah42JfLjJY72AajneU+6 fEzmn3yTtTXrDeZ5Sv6Dz/RTqB9DmOdTo9wsxJSR0X3XiHPJnaqMx/N2iLlqAtquDue+ HQIlPbKovNaWRNyeSdHTorWTK6VwaBwighHdJOQLWX4HMsKOqwF76saIBDwxlgi8oqiT /0Qe/JISm4pt+YGliFUQlpICdqSxFUIVlL2nn1DkcVyO8QspX91TsuFRRRiJz/gMjHBZ A4GE1+RvnG6t7JbrMnrbQ/Ti3kr/UfosuC9YEwDvysAIHntPsGI+GVQHndg59MUqx7QZ wstg== 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:dkim-signature; bh=pMoNVhrB9HtJ7NQwHRScMieH0XFhLihKIXGqcBbCmzc=; b=gT5TUVHTwxxfsVT1wcUWFF3suX4UigFS3P8xGhcrJQoEbqy0GcNf2ptvvYA9sqMF/v VZO+mze37U19s74XYawN1VSbfKeVHpnzKXyHLtG2E/oCs7HBBnMtxLzA0anbjFoAo8oD egxyZ34E8kSw7MjXxGHSmYHGun+sa5bCl/WZ8uo5egifJUyu8I3x/3DYz2lzkhqqHHyL 5Ru0nFxmtsKlAa62rCWAoOdsgrcsjTtHHH8NLzdXLBfolvOkHFBxuBar644yzLec40ke Qmbw3IR1GY8b1eQgxh9N7jxkOJNd3Zx4OARyUxxtfVWehKa/Xri8xMelo5IGJtp3+awv +q2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mNnuhKLE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn11si8406725edb.377.2021.09.24.07.40.05; Fri, 24 Sep 2021 07:40:29 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mNnuhKLE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346789AbhIXOjI (ORCPT + 99 others); Fri, 24 Sep 2021 10:39:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:38060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346731AbhIXOjH (ORCPT ); Fri, 24 Sep 2021 10:39:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0E40660F9C; Fri, 24 Sep 2021 14:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632494254; bh=BK3v+VyNJVPw8v2HTHk9VkzAkGeHSOjxEF6PdFPg4/s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mNnuhKLE1smaILowt3dkpobiGHmOMHiNuhHKko1SGVbJaNUflMK9ORhkRTs7AfYsP ysKoEoeeUSgsSHgOre+kfomjyb3+c5/BtWie8oLdgwyYMii6JZn7r2g3AZ+XSj3nly jrC7SIxTXdnYozdluz/AkaLO5V4g3wKnqhBm8wTJNP6SJ9yXpyKLB5PXmXvNMwLvEP 23u0kJT2Pd5qeULtU31rAsS9shI8qBPCC9ZHLqKdtDOuPJ5Qz799tlf/Ja9SAz2E/4 ys/dy+V2cufXUmoi9lu+kQ4Rltd9np4+X6Sy6sGsdBcJ+qPOx/nXOI7EhDhY1izzsZ QjlxREaYvIJyw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1mTmKW-0001Ow-4y; Fri, 24 Sep 2021 16:37:36 +0200 Date: Fri, 24 Sep 2021 16:37:36 +0200 From: Johan Hovold To: Tony Lindgren 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 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. > > 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. > And even if we could return a fake number of bytes written, we could > run into issues doing the real write to the serial port. > > > 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. Johan