Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4024526rwr; Mon, 8 May 2023 01:27:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74uE0WUn9sOz3bnAjcG3pS2ZF2aPLQ/s3li9Jz3wimteyr5B9WMZ8waKbGHbZbB/9JQ6lJ X-Received: by 2002:a17:902:6b03:b0:1a6:a1ec:53a3 with SMTP id o3-20020a1709026b0300b001a6a1ec53a3mr9860254plk.3.1683534476898; Mon, 08 May 2023 01:27:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683534476; cv=none; d=google.com; s=arc-20160816; b=cHFPOnG2OmAlWJ1xipzrU2oLJgQ/363/Itb5xSNw6bF+KjScycuFeiWtDT63KVPqET cXi9KzajGYchzNDG3PENA7hWGp+MzGnT+MwEdjMZ5NhjKMtU/eC63Gsuw2l2XIdeJFzy 4grYNb6o3P2EXb8qN4NPKrlOCT2bWbQAMksAU/ksy4R9kp2C4PzWoJB6AcWF71jRbzjL FF9lJMi779fFtldi/nC9NsR3OA1+9jb+BuoGgdgKrmqzrJhFWVQ1BLsUL/ofb94kC3bw xRhwCs7CR1dgzlXF1fIEr2jUQS3chieBooQ89IXr8ush/I1NK20EwvxVbKm+goy+AXdY CgrQ== 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 Return-Path: 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.27.44; Mon, 08 May 2023 01:27:56 -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 S232974AbjEHIVI (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=20J=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 Content-Transfer-Encoding: 8bit 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 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); -- 2.40.1