From patchwork Sun Aug 18 17:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 13767583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2645BC52D7C for ; Sun, 18 Aug 2024 17:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=DiA/aFsI+FjQmh1iA//vKZvUfmad+7NHlR0IbRzXHPk=; b=O220v8MK9teW97FlxY3wUU/Wrj daU0aMEp9M7Lm6o4rwYp03/LRKO+qYwX81032jRxqFjqmXfJu0XAIldeNuS2yNOLd2HPraL+uSnIe Kuu+x1KK0pqMpTiguExYmS4OjxfuEXmPd8mllxaqx06tICPB5nupbErfNjlWLvKSqovBhkjsz98rk TBaoJnPMxNqonjsdWfna6LcrSFaeSQ9D6+RWT+8U3CngBh42DBAUdez2zheNooWQtmYb4kWM9ggb6 /evjzGU+0TS/YUF34CXZrwxLXhunIUbgvR1i0aWs7/peYecD7X9l8J6VUFSyzGTYppnvtSvqtjXmU ghr2FJnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfk30-0000000GwBO-3r7M; Sun, 18 Aug 2024 17:50:35 +0000 Received: from mout.gmx.net ([212.227.15.15]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfk2L-0000000GwAG-187v for linux-arm-kernel@lists.infradead.org; Sun, 18 Aug 2024 17:49:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1724003385; x=1724608185; i=wahrenst@gmx.net; bh=DiA/aFsI+FjQmh1iA//vKZvUfmad+7NHlR0IbRzXHPk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id: MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=knbh2wsy4Io4LCm7M+Q/Ig02ViptwVDXHYMdI6BXfRrDXW3hjNQifyHvdsITackJ hERvNy1sf0hbFuiNaIVhKCRVtNiS2w+EzUCvQdXQ9cKuCveLwlllD8htWxazjloEF paWEr5K41ES9Pkj+7B6HkuGRpF5g49xEFSuQIhtfxsYmD14odV5eGVkcA4O0LM7vu 1an7VRxQGlS1fds3CO7M2e25HTMqbkBHXNSzJ17IaJ/zlFOqf5h+8m2IoNGCY/r4w UwpsmvglW6moE0eocTBFUvNRL56Qn0yG8pRxdm/OlLr+C8dy6FRH7j5xuGP5NNweT k9W1o4eWAUT1jtOrnA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from stefanw-SCHENKER ([37.4.248.43]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbzuH-1s9iKs1Ynn-00fciO; Sun, 18 Aug 2024 19:49:45 +0200 From: Stefan Wahren To: Greg Kroah-Hartman , Florian Fainelli , Ray Jui , Scott Branden , Ulf Hansson , Jiri Slaby Cc: Peter Robinson , bcm-kernel-feedback-list@broadcom.com, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel-list@raspberrypi.com, Stefan Wahren Subject: [PATCH] serial: 8250_bcm2835aux: Fix clock imbalance in PM resume Date: Sun, 18 Aug 2024 19:49:36 +0200 Message-Id: <20240818174936.88372-1-wahrenst@gmx.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:r9hNUuSdz7hN68T+5KzHyprrl4GZvilH7Zejm0cvXgVtQdCiMR3 r3bNsjJYZ9SXLTOdcgueSjRzBuFRpfk70PDDuA1kseQw4PL/35tz4QPiFw2JnGpznUEtLru mtr63iGmXySQUGS88yNHH3sTPErZxge1cfQKffkMx8FO35MpITyP35RQRRU9QKHpY0pS1BC fuJ69aIjTPB8nBo1hKaFg== UI-OutboundReport: notjunk:1;M01:P0:VaVAzzAIn7s=;1747lE/usUknmlBEGe6vElMyhvf 0f8lgPqUPMuuaY8TLgfm4goiIDGrdx+Q+9QCn/SqopJFtyXT65cBtASof5a6B0BZRZV4jEtme tKOZYU2gz111aJyFAzW7bOral9zB+uVNzuFNajsKpq0XOiJT2mn7m1t0E8a3o7qbT759/cUDf UiK0v7V+8vrgTpbI+54JznCo3I+XFCYXoQlLim0tGlsNNHt2HDFukYDfiHfCztt07sQuKTb+s xwDWkTP29pUKVpVkTH5VUAofbNly6QOBwEdjDEcwjrU7k4erUTLCx5hD2Xf1Kj7BSK99xvfw/ xYrQWMfPkuq3OW3X6E0SHz6YVWK5TSYye2rjwteqaQjh6srMrr5VltPDQdioy2QwissbFOVKw eVJk03uJodGy5Oh9K1lUqcpg2aVsdYFpAN+5R5r+X42P3aHwc1v0+q9s+ts19j/CAb3gA+8NV Q/+W0g0p7f6f3zCtLsk6orD+jwWGhVROUTmeu+YAnc7sTDxF1+h0UD3RFdqkwFNL+dQ6ACaGW NI0KwN0+K3bb086WmUxIvLMdb0wYcTUJvqttwVYMp8LWQ6ym1315Oxco2Be3vPwawxFsNdhp5 pASegorSE23flpn/gJRhdkFGFWHVBkKHwJYWzJG90ICQMqpKrRsOzmQRxyYgI1q8Gb4YbAZT+ RCdfNwptKmbkYP4ZPQ1CgAL5OPQWdGiYlIFxKhLHDnRty4hzAm00JEg/X+y3dSlnzl5iRQ7Zc 6sq65Y7tKsy7GK+yf7bko5AtvMPyM8a8W06mxNpX9cXpGwcX/SP9sFPlSjhN/5ReZ3Qwn7S8K XiPkYypPzTXzukpkCgs/775A== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240818_104953_698353_DE443279 X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org During review Ulf Hansson discovered a clock imbalance in the recently introduced PM resume code. The driver should enable the clock only in case it has been disabled in suspend before. In order to make the conditions easier to read, refactor this into a separate function. Reported-by: Ulf Hansson Closes: https://lore.kernel.org/linux-arm-kernel/CAPDyKFoJh3j8xSeXZ9o031YZLTCDYVA+dgvURuwozjDpU_aauA@mail.gmail.com/ Fixes: 0e1d8780526f ("serial: 8250_bcm2835aux: add PM suspend/resume support") Signed-off-by: Stefan Wahren --- drivers/tty/serial/8250/8250_bcm2835aux.c | 26 +++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) -- 2.34.1 diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c index 36e2bb34d82b..e6b42ca6151e 100644 --- a/drivers/tty/serial/8250/8250_bcm2835aux.c +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c @@ -214,17 +214,27 @@ static const struct acpi_device_id bcm2835aux_serial_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, bcm2835aux_serial_acpi_match); -static int bcm2835aux_suspend(struct device *dev) +static bool bcm2835aux_can_disable_clock(struct device *dev) { struct bcm2835aux_data *data = dev_get_drvdata(dev); struct uart_8250_port *up = serial8250_get_port(data->line); - serial8250_suspend_port(data->line); - if (device_may_wakeup(dev)) - return 0; + return false; if (uart_console(&up->port) && !console_suspend_enabled) + return false; + + return true; +} + +static int bcm2835aux_suspend(struct device *dev) +{ + struct bcm2835aux_data *data = dev_get_drvdata(dev); + + serial8250_suspend_port(data->line); + + if (!bcm2835aux_can_disable_clock(dev)) return 0; clk_disable_unprepare(data->clk); @@ -236,9 +246,11 @@ static int bcm2835aux_resume(struct device *dev) struct bcm2835aux_data *data = dev_get_drvdata(dev); int ret; - ret = clk_prepare_enable(data->clk); - if (ret) - return ret; + if (bcm2835aux_can_disable_clock(dev)) { + ret = clk_prepare_enable(data->clk); + if (ret) + return ret; + } serial8250_resume_port(data->line);