Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1623375rwr; Thu, 20 Apr 2023 19:04:24 -0700 (PDT) X-Google-Smtp-Source: AKy350YEvD6GodM44UyvARmEWgsoxjnvGZpjgLDMI55yIMcRFmeyJSRPlrJdkdar6nB55IbCgWrP X-Received: by 2002:a17:90b:30c2:b0:247:8ad:d5d4 with SMTP id hi2-20020a17090b30c200b0024708add5d4mr3755713pjb.8.1682042664524; Thu, 20 Apr 2023 19:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682042664; cv=none; d=google.com; s=arc-20160816; b=NrF8DhoPHk8n3Emq4Q1N1yphuuI4gPSn4a+2CeOE82vgOhxb1elWhgO067DS6CUztM m0KB3dp2VAQ+tGLRRFQU1A+Nlz1O3ILk1DdacwvxxP6xWeYyz3J0rg/h3BCI1KaA+dEz NqGMrZb5I0truX38UjmgNVMPIN00aq3cPIe5SIqhY8wuQ8jxf4EpSab10R18Xm0K4ilF sGvdxxWLRm/0JQruerXOjXZaz9MWXRXf/PxbUD2Jdo8l8wf1FgDnojLNxLFm7Y8zRO/N 4UQMOcytkyqHoJdE+k6qFJ3LzOxPRGmUka+4VTdkTolxkoOJ0/Z+AZWiHXWWCT+MTKdE xgtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/f8vrkm2cAJ52260pWJKPwWinmJZRqeY/2FosBMLkWU=; b=xTIsQj1t7i3hfdA/683OZcKVRtWWElqu1H/WRUFKztjUt+ynJUhGQFdNdAuOENuuGE WpgxJPU4hvEhpttBsJU9AoFdfmLY8987NOJIprKHbaDyiHXhJEh4uFnHAc5HZD42C2ic Ykjdlx5DKPPpNAdNk+3XF295AKuGNnJr2ae6QIGhvCGc2c3RpHX0jLyY/eTXsBaVpj2H 6/ZbUsbbpO4C5TsbsF40HrXrUNaU4Fv2Z62luFVyk3hwkPpIQSN2kgc4BFnYvxTXaVBt qbleetKyIE5JSXR3iQ50WaGWaLW6iQVIL8P7I4wo+XdAmdOrGTtqfkUD6gGNiu2nr4F9 nfig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AdWJmUnA; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gd17-20020a17090b0fd100b002308ac7a1b0si3374039pjb.117.2023.04.20.19.04.02; Thu, 20 Apr 2023 19:04:24 -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=AdWJmUnA; 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 S233237AbjDUBw6 (ORCPT + 99 others); Thu, 20 Apr 2023 21:52:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233431AbjDUBwz (ORCPT ); Thu, 20 Apr 2023 21:52:55 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA9C6E92; Thu, 20 Apr 2023 18:52:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682041972; x=1713577972; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=wf2qRT499V++XGkaDgCOEie+m/8H5p5OlkdjwovLSvg=; b=AdWJmUnA02Jv4dxiKHgqnU11+QJg3B8yB+C2fwEO4ttNfstB/hNDyTwI 9i8oSCjkn65U5KK7c/EK3UruWFF6o4z8dVMNZpFb/rdpUuRUVQEsB0kuP WHRq/lISYcW66oWRXJdyZOvkRP+UuRW1ETrByGIhohFSsOWh/QNfckDAY LuR4IbOVejckAJ+ZXiW87h1f1LBT8ygFEBn3lfbhOLmkQRkolo7uxpj5O Gqxt4Oq3wFcnsaBGmnAFVEcLE6qbUKYliZGXNvIrbyR4tif6TS7SKYOcS oHJKyJ39DMMr8yUJvVfCLTixyRkqTHcwoMaqc+NgYQ/D3gTGaBRmiv5Cs g==; X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="348684361" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="348684361" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2023 18:52:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10686"; a="724637676" X-IronPort-AV: E=Sophos;i="5.99,214,1677571200"; d="scan'208";a="724637676" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by orsmga001.jf.intel.com with ESMTP; 20 Apr 2023 18:52:24 -0700 Date: Fri, 21 Apr 2023 17:52:54 +0800 From: Xu Yilun To: Ilpo =?iso-8859-1?Q?J=E4rvinen?= Cc: Wu Hao , Tom Rix , Moritz Fischer , linux-fpga@vger.kernel.org, Lee Jones , Jean Delvare , Guenter Roeck , Russ Weight , linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org Subject: Re: [PATCH v3 2/4] mfd: intel-m10-bmc: Create m10bmc_sys_update_bits() Message-ID: References: <20230417092653.16487-1-ilpo.jarvinen@linux.intel.com> <20230417092653.16487-3-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230417092653.16487-3-ilpo.jarvinen@linux.intel.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 On 2023-04-17 at 12:26:51 +0300, Ilpo J?rvinen wrote: > 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 Acked-by: Xu Yilun > --- > 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 c0b8209fd842..dab1bb152fd6 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 > */ > -- > 2.30.2 >