lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CY5PR11MB636656BB76C04BD77F0ADB25ED90A@CY5PR11MB6366.namprd11.prod.outlook.com>
Date: Thu, 15 May 2025 10:11:08 +0000
From: "Usyskin, Alexander" <alexander.usyskin@...el.com>
To: "Jadav, Raag" <raag.jadav@...el.com>
CC: Miquel Raynal <miquel.raynal@...tlin.com>, Richard Weinberger
	<richard@....at>, Vignesh Raghavendra <vigneshr@...com>, "De Marchi, Lucas"
	<lucas.demarchi@...el.com>, Thomas Hellström
	<thomas.hellstrom@...ux.intel.com>, "Vivi, Rodrigo" <rodrigo.vivi@...el.com>,
	Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>, Maxime Ripard
	<mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>, David Airlie
	<airlied@...il.com>, Simona Vetter <simona@...ll.ch>, Jani Nikula
	<jani.nikula@...ux.intel.com>, Joonas Lahtinen
	<joonas.lahtinen@...ux.intel.com>, Tvrtko Ursulin <tursulin@...ulin.net>,
	"Poosa, Karthik" <karthik.poosa@...el.com>, "Abliyev, Reuven"
	<reuven.abliyev@...el.com>, "Weil, Oren jer" <oren.jer.weil@...el.com>,
	"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
	"intel-xe@...ts.freedesktop.org" <intel-xe@...ts.freedesktop.org>,
	"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
	"intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Tomas Winkler
	<tomasw@...il.com>
Subject: RE: [PATCH v9 02/12] mtd: add driver for intel graphics non-volatile
 memory device

> Subject: Re: [PATCH v9 02/12] mtd: add driver for intel graphics non-volatile
> memory device
> 
> 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?
> 
Will do

> > +	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?
Nope, removing

> 
> > +	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?
Not sure if adding exit path here adds something positive to driver
other than complexity.

> 
> > +	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.
Yes, will remove

> 
> > +		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?
Is there guaranty by auxiliary device that after release nothing is called?

> 
> > +	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.
Will remove
> 
> > +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
Will add
> 
> > +#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
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ