From: Raag Jadav <raag.jadav@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>,
"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>,
"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, "Tomas Winkler" <tomasw@gmail.com>
Subject: Re: [PATCH v9 02/12] mtd: add driver for intel graphics non-volatile memory device
Date: Tue, 29 Apr 2025 12:31:32 +0300 [thread overview]
Message-ID: <aBCcdPbIxthARrMj@black.fi.intel.com> (raw)
In-Reply-To: <20250424132536.3043825-3-alexander.usyskin@intel.com>
On Thu, Apr 24, 2025 at 04:25:26PM +0300, Alexander Usyskin wrote:
> Add auxiliary driver for intel discrete graphics
> non-volatile memory device.
...
> +static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,
> + const struct auxiliary_device_id *aux_dev_id)
> +{
> + struct intel_dg_nvm_dev *invm = auxiliary_dev_to_intel_dg_nvm_dev(aux_dev);
> + struct device *device;
> + struct intel_dg_nvm *nvm;
> + unsigned int nregions;
> + unsigned int i, n;
> + char *name;
Perhaps move this to the loop it is being used in?
> + int ret;
> +
> + 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 (!nregions) {
> + dev_err(device, "no regions defined\n");
> + return -ENODEV;
> + }
> +
> + nvm = kzalloc(struct_size(nvm, regions, nregions), GFP_KERNEL);
> + if (!nvm)
> + return -ENOMEM;
> +
> + kref_init(&nvm->refcnt);
> +
> + nvm->nregions = nregions;
Is this assignment useful?
> + for (n = 0, i = 0; i < INTEL_DG_NVM_REGIONS; i++) {
> + if (!invm->regions[i].name)
> + continue;
> +
> + name = kasprintf(GFP_KERNEL, "%s.%s",
> + dev_name(&aux_dev->dev), invm->regions[i].name);
> + if (!name)
> + continue;
> + nvm->regions[n].name = name;
> + nvm->regions[n].id = i;
> + n++;
> + }
> + nvm->nregions = n; /* in case where kasprintf fail */
Considering kasprintf failure, should we move forward if n == 0?
> + nvm->base = devm_ioremap_resource(device, &invm->bar);
> + if (IS_ERR(nvm->base)) {
> + dev_err(device, "mmio not mapped\n");
Is this useful? Perhaps the helper already does it for us.
> + ret = PTR_ERR(nvm->base);
> + goto err;
> + }
> +
> + dev_set_drvdata(&aux_dev->dev, nvm);
> +
> + return 0;
> +
> +err:
> + kref_put(&nvm->refcnt, intel_dg_nvm_release);
> + return ret;
> +}
> +
> +static void intel_dg_mtd_remove(struct auxiliary_device *aux_dev)
> +{
> + struct intel_dg_nvm *nvm = dev_get_drvdata(&aux_dev->dev);
> +
> + if (!nvm)
> + return;
Are we expecting this?
> + dev_set_drvdata(&aux_dev->dev, NULL);
Do we need this?
> + kref_put(&nvm->refcnt, intel_dg_nvm_release);
> +}
> +
> +static const struct auxiliary_device_id intel_dg_mtd_id_table[] = {
> + {
> + .name = "i915.nvm",
> + },
> + {
> + .name = "xe.nvm",
> + },
> + {
> + /* sentinel */
> + }
> +};
> +MODULE_DEVICE_TABLE(auxiliary, intel_dg_mtd_id_table);
> +
> +static struct auxiliary_driver intel_dg_mtd_driver = {
> + .probe = intel_dg_mtd_probe,
> + .remove = intel_dg_mtd_remove,
> + .driver = {
> + /* auxiliary_driver_register() sets .name to be the modname */
> + },
> + .id_table = intel_dg_mtd_id_table
> +};
> +
Nit: Redundant blank line.
> +module_auxiliary_driver(intel_dg_mtd_driver);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Intel Corporation");
> +MODULE_DESCRIPTION("Intel DGFX MTD driver");
> diff --git a/include/linux/intel_dg_nvm_aux.h b/include/linux/intel_dg_nvm_aux.h
> new file mode 100644
> index 000000000000..68df634c994c
> --- /dev/null
> +++ b/include/linux/intel_dg_nvm_aux.h
> @@ -0,0 +1,27 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright(c) 2019-2025, Intel Corporation. All rights reserved.
> + */
> +
> +#ifndef __INTEL_DG_NVM_AUX_H__
> +#define __INTEL_DG_NVM_AUX_H__
> +
> +#include <linux/auxiliary_bus.h>
Missing types.h, container_of.h
> +#define INTEL_DG_NVM_REGIONS 13
> +
> +struct intel_dg_nvm_region {
> + const char *name;
> +};
> +
> +struct intel_dg_nvm_dev {
> + struct auxiliary_device aux_dev;
> + bool writable_override;
> + struct resource bar;
> + const struct intel_dg_nvm_region *regions;
> +};
> +
> +#define auxiliary_dev_to_intel_dg_nvm_dev(auxiliary_dev) \
> + container_of(auxiliary_dev, struct intel_dg_nvm_dev, aux_dev)
> +
> +#endif /* __INTEL_DG_NVM_AUX_H__ */
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-04-29 9:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 13:25 [PATCH v9 00/12] mtd: add driver for Intel discrete graphics Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 01/12] mtd: core: always create master device Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 02/12] mtd: add driver for intel graphics non-volatile memory device Alexander Usyskin
2025-04-29 9:31 ` Raag Jadav [this message]
2025-05-15 10:11 ` Usyskin, Alexander
2025-05-15 12:13 ` Raag Jadav
2025-04-24 13:25 ` [PATCH v9 03/12] mtd: intel-dg: implement region enumeration Alexander Usyskin
2025-04-29 9:44 ` Raag Jadav
2025-05-15 11:23 ` Usyskin, Alexander
2025-05-15 12:19 ` Raag Jadav
2025-05-15 13:07 ` Usyskin, Alexander
2025-04-24 13:25 ` [PATCH v9 04/12] mtd: intel-dg: implement access functions Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 05/12] mtd: intel-dg: register with mtd Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 06/12] mtd: intel-dg: align 64bit read and write Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 07/12] mtd: intel-dg: wake card on operations Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 08/12] drm/i915/nvm: add nvm device for discrete graphics Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 09/12] drm/i915/nvm: add support for access mode Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 10/12] drm/xe/nvm: add on-die non-volatile memory device Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 11/12] drm/xe/nvm: add support for access mode Alexander Usyskin
2025-04-24 13:25 ` [PATCH v9 12/12] drm/xe/nvm: add support for non-posted erase Alexander Usyskin
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=aBCcdPbIxthARrMj@black.fi.intel.com \
--to=raag.jadav@intel.com \
--cc=airlied@gmail.com \
--cc=alexander.usyskin@intel.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=reuven.abliyev@intel.com \
--cc=richard@nod.at \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tomasw@gmail.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;
as well as URLs for NNTP newsgroup(s).