From patchwork Wed Oct 18 23:16:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 155211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp51874vqb; Wed, 18 Oct 2023 16:17:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFNHkZmEvMeor4xik/0xoG52TkIisSrYM2bwMNeVxMa9UKi2It0bx6b+Ex0WFSstbLlhIu X-Received: by 2002:a17:90b:3007:b0:27d:1571:f683 with SMTP id hg7-20020a17090b300700b0027d1571f683mr575596pjb.44.1697671050640; Wed, 18 Oct 2023 16:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697671050; cv=none; d=google.com; s=arc-20160816; b=AbAK9fTBNEZGwsdYNrm32+zQzjQM2KVFJb8pRfm9cm+CYN1pc5Q1DMhJgOktSm15+A SDmWmKRFEMMtrJk9wkavsacIJcgDvaMH4jKEpQFZu8sBBz7ZEmoNTQ0hLclxwW8X0re6 x37k/RA+fvGWuXnqVk2NM0om8ccvZ2dBBDtqR3nZZaQOf+aG044vZ7PorfCunlYT+WNQ DxXlW1YpxgdiDsAydGKnWUwoEVDxGM8RJLOH0lOcNf7ajyAo4IByzHQruLcoBQ7L2DjE SRAe13BWPwb5SuMb9Jg3JW0rzjZuteRxhLQHamquJmZJGcbzt+B1MdQ9k0jT+ez6JwEL vz3Q== 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=E2bX/0u6XiYgQMGaUe3Pi3B6kYgBnMguEzXF63r2e6E=; fh=d9G4dsZtlI8UONIvGKwhW94hCYEPGxy6CqYeKEG646A=; b=qDN6ZxFiMHQVXFOV1mxUwq4BXE/iHe3C2UM1w0WV4zlOJllYMpYGFZva+m+Rtczxmb 6E8XUOUoc2oKXWqQ9b9+MhX+FB+1VoTiJAIQ4BPOewpJ7EbxUjIT6dNmqdaLpF2Ad3pa nR9/enfgP8MrVnkOJuVPdsfqBQ//Hjzw012p3Hbkzw5mx+RedzhsYhaQUByraZp4IdNY Lnb4c+SZrEFgqTh0rfcGyoeSP1uH91hGdwXFbeqoIXyV4W3FLUHCvBioCztEkeBQ1Ya6 8z825jsuOebQA6GobMXHcUCWVjFRauT5ZOu5bxVZwvpec8YJGOYaceFLiv0Qf2GPyzdI zQWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k+dtvqEo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id az3-20020a17090b028300b00263c4af31f2si823542pjb.157.2023.10.18.16.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 16:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k+dtvqEo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id F38B48212A84; Wed, 18 Oct 2023 16:17:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232519AbjJRXRK (ORCPT + 24 others); Wed, 18 Oct 2023 19:17:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232041AbjJRXQa (ORCPT ); Wed, 18 Oct 2023 19:16:30 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C487123; Wed, 18 Oct 2023 16:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697670989; x=1729206989; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=q1Y1U/47kZM9h2ESP1lpqm0HnFB6ay06aMAyMzOh2eE=; b=k+dtvqEot1tKWEMs5mEHEaugE7veKJT02Ys5YG07QZd7zTh5PO2bzii3 i39kuYtx/7xbh1UCHFwGz8GYRR/Y5kIcqk0CbQEDbKZpFU+ujmVQkM1X3 90j3dUNMwWsOi4M5KW9iUkV64XEw+L+VM2IEVJ9qXdieHR2OPjapOZrLV MnGOoJ0lAEo+Z9I0fa16mT39QnNWkDVcDMVlZIviiAM2nn1+U3CBQA/1I hj3w1Hk88DXASGyL/3GhRd4iwIdWL6eBA6+AsgYg3C+EYXuOdfnnsK2EO y5SOmQVUOJtF/k0NlIUM/6R2a9Oz/vZ/8v/NzfQC95P3JdYL9x4GD2BKP w==; X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="452605960" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="452605960" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 16:16:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10867"; a="756782177" X-IronPort-AV: E=Sophos;i="6.03,236,1694761200"; d="scan'208";a="756782177" Received: from linux.intel.com ([10.54.29.200]) by orsmga002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 16:16:25 -0700 Received: from debox1-desk4.lan (unknown [10.209.71.91]) by linux.intel.com (Postfix) with ESMTP id A7BE8580DD4; Wed, 18 Oct 2023 16:16:25 -0700 (PDT) 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 V4 09/17] platform/x86/intel/pmc: Allow pmc_core_ssram_init to fail Date: Wed, 18 Oct 2023 16:16:16 -0700 Message-Id: <20231018231624.1044633-10-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018231624.1044633-1-david.e.box@linux.intel.com> References: <20231018231624.1044633-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 18 Oct 2023 16:17:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780137119410049530 X-GMAIL-MSGID: 1780137119410049530 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. Don't use the return value yet. This is in preparation for a future rework of pmc_core_sram_init(). Signed-off-by: David E. Box Reviewed-by: Ilpo Järvinen --- 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; }