Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	Lucas De Marchi <lucas.demarchi@intel.com>,
	John Harrison <John.C.Harrison@intel.com>
Subject: Re: [PATCH v6 10/11] drm/xe/configfs: Only allow configurations for supported devices
Date: Thu, 31 Jul 2025 16:35:53 -0400	[thread overview]
Message-ID: <aIvTqdzmbrtKED6N@intel.com> (raw)
In-Reply-To: <20250731193339.179829-11-michal.wajdeczko@intel.com>

On Thu, Jul 31, 2025 at 09:33:38PM +0200, Michal Wajdeczko wrote:
> Since we already lookup for the real PCI device before we allow
> to create its directory config, we might also check if the found
> device matches our driver PCI ID list. This will prevent creation
> of the directory configs for the unsupported devices.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: John Harrison <John.C.Harrison@Intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>

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

> ---
> v2: rebased
> v3: don't use -ECANCELED, print message instead (Rodrigo, John)
> ---
>  drivers/gpu/drm/xe/xe_configfs.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
> index 5f145ccdf535..0e2da7907afc 100644
> --- a/drivers/gpu/drm/xe/xe_configfs.c
> +++ b/drivers/gpu/drm/xe/xe_configfs.c
> @@ -275,11 +275,22 @@ static const struct config_item_type xe_config_device_type = {
>  	.ct_owner	= THIS_MODULE,
>  };
>  
> +static const struct xe_device_desc *xe_match_desc(struct pci_dev *pdev)
> +{
> +	struct device_driver *driver = driver_find("xe", &pci_bus_type);
> +	struct pci_driver *drv = to_pci_driver(driver);
> +	const struct pci_device_id *ids = drv ? drv->id_table : NULL;
> +	const struct pci_device_id *found = pci_match_id(ids, pdev);
> +
> +	return found ? (const void *)found->driver_data : NULL;
> +}
> +
>  static struct config_group *xe_config_make_device_group(struct config_group *group,
>  							const char *name)
>  {
>  	unsigned int domain, bus, slot, function;
>  	struct xe_config_group_device *dev;
> +	const struct xe_device_desc *match;
>  	struct pci_dev *pdev;
>  	char canonical[16];
>  	int ret;
> @@ -297,8 +308,16 @@ static struct config_group *xe_config_make_device_group(struct config_group *gro
>  	pdev = pci_get_domain_bus_and_slot(domain, bus, PCI_DEVFN(slot, function));
>  	if (!pdev)
>  		return ERR_PTR(-ENODEV);
> +
> +	match = xe_match_desc(pdev);
> +	if (!match)
> +		pci_info(pdev, "xe driver does not support configuration of this device\n");
> +
>  	pci_dev_put(pdev);
>  
> +	if (!match)
> +		return ERR_PTR(-ENOENT);
> +
>  	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
>  	if (!dev)
>  		return ERR_PTR(-ENOMEM);
> -- 
> 2.47.1
> 

  reply	other threads:[~2025-07-31 20:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31 19:33 [PATCH v6 00/11] Updates for drm/xe/configfs Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 01/11] drm/xe: Simplify module initialization code Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 02/11] drm/xe: Print module init abort code Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 03/11] drm/xe/configfs: Destroy xe_configfs.su_mutex on exit/error Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 04/11] drm/xe/configfs: Drop redundant init() error message Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 05/11] drm/xe/configfs: Rename struct xe_config_device Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 06/11] drm/xe/configfs: Rename configfs_find_group() helper Michal Wajdeczko
2025-08-05 13:14   ` Lucas De Marchi
2025-08-05 14:30     ` Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 07/11] drm/xe/configfs: Reintroduce struct xe_config_device Michal Wajdeczko
2025-07-31 19:33 ` [PATCH v6 08/11] drm/xe/configfs: Keep default device config settings together Michal Wajdeczko
2025-08-05 13:28   ` Lucas De Marchi
2025-08-05 15:09     ` Michal Wajdeczko
2025-08-06 14:29       ` Lucas De Marchi
2025-07-31 19:33 ` [PATCH v6 09/11] drm/xe/configfs: Check if device was preconfigured Michal Wajdeczko
2025-08-05 19:30   ` Lucas De Marchi
2025-08-05 23:14     ` John Harrison
2025-08-06 14:49       ` Lucas De Marchi
2025-07-31 19:33 ` [PATCH v6 10/11] drm/xe/configfs: Only allow configurations for supported devices Michal Wajdeczko
2025-07-31 20:35   ` Rodrigo Vivi [this message]
2025-07-31 19:33 ` [PATCH v6 11/11] drm/xe/configfs: Allow adding configurations for future VFs Michal Wajdeczko
2025-07-31 20:37   ` Rodrigo Vivi
2025-07-31 21:21   ` [PATCH v7 " Michal Wajdeczko
2025-08-01  0:05 ` ✓ CI.KUnit: success for Updates for drm/xe/configfs (rev8) Patchwork
2025-08-01  1:08 ` ✓ Xe.CI.BAT: " Patchwork
2025-08-01  2:31 ` ✓ Xe.CI.Full: " Patchwork
2025-08-05 19:44 ` [PATCH v6 00/11] Updates for drm/xe/configfs Lucas De Marchi

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=aIvTqdzmbrtKED6N@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=John.C.Harrison@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=michal.wajdeczko@intel.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