mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Alexander Usyskin <alexander.usyskin@intel.com>
Cc: "Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
	intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	"Menachem Adin" <menachem.adin@intel.com>
Subject: Re: [PATCH v3 1/2] mtd: mtd_intel_dg: add survivability partition
Date: Thu, 8 Oct 2026 12:42:34 -0400	[thread overview]
Message-ID: <asfH-tNJlKnNrJV2@intel.com> (raw)
In-Reply-To: <20260930-cri_surviv-v3-1-357aeed5fc60@intel.com>

On Wed, Sep 30, 2026 at 05:14:46PM +0300, Alexander Usyskin wrote:
> Add option to expose additional fixed-sized partition starting
> from the beginning of storage.
> Xe driver can request this partition exposure if firmware or hardware
> have detected failure that may involve corrupted partition table.
> Fixed-sized partition allows full storage re-write in this situation.
> 
> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
> ---
>  drivers/mtd/devices/mtd_intel_dg.c | 65 ++++++++++++++++++++++++++++----------
>  include/linux/intel_dg_nvm_aux.h   |  1 +
>  2 files changed, 50 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/mtd/devices/mtd_intel_dg.c b/drivers/mtd/devices/mtd_intel_dg.c
> index a566e86eb5e3..976246e94e79 100644
> --- a/drivers/mtd/devices/mtd_intel_dg.c
> +++ b/drivers/mtd/devices/mtd_intel_dg.c
> @@ -31,6 +31,7 @@ struct intel_dg_nvm {
>  	void __iomem *base;
>  	void __iomem *base2;
>  	bool non_posted_erase;
> +	bool survivability_enabled;
>  
>  	size_t size;
>  	unsigned int nregions;
> @@ -430,6 +431,15 @@ static int intel_dg_nvm_init(struct intel_dg_nvm *nvm, struct device *device,
>  	/* clean error register, previous errors are ignored */
>  	idg_nvm_error(nvm);
>  
> +	if (nvm->survivability_enabled) {
> +		nvm->size = nvm->regions[0].offset + nvm->regions[0].size - 1;

I see that this offset + region.size - 1 is also used in idg_nvm_get_region()
we could perhaps define a variable with this and document the - 1?!

But it looks right, no blocker...

> +		dev_dbg(device, "Registered survivability region %s size=%lld\n",
> +			nvm->regions[0].name,
> +			nvm->regions[0].size);
> +		n = 1;
> +		goto out;
> +	}
> +
>  	ret = idg_nvm_is_valid(nvm);
>  	if (ret) {
>  		dev_err(device, "The MEM is not valid %d\n", ret);
> @@ -481,6 +491,7 @@ static int intel_dg_nvm_init(struct intel_dg_nvm *nvm, struct device *device,
>  			n++;
>  	}
>  
> +out:
>  	nvm->non_posted_erase = non_posted_erase;
>  
>  	dev_dbg(device, "Registered %d regions\n", n);
> @@ -753,15 +764,19 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,
>  
>  	device = &aux_dev->dev;
>  
> -	/* count available regions */
> -	for (nregions = 0, i = 0; i < INTEL_DG_NVM_REGIONS; i++) {
> -		if (invm->regions[i].name)
> -			nregions++;
> -	}
> +	if (invm->survivability_size) {
> +		nregions = 1;
> +	} else {
> +		/* count available regions */
> +		for (nregions = 0, i = 0; i < INTEL_DG_NVM_REGIONS; i++) {
> +			if (invm->regions[i].name)
> +				nregions++;
> +		}
>  
> -	if (!nregions) {
> -		dev_err(device, "no regions defined\n");
> -		return -ENODEV;
> +		if (!nregions) {
> +			dev_err(device, "no regions defined\n");
> +			return -ENODEV;
> +		}
>  	}
>  
>  	nvm = kzalloc_flex(*nvm, regions, nregions);
> @@ -771,21 +786,39 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,
>  	kref_init(&nvm->refcnt);
>  	mutex_init(&nvm->lock);
>  	nvm->nregions = nregions;
> +	nvm->survivability_enabled = !!invm->survivability_size;
>  
> -	for (n = 0, i = 0; i < INTEL_DG_NVM_REGIONS; i++) {
> -		if (!invm->regions[i].name)
> -			continue;
> -
> +	if (invm->survivability_size) { /* survivability partition */
>  		char *name = kasprintf(GFP_KERNEL, "%s.%s",
> -				       dev_name(&aux_dev->dev), invm->regions[i].name);
> +				       dev_name(&aux_dev->dev), "DATA");
>  		if (!name) {
>  			ret = -ENOMEM;
>  			goto err_norpm;
>  		}
>  
> -		nvm->regions[n].name = name;
> -		nvm->regions[n].id = i;
> -		n++;
> +		nvm->regions[0].name = name;
> +		nvm->regions[0].id = 0;
> +		nvm->regions[0].offset  = 0;
> +		nvm->regions[0].size = invm->survivability_size;
> +		nvm->regions[0].is_readable = true;
> +		nvm->regions[0].is_writable = true;
> +		n = 1;
> +	} else {
> +		for (n = 0, i = 0; i < INTEL_DG_NVM_REGIONS; i++) {
> +			if (!invm->regions[i].name)
> +				continue;
> +
> +			char *name = kasprintf(GFP_KERNEL, "%s.%s",
> +					       dev_name(&aux_dev->dev), invm->regions[i].name);
> +			if (!name) {
> +				ret = -ENOMEM;
> +				goto err_norpm;
> +			}
> +
> +			nvm->regions[n].name = name;
> +			nvm->regions[n].id = i;
> +			n++;
> +		}

here as well, I believe the if survivability block should only select the
different print name and fix the for delimiter to 1 iteraction, then
you don't duplicate the rest of the code...
but also no blocker from my side:

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

>  	}
>  
>  	ret = devm_pm_runtime_enable(device);
> diff --git a/include/linux/intel_dg_nvm_aux.h b/include/linux/intel_dg_nvm_aux.h
> index 625d46a6b96e..84b5b6e0c4ea 100644
> --- a/include/linux/intel_dg_nvm_aux.h
> +++ b/include/linux/intel_dg_nvm_aux.h
> @@ -21,6 +21,7 @@ struct intel_dg_nvm_dev {
>  	struct auxiliary_device aux_dev;
>  	bool writable_override;
>  	bool non_posted_erase;
> +	size_t survivability_size;
>  	struct resource bar;
>  	struct resource bar2;
>  	const struct intel_dg_nvm_region *regions;
> 
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-10-08 16:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 14:14 [PATCH v3 0/2] drm/xe/nvm: add survivabilty partiton Alexander Usyskin
2026-09-30 14:14 ` [PATCH v3 1/2] mtd: mtd_intel_dg: add survivability partition Alexander Usyskin
2026-10-08 16:42   ` Rodrigo Vivi [this message]
2026-09-30 14:14 ` [PATCH v3 2/2] drm/xe/nvm: define survivabilty partition Alexander Usyskin
2026-10-08 16:43   ` Rodrigo Vivi

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=asfH-tNJlKnNrJV2@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=airlied@gmail.com \
    --cc=alexander.usyskin@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=matthew.brost@intel.com \
    --cc=menachem.adin@intel.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=simona@ffwll.ch \
    --cc=thomas.hellstrom@linux.intel.com \
    --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

all inboxes | Powered by JetHome®