Message ID | 20230808072625.2109564-1-nick.hu@sifive.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2309819vqr; Tue, 8 Aug 2023 11:19:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBSnr6+Z8XOvD5WEfYSNngwERU1QnksR9pJ3YOoFgADiYh5ftml2G9bNudcHSEP//9QNS1 X-Received: by 2002:a17:902:7408:b0:1bc:3944:9391 with SMTP id g8-20020a170902740800b001bc39449391mr483608pll.25.1691518753063; Tue, 08 Aug 2023 11:19:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691518753; cv=none; d=google.com; s=arc-20160816; b=mrC3qe+xaPQU1Sgm+8SF+qBjMrlYy/yeGKzoozDNiY7lVMJsEMZT1j4SKN2ZV/bgaW ZsVRrKkcafbOatCGhpiA73YmXcE14ABaRX4QP80+MHj11XWX9lUNR8UI9PJapJLTQY+N LNDMpoVjgbY/6tYQelepjmS4S387TfV9OQuvQjaKvggqI4d9RIKPBax9FkSoCnOCNeZL 4FF7zPhbrJwOqAf2cho5GyZE0S2YiRuogIpZKJ8dozm6j4c34ZY5gdp4XUNTjbWD1OD4 lnWqK5acmLST5xxwcjGvT8OfuUFTvx6rR4P0c5yeq0lBM7CIYXe3jyWasR8VeOhV4g9X gbIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zQFUtOqa2Nuhn55ogQXJygZpI6oY6Vmrz17l7AHTGDA=; fh=Rh6HoUsLduznJ0CVztCKN7xrzTKc1QihDW5l2uysiPw=; b=KOOq9pbv45XfpQXwpKXHj37D61tkeRc0cSzq0jnHIb7fnJhvJmSiMPaZMUeHntFfnK EloWfDJM5G78f/SxRQXBLBVZ3UicLMWoGPnfdgFYqp6sk+v06iWeghkFjNHyqTcdvhPb 9rLeC1EJd3R0agvtp0lZLRw+2Ls8ySvke7zAUVxe8/aOxHsNQcaMZ1Sj63Du/Im3/juH zOwec2PrJ5Go8b7YgJbCag5MSDoCOUo7hsclBp2w7iEVf/RmtBX1ilV0OyDDTmfjasou YmiOX830t1jT0X60pppIIu5Mg7cs0G0S1Y9HkJMJ7MyAcNBy2rIRjlX4UFWGeqHveGZ7 kQbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=F3706irn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ky15-20020a170902f98f00b001b9d180fd9asi5435857plb.121.2023.08.08.11.18.59; Tue, 08 Aug 2023 11:19:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=F3706irn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235159AbjHHR6t (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Tue, 8 Aug 2023 13:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235165AbjHHR60 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 8 Aug 2023 13:58:26 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C0B1C3BEC for <linux-kernel@vger.kernel.org>; Tue, 8 Aug 2023 09:26:25 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-56433b18551so3509298a12.3 for <linux-kernel@vger.kernel.org>; Tue, 08 Aug 2023 09:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1691511966; x=1692116766; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=zQFUtOqa2Nuhn55ogQXJygZpI6oY6Vmrz17l7AHTGDA=; b=F3706irnCSu2+LNU7v78iqqJf8mD2eEkHIAU87U84StncQZ78FIU2CS9X7yI+jym2h xt1l//2Tg6ow5KDICKM8k+IVr72p0ST84q0c+eoeG3rwgTM0/HWNcpSbzeKvS1IYMfKY eYqOf3CXqIUoUsatdNdJ+qKsPKXVEpfnTMw1X2d1+D5QoMlkitjcWIJ+VByk05Dooq+Q 6aVXAC5yNUnXPWjeDZWiAkjpQNJntKpje0U8DaXsYsGZfa8FOVqo6snGOJewAxszKCvZ y3si8UuQusvg3Hm27hW9hdxBsFSw0hyWaoGsBCDZheiMnUO94kBw97/LhMw8PDGWuC03 iNVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691511966; x=1692116766; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zQFUtOqa2Nuhn55ogQXJygZpI6oY6Vmrz17l7AHTGDA=; b=BSeI7/oLSZ4CC+B9CYwJSG8C4IC8ZG3bNkVupi7ARQB9EGdls6e+ooOidNHSlcZ3M/ ikhTnrdjgLwJPPPr8+gwCGfVBdqajywD6WFkv7fH7bKX52Vo4yUTqfA0qvHkDOTFPq+m FXCgzFUe3D8klD/XGDHt7Q5F+4DSnmpDercY5lCTuMXRCLTHqrXjSABtIrjbbBLxtvZW 2gTXJ5bZqbwVE1dDtxaNDM7pjNAlLOL8vVxPw+Enxy0xFi+qYy624cY9XFBs+nUlwjBc M5Wq2lKzslpZaHHc8/IpdDr4azTgeC0541tMMqN4FHLak4xmGS31wzW6wxvhrtU9Tm2K Im4g== X-Gm-Message-State: AOJu0YwV12c6ql/l4MMrGcVs193XrtdurQ7ceUZWcqLZLe1/4Tw7uBHb S6U7iGh1OfMTgvK3Ajq0crAgVtXMDcKBNGnib9Wy4g== X-Received: by 2002:a17:902:c20d:b0:1bb:9bc8:d22d with SMTP id 13-20020a170902c20d00b001bb9bc8d22dmr9696186pll.16.1691479591137; Tue, 08 Aug 2023 00:26:31 -0700 (PDT) Received: from work.. (1-161-169-231.dynamic-ip.hinet.net. [1.161.169.231]) by smtp.gmail.com with ESMTPSA id y23-20020a17090264d700b001bb24cb9a40sm8357436pli.39.2023.08.08.00.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 00:26:30 -0700 (PDT) From: Nick Hu <nick.hu@sifive.com> To: nick.hu@sifive.com, zong.li@sifive.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, palmer@dabbelt.com, paul.walmsley@sifive.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Ben Dooks <ben.dooks@codethink.co.uk> Subject: [PATCH 1/2] serial: sifive: Add suspend and resume operations Date: Tue, 8 Aug 2023 15:26:25 +0800 Message-Id: <20230808072625.2109564-1-nick.hu@sifive.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773680254066851351 X-GMAIL-MSGID: 1773685967776760150 |
Series |
[1/2] serial: sifive: Add suspend and resume operations
|
|
Commit Message
Nick Hu
Aug. 8, 2023, 7:26 a.m. UTC
If the Sifive Uart is not used as the wake up source, suspend the uart before the system enter the suspend state to prevent it woken up by unexpected uart interrupt. Resume the uart once the system woken up. Signed-off-by: Nick Hu <nick.hu@sifive.com> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> --- drivers/tty/serial/sifive.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
Comments
Hi Conor On Tue, Aug 8, 2023 at 4:44 PM Conor Dooley <conor@kernel.org> wrote: > > On Tue, Aug 08, 2023 at 03:26:25PM +0800, Nick Hu wrote: > > If the Sifive Uart is not used as the wake up source, suspend the uart > > before the system enter the suspend state to prevent it woken up by > > unexpected uart interrupt. Resume the uart once the system woken up. > > > > Signed-off-by: Nick Hu <nick.hu@sifive.com> > > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> > > Where is patch 2/2? This was my bad. There is no patch 2/2. I'll correct it in V2. Nick
Hi Ben On Tue, Aug 8, 2023 at 4:47 PM Ben Dooks <ben.dooks@codethink.co.uk> wrote: > > On 08/08/2023 08:26, Nick Hu wrote: > > If the Sifive Uart is not used as the wake up source, suspend the uart > > before the system enter the suspend state to prevent it woken up by > > unexpected uart interrupt. Resume the uart once the system woken up. > > > > Signed-off-by: Nick Hu <nick.hu@sifive.com> > > Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> > > ^ This should be Reviewed-by, as I did review on this earlier. > I'll correct it in V2 > > --- > > drivers/tty/serial/sifive.c | 26 ++++++++++++++++++++++++++ > > 1 file changed, 26 insertions(+) > > > > diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c > > index a19db49327e2..87994cb69007 100644 > > --- a/drivers/tty/serial/sifive.c > > +++ b/drivers/tty/serial/sifive.c > > @@ -1022,6 +1022,31 @@ static int sifive_serial_remove(struct platform_device *dev) > > return 0; > > } > > > > +static int sifive_serial_suspend(struct device *dev) > > +{ > > + int ret = 0; > > + struct sifive_serial_port *ssp = dev_get_drvdata(dev); > > Minor annyonance is ordering of ssp and ret, I think the showrter one > last is the nicest looking. > > > + if (ssp && ssp->port.type != PORT_UNKNOWN) > > + ret = uart_suspend_port(&sifive_serial_uart_driver, &ssp->port); > > Do we really need a test for ssp being valid if the device is bound. > Not sure if the port.type is also useful? > You are right. This might be an unnecessary check. The ssp is bound in the probe function and the PORT_UNKNOWN only be set when we do the sifive_serial_remove(). And for the ordering of ret, We don't need the ret if we move the check. We can just return uart_suspend_port(&sifive_serial_uart_driver, &ssp->port); Will correct it in V2. > > + return ret; > > +} > > + > > +static int sifive_serial_resume(struct device *dev) > > +{ > > + int ret = 0; > > + struct sifive_serial_port *ssp = dev_get_drvdata(dev); > > + > > + if (ssp && ssp->port.type != PORT_UNKNOWN) > > + ret = uart_resume_port(&sifive_serial_uart_driver, &ssp->port); > > + > > + return ret; > > +} > > + > > +DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend, > > + sifive_serial_resume); > > + > > static const struct of_device_id sifive_serial_of_match[] = { > > { .compatible = "sifive,fu540-c000-uart0" }, > > { .compatible = "sifive,uart0" }, > > @@ -1034,6 +1059,7 @@ static struct platform_driver sifive_serial_platform_driver = { > > .remove = sifive_serial_remove, > > .driver = { > > .name = SIFIVE_SERIAL_NAME, > > + .pm = pm_sleep_ptr(&sifive_uart_pm_ops), > > .of_match_table = of_match_ptr(sifive_serial_of_match), > > }, > > }; > > -- > Ben Dooks http://www.codethink.co.uk/ > Senior Engineer Codethink - Providing Genius > > https://www.codethink.co.uk/privacy.html >
diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c index a19db49327e2..87994cb69007 100644 --- a/drivers/tty/serial/sifive.c +++ b/drivers/tty/serial/sifive.c @@ -1022,6 +1022,31 @@ static int sifive_serial_remove(struct platform_device *dev) return 0; } +static int sifive_serial_suspend(struct device *dev) +{ + int ret = 0; + struct sifive_serial_port *ssp = dev_get_drvdata(dev); + + if (ssp && ssp->port.type != PORT_UNKNOWN) + ret = uart_suspend_port(&sifive_serial_uart_driver, &ssp->port); + + return ret; +} + +static int sifive_serial_resume(struct device *dev) +{ + int ret = 0; + struct sifive_serial_port *ssp = dev_get_drvdata(dev); + + if (ssp && ssp->port.type != PORT_UNKNOWN) + ret = uart_resume_port(&sifive_serial_uart_driver, &ssp->port); + + return ret; +} + +DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend, + sifive_serial_resume); + static const struct of_device_id sifive_serial_of_match[] = { { .compatible = "sifive,fu540-c000-uart0" }, { .compatible = "sifive,uart0" }, @@ -1034,6 +1059,7 @@ static struct platform_driver sifive_serial_platform_driver = { .remove = sifive_serial_remove, .driver = { .name = SIFIVE_SERIAL_NAME, + .pm = pm_sleep_ptr(&sifive_uart_pm_ops), .of_match_table = of_match_ptr(sifive_serial_of_match), }, };