Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp93785rdh; Wed, 22 Nov 2023 20:05:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmauy0ZSsK2zeyA9yjvxMG+5ula2A/pKh3JYu7E3MH13Sg5cvaE856iBU694W6tNjcYOVs X-Received: by 2002:a17:902:c20d:b0:1cc:337e:bd6d with SMTP id 13-20020a170902c20d00b001cc337ebd6dmr4392647pll.68.1700712312305; Wed, 22 Nov 2023 20:05:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700712312; cv=none; d=google.com; s=arc-20160816; b=hsER5iihqpoe1o86gEb/MYAwrH+MjC873V7DDlqB2Zwex2Ztbcbc4jM71inLcOKFLV 4Dq8r67wY6klAgECbT6tNgq70veo2ur3qF7h7BdTe+YlD9AGxdCMFE3Lz/aeV+EEs4bH KFnLgcARj/LhI7nqbGgVfAGD6qIjAu4BDF0JCsYuskwi11hAAj/qzZEBzyhTJjs6PS+S V7dL2eEvuimSxu51gpXU6dg8HOivO+RwIelR3EeiVDu3bpd/sMVdOUbjSw5XDtmtXaIE xNdAWYb0imp6NR2w2IBbmrBQWyfgazmyQp6p5/3nLajtkh+jvwU2VPxBUuX6kVT8ZMcn I62A== 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:to:from :dkim-signature; bh=l6GmsfJP9+WvSK8sZpXB5LCMAQxYGRJDdCN1L4EaP/M=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=QjcrMbDIgDbxI5lU+3BXqZMNsnu/YWmwOT9bLXveha4Q96N4XZAFeLzMEr3ik6n5Ae MD2uzPTUjZXA6ddOZpbrRSFnlBpAb/H8I11IfzkCMt9qbGIPyzOO+6leXojns1lnXIFe 2wkvsr/u7VRfWBTMsSxkL8nnohbknxjXvp2ePDbdvHKWcq/6uq2rUlw3R/Fw5IykUqTl MiXjnuYLLt8fW94VnTd+pxw3ZRo1ZnFtU88VrCVq4VD8kxJD9IKQPlRo1CDKRZSL9iah QTMRqZWgeZ0kUKvARIpnFbPSowsSTiJMHkNNrz2xB3hgohJTMJgGIMsrfpo5WHCIhK43 +mSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="mU/C5tzE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c21-20020a170902c1d500b001c62b659f98si341561plc.79.2023.11.22.20.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 20:05:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="mU/C5tzE"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 20BFF81EE2FF; Wed, 22 Nov 2023 20:05:05 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344715AbjKWEEf (ORCPT + 99 others); Wed, 22 Nov 2023 23:04:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232989AbjKWEDw (ORCPT ); Wed, 22 Nov 2023 23:03:52 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C61D44; Wed, 22 Nov 2023 20:03:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700712240; x=1732248240; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=2P//zGL+ImtfZApcWnHht/9BnGa2K8YOJPWY83LQtgg=; b=mU/C5tzE5ynOEh0zRunblsoeiUjfuw2N5IIvfHekSFIFyrVuX+utu6w6 3zjfmTwIgljAAzmYCoBpPmf4zqmEi921PM0Ah0AEUmts3SlDDwFktXdwb moiYVGuAajd1UrmDiApT/JmJaQOF/TDYzbEtez0H7+9sBePokVGaE6D1Q 5mNF9MAtp7CgT59Ou83WwOOUDvFNUkv2lfwewR985yf7yqiZ2m32O+EQO inKSwDINfWOFKwF/Q5eXByWzPv8A/gVBQBnIJnzEOAHSchf2z4b0869Rf B0xXAAQnflGMfZN+NcJQxMKwLRc0yQE/6jMC+n/eUqQ6bO1E8a+E+YCZP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="5334662" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="5334662" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="837671152" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="837671152" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:57 -0800 Received: from debox1-desk4.lan (snpatel1-mobl.amr.corp.intel.com [10.209.89.91]) by linux.intel.com (Postfix) with ESMTP id A8F20580D94; Wed, 22 Nov 2023 20:03:56 -0800 (PST) From: "David E. Box" To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, ilpo.jarvinen@linux.intel.com, rajvi.jingar@linux.intel.com Subject: [PATCH V5 11/20] platform/x86/intel/pmc: Allow pmc_core_ssram_init to fail Date: Wed, 22 Nov 2023 20:03:46 -0800 Message-Id: <20231123040355.82139-12-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231123040355.82139-1-david.e.box@linux.intel.com> References: <20231123040355.82139-1-david.e.box@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 22 Nov 2023 20:05:05 -0800 (PST) Currently, if the PMC SSRAM initialization fails, no error is returned and the only indication is that a PMC device has not been created. Instead, allow an error to be returned and handled directly by the caller. Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- V5 - No change V4 - Remove return value check in mtl.c. Proper use of the value would require returning an error status from pmc_core_add_pmc(). But the function that calls it will be removed in the next patch so wait to use it then. V3 - New patch split from V2 PATCH 9 - Add dev_warn on pmc_core_ssram_init fail drivers/platform/x86/intel/pmc/core.h | 2 +- drivers/platform/x86/intel/pmc/core_ssram.c | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/intel/pmc/core.h b/drivers/platform/x86/intel/pmc/core.h index ccf24e0f5e50..edaa70067e41 100644 --- a/drivers/platform/x86/intel/pmc/core.h +++ b/drivers/platform/x86/intel/pmc/core.h @@ -492,7 +492,7 @@ int pmc_core_resume_common(struct pmc_dev *pmcdev); int get_primary_reg_base(struct pmc *pmc); extern void pmc_core_get_low_power_modes(struct pmc_dev *pmcdev); -extern void pmc_core_ssram_init(struct pmc_dev *pmcdev); +extern int pmc_core_ssram_init(struct pmc_dev *pmcdev); int spt_core_init(struct pmc_dev *pmcdev); int cnp_core_init(struct pmc_dev *pmcdev); diff --git a/drivers/platform/x86/intel/pmc/core_ssram.c b/drivers/platform/x86/intel/pmc/core_ssram.c index 13fa16f0d52e..815950713e25 100644 --- a/drivers/platform/x86/intel/pmc/core_ssram.c +++ b/drivers/platform/x86/intel/pmc/core_ssram.c @@ -35,20 +35,20 @@ static inline u64 get_base(void __iomem *addr, u32 offset) return lo_hi_readq(addr + offset) & GENMASK_ULL(63, 3); } -static void +static int pmc_core_pmc_add(struct pmc_dev *pmcdev, u64 pwrm_base, const struct pmc_reg_map *reg_map, int pmc_index) { struct pmc *pmc = pmcdev->pmcs[pmc_index]; if (!pwrm_base) - return; + return -ENODEV; /* Memory for primary PMC has been allocated in core.c */ if (!pmc) { pmc = devm_kzalloc(&pmcdev->pdev->dev, sizeof(*pmc), GFP_KERNEL); if (!pmc) - return; + return -ENOMEM; } pmc->map = reg_map; @@ -57,10 +57,12 @@ pmc_core_pmc_add(struct pmc_dev *pmcdev, u64 pwrm_base, if (!pmc->regbase) { devm_kfree(&pmcdev->pdev->dev, pmc); - return; + return -ENOMEM; } pmcdev->pmcs[pmc_index] = pmc; + + return 0; } static void @@ -96,7 +98,7 @@ pmc_core_ssram_get_pmc(struct pmc_dev *pmcdev, void __iomem *ssram, u32 offset, iounmap(ssram); } -void pmc_core_ssram_init(struct pmc_dev *pmcdev) +int pmc_core_ssram_init(struct pmc_dev *pmcdev) { void __iomem *ssram; struct pci_dev *pcidev; @@ -105,7 +107,7 @@ void pmc_core_ssram_init(struct pmc_dev *pmcdev) pcidev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(20, 2)); if (!pcidev) - goto out; + return -ENODEV; ret = pcim_enable_device(pcidev); if (ret) @@ -123,11 +125,14 @@ void pmc_core_ssram_init(struct pmc_dev *pmcdev) pmc_core_ssram_get_pmc(pmcdev, ssram, SSRAM_PCH_OFFSET, PMC_IDX_PCH); iounmap(ssram); -out: - return; + + return 0; disable_dev: + pmcdev->ssram_pcidev = NULL; pci_disable_device(pcidev); release_dev: pci_dev_put(pcidev); + + return ret; } -- 2.34.1