From patchwork Wed Jul 3 18:02:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 13722667 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 E2CE7C30653 for ; Wed, 3 Jul 2024 18:05:56 +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-Type:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Reply-To:MIME-Version: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VoCFrvsL/ZMMc2mlbXqqlmOXmNWUWh6pr9wpC3BNDRo=; b=aTL+Va5q1uFO/sXzFn6zntXVSC McxbyaxfRNucg8VE9c9HTKeV8KMCeEXrB5TmY4DLMH1ezG6p3X7ZeeZoyYmPsJpUrk6HSAGqwPtxm 8Khq1Udq5yHuBoWnQC4emmtUcVOSQG7PrhOxpWc7fobaOUXXnT/ocu0AYJl+RLzc+zMe0//+B7Axh FKyoxbq3x5zDoc4EEtYxckl4Uxa4rZ74PyGQx0td9rAbZac0piLyoBEvKrNDQrC7p7n6e8R49vBdw NW7u5Y/EAdyhL6VdGrDDPm0L5f5qUtHzGqCwkjxPYZFEmKrR/4vbWOyuFan1LItHvJUEuOHP2eSW4 k4R6FCfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sP4MM-0000000B6HM-0KOJ; Wed, 03 Jul 2024 18:05:38 +0000 Received: from mail-qv1-xf35.google.com ([2607:f8b0:4864:20::f35]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sP4KB-0000000B57y-1vC3 for linux-arm-kernel@lists.infradead.org; Wed, 03 Jul 2024 18:03:25 +0000 Received: by mail-qv1-xf35.google.com with SMTP id 6a1803df08f44-6b5e4466931so3781856d6.0 for ; Wed, 03 Jul 2024 11:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720029802; x=1720634602; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=VoCFrvsL/ZMMc2mlbXqqlmOXmNWUWh6pr9wpC3BNDRo=; b=RcvXTmiFISani9/0fmHwEDkGSxUe5RLEuw36XxeOlFM1TMJAHbgw0OI2lEg99Gs7px cbdnZI3Uxq99gt7EK2Wue9a+iFH+ZED/G2FQqEKzf+seVbnUhpVktlL+YSWpecPZqO+3 ng6TJJrKhywBQZdIVoBHtDe/jd2kB3CwbDz0c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720029802; x=1720634602; h=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=VoCFrvsL/ZMMc2mlbXqqlmOXmNWUWh6pr9wpC3BNDRo=; b=bhTVuZa877Ip3loW5J8ByjgXkSgMAXWAuFzu6EdNGQVByv0jQGuQsSjXo+mIAOBqF1 X8Ug/h8HWgEsiIfr7/TzKNVth8x3Wj2+/31qY2Gi8b4bRmZHSg3rr/8ly4zxDPGWRHWy zTfT7LXJoKPesFWco1RDdvb2FXxgHWii8ufdbjO2628VSiuicR/Y6pfn5tq+ljU0VZGT W745RfT0Zsl1U4F71g6hmCscEz2bAtkg8bqN1G7NWTzTJJZFxHgP48AlzDMTHA6ViR6M Rro4IPfupqoLitefKkZY5eihEC1lE8bgSOTtuG+IVZZNWBjaMBP/EFwFpN7zpCjGpw/L jNiw== X-Forwarded-Encrypted: i=1; AJvYcCXls1ov+cOoWDo7NNMIAD6xvSCQQACpZik14v7DE/JA5qJdGxzGaOfJ5V4Zc4TwjKbKGxESLE6HqqU93PhTP9GjzanFQ2pB3KVLA9MEJ8fp30kzLko= X-Gm-Message-State: AOJu0YxbZQRhgTM8ik+sT2c72pN6ru1Bb01KcyAEB2nmMK2rbPYV6UlR iFYMuOoHV9bQ/qMp8n6rni1EuUmdhEVk75SInfynmuKGTQz18fZjsNiGm4iDfA== X-Google-Smtp-Source: AGHT+IGbJe5pkc2j7LdAc3NBpb3Lu+goP25Rbr3UThoc2CRUdNdd0GaOxU/sxrlkRDfdbHcsPnDlTw== X-Received: by 2002:a05:6214:4601:b0:6b5:9a89:35d9 with SMTP id 6a1803df08f44-6b5b71f4d19mr160016156d6.64.1720029801406; Wed, 03 Jul 2024 11:03:21 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b59e5f1a6dsm55589626d6.83.2024.07.03.11.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 11:03:20 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , Stanimir Varbanov , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Rob Herring , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 10/12] PCI: brcmstb: Check return value of all reset_control_xxx calls Date: Wed, 3 Jul 2024 14:02:54 -0400 Message-Id: <20240703180300.42959-11-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240703180300.42959-1-james.quinlan@broadcom.com> References: <20240703180300.42959-1-james.quinlan@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240703_110323_574788_0FE4AB0C X-CRM114-Status: GOOD ( 13.94 ) 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 In some cases the result of a reset_control_xxx() call have been ignored. Now we check all return values of such functions and at the least issue a dev_err(...) message if the return value is not zero. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 33 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 5f632fdc0052..1c3ce0c182d1 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -743,11 +743,16 @@ static void __iomem *brcm7425_pcie_map_bus(struct pci_bus *bus, static void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) { + int ret; + if (pcie->bridge) { if (val) - reset_control_assert(pcie->bridge); + ret = reset_control_assert(pcie->bridge); else - reset_control_deassert(pcie->bridge); + ret = reset_control_deassert(pcie->bridge); + if (ret) + dev_err(pcie->dev, "failed to %s 'bridge' reset, err=%d\n", + val ? "assert" : "deassert", ret); } else { u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK; u32 shift = RGR1_SW_INIT_1_INIT_GENERIC_SHIFT; @@ -770,13 +775,20 @@ static void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val) static void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val) { + int ret; + if (WARN_ONCE(!pcie->perst_reset, "missing PERST# reset controller\n")) return; if (val) - reset_control_assert(pcie->perst_reset); + ret = reset_control_assert(pcie->perst_reset); else - reset_control_deassert(pcie->perst_reset); + ret = reset_control_deassert(pcie->perst_reset); + + if (ret) + dev_err(pcie->dev, "failed to %s 'perst' reset, err=%d\n", + val ? "assert" : "deassert", ret); + } static void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val) @@ -1460,7 +1472,7 @@ static int brcm_pcie_suspend_noirq(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); - int ret; + int ret, rret; brcm_pcie_turn_off(pcie); /* @@ -1491,7 +1503,10 @@ static int brcm_pcie_suspend_noirq(struct device *dev) pcie->sr->supplies); if (ret) { dev_err(dev, "Could not turn off regulators\n"); - reset_control_reset(pcie->rescal); + rret = reset_control_reset(pcie->rescal); + if (rret) + dev_err(dev, "failed to reset 'rascal' controller ret=%d\n", + rret); return ret; } } @@ -1506,7 +1521,7 @@ static int brcm_pcie_resume_noirq(struct device *dev) struct brcm_pcie *pcie = dev_get_drvdata(dev); void __iomem *base; u32 tmp; - int ret; + int ret, rret; base = pcie->base; ret = clk_prepare_enable(pcie->clk); @@ -1568,7 +1583,9 @@ static int brcm_pcie_resume_noirq(struct device *dev) if (pcie->sr) regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); err_reset: - reset_control_rearm(pcie->rescal); + rret = reset_control_rearm(pcie->rescal); + if (rret) + dev_err(pcie->dev, "failed to rearm 'rescal' reset, err=%d\n", rret); err_disable_clk: clk_disable_unprepare(pcie->clk); return ret;