Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2279160rdb; Mon, 5 Feb 2024 01:10:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFvJN1agWxuDBxyps+jHpxHme7bINFlOkh06uuR4uNIfROivIrcyPrnUc3Xjr/FE/k2TdS X-Received: by 2002:a17:906:5395:b0:a37:bd9c:ad74 with SMTP id g21-20020a170906539500b00a37bd9cad74mr1080240ejo.75.1707124215015; Mon, 05 Feb 2024 01:10:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707124215; cv=pass; d=google.com; s=arc-20160816; b=qECU+D4mJRquR7IBbzaAFZaqoFkMJNGl0yQQ3z38tZaMSRHQuhBVqYxf1u+8xLVbf5 7LbR7w0qdpOD4rr64ZKT0mmyuFzHr9sZ/gP7gF6Rtn2EEzDlbn2jXJPAkRbWj8aUS2LE 9a9EUJMH386z0Suwl+mSuHfd+DCvnuLIDqQgh1wwy+4a3EGcc1bg+cbsjE1HfDZPB11T rtOsCu1/gibn+25y8gFWtsDkvxqB5iD41Br6068DwYcb2qLV4b3zw9Th4WlDa/UdTBbX bJQnmEbBcIyik8pwSpOZQ2Uqc1t10AFx/cf2k+2iOXVK4yni+nCfmxmdcWQR0cNk1u02 +Kmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gwQRaDo+ILUz3bB1YPueNhSvCyDvCyOSwRYykKLiahw=; fh=sLTecxAE4gTR1UE7++C25efmtfX3YnlNIWPmw9wCisU=; b=z76KNtxx8XcAoN8yEq82E11C1JjNKT0KsKr3Uta4MR50afUvmbZkSLcGXyNlGz3fhv t33N1HHjBPUtW5HUoPslSxrYTkPnTVJ3PmPUj7/krpbYWaNnjw5NCZs2n26EZV3JGltr T7+ljhVHH71AmpQGUB2N6e0wuDY2Ua7rKjL5rR/9I29+z9seKOUef6bo+fJw4KNlOxT3 UHGBDKjK+cdemv54EBI5w8aehj9Cp9VSOGG/YcaXGX/Hj+NFKThQVpI5/Dd3EKWfPzgD zIpg3QlDLPbhBWggJPFBMfBcD72ZbNygWLL6D1MCDp8fZInItB+5LhP/+q8iltPdnF6Y yr2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=hwgn3PrN; arc=pass (i=1 dkim=pass dkdomain=atomide.com); spf=pass (google.com: domain of linux-kernel+bounces-52261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52261-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUI+9AOnkITy6xvYMnqAWPBifoiyJcaZslyeZkVUHMCoaoUz6DSxBGG+/R1vf9AUXvzbqedetGz9bRnsK7232u4nApA2Zd18SfAZa59WQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h5-20020a1709062dc500b00a379181731csi1533830eji.1002.2024.02.05.01.10.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:10:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@atomide.com header.s=25mailst header.b=hwgn3PrN; arc=pass (i=1 dkim=pass dkdomain=atomide.com); spf=pass (google.com: domain of linux-kernel+bounces-52261-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52261-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BED601F2135F for ; Mon, 5 Feb 2024 09:10:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFB221427E; Mon, 5 Feb 2024 09:07:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=atomide.com header.i=@atomide.com header.b="hwgn3PrN" Received: from mail5.25mail.st (mail5.25mail.st [74.50.62.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E770513FE7; Mon, 5 Feb 2024 09:07:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.50.62.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707124065; cv=none; b=rBPdbi6xM0KmJC4j7KZXykm9Oya41Fw5ecEcgwDAcF4v25UlAngUr2Y+Yp5MDDATek34MXG5XQDnwFaR72cKmVUSDoEwrKlzHUhL5KoTGRoXCVBet6vevO5196Ys/dp9cZawShSS1KlX4YlaOHphbBjHu/BwRHvc8sj9uTbq3qg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707124065; c=relaxed/simple; bh=y+z9xVQilhhc12JJlLDw+v63p9nJbNGDefO4T0ZXh4k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=V4nYAKOfOkvxgw9xXz7FJDDA1i29QO36eyVwTijhExo/2Jw2TVq65ugmUfKiOfane5s2RemDU+9kMb9Oh0H8D4xfobEav8k56Ug8YJ7iapveciUkrzc3OxgR1aHnT55Im41TRvbRJFMGV+zhQH4tne5WrQwzS3gd1J68ElZ6gCk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomide.com; spf=fail smtp.mailfrom=atomide.com; dkim=pass (2048-bit key) header.d=atomide.com header.i=@atomide.com header.b=hwgn3PrN; arc=none smtp.client-ip=74.50.62.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=atomide.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=atomide.com Received: from localhost (91-158-86-216.elisa-laajakaista.fi [91.158.86.216]) by mail5.25mail.st (Postfix) with ESMTPSA id DA39C60372; Mon, 5 Feb 2024 09:07:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=atomide.com; s=25mailst; t=1707124062; bh=y+z9xVQilhhc12JJlLDw+v63p9nJbNGDefO4T0ZXh4k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hwgn3PrNMAjkMX+XS8UmD8BVTb00qt8zHYGzUAtCGpMsArJPxjKleZjYu0+fJAZZv Oker8ZGAHXnK2LOgB1i18XHQikNt1MatgPripF66eZszCd+6s9OXa9eDGx1LKKknWi OssM2goeu9TtOV3xgIm2DAlJdQBudJ2z5gpD6vGLDs3FeWyklFI920QjfzSzJiFcXf DzYPr8HYoaXk5BcLcY/cfNzxISHwFavvnmRThzVRqGK3WS2nfNGSBuTXm3a3ClN9aK /MCy/UaAspxxsxLW7ESuhUpOqtaFN85ukcb1btHBqAdfE8ZsSxvYuMWFbH3MNvpMKI kxDxO/JoGYG+Q== Date: Mon, 5 Feb 2024 11:07:13 +0200 From: Tony Lindgren To: Yicong Yang Cc: yangyicong@hisilicon.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, john.ogness@linutronix.de, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, linuxarm@huawei.com, prime.zeng@hisilicon.com, jonathan.cameron@huawei.com, fanghao11@huawei.com Subject: Re: [PATCH] serial: port: Don't suspend if the port is still busy Message-ID: <20240205090713.GE5185@atomide.com> References: <20240204031957.58176-1-yangyicong@huawei.com> <20240205065126.GB5185@atomide.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: * Yicong Yang [240205 08:55]: > On 2024/2/5 14:51, Tony Lindgren wrote: > > Can you please confirm if this still happens also with commit 6f699743aebf > > ("serial: core: Fix runtime PM handling for pending tx")? It adds a check > > for -EINPROGRESS. > > Tested nagetive on latest v6.8-rc3. Paste the current code snippet below in __uart_start(): OK thanks for confirming it. > In our issue case, the dev->power.runtime_status == RPM_RESUMING as analyzed in > commit. So we cannot pass the pm_runtime_active() check and the chars will still > be pending. OK > Do you mean something like below? > > static int serial_port_runtime_suspend(struct device *dev) > { > struct serial_port_device *port_dev = to_serial_base_port_device(dev); > struct uart_port *port; > unsigned long flags; > int ret = 0; > > port = port_dev->port; > > if (port->flags & UPF_DEAD) > return ret; > > spin_lock_irqsave(&port->lock, flags); > if (__serial_port_busy(port)) { > port->ops->start_tx(port); > ret = -EBUSY; > } > spin_unlock_irqrestore(&port->lock, flags); > > return ret; > } Yes the above should work. > If so will the port fail to suspend after flushing the pending chars? Considering > underlay driver like amba-pl011 doesn't implement runtime power management, does > anyone will get the port into suspend routine later? I'm not quite sure about it. Hmm yeah you may need to also call pm_runtime_mark_last_busy() to ensure the port gets idled later on. Not sure if PM runtime core does that for you on returning -EBUSY, worth checking it :) The PM runtime hierarchy will block the serial port controller driver from suspending, so the port drivers won't runtime suspend. > In the patch's implementation the pending chars will be flushed in runtime_resume() > callback and rpm_resume() will try to call rpm_idle() later. On serial_port_runtime_suspend() the serial port controller will be active, so you can call start_tx() directly. Regards, Tony