Files
linux/drivers/gpu/drm/xe/xe_gt_sysfs.c
Matthew Auld c60f91bbc4 drm/xe: covert sysfs over to devm
Hotunplugging the device seems to result in stuff like:

kobject_add_internal failed for tile0 with -EEXIST, don't try to
register things with the same name in the same directory.

We only remove the sysfs as part of drmm, however that is tied to the
lifetime of the driver instance and not the device underneath. Attempt
to fix by using devm for all of the remaining sysfs stuff related to the
device.

Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1667
Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/1432
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240522102143.128069-20-matthew.auld@intel.com
2024-05-22 13:22:38 +01:00

56 lines
998 B
C

// SPDX-License-Identifier: MIT
/*
* Copyright © 2022 Intel Corporation
*/
#include "xe_gt_sysfs.h"
#include <linux/kobject.h>
#include <linux/sysfs.h>
#include <drm/drm_managed.h>
#include "xe_gt.h"
static void xe_gt_sysfs_kobj_release(struct kobject *kobj)
{
kfree(kobj);
}
static const struct kobj_type xe_gt_sysfs_kobj_type = {
.release = xe_gt_sysfs_kobj_release,
.sysfs_ops = &kobj_sysfs_ops,
};
static void gt_sysfs_fini(void *arg)
{
struct xe_gt *gt = arg;
kobject_put(gt->sysfs);
}
int xe_gt_sysfs_init(struct xe_gt *gt)
{
struct xe_tile *tile = gt_to_tile(gt);
struct xe_device *xe = gt_to_xe(gt);
struct kobj_gt *kg;
int err;
kg = kzalloc(sizeof(*kg), GFP_KERNEL);
if (!kg)
return -ENOMEM;
kobject_init(&kg->base, &xe_gt_sysfs_kobj_type);
kg->gt = gt;
err = kobject_add(&kg->base, tile->sysfs, "gt%d", gt->info.id);
if (err) {
kobject_put(&kg->base);
return err;
}
gt->sysfs = &kg->base;
return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
}