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: John Harrison <john.c.harrison@intel.com>,
	<intel-xe@lists.freedesktop.org>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH v5 10/11] drm/xe/configfs: Only allow configurations for supported devices
Date: Wed, 30 Jul 2025 12:30:51 -0400	[thread overview]
Message-ID: <aIpIu4UdcmVDCzur@intel.com> (raw)
In-Reply-To: <91cb7b75-3fbb-4749-b048-de55a9599ada@intel.com>

On Wed, Jul 30, 2025 at 10:23:22AM +0200, Michal Wajdeczko wrote:
> 
> 
> On 7/30/2025 12:20 AM, John Harrison wrote:
> > On 7/29/2025 2:40 PM, Rodrigo Vivi wrote:
> >> On Tue, Jul 29, 2025 at 01:42:14PM +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>
> >>> ---
> >>> v2: rebased
> >>> ---
> >>>   drivers/gpu/drm/xe/xe_configfs.c | 17 +++++++++++++++++
> >>>   1 file changed, 17 insertions(+)
> >>>
> >>> diff --git a/drivers/gpu/drm/xe/xe_configfs.c b/drivers/gpu/drm/xe/xe_configfs.c
> >>> index 5f145ccdf535..766775772eef 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,14 @@ 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);
> >>> +
> >>>       pci_dev_put(pdev);
> >>>   +    if (!match)
> >>> +        return ERR_PTR(-ECANCELED);
> >> why ECANCELED instead of ENODEV?
> > Or EINVAL? This is for when a user has created a directory for a PCI device that exists but it is not a Xe device? Seems like ENODEV is not the correct option given that the device does exist. But ECANCELED also seems odd.
> 
> we can always return -EINVAL but user will have no clue what went wrong
> 
> so the idea was:
> 
> -EINVAL     when config directory name is malformed
> -ENODEV     config directory name is correct but
>             there is no such device under such BDF
> -ECANCELED  when device exists but it is not covered by Xe driver
> 
> since you both don't like -ECANCELED for this case, what about:
> 
> -ECONNREFUSED /* Connection refused */
> -EOPNOTSUPP   /* Operation not supported on transport endpoint */
> -ENXIO        /* No such device or address */

What about -ENODEV, but with debug messages to differentiate the cases?

Otherwise -ENXIO seems the best of the alternatives here.

> 
> > 
> > John.
> > 
> >>
> >>> +
> >>>       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> >>>       if (!dev)
> >>>           return ERR_PTR(-ENOMEM);
> >>> -- 
> >>> 2.47.1
> >>>
> > 
> 

  reply	other threads:[~2025-07-30 16:31 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29 11:42 [PATCH v5 00/11] Updates for drm/xe/configfs Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 01/11] drm/xe: Simplify module initialization code Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 02/11] drm/xe: Print module init abort code Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 03/11] drm/xe/configfs: Destroy xe_configfs.su_mutex on exit/error Michal Wajdeczko
2025-07-29 21:31   ` Rodrigo Vivi
2025-08-05 12:49   ` Lucas De Marchi
2025-07-29 11:42 ` [PATCH v5 04/11] drm/xe/configfs: Drop redundant init() error message Michal Wajdeczko
2025-07-29 17:58   ` John Harrison
2025-08-05 12:55   ` Lucas De Marchi
2025-07-29 11:42 ` [PATCH v5 05/11] drm/xe/configfs: Rename struct xe_config_device Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 06/11] drm/xe/configfs: Rename configfs_find_group() helper Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 07/11] drm/xe/configfs: Reintroduce struct xe_config_device Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 08/11] drm/xe/configfs: Keep default device config settings together Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 09/11] drm/xe/configfs: Check if device was preconfigured Michal Wajdeczko
2025-07-29 11:42 ` [PATCH v5 10/11] drm/xe/configfs: Only allow configurations for supported devices Michal Wajdeczko
2025-07-29 21:40   ` Rodrigo Vivi
2025-07-29 22:20     ` John Harrison
2025-07-30  8:23       ` Michal Wajdeczko
2025-07-30 16:30         ` Rodrigo Vivi [this message]
2025-07-30 17:12           ` John Harrison
2025-07-30 18:28             ` Rodrigo Vivi
2025-07-30 19:57               ` Michal Wajdeczko
2025-07-30 20:08                 ` Rodrigo Vivi
2025-07-30 20:10                   ` John Harrison
2025-07-29 11:42 ` [PATCH v5 11/11] drm/xe/configfs: Allow adding configurations for future VFs Michal Wajdeczko
2025-07-29 21:50   ` Rodrigo Vivi
2025-07-29 12:03 ` ✓ CI.KUnit: success for Updates for drm/xe/configfs (rev6) Patchwork
2025-07-29 13:16 ` ✓ Xe.CI.BAT: " Patchwork
2025-07-29 18:55 ` ✗ Xe.CI.Full: failure " Patchwork

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=aIpIu4UdcmVDCzur@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=john.c.harrison@intel.com \
    --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