From patchwork Mon Aug 22 17:05:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Manzanares X-Patchwork-Id: 12950959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EF11C28D13 for ; Mon, 22 Aug 2022 17:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235953AbiHVRGA (ORCPT ); Mon, 22 Aug 2022 13:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235132AbiHVRF7 (ORCPT ); Mon, 22 Aug 2022 13:05:59 -0400 Received: from mailout1.w2.samsung.com (mailout1.w2.samsung.com [211.189.100.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B24CA3ECD1; Mon, 22 Aug 2022 10:05:56 -0700 (PDT) Received: from uscas1p2.samsung.com (unknown [182.198.245.207]) by mailout1.w2.samsung.com (KnoxPortal) with ESMTP id 20220822170553usoutp0110887cd4535a13af7f67c00824a28d34~NuaRoeXj_2782127821usoutp01-; Mon, 22 Aug 2022 17:05:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w2.samsung.com 20220822170553usoutp0110887cd4535a13af7f67c00824a28d34~NuaRoeXj_2782127821usoutp01- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1661187953; bh=Bnxw5tMzchxMfhsqVWLqqRcZgO5MyayK/AJWfjtP/qo=; h=From:To:CC:Subject:Date:References:From; b=katzimIeGn2ViS84TTfFXch/X1YmrdG5+sQJwSFYoXK0QzodJV2/ERTu0VyX21W61 LztUHJAIluTTUF0tlNWPu9/1iuaUnOb6gyU3KYfuPz5tVKjuNBQ2Vyjs2bu2BN841l hUANwiC2Ca/sE7VsgBtajPgwURSlSwVA6srBLT/s= Received: from ussmges1new.samsung.com (u109.gpu85.samsung.co.kr [203.254.195.109]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20220822170552uscas1p1be94269293097026847ed264b653c2d8~NuaRQQ--V2902129021uscas1p1A; Mon, 22 Aug 2022 17:05:52 +0000 (GMT) Received: from uscas1p1.samsung.com ( [182.198.245.206]) by ussmges1new.samsung.com (USCPEMTA) with SMTP id 71.2C.65516.077B3036; Mon, 22 Aug 2022 13:05:52 -0400 (EDT) Received: from ussmgxs1new.samsung.com (u89.gpu85.samsung.co.kr [203.254.195.89]) by uscas1p1.samsung.com (KnoxPortal) with ESMTP id 20220822170552uscas1p1b1ee530bf38a14806010d65d1b593ab0~NuaQ9bHrZ2964029640uscas1p1H; Mon, 22 Aug 2022 17:05:52 +0000 (GMT) X-AuditID: cbfec36d-5b5ff7000000ffec-79-6303b770e120 Received: from SSI-EX3.ssi.samsung.com ( [105.128.2.146]) by ussmgxs1new.samsung.com (USCPEXMTA) with SMTP id F2.E3.59738.077B3036; Mon, 22 Aug 2022 13:05:52 -0400 (EDT) Received: from SSI-EX3.ssi.samsung.com (105.128.2.228) by SSI-EX3.ssi.samsung.com (105.128.2.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2375.24; Mon, 22 Aug 2022 10:05:51 -0700 Received: from SSI-EX3.ssi.samsung.com ([105.128.5.228]) by SSI-EX3.ssi.samsung.com ([105.128.5.228]) with mapi id 15.01.2375.024; Mon, 22 Aug 2022 10:05:51 -0700 From: Adam Manzanares To: "alison.schofield@intel.com" , "vishal.l.verma@intel.com" , "ira.weiny@intel.com" , "widawsk@kernel.org" , "dan.j.williams@intel.com" CC: "dave@stgolabs.net" , "Jonathan.Cameron@huawei.com" , "linux-cxl@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Adam Manzanares Subject: [PATCH] cxl: Replace HDM decoder granularity magic numbers Thread-Topic: [PATCH] cxl: Replace HDM decoder granularity magic numbers Thread-Index: AQHYtklu6j3UH4AVtU69YQX5WSmWHw== Date: Mon, 22 Aug 2022 17:05:51 +0000 Message-ID: <20220822170510.125082-1-a.manzanares@samsung.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [105.128.2.176] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFKsWRmVeSWpSXmKPExsWy7djXc7oF25mTDfr+GlvcfXyBzWL61AuM FqtvrmG02P/0OYvFqoXX2CzOzzrFYnF51xw2i1sTjjFZbH4wmcmB06PlyFtWj8V7XjJ5bFrV yeYxdXa9x+dNcgGsUVw2Kak5mWWpRfp2CVwZb6/tYSl4wFfxqHstawPjNJ4uRk4OCQETiS0d Pxm7GLk4hARWMkps2L6bHcJpZZJ43r+MBaZq8sQHUFVrGSV+vrvJBuF8YpQ4+OQcK4SzjFFi 48kedpAWNgEDid/HNzKD2CICnUwS3TckQWxmgUlMEjObs7oYOTiEBZwlfl1RhyjxkDg0/yYL hK0nMen7NDYQm0VAVaJ97XewOK+AnUTb3seMIDajgJjE91NrmCBGikvcejKfCeJSQYlFs/cw Q9hiEv92PWSDsBUl7n9/yQ5RrydxY+oUNghbW2LZwtfMEPMFJU7OfAL1saTEwRU3WED+khDY wyGx5N9tVoiEi8SnLfehbGmJq9enMkMUtTNKfJiwjxXCmcAoceftT6jV1hL/Oq9BreaT+Pvr ESPI9xICvBIdbUITGJVmIXliFpIDZyE5cBaSAxcwsqxiFC8tLs5NTy02zEst1ytOzC0uzUvX S87P3cQITE6n/x3O3cG449ZHvUOMTByMhxglOJiVRHirLzIkC/GmJFZWpRblxxeV5qQWH2KU 5mBREuddlrkhUUggPbEkNTs1tSC1CCbLxMEp1cCUZ2Rk+eVoS/MG5Yf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IsKOfTV1+0rWCO2efEHawi19t131W/uT 97y51RI7WrQmnLt5f5HiARP7BK6jPre1Mm99v/T3qkOFRMOW/T93cfJ9+riHm7HiqHXoDCcV TtmSj2UNV5pmRNSdPNokbjfTUWN171SFRYq/9Iz5EyftYz5WcePXa2cGl3nrpprd7f5vuXiy 9EErn/lp1r+0u32yTzLo71IR7z1Vertr6/KWBeEf3r/Zr1A2Xz5A4dmSy0pV93e/MLHxT7Iu +MQ4d7n6y7if02z6bCfnzzbav/qWwVO72I5fdzukBWTPHD93X1HOTV2JpTgj0VCLuag4EQAB HMF+NQMAAA== X-CMS-MailID: 20220822170552uscas1p1b1ee530bf38a14806010d65d1b593ab0 CMS-TYPE: 301P X-CMS-RootMailID: 20220822170552uscas1p1b1ee530bf38a14806010d65d1b593ab0 References: Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org 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 2.0 specification. Signed-off-by: Adam Manzanares --- 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..ba3a66b5b9cd 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 2.0 8.2.5.12.7 */ +#define CXL_DECODER_MIN_GRANULARITY 256 +#define CXL_DECODER_MAX_GRANULARITY_ORDER 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_GRANULARITY_ORDER) 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