From: Alexander Usyskin <alexander.usyskin@intel.com>
To: "Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Karthik Poosa" <karthik.poosa@intel.com>,
"Raag Jadav" <raag.jadav@intel.com>
Cc: Reuven Abliyev <reuven.abliyev@intel.com>,
Oren Weil <oren.jer.weil@intel.com>,
linux-mtd@lists.infradead.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Alexander Usyskin <alexander.usyskin@intel.com>
Subject: [PATCH v10 10/10] drm/xe/nvm: add support for non-posted erase
Date: Thu, 15 May 2025 16:33:45 +0300 [thread overview]
Message-ID: <20250515133345.2805031-11-alexander.usyskin@intel.com> (raw)
In-Reply-To: <20250515133345.2805031-1-alexander.usyskin@intel.com>
From: Reuven Abliyev <reuven.abliyev@intel.com>
Erase command is slow on discrete graphics storage
and may overshot PCI completion timeout.
BMG introduces the ability to have non-posted erase.
Add driver support for non-posted erase with polling
for erase completion.
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Reuven Abliyev <reuven.abliyev@intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
---
drivers/gpu/drm/xe/xe_nvm.c | 25 ++++++++++++++++++
drivers/mtd/devices/mtd_intel_dg.c | 42 ++++++++++++++++++++++++++++--
include/linux/intel_dg_nvm_aux.h | 2 ++
3 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_nvm.c b/drivers/gpu/drm/xe/xe_nvm.c
index 8aec20bc629a..dd91f2e37661 100644
--- a/drivers/gpu/drm/xe/xe_nvm.c
+++ b/drivers/gpu/drm/xe/xe_nvm.c
@@ -14,7 +14,15 @@
#include "xe_sriov.h"
#define GEN12_GUNIT_NVM_BASE 0x00102040
+#define GEN12_DEBUG_NVM_BASE 0x00101018
+
+#define GEN12_CNTL_PROTECTED_NVM_REG 0x0010100C
+
#define GEN12_GUNIT_NVM_SIZE 0x80
+#define GEN12_DEBUG_NVM_SIZE 0x4
+
+#define NVM_NON_POSTED_ERASE_CHICKEN_BIT BIT(13)
+
#define HECI_FW_STATUS_2_NVM_ACCESS_MODE BIT(3)
static const struct intel_dg_nvm_region regions[INTEL_DG_NVM_REGIONS] = {
@@ -28,6 +36,16 @@ static void xe_nvm_release_dev(struct device *dev)
{
}
+static bool xe_nvm_non_posted_erase(struct xe_device *xe)
+{
+ struct xe_gt *gt = xe_root_mmio_gt(xe);
+
+ if (xe->info.platform != XE_BATTLEMAGE)
+ return false;
+ return !(xe_mmio_read32(>->mmio, XE_REG(GEN12_CNTL_PROTECTED_NVM_REG)) &
+ NVM_NON_POSTED_ERASE_CHICKEN_BIT);
+}
+
static bool xe_nvm_writable_override(struct xe_device *xe)
{
struct xe_gt *gt = xe_root_mmio_gt(xe);
@@ -85,6 +103,7 @@ void xe_nvm_init(struct xe_device *xe)
nvm = xe->nvm;
nvm->writable_override = xe_nvm_writable_override(xe);
+ nvm->non_posted_erase = xe_nvm_non_posted_erase(xe);
nvm->bar.parent = &pdev->resource[0];
nvm->bar.start = GEN12_GUNIT_NVM_BASE + pdev->resource[0].start;
nvm->bar.end = nvm->bar.start + GEN12_GUNIT_NVM_SIZE - 1;
@@ -92,6 +111,12 @@ void xe_nvm_init(struct xe_device *xe)
nvm->bar.desc = IORES_DESC_NONE;
nvm->regions = regions;
+ nvm->bar2.parent = &pdev->resource[0];
+ nvm->bar2.start = GEN12_DEBUG_NVM_BASE + pdev->resource[0].start;
+ nvm->bar2.end = nvm->bar2.start + GEN12_DEBUG_NVM_SIZE - 1;
+ nvm->bar2.flags = IORESOURCE_MEM;
+ nvm->bar2.desc = IORES_DESC_NONE;
+
aux_dev = &nvm->aux_dev;
aux_dev->name = "nvm";
diff --git a/drivers/mtd/devices/mtd_intel_dg.c b/drivers/mtd/devices/mtd_intel_dg.c
index 2f32ed311ffd..4d96b1421148 100644
--- a/drivers/mtd/devices/mtd_intel_dg.c
+++ b/drivers/mtd/devices/mtd_intel_dg.c
@@ -25,6 +25,9 @@ struct intel_dg_nvm {
struct mtd_info mtd;
struct mutex lock; /* region access lock */
void __iomem *base;
+ void __iomem *base2;
+ bool non_posted_erase;
+
size_t size;
unsigned int nregions;
struct {
@@ -41,6 +44,7 @@ struct intel_dg_nvm {
#define NVM_VALSIG_REG 0x00000010
#define NVM_ADDRESS_REG 0x00000040
#define NVM_REGION_ID_REG 0x00000044
+#define NVM_DEBUG_REG 0x00000000
/*
* [15:0]-Erase size = 0x0010 4K 0x0080 32K 0x0100 64K
* [23:16]-Reserved
@@ -72,6 +76,9 @@ struct intel_dg_nvm {
#define NVM_FREG_ADDR_SHIFT 12
#define NVM_FREG_MIN_REGION_SIZE 0xFFF
+#define NVM_NON_POSTED_ERASE_DONE BIT(23)
+#define NVM_NON_POSTED_ERASE_DONE_ITER 3000
+
static inline void idg_nvm_set_region_id(struct intel_dg_nvm *nvm, u8 region)
{
iowrite32((u32)region, nvm->base + NVM_REGION_ID_REG);
@@ -375,11 +382,30 @@ idg_erase(struct intel_dg_nvm *nvm, u8 region, loff_t from, u64 len, u64 *fail_a
{
u64 i;
const u32 block = 0x10;
+ u32 reg;
+ u32 iter = 0;
void __iomem *base = nvm->base;
+ void __iomem *base2 = nvm->base2;
for (i = 0; i < len; i += SZ_4K) {
iowrite32(from + i, base + NVM_ADDRESS_REG);
iowrite32(region << 24 | block, base + NVM_ERASE_REG);
+ if (nvm->non_posted_erase) {
+ /* Wait for Erase Done */
+ reg = ioread32(base2 + NVM_DEBUG_REG);
+ while (!(reg & NVM_NON_POSTED_ERASE_DONE) &&
+ ++iter < NVM_NON_POSTED_ERASE_DONE_ITER) {
+ msleep(10);
+ reg = ioread32(base2 + NVM_DEBUG_REG);
+ }
+ if (reg & NVM_NON_POSTED_ERASE_DONE) {
+ /* Clear Erase Done */
+ iowrite32(reg, base2 + NVM_DEBUG_REG);
+ } else {
+ *fail_addr = from + i;
+ return -ETIME;
+ }
+ }
/* Since the writes are via sguint
* we cannot do back to back erases.
*/
@@ -388,7 +414,8 @@ idg_erase(struct intel_dg_nvm *nvm, u8 region, loff_t from, u64 len, u64 *fail_a
return len;
}
-static int intel_dg_nvm_init(struct intel_dg_nvm *nvm, struct device *device)
+static int intel_dg_nvm_init(struct intel_dg_nvm *nvm, struct device *device,
+ bool non_posted_erase)
{
int ret;
unsigned int i, n;
@@ -448,7 +475,10 @@ static int intel_dg_nvm_init(struct intel_dg_nvm *nvm, struct device *device)
n++;
}
+ nvm->non_posted_erase = non_posted_erase;
+
dev_dbg(device, "Registered %d regions\n", n);
+ dev_dbg(device, "Non posted erase %d\n", nvm->non_posted_erase);
/* Need to add 1 to the amount of memory
* so it is reported as an even block
@@ -731,7 +761,15 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,
goto err;
}
- ret = intel_dg_nvm_init(nvm, device);
+ if (invm->non_posted_erase) {
+ nvm->base2 = devm_ioremap_resource(device, &invm->bar2);
+ if (IS_ERR(nvm->base2)) {
+ ret = PTR_ERR(nvm->base2);
+ goto err;
+ }
+ }
+
+ ret = intel_dg_nvm_init(nvm, device, invm->non_posted_erase);
if (ret < 0) {
dev_err(device, "cannot initialize nvm %d\n", ret);
goto err;
diff --git a/include/linux/intel_dg_nvm_aux.h b/include/linux/intel_dg_nvm_aux.h
index 53193fda55eb..efeefd96f9df 100644
--- a/include/linux/intel_dg_nvm_aux.h
+++ b/include/linux/intel_dg_nvm_aux.h
@@ -19,7 +19,9 @@ struct intel_dg_nvm_region {
struct intel_dg_nvm_dev {
struct auxiliary_device aux_dev;
bool writable_override;
+ bool non_posted_erase;
struct resource bar;
+ struct resource bar2;
const struct intel_dg_nvm_region *regions;
};
--
2.43.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2025-05-15 13:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 13:33 [PATCH v10 00/10] mtd: add driver for Intel discrete graphics Alexander Usyskin
2025-05-15 13:33 ` [PATCH v10 01/10] mtd: add driver for intel graphics non-volatile memory device Alexander Usyskin
2025-05-16 22:19 ` Raag Jadav
2025-05-15 13:33 ` [PATCH v10 02/10] mtd: intel-dg: implement region enumeration Alexander Usyskin
2025-05-16 22:21 ` Raag Jadav
2025-05-15 13:33 ` [PATCH v10 03/10] mtd: intel-dg: implement access functions Alexander Usyskin
2025-05-20 17:31 ` Raag Jadav
2025-05-21 9:19 ` Usyskin, Alexander
2025-05-21 20:26 ` Raag Jadav
2025-05-22 10:26 ` Usyskin, Alexander
2025-05-15 13:33 ` [PATCH v10 04/10] mtd: intel-dg: register with mtd Alexander Usyskin
2025-05-21 21:37 ` Raag Jadav
2025-05-22 12:14 ` Usyskin, Alexander
2025-05-15 13:33 ` [PATCH v10 05/10] mtd: intel-dg: align 64bit read and write Alexander Usyskin
2025-05-24 10:01 ` Raag Jadav
2025-05-27 6:03 ` Usyskin, Alexander
2025-05-27 18:49 ` Raag Jadav
2025-05-15 13:33 ` [PATCH v10 06/10] drm/i915/nvm: add nvm device for discrete graphics Alexander Usyskin
2025-05-24 10:20 ` Raag Jadav
2025-05-27 6:00 ` Usyskin, Alexander
2025-05-27 18:35 ` Raag Jadav
2025-05-28 6:29 ` Usyskin, Alexander
2025-05-15 13:33 ` [PATCH v10 07/10] drm/i915/nvm: add support for access mode Alexander Usyskin
2025-05-15 13:33 ` [PATCH v10 08/10] drm/xe/nvm: add on-die non-volatile memory device Alexander Usyskin
2025-05-24 10:29 ` Raag Jadav
2025-05-27 6:25 ` Usyskin, Alexander
2025-05-27 18:37 ` Raag Jadav
2025-05-28 6:30 ` Usyskin, Alexander
2025-05-15 13:33 ` [PATCH v10 09/10] drm/xe/nvm: add support for access mode Alexander Usyskin
2025-05-15 13:33 ` Alexander Usyskin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250515133345.2805031-11-alexander.usyskin@intel.com \
--to=alexander.usyskin@intel.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=karthik.poosa@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lucas.demarchi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=oren.jer.weil@intel.com \
--cc=raag.jadav@intel.com \
--cc=reuven.abliyev@intel.com \
--cc=richard@nod.at \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox