Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I915: optimize create/remove syfs entry for memtrack interface #67

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/i915_gpu_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ static inline void
i915_error_state_buf_release(struct drm_i915_error_state_buf *eb)
{
kfree(eb->buf);
eb->buf = NULL;
}
#endif

Expand Down
21 changes: 15 additions & 6 deletions drivers/gpu/drm/i915/i915_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ int i915_gem_create_sysfs_file_entry(struct drm_device *dev,
struct drm_i915_file_private *file_priv_local =
file_local->driver_priv;

if (file_priv->tgid == file_priv_local->tgid) {
if (pid_nr(file_priv->tgid) == pid_nr(file_priv_local->tgid)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason to change this, it is better explain it in commit description.

file_priv->obj_attr = file_priv_local->obj_attr;
mutex_unlock(&dev->filelist_mutex);
return 0;
Expand Down Expand Up @@ -439,7 +439,6 @@ int i915_gem_create_sysfs_file_entry(struct drm_device *dev,
obj_attr->attr.mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
obj_attr->size = 0;
obj_attr->read = i915_gem_read_objects;

attr_priv->tgid = file_priv->tgid;
obj_attr->private = attr_priv;

Expand Down Expand Up @@ -487,19 +486,29 @@ void i915_gem_remove_sysfs_file_entry(struct drm_device *dev,
}
mutex_unlock(&dev->filelist_mutex);

mutex_lock(&drm_global_mutex);
if (open_count == 1) {
struct i915_gem_file_attr_priv *attr_priv;

if (WARN_ON(file_priv->obj_attr == NULL))
return;
if (file_priv->obj_attr == NULL)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARN_ON is still needed, otherwise, there is no warning or error reported.

goto out;

attr_priv = file_priv->obj_attr->private;
if (attr_priv == NULL)
goto out;

sysfs_remove_bin_file(&dev_priv->memtrack_kobj,
file_priv->obj_attr);
i915_error_state_buf_release(&attr_priv->buf);
kfree(file_priv->obj_attr->private);
if (attr_priv->buf.buf)
i915_error_state_buf_release(&attr_priv->buf);
kfree(attr_priv);
attr_priv = NULL;
kfree(file_priv->obj_attr);
file_priv->obj_attr = NULL;
}

out:
mutex_unlock(&drm_global_mutex);
}

static struct bin_attribute i915_gem_client_state_attr = {
Expand Down