From patchwork Thu Apr 27 18:19:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 88363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp464843vqo; Thu, 27 Apr 2023 11:48:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CrQzTEprhyxmp5XClObUCsfp+smYasTCXTVEDPrU8/oXGQOhnIWA7cuLC81sh2J5e7z2C X-Received: by 2002:a17:90a:db56:b0:24b:8b39:cd79 with SMTP id u22-20020a17090adb5600b0024b8b39cd79mr2607128pjx.32.1682621299467; Thu, 27 Apr 2023 11:48:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682621299; cv=none; d=google.com; s=arc-20160816; b=agJR4qYOOJC63bil+k78CHb3RueQzoy5jxelP2vZqIfoOv+978NuG0G1YqJxJmalm0 /Ra8ZlVBQcID07E1BMOAxQL+2ld6+w31M0jpbfcZQRPt16r/g98tSAR2cVaynRTB/tRE Xs9T6CRKh5XfdJEs82rGtU1om17aAFG7nDt92VeIdj2wyQTP60mXXp6D+/ut4cPfsbnW 35zhx595W4NinPEURKXypWm8zo/0lWaShiLTMUIcoh+A82ocmuwMBXMqLrEVEHd+NqsD g/wUCOCbSj0oUk3Lx+25rvwS6+z/MptMsDQu2Jb//bqoxPHTu1SgxSy6+aVF8oPlvcN2 Mr5A== 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 :dkim-signature; bh=AGaeocdiEgYYiyV9F2iOmV2bIeU06kUvSa9gWNEQaAQ=; b=cMymlWgvRXN0jO0LVrk4HGU355xlzsMgd9NBgpV4CdfQjN7JP/TvD7XqSg+QLWk/zy o8OOYmwk0wdfRg9toKW/gLM49/nFSlDfbDx00+CZi0ldvfYuZOPcEv2zOo6nNDqAUV3J 0iLbX8xM5bunG34A8FxKBSB1B4BCd0bHnoxm8MYlAWtYReO9gImQO59I3fF6cuEJqDGl gzaDVSXEV4LMac+qsawZX4RDx0Di/1e4SOz9BL57nrX72zllzyugx3RywlxgIYOFkHD5 vamZzhETJwBawe+MQVShcsxamTQ7VAQuAlSFv0G/8pNLhlzsp6LaeVAlYzkSWCeALvi/ Y0AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CncbTud9; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f22-20020a17090a639600b00247304b4a27si198186pjj.173.2023.04.27.11.48.04; Thu, 27 Apr 2023 11:48:19 -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=@gmail.com header.s=20221208 header.b=CncbTud9; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244517AbjD0SUI (ORCPT + 99 others); Thu, 27 Apr 2023 14:20:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231577AbjD0SUF (ORCPT ); Thu, 27 Apr 2023 14:20:05 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86DC30F6; Thu, 27 Apr 2023 11:20:02 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-5ef55901f49so39152116d6.2; Thu, 27 Apr 2023 11:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682619602; x=1685211602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AGaeocdiEgYYiyV9F2iOmV2bIeU06kUvSa9gWNEQaAQ=; b=CncbTud9qhe+DcKJhNq26tn506iRUu1rMfKkLCE2b8/U1gJkBqgfQ6/Ijmj74d/X4t ubcEUUmkWIPVBs7mBIuasRcDauhw51OQbgAFB9Dot1F/ZEAD8FnUt+F3hmuy5oxHmvTo Gfsu1/aWMx/SpPRClRUGf9iFhJFJyXdYUJhrfgAvQW09kgRo9ZAwHu0+b2naM+UoO2MH h4VqjwYrPZPpE+5OZKh3Sw8wpLJD+6QvdnYOW2CdSRysOvNQUClVEpKEpOHItrG/pH7z n4BH3dXTY/WKVp/MYhvjMHHPElYRx0py3WK1Tpn+6ShvW/97Le6gz+j+fMk/XXhzrJ9a KmJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682619602; x=1685211602; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AGaeocdiEgYYiyV9F2iOmV2bIeU06kUvSa9gWNEQaAQ=; b=UAANzka0m0t8X09pjegn1GERUfh+L/3yV6YYaFWIKI9B/q4gXrJjZGEXJIUvzOPU/p tNXCTnczm/nvos/nxcqSmEaphcCIN4K8UJ9Ytm7Xmdj7BFyksAQvRAlYYbpqR6ubZCQ4 TYOQQZwewBHiQHZGF++nr1yElxaK7nvaVoWc8Fvqv1n1DYpryOUuFGappQqkn6b0QOZ4 lux0AgjCT+bxZy099WMaRMWmts5DokkXSp5QQiA2sJU/xv1gD1sMxZMUW50CZ5Z4UdBM dtey5w7+5y6ujdyREe1eiaPNv8bD6HMSnHGdnoIf3WCw/T3ZVhhQEbjvI/dLSt3hOjHU fFhA== X-Gm-Message-State: AC+VfDzvZ7A3P92u7heaCrPzu6Y9xBucuhbqp43hhOcEGSZj9QQtR+// 9uccogYp39u5f0Y4Jj/rqJ0= X-Received: by 2002:ad4:5e89:0:b0:613:5d6a:94f6 with SMTP id jl9-20020ad45e89000000b006135d6a94f6mr4226699qvb.19.1682619601781; Thu, 27 Apr 2023 11:20:01 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s14-20020a0cdc0e000000b005e5b30eef24sm5788316qvk.56.2023.04.27.11.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 11:20:01 -0700 (PDT) From: Doug Berger To: Greg Kroah-Hartman Cc: Al Cooper , XuDong Liu , Dongliang Mu , Jiri Slaby , Florian Fainelli , Broadcom internal kernel review list , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe JAILLET , Doug Berger Subject: [PATCH 1/2] serial: 8250_bcm7271: balance clk_enable calls Date: Thu, 27 Apr 2023 11:19:15 -0700 Message-Id: <20230427181916.2983697-2-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230427181916.2983697-1-opendmb@gmail.com> References: <20230427181916.2983697-1-opendmb@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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?1764356311638363299?= X-GMAIL-MSGID: =?utf-8?q?1764356311638363299?= The sw_baud clock must be disabled when the device driver is not connected to the device. This now occurs when probe fails and upon remove. Fixes: 41a469482de2 ("serial: 8250: Add new 8250-core based Broadcom STB driver") Reported-by: XuDong Liu Link: https://lore.kernel.org/lkml/20230424125100.4783-1-m202071377@hust.edu.cn/ Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/tty/serial/8250/8250_bcm7271.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c index f801b1f5b46c..90ee7bc12f77 100644 --- a/drivers/tty/serial/8250/8250_bcm7271.c +++ b/drivers/tty/serial/8250/8250_bcm7271.c @@ -1032,7 +1032,7 @@ static int brcmuart_probe(struct platform_device *pdev) if (clk_rate == 0) { dev_err(dev, "clock-frequency or clk not defined\n"); ret = -EINVAL; - goto release_dma; + goto err_clk_disable; } dev_dbg(dev, "DMA is %senabled\n", priv->dma_enabled ? "" : "not "); @@ -1119,6 +1119,8 @@ static int brcmuart_probe(struct platform_device *pdev) serial8250_unregister_port(priv->line); err: brcmuart_free_bufs(dev, priv); +err_clk_disable: + clk_disable_unprepare(baud_mux_clk); release_dma: if (priv->dma_enabled) brcmuart_arbitration(priv, 0); @@ -1133,6 +1135,7 @@ static int brcmuart_remove(struct platform_device *pdev) hrtimer_cancel(&priv->hrt); serial8250_unregister_port(priv->line); brcmuart_free_bufs(&pdev->dev, priv); + clk_disable_unprepare(priv->baud_mux_clk); if (priv->dma_enabled) brcmuart_arbitration(priv, 0); return 0; From patchwork Thu Apr 27 18:19:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 88361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp456196vqo; Thu, 27 Apr 2023 11:29:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6LxhjSDKaOPCy7Hpfd51We+04zFTAiAILcPgawGSX/TogsAjo7P0OwB4l4bU6N74Fzuxgd X-Received: by 2002:a05:6a21:99a5:b0:ee:3824:664f with SMTP id ve37-20020a056a2199a500b000ee3824664fmr3213944pzb.47.1682620184640; Thu, 27 Apr 2023 11:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682620184; cv=none; d=google.com; s=arc-20160816; b=O2kWd3rcis4H/WwKL+ve6XYMA2W9ySkrP/uV/wffmzcuCtcA+H/isEgAkBZ9utDPYr dxLSZY1443nRDi5Bl4MkwFwJUWlW8G7uuYDWX8u0vQAmmvG9PCru4Trd1ZdugeoYOHgz O/ykJhUsb2vZbhT3LfgnZLs/wWMMAOObJTYMD1kyDt4fSymJH62enQE9SuoNFxEFE1Fi xo5uVU6yNPNEY0yTb1D5KGb64gAifVAfyq8sqTvNx0p6Kew6/nLlYCvH24HSDmEHjeUl 6KwFTTVlqWk/AECNLfIKLNQchvx5kggAGwuoBNgS/5R0bdWG72jX+qFMcUpJsoJslBq4 EzYA== 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 :dkim-signature; bh=M3ybj49I0azNPq8mUJZxYJ7OaIdhKs0dZovAgS2rqE8=; b=YWJVeDNhC+mFH0uwLiLqhUQX5NNEt0DWJCUgR6VWPwa+BJlSKnUWXX5vvz42xvhUWm 02tOQVyXWZqtgwBB4oe5uuV3QutYnkBQM4PYqUdJ9pRlulU5rbMLxhhdKeGsoxc1DtZT zPmDeG8p9fKWinAYkjA4x41ArpthGC2KEcfPCB70JVexyzeydKptHLuZ/vXJcjVINPsV C0qAvL/yDOKbslxIUngp0q58C/NpRPdeA6PM/VQX8J+ioX7DtO/NC5wMw750Et+xKAen V8ervZioyhR532+NKAWFvH1OUofcmDBaGsOZQHRJ2Efyy9QbjvnAkQC480TFz3WzIv50 CzoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=U89HRMpm; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l190-20020a6388c7000000b0051446aaeaf1si18929630pgd.637.2023.04.27.11.29.29; Thu, 27 Apr 2023 11:29:44 -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=@gmail.com header.s=20221208 header.b=U89HRMpm; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244525AbjD0SUK (ORCPT + 99 others); Thu, 27 Apr 2023 14:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244429AbjD0SUH (ORCPT ); Thu, 27 Apr 2023 14:20:07 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7C79449A; Thu, 27 Apr 2023 11:20:04 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id 6a1803df08f44-5ef8af5d211so68128706d6.3; Thu, 27 Apr 2023 11:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682619604; x=1685211604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M3ybj49I0azNPq8mUJZxYJ7OaIdhKs0dZovAgS2rqE8=; b=U89HRMpmyZlcTTn96nVf6SFQOC43UMedTYIBj2PDadzSbWoo792cepjuYgCy9eXraJ MQqMMxvgMRxDDehnECB6pWT3pfAJYJqZK0dRfqBl+dw+QQTYS5ESUlhlikynsPChclad +ENs6hONhfCZ/hCQsha4vW28bgnCF9b48fBosFRrqgNZrlxTuzPWOyEjfkerrCHW+XsF t/cEk6NEYeoij5WzgaH+Ym0eaYUVFEIENQLnZ0NtxhZawULOn0rE8Rp/z+mBCwBO127a NU9N21v8CVfN65WuOYWzQlFJ8NFGCQqBQy9IKwLRXg7k/sTEEIN2Ivx1KGD9xL5AFiSB h9qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682619604; x=1685211604; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M3ybj49I0azNPq8mUJZxYJ7OaIdhKs0dZovAgS2rqE8=; b=DFDiaurqMtRY2T0oNlYdr0qRX/zrI3f3GOL3nC0EXwc5WwFTL+J2mrccCExigxQDvN ObiBv1SmK/elOyJZcDPUTxqlq+yeqMdCDuVvi5TeGmHU4cVedMTTR8tRe15873OuUv1T 2dlnarJefeZdLjKvV3ZeIW9oj+rajL+lklmgDOBqe4CBQZUgXzSr8DNQpgVwJFN2R5WV M15jndHfKzb+Ex3UDuFWgv8v37XoV358EsvvablVigMhJrWifqWSA82n3CYx0IPdHRUX ckDHth/KHUtTcm3nQ6AOWslysLzk0AiYnGTcB8Jh9BLenLKVAs9YrwrH75s9s26hlpBT HRTQ== X-Gm-Message-State: AC+VfDwaHqrjclkzVY4Xc4+C0QSRtREByg9V+1nCYlNA/JYEDQ8+oQ0v I7rOgaM8ZJ5GNAaenbUqlXo= X-Received: by 2002:a05:6214:5015:b0:5dd:aee7:dffb with SMTP id jo21-20020a056214501500b005ddaee7dffbmr3785649qvb.22.1682619603698; Thu, 27 Apr 2023 11:20:03 -0700 (PDT) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id s14-20020a0cdc0e000000b005e5b30eef24sm5788316qvk.56.2023.04.27.11.20.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 11:20:03 -0700 (PDT) From: Doug Berger To: Greg Kroah-Hartman Cc: Al Cooper , XuDong Liu , Dongliang Mu , Jiri Slaby , Florian Fainelli , Broadcom internal kernel review list , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Christophe JAILLET , Doug Berger Subject: [PATCH 2/2] serial: 8250_bcm7271: fix leak in `brcmuart_probe` Date: Thu, 27 Apr 2023 11:19:16 -0700 Message-Id: <20230427181916.2983697-3-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230427181916.2983697-1-opendmb@gmail.com> References: <20230427181916.2983697-1-opendmb@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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?1764355142880166524?= X-GMAIL-MSGID: =?utf-8?q?1764355142880166524?= Smatch reports: drivers/tty/serial/8250/8250_bcm7271.c:1120 brcmuart_probe() warn: 'baud_mux_clk' from clk_prepare_enable() not released on lines: 1032. The issue is fixed by using a managed clock. Fixes: 41a469482de2 ("serial: 8250: Add new 8250-core based Broadcom STB driver") Reported-by: XuDong Liu Link: https://lore.kernel.org/lkml/20230424125100.4783-1-m202071377@hust.edu.cn/ Signed-off-by: Doug Berger Acked-by: Florian Fainelli --- drivers/tty/serial/8250/8250_bcm7271.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c index 90ee7bc12f77..af0e1c070187 100644 --- a/drivers/tty/serial/8250/8250_bcm7271.c +++ b/drivers/tty/serial/8250/8250_bcm7271.c @@ -1012,7 +1012,7 @@ static int brcmuart_probe(struct platform_device *pdev) of_property_read_u32(np, "clock-frequency", &clk_rate); /* See if a Baud clock has been specified */ - baud_mux_clk = of_clk_get_by_name(np, "sw_baud"); + baud_mux_clk = devm_clk_get(dev, "sw_baud"); if (IS_ERR(baud_mux_clk)) { if (PTR_ERR(baud_mux_clk) == -EPROBE_DEFER) { ret = -EPROBE_DEFER;