Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp907127rdb; Tue, 23 Jan 2024 21:03:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbWWgDVjmpLUPqd/R9zi0fZwztFTQOl8EKzfkeablClr408VsQOSi+n6iVHqBO52+KqlrW X-Received: by 2002:aa7:da09:0:b0:55a:a35:93cf with SMTP id r9-20020aa7da09000000b0055a0a3593cfmr1351439eds.39.1706072592647; Tue, 23 Jan 2024 21:03:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706072592; cv=pass; d=google.com; s=arc-20160816; b=MWd/TO2d25+BkDl2b0yV5Kk8g+X7RU86aM1/c5f13hLJsHgeqZ4bHeOTzGphshXFrX gFt548WHhgB0VXYleSUmrfHRXcDgJgQmywK9KXbbTdhx22WnOvOIN2Ymg9vJBrKrpCy9 23rRl/GdV1Sl9ssTDwRee+Thocx10iHQyRvwT2iLvWlN5gkNMz9us0vtPVbXQq/5/DEC rXpYxIIZ2fTHranvLIpgceHLl0XpdH0LExp8o89J9PXsByB/xOotS51D97V1v3ebr60/ XfBPG227drMrgYToEYW4a393GZjLnpLX0jNqZKHFvLG0wMfcyyFTLKNAcz4joZEHDOMv dbDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fqsMqCW/wWYjuM/HLuH9RgfDyjHwAZQB1sObX3vYq8s=; fh=GrJu7WEKMDCoaMYblymFhfIS8N+GbFr4FHsLoZJFT3E=; b=qEmqlJ36ck9szXoe4/r/jAaHOGKsy7ylyAy/1SFPF1PHDEowpJUyYkHAXLLuwOAP/B 4uvsDHpBxdZ8RAVQwvpGSGJPIsfq3vPXP67TeNKdiTIJmEy68ySOL7OVIgF5kT/BhgJq friI5W3q/eIB6pDkXGqpZ/Y6yHa5UhzNMMCv7k8fMlFmAjtfrXS97QmEBeTy7Kg1Atn4 N9Mfz/H27We7zq7KW2hG5hrMM6Z0Y5hpUGrtHF9QWBJdqXO6LnvAkisf61XUrACEEaC9 GXKvvv4l/eU1VJqqZ5UbP4iD13+89qRB3W6peztM6fOuBQkIhRqFZMpsUh8iDES9TuU2 4Zuw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gTJfdyCe; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-36447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id fk6-20020a056402398600b00559edbb1bd8si7309600edb.219.2024.01.23.21.03.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 21:03:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gTJfdyCe; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-36447-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 45B7F1F220B3 for ; Wed, 24 Jan 2024 05:03:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80FA9101CA; Wed, 24 Jan 2024 05:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gTJfdyCe" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCEC8DDD0 for ; Wed, 24 Jan 2024 05:02:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.55.52.115 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706072550; cv=none; b=tRUXtdb5MLwhmxws5G2GGRZfsOhkrhx1e8lwgiMMvniB2cqpdj5khz67urcIwALkP9PFS9401mRLcRTILEZb/3Ktx91Ge7BPtRbwuPXEgKqFhyD9sbI25VsXu6uz5Pxl6i0YswMXu9+JPwwQOAbMLwmwgbrVNVAACx7T+Rj9K/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706072550; c=relaxed/simple; bh=P8PQBBw9UEqmtPjJgNQPIytPI7cLia4XHiT7U1LD/g0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c3SbLRfJyCQYunBQHKWiOtrVoSEPwcbLPy+BTT1irbOu7HS1yvyVaHxXhz/wI+oGmQQLicWF3yWvps0cx3FWkCGoHKJBbnchTsB+yZaVSK0NoCcDtOgNLDDXOTbi3j3/KgTudrb+bEKpBY5cPAGaY5OZ5wMZIXinZgsWirafvw8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gTJfdyCe; arc=none smtp.client-ip=192.55.52.115 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706072548; x=1737608548; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=P8PQBBw9UEqmtPjJgNQPIytPI7cLia4XHiT7U1LD/g0=; b=gTJfdyCe1czyVvvG0ftDBiRxRro9P5ncWmvCFPSLGNMWPZrgdhBnX8Cx Ze+WOC/r6RYYQlXqdQDi2PLLSArpVRLl4nR4d9aBp1tUtU2iwWOM04IWg G33cgj17Wo4u1Bf/sQGqMxf7hKxSnxU7WggA1C79UqXEAsKvO3b2to5to ijLDB1J+vS6hbKYgW1OVaCyytu2CLyGLFV9Q5zWBlEJjnNSle9Sf8D6LU aStWgYhrGT90CDuU0gmVcyZ0nOsGoDvg95m5QwzobQna5nRsqSc96e3Tm uz15DehU3uMxNcmFmFRk3EwrKqiUQ6Ch/ooHC9iKL5NnGXOPB6NOEBvIv w==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="401399362" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="401399362" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2024 21:02:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="909551512" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="909551512" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2024 21:02:23 -0800 From: Lucas De Marchi To: Yury Norov Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Andy Shevchenko , Jani Nikula , intel-xe@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Lucas De Marchi Subject: [PATCH 3/3] drm/i915: Convert REG_GENMASK* to fixed-width GENMASK_* Date: Tue, 23 Jan 2024 21:02:05 -0800 Message-ID: <20240124050205.3646390-4-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124050205.3646390-1-lucas.demarchi@intel.com> References: <20240124050205.3646390-1-lucas.demarchi@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Now that include/linux/bits.h implements fixed-width GENMASK_*, use them to implement the i915/xe specific macros. Converting each driver to use the generic macros are left for later, when/if other driver-specific macros are also generalized. Signed-off-by: Lucas De Marchi --- drivers/gpu/drm/i915/i915_reg_defs.h | 108 +++------------------------ 1 file changed, 11 insertions(+), 97 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_reg_defs.h b/drivers/gpu/drm/i915/i915_reg_defs.h index a685db1e815d..52f99eb96f86 100644 --- a/drivers/gpu/drm/i915/i915_reg_defs.h +++ b/drivers/gpu/drm/i915/i915_reg_defs.h @@ -9,76 +9,19 @@ #include #include -/** - * REG_BIT() - Prepare a u32 bit value - * @__n: 0-based bit number - * - * Local wrapper for BIT() to force u32, with compile time checks. - * - * @return: Value with bit @__n set. - */ -#define REG_BIT(__n) \ - ((u32)(BIT(__n) + \ - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ - ((__n) < 0 || (__n) > 31)))) - -/** - * REG_BIT8() - Prepare a u8 bit value - * @__n: 0-based bit number - * - * Local wrapper for BIT() to force u8, with compile time checks. - * - * @return: Value with bit @__n set. - */ -#define REG_BIT8(__n) \ - ((u8)(BIT(__n) + \ - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ - ((__n) < 0 || (__n) > 7)))) - -/** - * REG_GENMASK() - Prepare a continuous u32 bitmask - * @__high: 0-based high bit - * @__low: 0-based low bit - * - * Local wrapper for GENMASK() to force u32, with compile time checks. - * - * @return: Continuous bitmask from @__high to @__low, inclusive. - */ -#define REG_GENMASK(__high, __low) \ - ((u32)(GENMASK(__high, __low) + \ - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ - __is_constexpr(__low) && \ - ((__low) < 0 || (__high) > 31 || (__low) > (__high))))) - -/** - * REG_GENMASK64() - Prepare a continuous u64 bitmask - * @__high: 0-based high bit - * @__low: 0-based low bit - * - * Local wrapper for GENMASK_ULL() to force u64, with compile time checks. - * - * @return: Continuous bitmask from @__high to @__low, inclusive. +/* + * Wrappers over the generic BIT_* and GENMASK_* implementations, + * for compatibility reasons with previous implementation */ -#define REG_GENMASK64(__high, __low) \ - ((u64)(GENMASK_ULL(__high, __low) + \ - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ - __is_constexpr(__low) && \ - ((__low) < 0 || (__high) > 63 || (__low) > (__high))))) +#define REG_GENMASK(__high, __low) GENMASK_U32(__high, __low) +#define REG_GENMASK64(__high, __low) GENMASK_U64(__high, __low) +#define REG_GENMASK16(__high, __low) GENMASK_U16(__high, __low) +#define REG_GENMASK8(__high, __low) GENMASK_U8(__high, __low) -/** - * REG_GENMASK8() - Prepare a continuous u8 bitmask - * @__high: 0-based high bit - * @__low: 0-based low bit - * - * Local wrapper for GENMASK() to force u8, with compile time checks. - * - * @return: Continuous bitmask from @__high to @__low, inclusive. - */ -#define REG_GENMASK8(__high, __low) \ - ((u8)(GENMASK(__high, __low) + \ - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ - __is_constexpr(__low) && \ - ((__low) < 0 || (__high) > 7 || (__low) > (__high))))) +#define REG_BIT(__n) BIT_U32(__n) +#define REG_BIT64(__n) BIT_U64(__n) +#define REG_BIT16(__n) BIT_U16(__n) +#define REG_BIT8(__n) BIT_U8(__n) /* * Local integer constant expression version of is_power_of_2(). @@ -143,35 +86,6 @@ */ #define REG_FIELD_GET64(__mask, __val) ((u64)FIELD_GET(__mask, __val)) -/** - * REG_BIT16() - Prepare a u16 bit value - * @__n: 0-based bit number - * - * Local wrapper for BIT() to force u16, with compile time - * checks. - * - * @return: Value with bit @__n set. - */ -#define REG_BIT16(__n) \ - ((u16)(BIT(__n) + \ - BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \ - ((__n) < 0 || (__n) > 15)))) - -/** - * REG_GENMASK16() - Prepare a continuous u8 bitmask - * @__high: 0-based high bit - * @__low: 0-based low bit - * - * Local wrapper for GENMASK() to force u16, with compile time - * checks. - * - * @return: Continuous bitmask from @__high to @__low, inclusive. - */ -#define REG_GENMASK16(__high, __low) \ - ((u16)(GENMASK(__high, __low) + \ - BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \ - __is_constexpr(__low) && \ - ((__low) < 0 || (__high) > 15 || (__low) > (__high))))) /** * REG_FIELD_PREP16() - Prepare a u16 bitfield value -- 2.43.0