From patchwork Mon Aug 19 18:44:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13768870 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 363B9C3DA4A for ; Mon, 19 Aug 2024 18:45:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD9FB10E26F; Mon, 19 Aug 2024 18:45:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="NwZuvR9N"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id A971610E26F; Mon, 19 Aug 2024 18:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724093113; x=1755629113; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kTfCC9csSux6b8n2wu/CXbN22xuAKXGJSDkqdw7YrLc=; b=NwZuvR9NCtw/TfU4YaXYWCdjfieuT4D2mxlMwFWKCDDHI5PoPEmvd9Fl 7cOi2kqBk7jzzvV53xVmVV7RRFYcmW/iVypduDBwIkwmDJMo7Z6QMrtIR DtRQa1A4Z1Ia2JcUg8Kwr7z6mehlA+Pg9W4zIKKUjn18Rz03F2EvYQafe d0zHF4ahGsRrOH0SESK2AtY9OiQ0Y6qRefuDU0JYd2879KLrI8EXUhuo0 PTtPB0glw1RetgJ4rPzsB+MsTE3NX3kkeF95b7YoOEE6/AZbnIJi8h+AZ M+2MrD/clNSdZrhoSOwQ0hiKjEcs3qrHy38sOJHOcTBX9zHlmDs4T94SS Q==; X-CSE-ConnectionGUID: kCM9417kSgOkOTgVai5L9A== X-CSE-MsgGUID: unQWinODRge1KnfnvgNlRw== X-IronPort-AV: E=McAfee;i="6700,10204,11169"; a="26157515" X-IronPort-AV: E=Sophos;i="6.10,159,1719903600"; d="scan'208";a="26157515" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 11:45:13 -0700 X-CSE-ConnectionGUID: 3XECO2avT8aadsydDVScag== X-CSE-MsgGUID: n2r207opRZeRIWFdUvRJRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,159,1719903600"; d="scan'208";a="97940427" Received: from mwiniars-desk2.ger.corp.intel.com (HELO localhost) ([10.245.246.70]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2024 11:45:10 -0700 From: Jani Nikula To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org Cc: jani.nikula@intel.com, rodrigo.vivi@intel.com, lucas.demarchi@intel.com, ville.syrjala@linux.intel.com Subject: [PATCH v2 5/9] drm/i915/display: add platforms "is" member to struct intel_display Date: Mon, 19 Aug 2024 21:44:32 +0300 Message-Id: <7219e172b99401458ef6783c67b0b47115c6e772.1724092799.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Facilitate using display->is.HASWELL and display->is.HASWELL_ULT etc. for identifying platforms and subplatforms. Merge platform and subplatform members together. v2: - Use bitmap ops - Add some sanity checks with warnings Signed-off-by: Jani Nikula Reviewed-by: Rodrigo Vivi --- .../gpu/drm/i915/display/intel_display_core.h | 3 ++ .../drm/i915/display/intel_display_device.c | 31 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h index 0a711114ff2b..b2907894fa28 100644 --- a/drivers/gpu/drm/i915/display/intel_display_core.h +++ b/drivers/gpu/drm/i915/display/intel_display_core.h @@ -286,6 +286,9 @@ struct intel_display { /* drm device backpointer */ struct drm_device *drm; + /* Platform (and subplatform, if any) identification */ + struct intel_display_platforms is; + /* Display functions */ struct { /* Top level crtc-ish functions */ diff --git a/drivers/gpu/drm/i915/display/intel_display_device.c b/drivers/gpu/drm/i915/display/intel_display_device.c index 55ab1923c8b3..3d3b4ed7940e 100644 --- a/drivers/gpu/drm/i915/display/intel_display_device.c +++ b/drivers/gpu/drm/i915/display/intel_display_device.c @@ -1269,8 +1269,28 @@ find_subplatform_desc(struct pci_dev *pdev, const struct platform_desc *desc) return NULL; } +/* Size of the entire bitmap, not the number of platforms */ +static unsigned int display_platforms_num_bits(void) +{ + return sizeof(((struct intel_display_platforms *)0)->bitmap) * BITS_PER_BYTE; +} + +/* Number of platform bits set */ +static unsigned int display_platforms_weight(const struct intel_display_platforms *p) +{ + return bitmap_weight(p->bitmap, display_platforms_num_bits()); +} + +/* Merge the subplatform information from src to dst */ +static void display_platforms_or(struct intel_display_platforms *dst, + const struct intel_display_platforms *src) +{ + bitmap_or(dst->bitmap, dst->bitmap, src->bitmap, display_platforms_num_bits()); +} + void intel_display_device_probe(struct drm_i915_private *i915) { + struct intel_display *display = &i915->display; struct pci_dev *pdev = to_pci_dev(i915->drm.dev); const struct intel_display_device_info *info; struct intel_display_ip_ver ip_ver = {}; @@ -1306,13 +1326,20 @@ void intel_display_device_probe(struct drm_i915_private *i915) &DISPLAY_INFO(i915)->__runtime_defaults, sizeof(*DISPLAY_RUNTIME_INFO(i915))); - drm_WARN_ON(&i915->drm, !desc->platform || !desc->name); + drm_WARN_ON(&i915->drm, !desc->platform || !desc->name || + display_platforms_weight(&desc->platforms) != 1); DISPLAY_RUNTIME_INFO(i915)->platform = desc->platform; + display->is = desc->platforms; subdesc = find_subplatform_desc(pdev, desc); if (subdesc) { - drm_WARN_ON(&i915->drm, !subdesc->subplatform || !subdesc->name); + drm_WARN_ON(&i915->drm, !subdesc->subplatform || !subdesc->name || + display_platforms_weight(&subdesc->platforms) != 1); DISPLAY_RUNTIME_INFO(i915)->subplatform = subdesc->subplatform; + display_platforms_or(&display->is, &subdesc->platforms); + + /* Ensure platform and subplatform are distinct */ + drm_WARN_ON(&i915->drm, display_platforms_weight(&subdesc->platforms) == 1); } if (ip_ver.ver || ip_ver.rel || ip_ver.step)