Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3209403imu; Sat, 24 Nov 2018 00:09:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/VW0cjTdeIkeKhuSipVM3QwL+olEAi+RrFmhRO7VArqAlRBUKfin1oVrHvlBrArTim1MK36 X-Received: by 2002:a63:fb10:: with SMTP id o16mr14537756pgh.211.1543046949837; Sat, 24 Nov 2018 00:09:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543046949; cv=none; d=google.com; s=arc-20160816; b=inoUAX1SQ4+D5ByHb0o/G96V1GcEXF1X3igRHahF54Iv6gBIusi9pKlPIFG1nYW4su mnbo801z7sASSnoFkOfkf2IzTfZzNf+xIEMuWLts5j4S6ZFus6U87IyPCM0z75nqzSVa Tt+wUfCwEgP11lSWw5LEa6PVlmXpSPWOQFWC25drFcboZr7UszzTh03fEyjfgydvuQR8 ViNmn6wDeJDyXrwRiyquQkNLthH/Mn0/DKQKuDbMR9fN2eTU8LFaX7ZCbT/xq5ePjRDb d9IkgZnMgXqmVeL7ys+nZ7UwPWDCAyF5TfJGp+UwH0dhkpcWyojWsRoCJn07r2FpAh3M hvSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=B9wxqTBxJ4083uvXUnOn+6XFTnc7w8oYu003Wa8vY4E=; b=VB2bBke6sU7pSwd3WsNXBaMqbs0K2bf26HVVGnfHup0JATsQrmPnf1KeSLFa4rT4ij tImluwj/uICrqk8Bp9AHzjBtmC+xV5DJJ4Rhva/uivloNzmcdhYRGiQ05gBzGl3nsB8R ZaxPE0XPySdPbEzgR4bD6y7LJgF/5sJjSMDtSJ/ojewm79qhjKV/YuLTerL7vEif6HsP 1HypDxPAIZuUv1FAekbCA9ogPtGUMPSgxxnZVuXwA5NniMmlghneIKq/D2bqn4bPkLUA NdtaSnVQGnuCz6f05i/RAxY/xpSsU7s6vj/8u9jmsjHDKSMzB8E0XPPsfMvDZ+XdOGf2 cEWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si10291409pfg.135.2018.11.24.00.08.54; Sat, 24 Nov 2018 00:09:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393531AbeKWSvY (ORCPT + 99 others); Fri, 23 Nov 2018 13:51:24 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:48985 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732073AbeKWSvY (ORCPT ); Fri, 23 Nov 2018 13:51:24 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gQ6VY-0005N0-4s; Fri, 23 Nov 2018 09:08:12 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1gQ6VX-0008WU-BX; Fri, 23 Nov 2018 09:08:11 +0100 Date: Fri, 23 Nov 2018 09:08:11 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Stefan Agner Cc: gregkh@linuxfoundation.org, jslaby@suse.com, fabio.estevam@nxp.com, s.hauer@pengutronix.de, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] serial: imx: unprepare console clocks on remove Message-ID: <20181123080811.nezdtq47fqd265kx@pengutronix.de> References: <20181114174940.7865-1-stefan@agner.ch> <20181114174940.7865-2-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20181114174940.7865-2-stefan@agner.ch> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 14, 2018 at 06:49:39PM +0100, Stefan Agner wrote: > Currently imx_uart_console_setup() prepares clocks which do not > get unprepared anywhere. Check whether the console has been used > by testing if index is set and unprepare clocks in this case. > > This makes sure that clocks are properly unprepared after the > console device has been unbound. > > Signed-off-by: Stefan Agner > --- > drivers/tty/serial/imx.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > index 313c3b1900a8..757c91e5105a 100644 > --- a/drivers/tty/serial/imx.c > +++ b/drivers/tty/serial/imx.c > @@ -2085,7 +2085,7 @@ static struct console imx_uart_console = { > .data = &imx_uart_uart_driver, > }; > > -#define IMX_CONSOLE &imx_uart_console > +#define IMX_CONSOLE (&imx_uart_console) > > #ifdef CONFIG_OF > static void imx_uart_console_early_putchar(struct uart_port *port, int ch) > @@ -2378,8 +2378,17 @@ static int imx_uart_probe(struct platform_device *pdev) > static int imx_uart_remove(struct platform_device *pdev) > { > struct imx_port *sport = platform_get_drvdata(pdev); > + int ret; > + > + ret = uart_remove_one_port(&imx_uart_uart_driver, &sport->port); > + > + if (IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE) && IMX_CONSOLE->index >= 0) { > + clk_unprepare(sport->clk_ipg); > + clk_unprepare(sport->clk_per); > + IMX_CONSOLE->index = -1; > + } > > - return uart_remove_one_port(&imx_uart_uart_driver, &sport->port); > + return ret; I doubt this is right. imx_uart_console_setup is called once, and if the console is on (say) ttymxc0 you don't want to unprepare the clocks if ttymxc3 gets unbound. So I think this cleanup must go into imx_uart_exit(). Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |