Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2274632rdb; Mon, 5 Feb 2024 01:00:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEF/ifKMwDDKtYARMSoLCgEwUvAEhh6qKJofimh03f/XQDfsvcy1xaVK7+lSL2uTByYGkNj X-Received: by 2002:a0c:dd04:0:b0:68c:67ad:93cb with SMTP id u4-20020a0cdd04000000b0068c67ad93cbmr5844415qvk.37.1707123658483; Mon, 05 Feb 2024 01:00:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707123658; cv=pass; d=google.com; s=arc-20160816; b=y3TSpsvEmAT4oQclbwFsjxFXPJdNF1buefPLuW+scT7af/NE6noGU62+F4KXn5jSlI csJysTAyvWaNixwxWj7lmlZJit+7yrnhrQsdzWoq6X7tpzGfRGUCrrt8lr1O1i0P7zu4 yT5Hs9sxYlA5EHKXEzgpKQbyA76hAama107BNF9msGWa3fvvTD47wKH78JbjDkQjUPmc iMjbZaEbrt9WKCxITKi01zz793yiDzpTcz8NCAT50WxRbfiviPIAMjlXsTfDCm2Amwo8 DIe4AjGLjAE8+6j/0GQUvwiBMhvAcsykHwiV9lNXT50quJirJHnVH8Jpkk7j/yeDHNkV /+Kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:to:subject:cc; bh=bU6i7YJ1Cg2Nfc1D2Sb5xYlQZk22LjfkS7g3ZrMUr5k=; fh=+HtkTWjGAk/PAJn9cct00NsuXrNw/CKRm15jTsT1g2U=; b=Ts8O/imqxwXH/kByzepnY4epoiha1zYPV397YM7lgMJKeU4WsjE6+cIH+odxCaMEaI QyCCvyjNc8izh8XN4wVzcoKKYdah9Pbnx16BduUL8v1DvpJE6PGJTQFbRbvGJ+REi9/T I92td3sVl+birsFF0ffD4pLGXr6DlJFFoTe/1XaIbf+pV9L8gdRTAYPuokjyIScWJjS9 iLF1AuYKdk2OjstjdEtjd+btrqg1I3ndApZJ1jjnT2y5R5ChrSLRLnaqRgRQ1XYfUTm2 u5EYzTCIvVhgoVZc1pZrurcEMDO/1s8LhTyWkdQO36frVg/pvvFwmL45PKeSDXwSS4QC MGEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-52234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=1; AJvYcCXzEQnw3d4pQG9zaMzyVO4i432/JfZQfVpOEn2+q/5kbbFIHcWUZ9vgBka3qKDTJ0wuJPygOm8hg08iai5+mNiHolOjPSs3TfjlqIP9Wg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u14-20020a0cf88e000000b0068c458a7696si7725691qvn.277.2024.02.05.01.00.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:00:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-52234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 25DC21C2404B for ; Mon, 5 Feb 2024 09:00:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9D4411CB3; Mon, 5 Feb 2024 09:00:24 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 1BA5D11CAD; Mon, 5 Feb 2024 09:00:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707123624; cv=none; b=iB+jDdaXWMTQotoB5S5WSXsma4pdQMoWVbu8TqTtbp1KVC5y/wRuYyD7gi6hJ607nx9c/riRvlNfVeAaWboRSqZCmik7UwsrdqKt4yAl9UYktHPSJIe71+znjAcd/IUk3AMAPL/ExmXexcZEILaPf5dfL2ZQPlWtQPY2LNYufRM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707123624; c=relaxed/simple; bh=fhBKaVEYrEHPBmY52GfTCngYum3bYZxkD05PkUODcO8=; h=CC:Subject:To:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=O3J4xFoLL5XzQYwDjd/dlvjemIsKfp1sut7PczhIFZ/7tLNrRTiceVkxXOWj4OKijiBwez2+UFySaTjuVmFwBVDaXhg1xGYlnPJ4j5pA/RWZgx1+nxCpN2TPi5ov6Ekx0arjlF0ZJtIt/1P2TGk+k0+5P0zNoOUc5MmH3mprmQo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TT0f15Y80z1gyZS; Mon, 5 Feb 2024 16:58:17 +0800 (CST) Received: from canpemm500009.china.huawei.com (unknown [7.192.105.203]) by mail.maildlp.com (Postfix) with ESMTPS id 5D66E1A016B; Mon, 5 Feb 2024 17:00:12 +0800 (CST) Received: from [10.67.121.177] (10.67.121.177) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 5 Feb 2024 17:00:11 +0800 CC: , , , , , , , , , , , Subject: Re: [PATCH] serial: port: Don't suspend if the port is still busy To: John Ogness References: <20240204031957.58176-1-yangyicong@huawei.com> <878r3zpaba.fsf@jogness.linutronix.de> From: Yicong Yang Message-ID: Date: Mon, 5 Feb 2024 17:00:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <878r3zpaba.fsf@jogness.linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500009.china.huawei.com (7.192.105.203) On 2024/2/5 16:47, John Ogness wrote: > On 2024-02-04, Yicong Yang wrote: >> diff --git a/drivers/tty/serial/serial_port.c b/drivers/tty/serial/serial_port.c >> index 88975a4df306..60d1eec6b6b7 100644 >> --- a/drivers/tty/serial/serial_port.c >> +++ b/drivers/tty/serial/serial_port.c >> @@ -46,8 +46,28 @@ static int serial_port_runtime_resume(struct device *dev) >> return 0; >> } >> >> +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; >> + >> + port = port_dev->port; >> + >> + if (port->flags & UPF_DEAD) >> + return 0; >> + >> + spin_lock_irqsave(&port->lock, flags); >> + if (__serial_port_busy(port)) >> + pm_request_resume(dev); >> + spin_unlock_irqrestore(&port->lock, flags); > > Please use the wrapper functions for the uart port lock: > > uart_port_lock_irqsave() > uart_port_unlock_irqrestore() > Sure. Thanks for the information.