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: 13722653 X-Patchwork-Delegate: kw@linux.com Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B495A187349 for ; Wed, 3 Jul 2024 18:03:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720029806; cv=none; b=IBZaa3FmYXUuWovYyt1UGBk6pVOp4WFuSsQIoYgqwaoyZe1xVsYaZofHGHMF3qdA0vvOz97fuY1f+WDjBZaFO+eqSVzqmGTmQIYy2aOg2ERqIvob8jvce0xSLTv0YwIvcn5yBQlliNy/p+mpIRgT6HFStx4V0HNlgznBAT97/1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720029806; c=relaxed/simple; bh=lpboFPYNGKHDeKT3paxfDikOo+RVK8miIjSXEwG1yCQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type; b=hffSW6F1oYwHa6zKymWtLNEAxPm5srAWXwmbfdmDHZ0WGVcoKuX1B4zhvHyAZQ5HZtCVSK8dPv8w2p1dRSDE+C5778zgewfjFmpOoZ6lAobNxEmVCIn29BdV0i4bfw0Aw5NfE35L6Z6Z1tj3dLf7Jd1QaN+uZkR4WE5GttXoqUM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=DV3sv8j9; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="DV3sv8j9" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6b5e4466931so3782026d6.0 for ; Wed, 03 Jul 2024 11:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720029803; x=1720634603; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=RGurkoWoeECdUD1TfMD8b3mE+TrTCXJB2kN70RXwrl4=; b=DV3sv8j9q3mIbb19U6NoRRYDLS2v+sYSSG5NeHrU0ZpyWjrVFIC1HfQmLYLPDbAnfZ odusIiXOS38xyd3oxaL5RZESOFrphSj2XdFW2rfyZHY8yv0DCXxd7ZGhFmndYTt+24tl sWrXxDjf+MaKTMm1ItTzH+NGXBfmtn0X9HkGg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720029803; x=1720634603; 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=RGurkoWoeECdUD1TfMD8b3mE+TrTCXJB2kN70RXwrl4=; b=okGhuXbmDfZ5HmQXU0CPoWkZubvqI3MQJ0LCbMWXfNbe83ABmMDBXqK7LRWBtK2qSK 7s27tgPJDCUwkOws2fcHB3e9O5jnXb4yTHF2wwzdwBQKkCip4VTdTKHt7nrl1EL3nrlQ 7EUTQMehNjm7eL+SG8fmuA7EDtYudARnZRX+KpbHGZz3hecHeB9WzReSZl9h9rWjblc1 pP9kspM+DOmREZIcMftAvIhCa1YaBdoIZhoz1vZAGoOAgfU5pu4CIYg+NzSKFmnxvMvi dieZG76XbVH7D8Jswh7RV+PacFuyaC6ycEO1YEXdXvf/tcAPT7lHyrAqThuoykgaF2OV YlTA== X-Gm-Message-State: AOJu0YwYYyXLqs+BcsJ7WDtuzIlOvsVI500IV57seT8U0P4OD+gqFxjq ZSXSl0hndVrCbUHGKRGtEeZ+boR9CS1mZO8s3hNKSFNgIOCZiT0dPQl8oFKiiO+A+hRNk0kPAfK G8HRtgiQCFBCLzpHmVjKGKdDxJAIaOX220FevtVhvzr+kylgQIkYTwwageIm/5VEmAo9h9n6ZrO DIVeRRbrSwng9xKkTQmaIewkey6LCZ0xv+GlFWXlcATFz1413e 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> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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;