Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp771284rwb; Wed, 28 Sep 2022 08:56:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HTJxvylgws1XhEK6GQ4rRdtz7bkmiOVQagRv5oR6c2oEfEYqfChu0QNbjAW7hRkh4QFRl X-Received: by 2002:a17:90a:d181:b0:205:e100:3000 with SMTP id fu1-20020a17090ad18100b00205e1003000mr8664495pjb.184.1664380561658; Wed, 28 Sep 2022 08:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664380561; cv=none; d=google.com; s=arc-20160816; b=VNz4nf0OfXeZsyhl5v5OxKN+Brt9ETzJThaIUv+RXlF5CVIUTeNotFpPx3Qc6TViVh qoJukBnaQ1INlXnic2xt7DrxcgF0AyGwykXHQWktATzhyNLRxlt380LS/kZV5Bnq5L74 H5Dwno5yBP8rZqF4oLoLy3Ae5u6F1jbja0wYGTw0YSl4/L8zJ2lvmWfApKqJsTBRefsM dBafpQ6IwgKTsVKuSm3QYk3J0VuppBnsZHFaOt0WmF16Cym2jjv0O884hy3Uzuoroz6R we4DtIBlRQWlsIU50+slEfIZMehWCkGwEKQkI8sHaUAl6kfy6yobvqbM1KVM24YwQapX uD+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=fHSBeyAoGyWTO5wFLOKFDKEJ4mB5euxu2LBuSSah6A4=; b=YoQ3o0QcEo2p4tAB/JRqZ/gGN0WoDVt83cBGoz2Wkl9Leh7/LUzFlmebkXalYb3oa9 VizK/86jt7bOhy6JrPg/Uf2nFsSG7A1wP9W8/iqrnbd12buDVA6HTEkBGCqETg+HyV6H TK4acPVEof0zRlAEiekDZZRwZSJdN0vKUuhGoWhW0++ALLXj7FO7J344j7Tq3yYqnhEu z9buj8Q5Cl6Ar/DFsdCzKqBlKZ0fB3T+LkFm7MsmS9QOgbBIzlKqKjYz19a3nciKxzYG v1nvcErUbtEn08JzojKD4qrbOZEul3pafLK06gMTCwyRFme1jSODwpwkmZr7bLbwNrW/ QT4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JOWulIuB; 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 m2-20020a17090a3f8200b00200b5c30f73si2323281pjc.106.2022.09.28.08.55.48; Wed, 28 Sep 2022 08:56: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=JOWulIuB; 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 S233383AbiI1PpQ (ORCPT + 99 others); Wed, 28 Sep 2022 11:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233659AbiI1PpL (ORCPT ); Wed, 28 Sep 2022 11:45:11 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A0FB7C1F5; Wed, 28 Sep 2022 08:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664379908; x=1695915908; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=L+jkqIsexqlzrYFOaFhwPJa/Gp1nFns+DyV2+D9NJWI=; b=JOWulIuBsr+J0ADIGh2uwt9gyC1Ia35lVwj6a9pOXfRYX0q7cV0zdoFb xmBgp5H4DRpeMrMmp/3+aFqCQv+tG83HrqZcoRdg5F7okr5nuJbSWD7d1 5STNRuN1ovj8xyo0rs1yNWCwPBGiOMPiIXwi4Ruz0dLI8Qo/cmvdY5QyZ 7AOe71HM2wDN2yUIIjgPbo2XnO+2xBOoYfxMtywAyesoilDcQJx5f28Ul RT3pZ1AoSviOKK9IfsotnI0hnUMYpvfl8hWqTX+oy+K0ZSBWqf+wYocf+ P3jOOocKbwJ/fnPsoR/JNa8pSmfgyu8zkqqqPAGXTJsEBIbcrm+SDIcIz Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="284769708" X-IronPort-AV: E=Sophos;i="5.93,352,1654585200"; d="scan'208";a="284769708" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2022 08:45:07 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10484"; a="684454239" X-IronPort-AV: E=Sophos;i="5.93,352,1654585200"; d="scan'208";a="684454239" Received: from djiang5-mobl2.amr.corp.intel.com (HELO [10.212.108.153]) ([10.212.108.153]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2022 08:45:05 -0700 Message-ID: Date: Wed, 28 Sep 2022 08:45:02 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.3.0 Subject: Re: [PATCH v2] cxl: Replace HDM decoder granularity magic numbers Content-Language: en-US To: Adam Manzanares , "alison.schofield@intel.com" , "vishal.l.verma@intel.com" , "ira.weiny@intel.com" , "bwidawsk@kernel.org" , "dan.j.williams@intel.com" , "dave@stgolabs.net" , "Jonathan.Cameron@huawei.com" Cc: "linux-cxl@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20220829220249.243888-1-a.manzanares@samsung.com> From: Dave Jiang In-Reply-To: <20220829220249.243888-1-a.manzanares@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 On 8/29/2022 3:03 PM, Adam Manzanares wrote: > When reviewing the CFMWS parsing code that deals with the HDM decoders, > I noticed a couple of magic numbers. This commit replaces these magic numbers > with constants defined by the CXL 3.0 specification. > > v2: > - Change references to CXL 3.0 specification (David) > - CXL_DECODER_MAX_GRANULARITY_ORDER -> CXL_DECODER_MAX_ENCODED_IG (Dan) > > Signed-off-by: Adam Manzanares Reviewed-by: Dave Jiang > --- > drivers/cxl/cxl.h | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h > index f680450f0b16..3ab81ad9d2e5 100644 > --- a/drivers/cxl/cxl.h > +++ b/drivers/cxl/cxl.h > @@ -61,6 +61,10 @@ > #define CXL_HDM_DECODER0_SKIP_LOW(i) CXL_HDM_DECODER0_TL_LOW(i) > #define CXL_HDM_DECODER0_SKIP_HIGH(i) CXL_HDM_DECODER0_TL_HIGH(i) > > +/* HDM decoder control register constants CXL 3.0 8.2.5.19.7 */ > +#define CXL_DECODER_MIN_GRANULARITY 256 > +#define CXL_DECODER_MAX_ENCODED_IG 6 > + > static inline int cxl_hdm_decoder_count(u32 cap_hdr) > { > int val = FIELD_GET(CXL_HDM_DECODER_COUNT_MASK, cap_hdr); > @@ -71,9 +75,9 @@ static inline int cxl_hdm_decoder_count(u32 cap_hdr) > /* Encode defined in CXL 2.0 8.2.5.12.7 HDM Decoder Control Register */ > static inline int cxl_to_granularity(u16 ig, unsigned int *val) > { > - if (ig > 6) > + if (ig > CXL_DECODER_MAX_ENCODED_IG) > return -EINVAL; > - *val = 256 << ig; > + *val = CXL_DECODER_MIN_GRANULARITY << ig; > return 0; > } > > @@ -96,7 +100,7 @@ static inline int cxl_to_ways(u8 eniw, unsigned int *val) > > static inline int granularity_to_cxl(int g, u16 *ig) > { > - if (g > SZ_16K || g < 256 || !is_power_of_2(g)) > + if (g > SZ_16K || g < CXL_DECODER_MIN_GRANULARITY || !is_power_of_2(g)) > return -EINVAL; > *ig = ilog2(g) - 8; > return 0; > @@ -248,7 +252,6 @@ enum cxl_decoder_type { > */ > #define CXL_DECODER_MAX_INTERLEAVE 16 > > -#define CXL_DECODER_MIN_GRANULARITY 256 > > /** > * struct cxl_decoder - Common CXL HDM Decoder Attributes