Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1017775imw; Wed, 13 Jul 2022 12:14:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s8r/wpuYFMabu4Tt72euGF5Mdta+ug/XEJDMi3ki7c2ediZ1DHAuLJ3nr+K+mBhUK49mjg X-Received: by 2002:a17:907:7b92:b0:72b:67fb:8985 with SMTP id ne18-20020a1709077b9200b0072b67fb8985mr4683906ejc.569.1657739641090; Wed, 13 Jul 2022 12:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657739641; cv=none; d=google.com; s=arc-20160816; b=MXrSR2o7fGHKQhdNnvLzftfR+nMfrPYbYG1qmCHzFJ9HD1z4w5DghWJqe8YMnBVihq WjOPNnxYslSVzsLIi9COfclVQEKzV2vqslKj+zP0hgUpA7xx6nK4v50DEfJegidvc5/0 cpbhWLKK4qzpPjtSitVaIZGaUf2RBqk0F/ZcoNVthKreH0JIMGrMtpqVJZLsj94E/SZ0 oWrQ3khtHTh13oTrcZ3Hms9smAn5f5GW1BvTZ07fg85ATeQxw5cutmM03QQkJBm0HX2L POtRbTCF6Sr2qn5ByxyszyWZk9Ox+4t/RPZemCzSrILsY8nYacHHSL4n3dQ6/0QHO1Js PmrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=5aekaPOwcHhzeYxqavxdIOs4PfpSzqjGO/pe0nIjmN8=; b=UiiD+bEj/Jrt9euU36zZ6ftURb8eWOo5XE2LxwcJZTDEZZI6dSiklk/SnzLdpkfNaK ajkJs2EAq0UaDEkTaBrqfIQiLkxnsPjbQyTdYPspop1zb4uNyJ2qvhXN+t95GiMhIsF6 JZZmogLoGoHL2xEmyEi91teBxqoXEnNH+XvQRAdeikvajsvY56xuFjmOE0u1wSNRUm0k 1trURqja1HQFO9WoSM8gWh5w7mwOgkY/lDw49UbY9igf1GCxeybeo0Ow+uh6c4bNFkt6 Y1YCgCmM9277WwJ0QfZomdWgtKPAHc0Rl+JiDy969FIyxGPqpKEuQqDt/bdqkn6gfSK4 wbWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UFJZIRsw; 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 z2-20020a056402274200b004396b724878si7228913edd.441.2022.07.13.12.13.35; Wed, 13 Jul 2022 12:14: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=UFJZIRsw; 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 S236680AbiGMTGt (ORCPT + 99 others); Wed, 13 Jul 2022 15:06:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236359AbiGMTGs (ORCPT ); Wed, 13 Jul 2022 15:06:48 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2135D2CE16; Wed, 13 Jul 2022 12:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657739207; x=1689275207; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=KHsybcTTtmSjs79flHrFsftHV7qrjOVYH+3rw2fKiEM=; b=UFJZIRswcaiVQdOQeZk4q1op5sURCc7cd7taL+Q/wRFII/dFl0javkCm jRpFIef1acOkaULnj0sTm6A0GtKGiAq4R6q+ZfYsY06wzr9rIDa5dfmww oGPZihmo/+WrM6av2PNuiwwko560OysIA++P3X1Dw0GSuobyZf5+5EJC5 b4/eu3PoVJU2Cic0Ed9HH/p/nlZ3STVDG+L3BpBQ6IhbqmqZNa172U6rK bHl3zkNcbF97AxbEwjPzYwLHzTfLBs6Ux5N9lK4gxMmyvqbshJCkZ6FH5 vYvxV3yefUzMAWmNKJJlrWdaTdSkcfyhgcf+AOIdv5RZ7HXcl9+ISqy3P Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10407"; a="310965300" X-IronPort-AV: E=Sophos;i="5.92,267,1650956400"; d="scan'208";a="310965300" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2022 12:06:46 -0700 X-IronPort-AV: E=Sophos;i="5.92,267,1650956400"; d="scan'208";a="922763254" Received: from rhweight-wrk1.ra.intel.com ([137.102.106.43]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2022 12:06:46 -0700 Date: Wed, 13 Jul 2022 12:06:39 -0700 (PDT) From: matthew.gerlach@linux.intel.com X-X-Sender: mgerlach@rhweight-WRK1 To: Tianfei Zhang cc: ssantosh@kernel.org, krzysztof.kozlowski@linaro.org, trix@redhat.com, yilun.xu@intel.com, russell.h.weight@intel.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, Debarati Biswas Subject: Re: [PATCH v2] memory: dfl-emif: Update the dfl emif driver support revision 1 In-Reply-To: <20220713130355.196115-1-tianfei.zhang@intel.com> Message-ID: References: <20220713130355.196115-1-tianfei.zhang@intel.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Wed, 13 Jul 2022, Tianfei Zhang wrote: > From: Debarati Biswas > > The next generation (revision 1) of the DFL EMIF feature device requires > support for more than 4 memory banks. It does not support the selective > clearing of memory banks. A capability register replaces the previous > control register, and contains a bitmask to indicate the presence of each > memory bank. This bitmask aligns with the previous control register > bitmask that served the same purpose. The control and capability > registers are treated like a C Union structure in order to support both > the new and old revisions of the EMIF device. > > Signed-off-by: Debarati Biswas > Signed-off-by: Russ Weight > Signed-off-by: Tianfei Zhang Reviewed-by: Matthew Gerlach > --- > v2: no code change, just rebased to v5.19-rc6. > --- > drivers/memory/dfl-emif.c | 62 +++++++++++++++++++++++++++++++++++---- > 1 file changed, 57 insertions(+), 5 deletions(-) > > diff --git a/drivers/memory/dfl-emif.c b/drivers/memory/dfl-emif.c > index 3f719816771d..da06cd30a016 100644 > --- a/drivers/memory/dfl-emif.c > +++ b/drivers/memory/dfl-emif.c > @@ -24,11 +24,24 @@ > #define EMIF_STAT_CLEAR_BUSY_SFT 16 > #define EMIF_CTRL 0x10 > #define EMIF_CTRL_CLEAR_EN_SFT 0 > -#define EMIF_CTRL_CLEAR_EN_MSK GENMASK_ULL(3, 0) > +#define EMIF_CTRL_CLEAR_EN_MSK GENMASK_ULL(7, 0) > > #define EMIF_POLL_INVL 10000 /* us */ > #define EMIF_POLL_TIMEOUT 5000000 /* us */ > > +/* > + * The Capability Register replaces the Control Register (at the same > + * offset) for EMIF feature revisions > 0. The bitmask that indicates > + * the presence of memory channels exists in both the Capability Register > + * and Control Register definitions. These can be thought of as a C union. > + * The Capability Register definitions are used to check for the existence > + * of a memory channel, and the Control Register definitions are used for > + * managing the memory-clear functionality in revision 0. > + */ > +#define EMIF_CAPABILITY_BASE 0x10 > +#define EMIF_CAPABILITY_CHN_MSK_V0 GENMASK_ULL(3, 0) > +#define EMIF_CAPABILITY_CHN_MSK GENMASK_ULL(7, 0) > + > struct dfl_emif { > struct device *dev; > void __iomem *base; > @@ -106,16 +119,30 @@ emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 0); > emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 1); > emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 2); > emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 3); > +emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 4); > +emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 5); > +emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 6); > +emif_state_attr(init_done, EMIF_STAT_INIT_DONE_SFT, 7); > > emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 0); > emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 1); > emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 2); > emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 3); > +emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 4); > +emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 5); > +emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 6); > +emif_state_attr(cal_fail, EMIF_STAT_CALC_FAIL_SFT, 7); > + > > emif_clear_attr(0); > emif_clear_attr(1); > emif_clear_attr(2); > emif_clear_attr(3); > +emif_clear_attr(4); > +emif_clear_attr(5); > +emif_clear_attr(6); > +emif_clear_attr(7); > + > > static struct attribute *dfl_emif_attrs[] = { > &emif_attr_inf0_init_done.attr.attr, > @@ -134,6 +161,22 @@ static struct attribute *dfl_emif_attrs[] = { > &emif_attr_inf3_cal_fail.attr.attr, > &emif_attr_inf3_clear.attr.attr, > > + &emif_attr_inf4_init_done.attr.attr, > + &emif_attr_inf4_cal_fail.attr.attr, > + &emif_attr_inf4_clear.attr.attr, > + > + &emif_attr_inf5_init_done.attr.attr, > + &emif_attr_inf5_cal_fail.attr.attr, > + &emif_attr_inf5_clear.attr.attr, > + > + &emif_attr_inf6_init_done.attr.attr, > + &emif_attr_inf6_cal_fail.attr.attr, > + &emif_attr_inf6_clear.attr.attr, > + > + &emif_attr_inf7_init_done.attr.attr, > + &emif_attr_inf7_cal_fail.attr.attr, > + &emif_attr_inf7_clear.attr.attr, > + > NULL, > }; > > @@ -143,15 +186,24 @@ static umode_t dfl_emif_visible(struct kobject *kobj, > struct dfl_emif *de = dev_get_drvdata(kobj_to_dev(kobj)); > struct emif_attr *eattr = container_of(attr, struct emif_attr, > attr.attr); > + struct dfl_device *ddev = to_dfl_dev(de->dev); > u64 val; > > /* > - * This device supports upto 4 memory interfaces, but not all > + * This device supports up to 8 memory interfaces, but not all > * interfaces are used on different platforms. The read out value of > - * CLEAN_EN field (which is a bitmap) could tell how many interfaces > - * are available. > + * CAPABILITY_CHN_MSK field (which is a bitmap) indicates which > + * interfaces are available. > */ > - val = FIELD_GET(EMIF_CTRL_CLEAR_EN_MSK, readq(de->base + EMIF_CTRL)); > + if (ddev->revision > 0 && strstr(attr->name, "_clear")) > + return 0; > + > + if (ddev->revision == 0) > + val = FIELD_GET(EMIF_CAPABILITY_CHN_MSK_V0, > + readq(de->base + EMIF_CAPABILITY_BASE)); > + else > + val = FIELD_GET(EMIF_CAPABILITY_CHN_MSK, > + readq(de->base + EMIF_CAPABILITY_BASE)); > > return (val & BIT_ULL(eattr->index)) ? attr->mode : 0; > } > -- > 2.26.2 > >