From patchwork Mon May 8 08:20:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 91023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1995371vqo; Mon, 8 May 2023 01:29:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4swQXtoi3jxmyujWUa0MUwVdrWKpUVMw4mMy2TW8DYFB4G9GPux05GPiyxCuj0tS87P6DE X-Received: by 2002:a17:902:ce81:b0:1a6:e564:6046 with SMTP id f1-20020a170902ce8100b001a6e5646046mr13029662plg.46.1683534542756; Mon, 08 May 2023 01:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683534542; cv=none; d=google.com; s=arc-20160816; b=n0RTxqZL2aQfWr08vgzNARXiLNKoKTIu8SC812EMvw0wBSyEqUciaKg8ziFshzEIST XW0KC5raUoOKLIOzTmx9L0GBuJRAEheQN3fCvRZFFF03W0MQdZz9bR1cJO4XjybcHpUl gyI2yY/2YWTl+90KD6VAz+gfrP6uibnPLYIfumgjiLs3RBGuEJPbXGA34PkyPj0tDTfn jEWcZ+Eb5AQCzSyYVWGCjO1J1e0xL0Nf4t4qSUmpqfFbecuY8KnmN8yz8XDklMfvY0nw BIU7dmK4omkjxELWHvHg/Y0WgcMSYPgWar0f0lTrxVGSgWBgF+DjiHyrkcylk4QGTL5y +l9Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=bWZQWJVzcDspdMLGZvVDG7s32MtAO4hCII5PjBmOu8o=; b=RPvodbz/4w62EvASgNoj2aFzkJVH6hJVGu8DW9eEngsQseAggeh4fK3oNLZyMb9whm DSJ1Mc8aY0vdgd9Zt2wVyB/eX0ryCRcGcqd3hgDAnPoeyisiOH0/g9jGKtff8eReEh38 4fAxYKxos38PVjE9BnPPkMdlKVcP5/UFa9sAVDmfRcNaKx707LYYj82XAWnKt9FA9Gpw Hd89+DXnZzHlq6BY1ePw6jSOKRvGJtenqAIrwyZ8AtSeQ+siGF76Dt+in+rr77rYyGUf vNMix6nrL1/CVvpzKSpj/t8q5CRX3kTCcz6RU8DXIdKmigsEcJAffB6v59LxG3y9n+pO LDVA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l9-20020a170903244900b001aafda896b3si8170181pls.626.2023.05.08.01.28.49; Mon, 08 May 2023 01:29:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233487AbjEHIVI (ORCPT + 99 others); Mon, 8 May 2023 04:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233655AbjEHIUz (ORCPT ); Mon, 8 May 2023 04:20:55 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB4401F4BF; Mon, 8 May 2023 01:20:46 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 675FD8111; Mon, 8 May 2023 08:20:44 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby Cc: Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-omap@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] serial: 8250: omap: Shut down on remove for console uart Date: Mon, 8 May 2023 11:20:14 +0300 Message-Id: <20230508082014.23083-5-tony@atomide.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230508082014.23083-1-tony@atomide.com> References: <20230508082014.23083-1-tony@atomide.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765313916592590346?= X-GMAIL-MSGID: =?utf-8?q?1765313916592590346?= When unbinding the console uart, we want to power down the uart hardware on remove. For the console uart, the normal shutdown path will never get called as the cons_filp stays open. Let's rearrange the dma related functions a bit so we can call driver shutdown also on console uart rebind. Currently we set up->dma on probe, but that causes issues calling omap_8250_shutdown() on remove. The dma startup will not get called on the next rebind as we still have up->dma set from probe. Note that serial8250_release_dma() already checks for dma so we can remove the check for it in 8205_omap driver. With these changes we also avoid hogging dma virtual channels for the unused uarts that may be limited on some devices. Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 36 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -679,6 +679,7 @@ static int omap_8250_startup(struct uart_port *port) { struct uart_8250_port *up = up_to_u8250p(port); struct omap8250_priv *priv = port->private_data; + struct uart_8250_dma *dma = &priv->omap8250_dma; int ret; if (priv->wakeirq) { @@ -697,16 +698,16 @@ static int omap_8250_startup(struct uart_port *port) up->msr_saved_flags = 0; /* Disable DMA for console UART */ - if (uart_console(port)) - up->dma = NULL; - - if (up->dma) { + if (dma->fn && !uart_console(port)) { + up->dma = &priv->omap8250_dma; ret = serial8250_request_dma(up); if (ret) { dev_warn_ratelimited(port->dev, "failed to request DMA\n"); up->dma = NULL; } + } else { + up->dma = NULL; } up->ier = UART_IER_RLSI | UART_IER_RDI; @@ -752,8 +753,8 @@ static void omap_8250_shutdown(struct uart_port *port) disable_irq_nosync(up->port.irq); dev_pm_clear_wake_irq(port->dev); - if (up->dma) - serial8250_release_dma(up); + serial8250_release_dma(up); + up->dma = NULL; /* * Disable break condition and FIFOs @@ -1499,24 +1500,24 @@ static int omap8250_probe(struct platform_device *pdev) ret = of_property_count_strings(np, "dma-names"); if (ret == 2) { struct omap8250_dma_params *dma_params = NULL; + struct uart_8250_dma *dma = &priv->omap8250_dma; - up.dma = &priv->omap8250_dma; - up.dma->fn = the_no_dma_filter_fn; - up.dma->tx_dma = omap_8250_tx_dma; - up.dma->rx_dma = omap_8250_rx_dma; + dma->fn = the_no_dma_filter_fn; + dma->tx_dma = omap_8250_tx_dma; + dma->rx_dma = omap_8250_rx_dma; if (pdata) dma_params = pdata->dma_params; if (dma_params) { - up.dma->rx_size = dma_params->rx_size; - up.dma->rxconf.src_maxburst = dma_params->rx_trigger; - up.dma->txconf.dst_maxburst = dma_params->tx_trigger; + dma->rx_size = dma_params->rx_size; + dma->rxconf.src_maxburst = dma_params->rx_trigger; + dma->txconf.dst_maxburst = dma_params->tx_trigger; priv->rx_trigger = dma_params->rx_trigger; priv->tx_trigger = dma_params->tx_trigger; } else { - up.dma->rx_size = RX_TRIGGER; - up.dma->rxconf.src_maxburst = RX_TRIGGER; - up.dma->txconf.dst_maxburst = TX_TRIGGER; + dma->rx_size = RX_TRIGGER; + dma->rxconf.src_maxburst = RX_TRIGGER; + dma->txconf.dst_maxburst = TX_TRIGGER; } } #endif @@ -1550,12 +1551,15 @@ static int omap8250_probe(struct platform_device *pdev) static int omap8250_remove(struct platform_device *pdev) { struct omap8250_priv *priv = platform_get_drvdata(pdev); + struct uart_8250_port *up; int err; err = pm_runtime_resume_and_get(&pdev->dev); if (err) return err; + up = serial8250_get_port(priv->line); + omap_8250_shutdown(&up->port); serial8250_unregister_port(priv->line); priv->line = -ENODEV; pm_runtime_dont_use_autosuspend(&pdev->dev);