From patchwork Mon Dec 16 15:46:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sebastian Brzezinka X-Patchwork-Id: 13909922 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 D8C98E77180 for ; Mon, 16 Dec 2024 15:46:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4588A10E6DD; Mon, 16 Dec 2024 15:46:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="GehGl2Bh"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC42910E6DD for ; Mon, 16 Dec 2024 15:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1734364019; x=1765900019; h=date:from:to:cc:subject:message-id: content-transfer-encoding:mime-version; bh=WO4+7y4A1Z1vjYpLq7YCujbHylFxnVtebJLvjxJuZ7E=; b=GehGl2BhqkYq5HYyKwnZQDNmzOV7fLzsx0QTRlC8FJisYzlv10xnJASz o+Cip4x5dFqQqH53RabBga5kYWlzayPwAhmr4pYeIhg7SZ9t4HHPdgtsC 4FQcoHzz4PMda0TkKtsvPwfTjNSo8HqhhNkDadkJ9HXWsVoYgc4hGtAnD P0PHn6UcNK4SvZBtQiIBVP+Ux1oJ4FT0xj2UDh1ixyR4vr8EsLChtKqd4 ryXYkAG4gZBGfArBSJ/8Ay58CgoztcR1qWUH8+6WuFqeXyB4h5FkRwGhX LEX36eYJ/WYh2uvP3ATdIBD5bpsjQnst9Depy9sYW12v3feJC4CdR0cl2 A==; X-CSE-ConnectionGUID: Ricj8GQkSYKmYhorR4kOmA== X-CSE-MsgGUID: IzJ29K9ATjS187AqYvJSjw== X-IronPort-AV: E=McAfee;i="6700,10204,11282"; a="45758610" X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="45758610" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Dec 2024 07:46:59 -0800 X-CSE-ConnectionGUID: 9UoWMPItSFS8rdCs/8ZOXg== X-CSE-MsgGUID: rFtU/CK7QV2B8WZLK8KbYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,239,1728975600"; d="scan'208";a="97666502" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa010.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 16 Dec 2024 07:46:58 -0800 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Mon, 16 Dec 2024 07:46:57 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44 via Frontend Transport; Mon, 16 Dec 2024 07:46:57 -0800 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.49) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.44; Mon, 16 Dec 2024 07:46:56 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=QlJwCCMY99WG0DD/SCPkHh/aW/JW+9NFK81fCIqAutGIgy+YMIzR/YksjHQS+7oebkgmED+8ASdWHsik4wad/OK2TTwk7SoYlju9QTb3vo5lHOAUHRD3g3SRY11KKcpTHaEnlb/zJOsZnq6cs6O3zfzh4vUA3pXQLSzpvwqRu7mHHNXC/kaDl5Hr31uRAH3ugQplSr8XKyfCc27ih0Ip2x6481XaECT8+FEDbAxa4JCynwqMCoZ1X+77H+xHp+th624B480AMc1ICak9Vw6LVqr1Ni4Y7ORSyEKsAf+uyolMFDmcBueRXilxHjcKAG/hqPv/hKnKhkHNSLmGu19V9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3xuL/eLIP7b5DKwyrAxclZOSG7zOVRcmW9TGG24V/ig=; b=DkXi0prep0WepNOLnyrVsBlhBBBtT+a8n8Ce9aVKwMWhYJpmOuE0iSxusEz117GQlaLcDI8AjNHSwVWUQxPX/5i8fqo4+2RC/882DQTZJjC1COtGActz++DKgoDAQX7x40P8gt88Jx+dr+GtNojZuiTPJ/UG0cKwzUuEG/4yzi8e15GvQCmriGJsPBeTWT/hOUIkpDQsKyDvT+oKKYSVQESLQ02yMe7+6WQVGcPZF9ztkAlR1Zl218wG+1d8gJMHcnkdWuPf4w6PWMi5MSzat9cL8/mMAIp4SMOhYSUYsT/LycfCCAyU2HLMGCdPGV6OgEa5f3aBKouapK/VjdY1oQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MW4PR11MB6909.namprd11.prod.outlook.com (2603:10b6:303:224::12) by DM3PR11MB8734.namprd11.prod.outlook.com (2603:10b6:8:1af::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.20; Mon, 16 Dec 2024 15:46:53 +0000 Received: from MW4PR11MB6909.namprd11.prod.outlook.com ([fe80::28da:9438:a3ef:19c0]) by MW4PR11MB6909.namprd11.prod.outlook.com ([fe80::28da:9438:a3ef:19c0%6]) with mapi id 15.20.8251.015; Mon, 16 Dec 2024 15:46:53 +0000 Date: Mon, 16 Dec 2024 15:46:49 +0000 From: Sebastian Brzezinka To: CC: , , Subject: [PATCH v2] i915/gt: Reapply workarounds in case the previous attempt failed. Message-ID: <752zde6fl47boamqiccdhz2wmkxoee5rmzqucphvglhs53bclz@jlv5clqnxngh> Content-Disposition: inline X-ClientProxiedBy: DUZP191CA0061.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4fa::16) To MW4PR11MB6909.namprd11.prod.outlook.com (2603:10b6:303:224::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR11MB6909:EE_|DM3PR11MB8734:EE_ X-MS-Office365-Filtering-Correlation-Id: b2d2ee15-8e80-4a9c-1d1f-08dd1de8dd1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?q?CX5ELzsvpKqGTSf2+gasP6iXoUAvqz5?= =?utf-8?q?bYPbnuCSXek5n053HXYNJc9uLf5GSAZ1WNhzhCGwIz9d9dMHlJaxlt785IaLl4Fkk?= =?utf-8?q?BSlmy/uFAjVol35BFajH/NworQPpkO8TTEznoK522GK+VHFZvQrog/StWaon7R+Zl?= =?utf-8?q?xRozCIOCmf65cQ8aE4bD5t4KKCRhpd+grBPwL+ZmdC4CGaMVjoW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kN17O?= =?utf-8?q?QkguMK5tgYTkxBFKec8Lii7ZBFwpQb9ZnfuzGB80fEjLc4bT8THC1B8JaDHYvo2nW?= =?utf-8?q?mDYkngP2P6oHdvttAGZzql10Do4Wp4Fg+aBrbzHX4hY8idW6KaZuDjgTpA6qAwU/H?= =?utf-8?q?4jWKAL4kx+tnhNWmWNpDLSmh/MBP2TYMVYN+4SoqllfC1X+DYPtL1W0LizYyiJa58?= =?utf-8?q?QIWAUIrstrbBo+3D7cKml0CnV4nP13Yn5wQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR11MB6909.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ltyh76M249+RJaBqZwMc7/wRnjXU?= =?utf-8?q?DdBwpqVOnsSG1VJhYnvsSfwijM2Mu8EtSTG3IhSjS/aj2RHrJDwo7HjKFsfB2IjoT?= =?utf-8?q?RkLPHcqzDcCixoXRdczqxJtF31aMOkTqzi4I28GiG7tJ66oHMnP7zYFPVfdCV4MOk?= =?utf-8?q?cvm8xSlJn2HkowLMZHGb3FINnq64D92OrrNqqI+yanLu0ZY3Dt4kz9shbr6vVX68M?= =?utf-8?q?E4ji3SZsTeEx4XY6kXtX7P/vwCu+bHNzU2Jk0rOyY0oShqVWZWqb2jBlLGfYoXGWD?= =?utf-8?q?6WjlqbuVBIqtwkNO+I2dSwxAUPODskE6eVuNSmIsT3Q2uKMarapZRgJruQ2ONbWUz?= =?utf-8?q?jLXp7O00jOQwAHY4dJbwMQhA9DiBliNkfmO3caTfqI28xeNIX68FDuqan3AhCF2BJ?= =?utf-8?q?SbTnnajf9frC6XdRlZ62l6YNA6mQZ9h704oz7pJYUVu+s4qD0jhRMmiWJx6l9Qvv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?= =?utf-8?q?rpCQAlpjVcRGs+uk4JwI27wnZsXvpDRvE7qnJo6ImPSQG595kaE96ZA656p4vwipe?= =?utf-8?q?W1sm4NsCmNMVMkdlTYgrsB/bu+gDNUYScQixSPeTo/ngQT74gmzXBTnaR4SPKnYyE?= =?utf-8?q?v3M2sHBFYv1HQXfeO6Ocw1KU5xG35g/LY94S7x7XT5k3uzX+e1lD4+ZSQAetGg7gv?= =?utf-8?q?2XdM/KGBaK4EJMuk1AkIzmGYTBLtCvitXQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b2d2ee15-8e80-4a9c-1d1f-08dd1de8dd1f X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB6909.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 15:46:53.7387 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sscBT6/MTMnFxV+9ttWy3p6dn+62UW7pVvXPqfPkxrrd3szI84EbC7642Q0pMcY7CUgnTKoH6lFBss8J5JfyiHDnyvczFziacKDq4kP2kzI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR11MB8734 X-OriginatorOrg: intel.com 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" `wa_verify`sporadically detects lost workaround on application; this is unusual behavior since wa are applied at `intel_gt_init_hw` and verified right away by `intel_gt_verify_workarounds`, and  `wa_verify` doesn't fail on initialization as one might suspect would happen. One approach that may be somewhat beneficial is to reapply workarounds in the event of failure, or even get rid of verify on application, since it's redundant to `intel_gt_verify_workarounds`. v2: Remove duplicate code, move workarounds read/write to separated functions. Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12668 Signed-off-by: Sebastian Brzezinka --- drivers/gpu/drm/i915/gt/intel_workarounds.c | 60 ++++++++++++--------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c index 570c91878189..c0bf909afe8e 100644 --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c @@ -1722,6 +1722,30 @@ wa_verify(struct intel_gt *gt, const struct i915_wa *wa, u32 cur, return true; } +static u32 wa_read_fw(struct intel_gt *gt, struct i915_wa *wa) +{ + return wa->is_mcr ? intel_gt_mcr_read_any_fw(gt, wa->mcr_reg) : + intel_uncore_read_fw(gt->uncore, wa->reg); + +} + +static void wa_write_fw(struct intel_gt *gt, struct i915_wa *wa) +{ + u32 val, old = 0; + + /* open-coded rmw due to steering */ + if (wa->clr) + old = wa_read_fw(gt, wa); + + val = (old & ~wa->clr) | wa->set; + if (val != old || !wa->clr) { + if (wa->is_mcr) + intel_gt_mcr_multicast_write_fw(gt, wa->mcr_reg, val); + else + intel_uncore_write_fw(gt->uncore, wa->reg, val); + } +} + static void wa_list_apply(const struct i915_wa_list *wal) { struct intel_gt *gt = wal->gt; @@ -1741,28 +1765,17 @@ static void wa_list_apply(const struct i915_wa_list *wal) intel_uncore_forcewake_get__locked(uncore, fw); for (i = 0, wa = wal->list; i < wal->count; i++, wa++) { - u32 val, old = 0; - - /* open-coded rmw due to steering */ - if (wa->clr) - old = wa->is_mcr ? - intel_gt_mcr_read_any_fw(gt, wa->mcr_reg) : - intel_uncore_read_fw(uncore, wa->reg); - val = (old & ~wa->clr) | wa->set; - if (val != old || !wa->clr) { - if (wa->is_mcr) - intel_gt_mcr_multicast_write_fw(gt, wa->mcr_reg, val); - else - intel_uncore_write_fw(uncore, wa->reg, val); - } - - if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM)) { - u32 val = wa->is_mcr ? - intel_gt_mcr_read_any_fw(gt, wa->mcr_reg) : - intel_uncore_read_fw(uncore, wa->reg); + /* + * Writing workarounds can sporadically fail, + * in which case try to apply it again. + */ + uint repeat = 1; - wa_verify(gt, wa, val, wal->name, "application"); - } + do { + wa_write_fw(gt, wa); + } while (!wa_verify(gt, wa, wa_read_fw(gt, wa), wal->name, + "application") + && repeat--); } intel_uncore_forcewake_put__locked(uncore, fw); @@ -1793,9 +1806,8 @@ static bool wa_list_verify(struct intel_gt *gt, intel_uncore_forcewake_get__locked(uncore, fw); for (i = 0, wa = wal->list; i < wal->count; i++, wa++) - ok &= wa_verify(wal->gt, wa, wa->is_mcr ? - intel_gt_mcr_read_any_fw(gt, wa->mcr_reg) : - intel_uncore_read_fw(uncore, wa->reg), + ok &= wa_verify(wal->gt, wa, + wa_read_fw(wal->gt, wa), wal->name, from); intel_uncore_forcewake_put__locked(uncore, fw);