From patchwork Wed Apr 5 08:01:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 79495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp137502vqo; Wed, 5 Apr 2023 01:21:38 -0700 (PDT) X-Google-Smtp-Source: AKy350ZvwnmM2LxGfjzdKLTj/7dMae0GxfZTZxR7gWULPDEHCUXAd1bHoBDTa0DK4/KscI3TjAMJ X-Received: by 2002:a17:906:d149:b0:930:4eba:1640 with SMTP id br9-20020a170906d14900b009304eba1640mr1357839ejb.38.1680682898421; Wed, 05 Apr 2023 01:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680682898; cv=none; d=google.com; s=arc-20160816; b=H8vezaDLnrDxLbFQXypSA5949GdiYqoWBMIRkxMvn0EV2xanhLe4Bbv4yCbhWUTIFp B7shu47NUJgyGUgFZ+5O/DHguYIwjQW130FCXhyCy+Ey1TTmixNr3eFkKkzOprRXL2An uMCcmSo413Nj/IWrha0Cr8cE2Ezht1zyDnkzqMvi+Rt1un6RhFPnvqr8sz0mpQcAHbTw d5Z8q7UQylMYef9WORq/+seuePf38YNzkqWjMTW5OtZjXpuI+ZOYjrsoBjQTRlnQWQQZ ttSE29pECW8C7NFwa666RQ3aYri6F4y/fH4aPCr7yCdyf/XHhGANoaF6oaR5kvyy1Ai9 troQ== 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=VW68XYq+Grdnnex0s2P4fbzPqqwAQH/LqdiGLYfMLTQ=; b=De7wJqq4fXa27il4ya54WY82GaDBbcVI6JNDNtkUKDSw8mcCoV82smgApSLqJah9Qq f+DuhBGgIIR/mtewcXXn1Crg/ULqQ+qA8knG/pi1HGThz3X07mrTo1DrhzCSy4jJOAmP zz9cxwQvXhniUiVAdn11uyYoERqU788+yV/pF1vx9Xopvllwc+QnOWLW+udGC2OwQf5r cHoba122Ub3ncg2kksrPZ236ZboL671Nw7UDp4PGzENlDVh8FcW9vuhE99LnSUe9eAaU T+hchJ1Q3k0q5aY4FmWdur+eZAwz47BRmfalzm+PHlJOEFccpvcw1q34s/hZIZW5fopv qlIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kJ4zBewq; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a17090604c900b00930625d6a34si724eja.972.2023.04.05.01.21.14; Wed, 05 Apr 2023 01:21:38 -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=@intel.com header.s=Intel header.b=kJ4zBewq; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237241AbjDEICU (ORCPT + 99 others); Wed, 5 Apr 2023 04:02:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237228AbjDEICS (ORCPT ); Wed, 5 Apr 2023 04:02:18 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FCA83C32; Wed, 5 Apr 2023 01:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680681737; x=1712217737; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BbQrm2hVJXugEoU9akTq2r86Vq3neTtzZG3wnmgyjIk=; b=kJ4zBewqi/LvgzEXndVxR4IjtlgOsd9R9PPjRyCkMHimVkCEIJsQg0Er 1uLG8hkIatGrKrdzyaZJhJ+UpFaAaR7WXlQJl6+tAKQZC1LAC2RVUP5Gg MOr7izPHjwh8G6uozC7IrtUS7US4KsAO9yKgDew4BW14NGBjBvv2xw9S7 cf5sikeAarVlhXpOh5eHnenrRygfJXqtRqnU1U/WQzWLpA5xjWEbu77t7 HnUJhaG9I4BVDwhn9Wj79Mbsea2NeRqz1Oop5gzWwBfc1iF4yUWaR0j5w L9KGw86UVIDG+GMgVe0wZc9BySgnyPZNOmtO0LfuMvTA0MNVTsD9yxxhZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="428680216" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="428680216" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="775959622" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="775959622" Received: from wtedesch-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.53.134]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:04 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, Lee Jones , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, Russ Weight , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 1/4] mfd: intel-m10-bmc: Move core symbols to own namespace Date: Wed, 5 Apr 2023 11:01:49 +0300 Message-Id: <20230405080152.6732-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> References: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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?1762323750816607257?= X-GMAIL-MSGID: =?utf-8?q?1762323750816607257?= Create INTEL_M10_BMC_CORE namespace for symbols exported by intel-m10-bmc-core. Signed-off-by: Ilpo Järvinen Reviewed-by: Russ Weight --- drivers/mfd/intel-m10-bmc-core.c | 2 +- drivers/mfd/intel-m10-bmc-pmci.c | 1 + drivers/mfd/intel-m10-bmc-spi.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/intel-m10-bmc-core.c b/drivers/mfd/intel-m10-bmc-core.c index dac9cf7bcb4a..b94412813887 100644 --- a/drivers/mfd/intel-m10-bmc-core.c +++ b/drivers/mfd/intel-m10-bmc-core.c @@ -98,7 +98,7 @@ const struct attribute_group *m10bmc_dev_groups[] = { &m10bmc_group, NULL, }; -EXPORT_SYMBOL_GPL(m10bmc_dev_groups); +EXPORT_SYMBOL_NS_GPL(m10bmc_dev_groups, INTEL_M10_BMC_CORE); int m10bmc_dev_init(struct intel_m10bmc *m10bmc, const struct intel_m10bmc_platform_info *info) { diff --git a/drivers/mfd/intel-m10-bmc-pmci.c b/drivers/mfd/intel-m10-bmc-pmci.c index 8821f1876dd6..0392ef8b57d8 100644 --- a/drivers/mfd/intel-m10-bmc-pmci.c +++ b/drivers/mfd/intel-m10-bmc-pmci.c @@ -453,3 +453,4 @@ module_dfl_driver(m10bmc_pmci_driver); MODULE_DESCRIPTION("MAX10 BMC PMCI-based interface"); MODULE_AUTHOR("Intel Corporation"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(INTEL_M10_BMC_CORE); diff --git a/drivers/mfd/intel-m10-bmc-spi.c b/drivers/mfd/intel-m10-bmc-spi.c index 957200e17fed..edd266557ab9 100644 --- a/drivers/mfd/intel-m10-bmc-spi.c +++ b/drivers/mfd/intel-m10-bmc-spi.c @@ -166,3 +166,4 @@ MODULE_DESCRIPTION("Intel MAX 10 BMC SPI bus interface"); MODULE_AUTHOR("Intel Corporation"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("spi:intel-m10-bmc"); +MODULE_IMPORT_NS(INTEL_M10_BMC_CORE); From patchwork Wed Apr 5 08:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 79500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp140780vqo; Wed, 5 Apr 2023 01:30:01 -0700 (PDT) X-Google-Smtp-Source: AKy350asSixGSc/GU6owgU0dK0AK/E6kvJic0fpZ6Ud1QceVusEEb82xjRbfyKP3d0aKpwFnl0EQ X-Received: by 2002:a17:906:9485:b0:932:e9c7:c32 with SMTP id t5-20020a170906948500b00932e9c70c32mr2280330ejx.59.1680683401118; Wed, 05 Apr 2023 01:30:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680683401; cv=none; d=google.com; s=arc-20160816; b=L3LqyxTAvX49uIr6LJYAK2vuBnr1H2OcjkEVnWvifUmK+YIlNlemiOu/ykfP/X+9nR 2Ru2wieyz4o/oQVfVyyrdQZVHIlf18NR+W+lhtWLQOAoq/WVfaG45lQzJc9ppLZ/Ddsr 8GTA5vZy4sDq1mD58x5fCBjcJrZrCP8diB0B5cj+jq2VHxt62lc30qd2luZcfhCbffWV 3xFf0kz7xr/h1dltoirEX19CtTBm8kFP9UYDQ9O40EfgUZNemeUc8HdisIxYulhOTpUJ J0s2JLoMuNyrrFU7cQCFF73omonSXnDseRI9eqBktw14RbrhsWckgVY10zfi6h2+G+Iq 75sg== 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=wB+Tm9lKVoh5HUY8IHEflDseB0nA6mqscOZAFXx+cdo=; b=Y10r0WnBaQFDXUnRIljn30f2oGIXYlJoVwK3lv/bH4zXe13yQIFdqzLlmLFnXUauHX MdDhF08CAPTgRgoSkXPX3tP/Fm+3rTKoqJnDCKz6vwu0JPk/ydDdG3WFv9fnuSw0bDuI CTCiOq7GO/Aaac0hXIvjZrPhOJ1T8Rn6PC3Fj3pQ++iR7uEDdXq1e8nlUc46pmDNPkPM Q2cxO51IdVDl9useAWNniKkG9lKOMZaYgVcXAm592SWIhQHTKbrLNqY3XDE+/AUZMAXG WDGCHcfKYrEmp+bU+AToUfqbHVxjm6relbVeg87rYsxrmjw0iLAX1uKPJMX9Z+qumXWf l3tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HjvVOzik; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i20-20020a056402055400b005002ec25762si1212406edx.192.2023.04.05.01.29.37; Wed, 05 Apr 2023 01:30:01 -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=@intel.com header.s=Intel header.b=HjvVOzik; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237279AbjDEIC2 (ORCPT + 99 others); Wed, 5 Apr 2023 04:02:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237231AbjDEICT (ORCPT ); Wed, 5 Apr 2023 04:02:19 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27DD340EE; Wed, 5 Apr 2023 01:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680681738; x=1712217738; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5O3kpADpDKviaqUjctZBRUN1WdPPnVBWYgqfDgkMEqo=; b=HjvVOzik2rrOD23vuSuMIoCVn0t6+UIxHMTKxz6Y9eX7Mrd5Tbe/QuUb 9VnaiBDpgH39FSa4VLP+vH2PDrVAhit36SijPnuBommRBtMou34ErB7Le Y5x/hYAuzSRoSJVegPP0EwrFHam/sEzKBL/vy2oP1or9Iw2cPVqFUYwwp HqXuLcH0xfLFa79Tbf4tgSBFKlqSeEgqOfNZGlqq7Mn7BwabGo+Ta4UlQ U5cIdlBO/qG+unF0JVlWKBERoW0PhKvzsSQ7v9OVVQ4UivpmPCV/g6qMS Sre055REEycQXuF8ePL6OfaKZSHEpLnPeprHzgiCe3iXP+bpNDZc/Bta7 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="428680225" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="428680225" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="775959628" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="775959628" Received: from wtedesch-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.53.134]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:08 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, Lee Jones , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, Russ Weight , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 2/4] mfd: intel-m10-bmc: Create m10bmc_sys_update_bits() Date: Wed, 5 Apr 2023 11:01:50 +0300 Message-Id: <20230405080152.6732-3-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> References: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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?1762324278060045694?= X-GMAIL-MSGID: =?utf-8?q?1762324278060045694?= Wrap regmap_update_bits() with m10bmc_sys_update_bits() in order to be able to add additional checks into it. Co-developed-by: Russ Weight Signed-off-by: Russ Weight Signed-off-by: Ilpo Järvinen --- drivers/fpga/intel-m10-bmc-sec-update.c | 30 ++++++++++++------------- drivers/mfd/intel-m10-bmc-core.c | 9 ++++++++ include/linux/mfd/intel-m10-bmc.h | 4 ++++ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/fpga/intel-m10-bmc-sec-update.c b/drivers/fpga/intel-m10-bmc-sec-update.c index d7e2f9f461bc..fe0127a58eff 100644 --- a/drivers/fpga/intel-m10-bmc-sec-update.c +++ b/drivers/fpga/intel-m10-bmc-sec-update.c @@ -376,12 +376,11 @@ static enum fw_upload_err rsu_update_init(struct m10bmc_sec *sec) u32 doorbell_reg, progress, status; int ret, err; - ret = regmap_update_bits(sec->m10bmc->regmap, - csr_map->base + csr_map->doorbell, - DRBL_RSU_REQUEST | DRBL_HOST_STATUS, - DRBL_RSU_REQUEST | - FIELD_PREP(DRBL_HOST_STATUS, - HOST_STATUS_IDLE)); + ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell, + DRBL_RSU_REQUEST | DRBL_HOST_STATUS, + DRBL_RSU_REQUEST | + FIELD_PREP(DRBL_HOST_STATUS, + HOST_STATUS_IDLE)); if (ret) return FW_UPLOAD_ERR_RW_ERROR; @@ -450,11 +449,10 @@ static enum fw_upload_err rsu_send_data(struct m10bmc_sec *sec) u32 doorbell_reg, status; int ret; - ret = regmap_update_bits(sec->m10bmc->regmap, - csr_map->base + csr_map->doorbell, - DRBL_HOST_STATUS, - FIELD_PREP(DRBL_HOST_STATUS, - HOST_STATUS_WRITE_DONE)); + ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell, + DRBL_HOST_STATUS, + FIELD_PREP(DRBL_HOST_STATUS, + HOST_STATUS_WRITE_DONE)); if (ret) return FW_UPLOAD_ERR_RW_ERROR; @@ -517,11 +515,10 @@ static enum fw_upload_err rsu_cancel(struct m10bmc_sec *sec) if (rsu_prog(doorbell) != RSU_PROG_READY) return FW_UPLOAD_ERR_BUSY; - ret = regmap_update_bits(sec->m10bmc->regmap, - csr_map->base + csr_map->doorbell, - DRBL_HOST_STATUS, - FIELD_PREP(DRBL_HOST_STATUS, - HOST_STATUS_ABORT_RSU)); + ret = m10bmc_sys_update_bits(sec->m10bmc, csr_map->doorbell, + DRBL_HOST_STATUS, + FIELD_PREP(DRBL_HOST_STATUS, + HOST_STATUS_ABORT_RSU)); if (ret) return FW_UPLOAD_ERR_RW_ERROR; @@ -764,3 +761,4 @@ module_platform_driver(intel_m10bmc_sec_driver); MODULE_AUTHOR("Intel Corporation"); MODULE_DESCRIPTION("Intel MAX10 BMC Secure Update"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(INTEL_M10_BMC_CORE); diff --git a/drivers/mfd/intel-m10-bmc-core.c b/drivers/mfd/intel-m10-bmc-core.c index b94412813887..879d98b9b14d 100644 --- a/drivers/mfd/intel-m10-bmc-core.c +++ b/drivers/mfd/intel-m10-bmc-core.c @@ -12,6 +12,15 @@ #include #include +int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, + unsigned int msk, unsigned int val) +{ + const struct m10bmc_csr_map *csr_map = m10bmc->info->csr_map; + + return regmap_update_bits(m10bmc->regmap, csr_map->base + offset, msk, val); +} +EXPORT_SYMBOL_NS_GPL(m10bmc_sys_update_bits, INTEL_M10_BMC_CORE); + static ssize_t bmc_version_show(struct device *dev, struct device_attribute *attr, char *buf) { diff --git a/include/linux/mfd/intel-m10-bmc.h b/include/linux/mfd/intel-m10-bmc.h index 1812ebfa11a8..5418f7279ed0 100644 --- a/include/linux/mfd/intel-m10-bmc.h +++ b/include/linux/mfd/intel-m10-bmc.h @@ -251,6 +251,7 @@ struct intel_m10bmc { * * m10bmc_raw_read - read m10bmc register per addr * m10bmc_sys_read - read m10bmc system register per offset + * m10bmc_sys_update_bits - update m10bmc system register per offset */ static inline int m10bmc_raw_read(struct intel_m10bmc *m10bmc, unsigned int addr, @@ -282,6 +283,9 @@ static inline int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offs return m10bmc_raw_read(m10bmc, csr_map->base + offset, val); } +int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, + unsigned int msk, unsigned int val); + /* * MAX10 BMC Core support */ From patchwork Wed Apr 5 08:01:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 79494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp137028vqo; Wed, 5 Apr 2023 01:20:32 -0700 (PDT) X-Google-Smtp-Source: AKy350a3z0ow4gjzDon2J6Ad+hRF4Og+0f3a3Tqi7Xs10NmS/ACInvsUEqfmilpOFbDwMJ+b7Ejn X-Received: by 2002:a17:906:c44d:b0:92f:bef6:7843 with SMTP id ck13-20020a170906c44d00b0092fbef67843mr2242613ejb.22.1680682832478; Wed, 05 Apr 2023 01:20:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680682832; cv=none; d=google.com; s=arc-20160816; b=lamiteTspvxVf+UINlpfJuJGam9JOMNoMPuurlo5j2+NdpFLCHR5T2w3dBZ1dMepNP e14KIaWSuFAH9pCjnjcxHl/rLNGLYqIOfCSMj0/FzR5hN1TYJlRfoJ9NOhZMHXwWIdF6 cdXtnFOm8EgdvW63itm2oehz5brmHANxHBXEnjMnpB2qfrUZwX1SnMdLcAfy7JXbQqE6 ThE5nIyaXO6q067Iw0ODL4b3b2DCBztCXai8AzM+feiFgxU/P7nT72StDQebaarfiKpQ xIP1Cxt7ZVauD+JmN8fNpJGmdbrnHSTFVOatNFK3ucPFReFn7QjlDZ9Ul+SSUcFnSFGV eCCA== 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=CrPJKG2UOv2/LPPt75qrKIPVdhPcOqKlAEpQylDMlak=; b=vE8wdlQwJMFVVjoxoRl4MrNEtknbTpHE328zVgfLJYlhLU7U4JJzBCLFGyOpeIL1pw aq/TzjOw5K5o56/scTBEI4fvX2NaPYQmhcCvq8QD48dZo7oFYeSRCb6hFBPZsP2rfch7 UnQrjeTbHrGFYuhjAn635xYZlPFjJBe59U6hUcl4bY4UwPSGQ67Ffp1av92dNNGJ2r4a oaTVUDoRmcU0qjhbvA5kIdWcfZjYM9Jyu9DRlYwobkXQ2GgEz81e3rlrT3DZE8c8xUoO 0qiLUVJoCGwdZdNtsTfaDSxx7U3/ZEGSGJKrTcQBgPM8Ur0v4clXhLfAKvUGmSwznwaT B0ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="bwfV/PuB"; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020aa7c648000000b005024d6d6d5bsi4639367edr.532.2023.04.05.01.20.08; Wed, 05 Apr 2023 01:20:32 -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=@intel.com header.s=Intel header.b="bwfV/PuB"; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237271AbjDEICZ (ORCPT + 99 others); Wed, 5 Apr 2023 04:02:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237230AbjDEICT (ORCPT ); Wed, 5 Apr 2023 04:02:19 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3736C4236; Wed, 5 Apr 2023 01:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680681738; x=1712217738; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ys3C2wRBEsybGWReoS1y6LBFNQYIzJzXBbmVnoIbRU4=; b=bwfV/PuB4KGFbe+GoygMjEbipV/xqT2Qn/kqgxB8Y8PeEbaC2VsbWaC+ XGJad1EbCVDvcNY2/RQH5r3IAelBZMDb3Wz4jNKAqTHTpmkAF1YBX0D+j ulzpSEPJ6rQMSglg37QT1eIczus+O5FXkDIl9N7rP32XyWrnJGuyJmVdx 7d5Qhl+P1keRInJZuVl2Efy2WQCsz19/ZyknvJs1eonDGlpRQYtEqP9YQ xQC5AKzKJoo9rqUN1wxKEB0tUqxo0JftrbMHhiLt3hIyaPkDW9OLjbeb0 YnoBhAOY3R8MlcniF792r8V3AiwdgGmmjv9WDI5XtA33S8AuoGT1eTzLT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="428680231" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="428680231" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="775959633" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="775959633" Received: from wtedesch-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.53.134]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:12 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, Lee Jones , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, Russ Weight , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 3/4] mfd: intel-m10-bmc: Move m10bmc_sys_read() away from header Date: Wed, 5 Apr 2023 11:01:51 +0300 Message-Id: <20230405080152.6732-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> References: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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?1762323681784245765?= X-GMAIL-MSGID: =?utf-8?q?1762323681784245765?= Move m10bmc_sys_read() out from the header to prepare it for adding more code into the function which would make it too large to be a static inline any more. While at it, replace the vague wording in function comment with more precise statements. Signed-off-by: Ilpo Järvinen Acked-by: Guenter Roeck Reviewed-by: Russ Weight --- drivers/hwmon/intel-m10-bmc-hwmon.c | 1 + drivers/mfd/intel-m10-bmc-core.c | 14 ++++++++++++++ include/linux/mfd/intel-m10-bmc.h | 17 +---------------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/hwmon/intel-m10-bmc-hwmon.c b/drivers/hwmon/intel-m10-bmc-hwmon.c index 2f0323c14bab..92900ce7986b 100644 --- a/drivers/hwmon/intel-m10-bmc-hwmon.c +++ b/drivers/hwmon/intel-m10-bmc-hwmon.c @@ -794,3 +794,4 @@ MODULE_DEVICE_TABLE(platform, intel_m10bmc_hwmon_ids); MODULE_AUTHOR("Intel Corporation"); MODULE_DESCRIPTION("Intel MAX 10 BMC hardware monitor"); MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(INTEL_M10_BMC_CORE); diff --git a/drivers/mfd/intel-m10-bmc-core.c b/drivers/mfd/intel-m10-bmc-core.c index 879d98b9b14d..4a1bfe135293 100644 --- a/drivers/mfd/intel-m10-bmc-core.c +++ b/drivers/mfd/intel-m10-bmc-core.c @@ -12,6 +12,20 @@ #include #include +/* + * This function helps to simplify the accessing of the system registers. + * + * The base of the system registers is configured through the struct + * csr_map. + */ +int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int *val) +{ + const struct m10bmc_csr_map *csr_map = m10bmc->info->csr_map; + + return m10bmc_raw_read(m10bmc, csr_map->base + offset, val); +} +EXPORT_SYMBOL_NS_GPL(m10bmc_sys_read, INTEL_M10_BMC_CORE); + int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int msk, unsigned int val) { diff --git a/include/linux/mfd/intel-m10-bmc.h b/include/linux/mfd/intel-m10-bmc.h index 5418f7279ed0..252644fa61be 100644 --- a/include/linux/mfd/intel-m10-bmc.h +++ b/include/linux/mfd/intel-m10-bmc.h @@ -267,22 +267,7 @@ m10bmc_raw_read(struct intel_m10bmc *m10bmc, unsigned int addr, return ret; } -/* - * The base of the system registers could be configured by HW developers, and - * in HW SPEC, the base is not added to the addresses of the system registers. - * - * This function helps to simplify the accessing of the system registers. And if - * the base is reconfigured in HW, SW developers could simply change the - * csr_map's base accordingly. - */ -static inline int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offset, - unsigned int *val) -{ - const struct m10bmc_csr_map *csr_map = m10bmc->info->csr_map; - - return m10bmc_raw_read(m10bmc, csr_map->base + offset, val); -} - +int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int *val); int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int msk, unsigned int val); From patchwork Wed Apr 5 08:01:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 79489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp136243vqo; Wed, 5 Apr 2023 01:18:46 -0700 (PDT) X-Google-Smtp-Source: AKy350aDBWuLg1wx8+7AaanYivsLzt6v3vRY7toRhibI27KxqSz9Wa+qyrSdCe+RaiMvHd0bK9g8 X-Received: by 2002:a17:906:fb0e:b0:933:3aa7:57a6 with SMTP id lz14-20020a170906fb0e00b009333aa757a6mr2201051ejb.12.1680682725945; Wed, 05 Apr 2023 01:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680682725; cv=none; d=google.com; s=arc-20160816; b=Dv7qubbA2MTbqVKm6dHKUAlv9WxjMhDUS5rwnFTltAFMWvh/etmpM232ueqqgpZ2MO gFOuV1RQX9toWUDgQlo1/wuQTn/rvh2FSQs170YmgPX/Vy8DR1U7AWmtxVmY1vYyJMjX Zr6p2Hnu1pgt8cBDbZS4t2vBoL4o6AuZ/z7rSjzkQAP49CACJkKufcg5xf0jxK5eM9/d m45nGXAazJdFijJYmrXOCWJ60U47ioroNsm4ID6ufjs0U3b5WIeln9bkuFtl5EQUyh7y 6LZyNE/kDiSaG6nnv36pv6f81JhS14OhpTC40jZVFurcwMY0nA8w4iKKCrCuepPEVogO mvDg== 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=nHYlHlmXaRzdEViomAz4cjVvO9HMy50mJHIMIwJISYs=; b=Zcux0uselhajMh/+Uwo01lD1sRx1VhnHAd/DnPQFXTqxltH1NQ5Rbx2cGzboJm468E Pb/oBmlypnanujBy1833P9QHiOBsDbcoGldBLZOQiVvWuYK0idMmEMiCjPdy0RGmxYjy U7LxVCiZouVZQOucE8YCHy4LOe5npP8VwYbEsLEX7JslvYVO4URanuIdBHQvfJ4/opWL +npMEvqIoHzramvY7OI/ewPp8U2+aTfvmCES7vWVFgvnYt4zkk3X9jv+wOarMxS+MNfM FrRmQgR8nfjtjF7Fw6xNzgum7sKmKbhFYHkqpN1kqbuoALFS+5FvcUsXjWRiVyL8NZIQ 3Fwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=H+qMyYEx; 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=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020aa7d0c8000000b004fcdb490ae2si11713542edo.327.2023.04.05.01.18.22; Wed, 05 Apr 2023 01:18:45 -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=@intel.com header.s=Intel header.b=H+qMyYEx; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237287AbjDEICr (ORCPT + 99 others); Wed, 5 Apr 2023 04:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237228AbjDEICW (ORCPT ); Wed, 5 Apr 2023 04:02:22 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3A846A8; Wed, 5 Apr 2023 01:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680681741; x=1712217741; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=trc/eZyT9AujKD2xdLmeW4Ef3XqvOj8t/8MJThMLuEc=; b=H+qMyYExTEqn3f721IpAs3O/RnwjvKCqeaxCD1Z08TxhbghX42aVjqFK /jtrqurjLQrgQciWxKBZUlspmc6HfPqIbVlvB18rv2uMKPVyNl5cU/zxc pl7S0IsEXZopL5H27Cxxo2oxcRgUEZUpZygJyQ46l6/7XKeZC9EcVXedU U+6pWxb7qlfn4s8jfuTkViwyzzewMgAFLQ6BpmD2p82QeoNoMJAdzyW02 RBP3Esuw0jo3S7xyjyUmupKhhAXw88+vAD//4OAOAEFEyq3e/+QxGTZW2 vrTylScbMX7gHZIm+CMwctLoznye3M4KJ7/3ExHCEEfdL4wztSXW/tukh A==; X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="428680247" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="428680247" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="775959665" X-IronPort-AV: E=Sophos;i="5.98,319,1673942400"; d="scan'208";a="775959665" Received: from wtedesch-mobl1.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.53.134]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 01:02:17 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , linux-fpga@vger.kernel.org, Lee Jones , Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, Russ Weight , linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH 4/4] mfd: intel-m10-bmc: Manage access to MAX 10 fw handshake registers Date: Wed, 5 Apr 2023 11:01:52 +0300 Message-Id: <20230405080152.6732-5-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> References: <20230405080152.6732-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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?1762323570015251294?= X-GMAIL-MSGID: =?utf-8?q?1762323570015251294?= On some MAX 10 cards, the BMC firmware is not available to service handshake registers during secure update erase and write phases at normal speeds. This problem affects at least hwmon driver. When the MAX 10 hwmon driver tries to read the sensor values during a secure update, the reads are slowed down (e.g., reading all D5005 sensors takes ~24s which is magnitudes worse than the normal <0.02s). Manage access to the handshake registers using a rw semaphore and a FW state variable to prevent accesses during those secure update phases and return -EBUSY instead. Co-developed-by: Russ Weight Signed-off-by: Russ Weight Co-developed-by: Xu Yilun Signed-off-by: Xu Yilun Signed-off-by: Ilpo Järvinen --- drivers/fpga/intel-m10-bmc-sec-update.c | 17 +++++-- drivers/mfd/intel-m10-bmc-core.c | 63 ++++++++++++++++++++++++- drivers/mfd/intel-m10-bmc-pmci.c | 4 ++ drivers/mfd/intel-m10-bmc-spi.c | 14 ++++++ include/linux/mfd/intel-m10-bmc.h | 27 +++++++++++ 5 files changed, 120 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/intel-m10-bmc-sec-update.c b/drivers/fpga/intel-m10-bmc-sec-update.c index fe0127a58eff..31af2e08c825 100644 --- a/drivers/fpga/intel-m10-bmc-sec-update.c +++ b/drivers/fpga/intel-m10-bmc-sec-update.c @@ -544,21 +544,28 @@ static enum fw_upload_err m10bmc_sec_prepare(struct fw_upload *fwl, if (ret != FW_UPLOAD_ERR_NONE) goto unlock_flash; + m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_SEC_UPDATE_PREPARE); + ret = rsu_update_init(sec); if (ret != FW_UPLOAD_ERR_NONE) - goto unlock_flash; + goto fw_state_exit; ret = rsu_prog_ready(sec); if (ret != FW_UPLOAD_ERR_NONE) - goto unlock_flash; + goto fw_state_exit; if (sec->cancel_request) { ret = rsu_cancel(sec); - goto unlock_flash; + goto fw_state_exit; } + m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_SEC_UPDATE_WRITE); + return FW_UPLOAD_ERR_NONE; +fw_state_exit: + m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_NORMAL); + unlock_flash: if (sec->m10bmc->flash_bulk_ops) sec->m10bmc->flash_bulk_ops->unlock_write(sec->m10bmc); @@ -607,6 +614,8 @@ static enum fw_upload_err m10bmc_sec_poll_complete(struct fw_upload *fwl) if (sec->cancel_request) return rsu_cancel(sec); + m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_SEC_UPDATE_PROGRAM); + result = rsu_send_data(sec); if (result != FW_UPLOAD_ERR_NONE) return result; @@ -650,6 +659,8 @@ static void m10bmc_sec_cleanup(struct fw_upload *fwl) (void)rsu_cancel(sec); + m10bmc_fw_state_set(sec->m10bmc, M10BMC_FW_STATE_NORMAL); + if (sec->m10bmc->flash_bulk_ops) sec->m10bmc->flash_bulk_ops->unlock_write(sec->m10bmc); } diff --git a/drivers/mfd/intel-m10-bmc-core.c b/drivers/mfd/intel-m10-bmc-core.c index 4a1bfe135293..ae976fe0baed 100644 --- a/drivers/mfd/intel-m10-bmc-core.c +++ b/drivers/mfd/intel-m10-bmc-core.c @@ -12,6 +12,42 @@ #include #include +void m10bmc_fw_state_set(struct intel_m10bmc *m10bmc, enum m10bmc_fw_state new_state) +{ + down_write(&m10bmc->bmcfw_lock); + m10bmc->bmcfw_state = new_state; + up_write(&m10bmc->bmcfw_lock); +} +EXPORT_SYMBOL_NS_GPL(m10bmc_fw_state_set, INTEL_M10_BMC_CORE); + +/* + * For some Intel FPGA devices, the BMC firmware is not available to service + * handshake registers during a secure update. + */ +static bool m10bmc_reg_always_available(struct intel_m10bmc *m10bmc, unsigned int offset) +{ + if (!m10bmc->info->handshake_sys_reg_nranges) + return true; + + return !regmap_reg_in_ranges(offset, m10bmc->info->handshake_sys_reg_ranges, + m10bmc->info->handshake_sys_reg_nranges); +} + +/* + * m10bmc_handshake_reg_unavailable - Checks if reg access collides with secure update state + * @m10bmc: M10 BMC structure + * + * For some Intel FPGA devices, the BMC firmware is not available to service + * handshake registers during a secure update erase and write phases. + * + * Context: @m10bmc->bmcfw_lock must be held. + */ +static bool m10bmc_handshake_reg_unavailable(struct intel_m10bmc *m10bmc) +{ + return m10bmc->bmcfw_state == M10BMC_FW_STATE_SEC_UPDATE_PREPARE || + m10bmc->bmcfw_state == M10BMC_FW_STATE_SEC_UPDATE_WRITE; +} + /* * This function helps to simplify the accessing of the system registers. * @@ -21,8 +57,19 @@ int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int *val) { const struct m10bmc_csr_map *csr_map = m10bmc->info->csr_map; + int ret; + + if (m10bmc_reg_always_available(m10bmc, offset)) + return m10bmc_raw_read(m10bmc, csr_map->base + offset, val); - return m10bmc_raw_read(m10bmc, csr_map->base + offset, val); + down_read(&m10bmc->bmcfw_lock); + if (m10bmc_handshake_reg_unavailable(m10bmc)) + ret = -EBUSY; /* Reg not available during secure update */ + else + ret = m10bmc_raw_read(m10bmc, csr_map->base + offset, val); + up_read(&m10bmc->bmcfw_lock); + + return ret; } EXPORT_SYMBOL_NS_GPL(m10bmc_sys_read, INTEL_M10_BMC_CORE); @@ -30,8 +77,19 @@ int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int msk, unsigned int val) { const struct m10bmc_csr_map *csr_map = m10bmc->info->csr_map; + int ret; - return regmap_update_bits(m10bmc->regmap, csr_map->base + offset, msk, val); + if (m10bmc_reg_always_available(m10bmc, offset)) + return regmap_update_bits(m10bmc->regmap, csr_map->base + offset, msk, val); + + down_read(&m10bmc->bmcfw_lock); + if (m10bmc_handshake_reg_unavailable(m10bmc)) + ret = -EBUSY; /* Reg not available during secure update */ + else + ret = regmap_update_bits(m10bmc->regmap, csr_map->base + offset, msk, val); + up_read(&m10bmc->bmcfw_lock); + + return ret; } EXPORT_SYMBOL_NS_GPL(m10bmc_sys_update_bits, INTEL_M10_BMC_CORE); @@ -129,6 +187,7 @@ int m10bmc_dev_init(struct intel_m10bmc *m10bmc, const struct intel_m10bmc_platf m10bmc->info = info; dev_set_drvdata(m10bmc->dev, m10bmc); + init_rwsem(&m10bmc->bmcfw_lock); ret = devm_mfd_add_devices(m10bmc->dev, PLATFORM_DEVID_AUTO, info->cells, info->n_cells, diff --git a/drivers/mfd/intel-m10-bmc-pmci.c b/drivers/mfd/intel-m10-bmc-pmci.c index 0392ef8b57d8..8cdbabe37708 100644 --- a/drivers/mfd/intel-m10-bmc-pmci.c +++ b/drivers/mfd/intel-m10-bmc-pmci.c @@ -352,6 +352,8 @@ static struct mfd_cell m10bmc_pmci_n6000_bmc_subdevs[] = { { .name = "n6000bmc-sec-update" }, }; +static const struct regmap_range null_fw_handshake_regs[0]; + static const struct m10bmc_csr_map m10bmc_n6000_csr_map = { .base = M10BMC_N6000_SYS_BASE, .build_version = M10BMC_N6000_BUILD_VER, @@ -375,6 +377,8 @@ static const struct m10bmc_csr_map m10bmc_n6000_csr_map = { static const struct intel_m10bmc_platform_info m10bmc_pmci_n6000 = { .cells = m10bmc_pmci_n6000_bmc_subdevs, .n_cells = ARRAY_SIZE(m10bmc_pmci_n6000_bmc_subdevs), + .handshake_sys_reg_ranges = null_fw_handshake_regs, + .handshake_sys_reg_nranges = 0, .csr_map = &m10bmc_n6000_csr_map, }; diff --git a/drivers/mfd/intel-m10-bmc-spi.c b/drivers/mfd/intel-m10-bmc-spi.c index edd266557ab9..cbeb7de9e041 100644 --- a/drivers/mfd/intel-m10-bmc-spi.c +++ b/drivers/mfd/intel-m10-bmc-spi.c @@ -116,12 +116,20 @@ static struct mfd_cell m10bmc_d5005_subdevs[] = { { .name = "d5005bmc-sec-update" }, }; +static const struct regmap_range m10bmc_d5005_fw_handshake_regs[] = { + regmap_reg_range(M10BMC_N3000_TELEM_START, M10BMC_D5005_TELEM_END), +}; + static struct mfd_cell m10bmc_pacn3000_subdevs[] = { { .name = "n3000bmc-hwmon" }, { .name = "n3000bmc-retimer" }, { .name = "n3000bmc-sec-update" }, }; +static const struct regmap_range m10bmc_n3000_fw_handshake_regs[] = { + regmap_reg_range(M10BMC_N3000_TELEM_START, M10BMC_N3000_TELEM_END), +}; + static struct mfd_cell m10bmc_n5010_subdevs[] = { { .name = "n5010bmc-hwmon" }, }; @@ -129,18 +137,24 @@ static struct mfd_cell m10bmc_n5010_subdevs[] = { static const struct intel_m10bmc_platform_info m10bmc_spi_n3000 = { .cells = m10bmc_pacn3000_subdevs, .n_cells = ARRAY_SIZE(m10bmc_pacn3000_subdevs), + .handshake_sys_reg_ranges = m10bmc_n3000_fw_handshake_regs, + .handshake_sys_reg_nranges = ARRAY_SIZE(m10bmc_n3000_fw_handshake_regs), .csr_map = &m10bmc_n3000_csr_map, }; static const struct intel_m10bmc_platform_info m10bmc_spi_d5005 = { .cells = m10bmc_d5005_subdevs, .n_cells = ARRAY_SIZE(m10bmc_d5005_subdevs), + .handshake_sys_reg_ranges = m10bmc_d5005_fw_handshake_regs, + .handshake_sys_reg_nranges = ARRAY_SIZE(m10bmc_d5005_fw_handshake_regs), .csr_map = &m10bmc_n3000_csr_map, }; static const struct intel_m10bmc_platform_info m10bmc_spi_n5010 = { .cells = m10bmc_n5010_subdevs, .n_cells = ARRAY_SIZE(m10bmc_n5010_subdevs), + .handshake_sys_reg_ranges = m10bmc_n3000_fw_handshake_regs, + .handshake_sys_reg_nranges = ARRAY_SIZE(m10bmc_n3000_fw_handshake_regs), .csr_map = &m10bmc_n3000_csr_map, }; diff --git a/include/linux/mfd/intel-m10-bmc.h b/include/linux/mfd/intel-m10-bmc.h index 252644fa61be..afa634c9981a 100644 --- a/include/linux/mfd/intel-m10-bmc.h +++ b/include/linux/mfd/intel-m10-bmc.h @@ -11,6 +11,7 @@ #include #include #include +#include #define M10BMC_N3000_LEGACY_BUILD_VER 0x300468 #define M10BMC_N3000_SYS_BASE 0x300800 @@ -39,6 +40,11 @@ #define M10BMC_N3000_VER_PCB_INFO_MSK GENMASK(31, 24) #define M10BMC_N3000_VER_LEGACY_INVALID 0xffffffff +/* Telemetry registers */ +#define M10BMC_N3000_TELEM_START 0x100 +#define M10BMC_N3000_TELEM_END 0x250 +#define M10BMC_D5005_TELEM_END 0x300 + /* Secure update doorbell register, in system register region */ #define M10BMC_N3000_DOORBELL 0x400 @@ -205,11 +211,15 @@ struct m10bmc_csr_map { * struct intel_m10bmc_platform_info - Intel MAX 10 BMC platform specific information * @cells: MFD cells * @n_cells: MFD cells ARRAY_SIZE() + * @handshake_sys_reg_ranges: array of register ranges for fw handshake regs + * @handshake_sys_reg_nranges: number of register ranges for fw handshake regs * @csr_map: the mappings for register definition of MAX10 BMC */ struct intel_m10bmc_platform_info { struct mfd_cell *cells; int n_cells; + const struct regmap_range *handshake_sys_reg_ranges; + unsigned int handshake_sys_reg_nranges; const struct m10bmc_csr_map *csr_map; }; @@ -232,18 +242,29 @@ struct intel_m10bmc_flash_bulk_ops { void (*unlock_write)(struct intel_m10bmc *m10bmc); }; +enum m10bmc_fw_state { + M10BMC_FW_STATE_NORMAL, + M10BMC_FW_STATE_SEC_UPDATE_PREPARE, + M10BMC_FW_STATE_SEC_UPDATE_WRITE, + M10BMC_FW_STATE_SEC_UPDATE_PROGRAM, +}; + /** * struct intel_m10bmc - Intel MAX 10 BMC parent driver data structure * @dev: this device * @regmap: the regmap used to access registers by m10bmc itself * @info: the platform information for MAX10 BMC * @flash_bulk_ops: optional device specific operations for flash R/W + * @bmcfw_lock: read/write semaphore to BMC firmware running state + * @bmcfw_state: BMC firmware running state */ struct intel_m10bmc { struct device *dev; struct regmap *regmap; const struct intel_m10bmc_platform_info *info; const struct intel_m10bmc_flash_bulk_ops *flash_bulk_ops; + struct rw_semaphore bmcfw_lock; /* Protects bmcfw_state */ + enum m10bmc_fw_state bmcfw_state; }; /* @@ -271,6 +292,12 @@ int m10bmc_sys_read(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned i int m10bmc_sys_update_bits(struct intel_m10bmc *m10bmc, unsigned int offset, unsigned int msk, unsigned int val); +/* + * Track the state of the firmware, as it is not available for register + * handshakes during secure updates on some MAX 10 cards. + */ +void m10bmc_fw_state_set(struct intel_m10bmc *m10bmc, enum m10bmc_fw_state new_state); + /* * MAX10 BMC Core support */