From nobody Tue Nov 26 04:35:28 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) (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 A759519DF44 for ; Tue, 22 Oct 2024 10:54:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729594442; cv=none; b=onLXXLHhPMjUK9X1ueVLVo8KZ86SqZhCidfbcBQ8tpxq9gQilPXG5gZpTTSV/w1irGmoGZ/5OAHxivgFXdieEytA2564EH5cX4SREDZyOKTt4VRJ/8L7Wi0dTUC8DDDZrG9d4zhDd6Vuin16IBcStI3NxWap3/v+tzxqXcj/9nA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729594442; c=relaxed/simple; bh=LTQxSt5Px9IozrANOPhprQ5ndNLgnhwoRB2kKrG/R8o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YdSrLmFR9DQls4tcRpRG+BcD/2gNiqvMaQcQeo5SHVEaP6Fw6CD/P2staahrMGwlpL2Y/PsxXyBK1vnGWwE6K1vgJX5iLz/HwySz5Xa6cKgUwm6O0US3wh163C5a/E11AP9K6HKkkCsnicAi/kM1c8oYLP3mvkHwF8K6wqFNLK4= 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=B84ndPZJ; arc=none smtp.client-ip=192.198.163.11 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="B84ndPZJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729594441; x=1761130441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LTQxSt5Px9IozrANOPhprQ5ndNLgnhwoRB2kKrG/R8o=; b=B84ndPZJvbgleNaTQQ6Oz8toaxkOj4ebsRnYE63Ttb73GNP35e4eCZia X6K1yxoS7kR+F3dyDbw5eNGXqP66fZ+UT14kp0Zk7d0MEdo7VNLP7Rwj2 +yZojJRDNGnVQWeimQVKySDuEyISt1T8NVQpVU5KxGbm53slnRHuoTMjp zwu1Yr87VrQiBw/Hl629qesf07P/xDNSzkpfh0A3lqP95xTC0RgtqgTky Ufp0ncwpI3ZPbloAjQBRswXlTsjU+QMJAl3KOfwmVHs25InKAR9fxHuuu 2FTtdCSMRhuL4WHgZVtA09UWQ0vkg5s7ahzg8OYD4/tg8iwo6Pc8weSqZ w==; X-CSE-ConnectionGUID: X95ZI/p9ReicdCkCUPlQ2Q== X-CSE-MsgGUID: tYBE++xzSgOIy20bGuLxEQ== X-IronPort-AV: E=McAfee;i="6700,10204,11232"; a="39705171" X-IronPort-AV: E=Sophos;i="6.11,223,1725346800"; d="scan'208";a="39705171" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 03:54:00 -0700 X-CSE-ConnectionGUID: ZaGdeR2sQeK5iQp0cRAGMw== X-CSE-MsgGUID: pJxltlPWRX63RLvbHAGVhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,223,1725346800"; d="scan'208";a="79847818" Received: from sannilnx-dsk.jer.intel.com ([10.12.231.107]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2024 03:53:56 -0700 From: Alexander Usyskin To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Lucas De Marchi , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Rodrigo Vivi , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jani Nikula , Joonas Lahtinen , Tvrtko Ursulin Cc: Oren Weil , linux-mtd@lists.infradead.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, Alexander Usyskin Subject: [PATCH 10/10] drm/xe/nvm: add support for access mode Date: Tue, 22 Oct 2024 13:41:19 +0300 Message-ID: <20241022104119.3149051-11-alexander.usyskin@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241022104119.3149051-1-alexander.usyskin@intel.com> References: <20241022104119.3149051-1-alexander.usyskin@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: quoted-printable Content-Type: text/plain; charset="utf-8" Check NVM access mode from GSC FW status registers and overwrite access status read from SPI descriptor, if needed. Signed-off-by: Alexander Usyskin --- drivers/gpu/drm/xe/regs/xe_gsc_regs.h | 4 ++++ drivers/gpu/drm/xe/xe_heci_gsc.c | 5 +--- drivers/gpu/drm/xe/xe_nvm.c | 33 ++++++++++++++++++++++++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/xe/regs/xe_gsc_regs.h b/drivers/gpu/drm/xe/reg= s/xe_gsc_regs.h index 7702364b65f1..9b66cc972a63 100644 --- a/drivers/gpu/drm/xe/regs/xe_gsc_regs.h +++ b/drivers/gpu/drm/xe/regs/xe_gsc_regs.h @@ -16,6 +16,10 @@ #define MTL_GSC_HECI1_BASE 0x00116000 #define MTL_GSC_HECI2_BASE 0x00117000 =20 +#define DG1_GSC_HECI2_BASE 0x00259000 +#define PVC_GSC_HECI2_BASE 0x00285000 +#define DG2_GSC_HECI2_BASE 0x00374000 + #define HECI_H_CSR(base) XE_REG((base) + 0x4) #define HECI_H_CSR_IE REG_BIT(0) #define HECI_H_CSR_IS REG_BIT(1) diff --git a/drivers/gpu/drm/xe/xe_heci_gsc.c b/drivers/gpu/drm/xe/xe_heci_= gsc.c index 65b2e147c4b9..27734085164e 100644 --- a/drivers/gpu/drm/xe/xe_heci_gsc.c +++ b/drivers/gpu/drm/xe/xe_heci_gsc.c @@ -11,14 +11,11 @@ #include "xe_device_types.h" #include "xe_drv.h" #include "xe_heci_gsc.h" +#include "regs/xe_gsc_regs.h" #include "xe_platform_types.h" =20 #define GSC_BAR_LENGTH 0x00000FFC =20 -#define DG1_GSC_HECI2_BASE 0x259000 -#define PVC_GSC_HECI2_BASE 0x285000 -#define DG2_GSC_HECI2_BASE 0x374000 - static void heci_gsc_irq_mask(struct irq_data *d) { /* generic irq handling */ diff --git a/drivers/gpu/drm/xe/xe_nvm.c b/drivers/gpu/drm/xe/xe_nvm.c index ce56bff1268b..fbebe02522c0 100644 --- a/drivers/gpu/drm/xe/xe_nvm.c +++ b/drivers/gpu/drm/xe/xe_nvm.c @@ -5,8 +5,11 @@ =20 #include #include +#include "xe_device.h" #include "xe_device_types.h" +#include "xe_mmio.h" #include "xe_nvm.h" +#include "regs/xe_gsc_regs.h" #include "xe_sriov.h" =20 #define GEN12_GUNIT_NVM_BASE 0x00102040 @@ -24,6 +27,34 @@ static void xe_nvm_release_dev(struct device *dev) { } =20 +static bool xe_nvm_writeable_override(struct xe_device *xe) +{ + struct xe_gt *gt =3D xe_root_mmio_gt(xe); + struct pci_dev *pdev =3D to_pci_dev(xe->drm.dev); + resource_size_t base; + bool writeable_override; + + if (xe->info.platform =3D=3D XE_BATTLEMAGE) { + base =3D DG2_GSC_HECI2_BASE; + } else if (xe->info.platform =3D=3D XE_PVC) { + base =3D PVC_GSC_HECI2_BASE; + } else if (xe->info.platform =3D=3D XE_DG2) { + base =3D DG2_GSC_HECI2_BASE; + } else if (xe->info.platform =3D=3D XE_DG1) { + base =3D DG1_GSC_HECI2_BASE; + } else { + dev_err(&pdev->dev, "Unknown platform\n"); + return true; + } + + writeable_override =3D + !(xe_mmio_read32(>->mmio, HECI_H_GS1(base)) & + HECI_FW_STATUS_2_NVM_ACCESS_MODE); + if (writeable_override) + dev_info(&pdev->dev, "NVM access overridden by jumper\n"); + return writeable_override; +} + void xe_nvm_init(struct xe_device *xe) { struct pci_dev *pdev =3D to_pci_dev(xe->drm.dev); @@ -48,7 +79,7 @@ void xe_nvm_init(struct xe_device *xe) =20 nvm =3D xe->nvm; =20 - nvm->writeable_override =3D false; + nvm->writeable_override =3D xe_nvm_writeable_override(xe); nvm->bar.parent =3D &pdev->resource[0]; nvm->bar.start =3D GEN12_GUNIT_NVM_BASE + pdev->resource[0].start; nvm->bar.end =3D nvm->bar.start + GEN12_GUNIT_NVM_SIZE - 1; --=20 2.43.0