drm/i915: Use the fdinfo helper
Use the common fdinfo helper for printing the basics. Remove now unused client id allocation code. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Rob Clark <robdclark@chromium.org> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230605123224.373633-1-tvrtko.ursulin@linux.intel.com
This commit is contained in:
parent
744bbf2a67
commit
e894b724c3
5 changed files with 18 additions and 83 deletions
|
@ -243,8 +243,6 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_rootgt;
|
goto err_rootgt;
|
||||||
|
|
||||||
i915_drm_clients_init(&dev_priv->clients, dev_priv);
|
|
||||||
|
|
||||||
i915_gem_init_early(dev_priv);
|
i915_gem_init_early(dev_priv);
|
||||||
|
|
||||||
/* This must be called before any calls to HAS_PCH_* */
|
/* This must be called before any calls to HAS_PCH_* */
|
||||||
|
@ -278,7 +276,6 @@ static void i915_driver_late_release(struct drm_i915_private *dev_priv)
|
||||||
intel_power_domains_cleanup(dev_priv);
|
intel_power_domains_cleanup(dev_priv);
|
||||||
i915_gem_cleanup_early(dev_priv);
|
i915_gem_cleanup_early(dev_priv);
|
||||||
intel_gt_driver_late_release_all(dev_priv);
|
intel_gt_driver_late_release_all(dev_priv);
|
||||||
i915_drm_clients_fini(&dev_priv->clients);
|
|
||||||
intel_region_ttm_device_fini(dev_priv);
|
intel_region_ttm_device_fini(dev_priv);
|
||||||
vlv_suspend_cleanup(dev_priv);
|
vlv_suspend_cleanup(dev_priv);
|
||||||
i915_workqueues_cleanup(dev_priv);
|
i915_workqueues_cleanup(dev_priv);
|
||||||
|
@ -1706,7 +1703,7 @@ static const struct file_operations i915_driver_fops = {
|
||||||
.compat_ioctl = i915_ioc32_compat_ioctl,
|
.compat_ioctl = i915_ioc32_compat_ioctl,
|
||||||
.llseek = noop_llseek,
|
.llseek = noop_llseek,
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
.show_fdinfo = i915_drm_client_fdinfo,
|
.show_fdinfo = drm_show_fdinfo,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1806,6 +1803,7 @@ static const struct drm_driver i915_drm_driver = {
|
||||||
.open = i915_driver_open,
|
.open = i915_driver_open,
|
||||||
.lastclose = i915_driver_lastclose,
|
.lastclose = i915_driver_lastclose,
|
||||||
.postclose = i915_driver_postclose,
|
.postclose = i915_driver_postclose,
|
||||||
|
.show_fdinfo = i915_drm_client_fdinfo,
|
||||||
|
|
||||||
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
|
||||||
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
|
||||||
|
|
|
@ -17,64 +17,29 @@
|
||||||
#include "i915_gem.h"
|
#include "i915_gem.h"
|
||||||
#include "i915_utils.h"
|
#include "i915_utils.h"
|
||||||
|
|
||||||
void i915_drm_clients_init(struct i915_drm_clients *clients,
|
struct i915_drm_client *i915_drm_client_alloc(void)
|
||||||
struct drm_i915_private *i915)
|
|
||||||
{
|
|
||||||
clients->i915 = i915;
|
|
||||||
clients->next_id = 0;
|
|
||||||
|
|
||||||
xa_init_flags(&clients->xarray, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients)
|
|
||||||
{
|
{
|
||||||
struct i915_drm_client *client;
|
struct i915_drm_client *client;
|
||||||
struct xarray *xa = &clients->xarray;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
client = kzalloc(sizeof(*client), GFP_KERNEL);
|
client = kzalloc(sizeof(*client), GFP_KERNEL);
|
||||||
if (!client)
|
if (!client)
|
||||||
return ERR_PTR(-ENOMEM);
|
return NULL;
|
||||||
|
|
||||||
xa_lock_irq(xa);
|
|
||||||
ret = __xa_alloc_cyclic(xa, &client->id, client, xa_limit_32b,
|
|
||||||
&clients->next_id, GFP_KERNEL);
|
|
||||||
xa_unlock_irq(xa);
|
|
||||||
if (ret < 0)
|
|
||||||
goto err;
|
|
||||||
|
|
||||||
kref_init(&client->kref);
|
kref_init(&client->kref);
|
||||||
spin_lock_init(&client->ctx_lock);
|
spin_lock_init(&client->ctx_lock);
|
||||||
INIT_LIST_HEAD(&client->ctx_list);
|
INIT_LIST_HEAD(&client->ctx_list);
|
||||||
client->clients = clients;
|
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
|
||||||
err:
|
|
||||||
kfree(client);
|
|
||||||
|
|
||||||
return ERR_PTR(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void __i915_drm_client_free(struct kref *kref)
|
void __i915_drm_client_free(struct kref *kref)
|
||||||
{
|
{
|
||||||
struct i915_drm_client *client =
|
struct i915_drm_client *client =
|
||||||
container_of(kref, typeof(*client), kref);
|
container_of(kref, typeof(*client), kref);
|
||||||
struct xarray *xa = &client->clients->xarray;
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
xa_lock_irqsave(xa, flags);
|
|
||||||
__xa_erase(xa, client->id);
|
|
||||||
xa_unlock_irqrestore(xa, flags);
|
|
||||||
kfree(client);
|
kfree(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i915_drm_clients_fini(struct i915_drm_clients *clients)
|
|
||||||
{
|
|
||||||
GEM_BUG_ON(!xa_empty(&clients->xarray));
|
|
||||||
xa_destroy(&clients->xarray);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
static const char * const uabi_class_names[] = {
|
static const char * const uabi_class_names[] = {
|
||||||
[I915_ENGINE_CLASS_RENDER] = "render",
|
[I915_ENGINE_CLASS_RENDER] = "render",
|
||||||
|
@ -101,38 +66,34 @@ static u64 busy_add(struct i915_gem_context *ctx, unsigned int class)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_client_class(struct seq_file *m,
|
show_client_class(struct drm_printer *p,
|
||||||
|
struct drm_i915_private *i915,
|
||||||
struct i915_drm_client *client,
|
struct i915_drm_client *client,
|
||||||
unsigned int class)
|
unsigned int class)
|
||||||
{
|
{
|
||||||
const struct list_head *list = &client->ctx_list;
|
const unsigned int capacity = i915->engine_uabi_class_count[class];
|
||||||
u64 total = atomic64_read(&client->past_runtime[class]);
|
u64 total = atomic64_read(&client->past_runtime[class]);
|
||||||
const unsigned int capacity =
|
|
||||||
client->clients->i915->engine_uabi_class_count[class];
|
|
||||||
struct i915_gem_context *ctx;
|
struct i915_gem_context *ctx;
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
list_for_each_entry_rcu(ctx, list, client_link)
|
list_for_each_entry_rcu(ctx, &client->ctx_list, client_link)
|
||||||
total += busy_add(ctx, class);
|
total += busy_add(ctx, class);
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
if (capacity)
|
if (capacity)
|
||||||
seq_printf(m, "drm-engine-%s:\t%llu ns\n",
|
drm_printf(p, "drm-engine-%s:\t%llu ns\n",
|
||||||
uabi_class_names[class], total);
|
uabi_class_names[class], total);
|
||||||
|
|
||||||
if (capacity > 1)
|
if (capacity > 1)
|
||||||
seq_printf(m, "drm-engine-capacity-%s:\t%u\n",
|
drm_printf(p, "drm-engine-capacity-%s:\t%u\n",
|
||||||
uabi_class_names[class],
|
uabi_class_names[class],
|
||||||
capacity);
|
capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
|
void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file)
|
||||||
{
|
{
|
||||||
struct drm_file *file = f->private_data;
|
|
||||||
struct drm_i915_file_private *file_priv = file->driver_priv;
|
struct drm_i915_file_private *file_priv = file->driver_priv;
|
||||||
struct drm_i915_private *i915 = file_priv->i915;
|
struct drm_i915_private *i915 = file_priv->i915;
|
||||||
struct i915_drm_client *client = file_priv->client;
|
|
||||||
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -141,16 +102,10 @@ void i915_drm_client_fdinfo(struct seq_file *m, struct file *f)
|
||||||
* ******************************************************************
|
* ******************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
seq_printf(m, "drm-driver:\t%s\n", i915->drm.driver->name);
|
|
||||||
seq_printf(m, "drm-pdev:\t%04x:%02x:%02x.%d\n",
|
|
||||||
pci_domain_nr(pdev->bus), pdev->bus->number,
|
|
||||||
PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn));
|
|
||||||
seq_printf(m, "drm-client-id:\t%u\n", client->id);
|
|
||||||
|
|
||||||
if (GRAPHICS_VER(i915) < 8)
|
if (GRAPHICS_VER(i915) < 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
|
for (i = 0; i < ARRAY_SIZE(uabi_class_names); i++)
|
||||||
show_client_class(m, client, i);
|
show_client_class(p, i915, file_priv->client, i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,20 +9,13 @@
|
||||||
#include <linux/kref.h>
|
#include <linux/kref.h>
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/xarray.h>
|
|
||||||
|
|
||||||
#include <uapi/drm/i915_drm.h>
|
#include <uapi/drm/i915_drm.h>
|
||||||
|
|
||||||
#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
|
#define I915_LAST_UABI_ENGINE_CLASS I915_ENGINE_CLASS_COMPUTE
|
||||||
|
|
||||||
struct drm_i915_private;
|
struct drm_file;
|
||||||
|
struct drm_printer;
|
||||||
struct i915_drm_clients {
|
|
||||||
struct drm_i915_private *i915;
|
|
||||||
|
|
||||||
struct xarray xarray;
|
|
||||||
u32 next_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct i915_drm_client {
|
struct i915_drm_client {
|
||||||
struct kref kref;
|
struct kref kref;
|
||||||
|
@ -32,17 +25,12 @@ struct i915_drm_client {
|
||||||
spinlock_t ctx_lock; /* For add/remove from ctx_list. */
|
spinlock_t ctx_lock; /* For add/remove from ctx_list. */
|
||||||
struct list_head ctx_list; /* List of contexts belonging to client. */
|
struct list_head ctx_list; /* List of contexts belonging to client. */
|
||||||
|
|
||||||
struct i915_drm_clients *clients;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
|
* @past_runtime: Accumulation of pphwsp runtimes from closed contexts.
|
||||||
*/
|
*/
|
||||||
atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
|
atomic64_t past_runtime[I915_LAST_UABI_ENGINE_CLASS + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
void i915_drm_clients_init(struct i915_drm_clients *clients,
|
|
||||||
struct drm_i915_private *i915);
|
|
||||||
|
|
||||||
static inline struct i915_drm_client *
|
static inline struct i915_drm_client *
|
||||||
i915_drm_client_get(struct i915_drm_client *client)
|
i915_drm_client_get(struct i915_drm_client *client)
|
||||||
{
|
{
|
||||||
|
@ -57,12 +45,10 @@ static inline void i915_drm_client_put(struct i915_drm_client *client)
|
||||||
kref_put(&client->kref, __i915_drm_client_free);
|
kref_put(&client->kref, __i915_drm_client_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct i915_drm_client *i915_drm_client_add(struct i915_drm_clients *clients);
|
struct i915_drm_client *i915_drm_client_alloc(void);
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
void i915_drm_client_fdinfo(struct seq_file *m, struct file *f);
|
void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void i915_drm_clients_fini(struct i915_drm_clients *clients);
|
|
||||||
|
|
||||||
#endif /* !__I915_DRM_CLIENT_H__ */
|
#endif /* !__I915_DRM_CLIENT_H__ */
|
||||||
|
|
|
@ -347,8 +347,6 @@ struct drm_i915_private {
|
||||||
|
|
||||||
struct i915_pmu pmu;
|
struct i915_pmu pmu;
|
||||||
|
|
||||||
struct i915_drm_clients clients;
|
|
||||||
|
|
||||||
/* The TTM device structure. */
|
/* The TTM device structure. */
|
||||||
struct ttm_device bdev;
|
struct ttm_device bdev;
|
||||||
|
|
||||||
|
|
|
@ -1325,11 +1325,9 @@ int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file)
|
||||||
if (!file_priv)
|
if (!file_priv)
|
||||||
goto err_alloc;
|
goto err_alloc;
|
||||||
|
|
||||||
client = i915_drm_client_add(&i915->clients);
|
client = i915_drm_client_alloc();
|
||||||
if (IS_ERR(client)) {
|
if (!client)
|
||||||
ret = PTR_ERR(client);
|
|
||||||
goto err_client;
|
goto err_client;
|
||||||
}
|
|
||||||
|
|
||||||
file->driver_priv = file_priv;
|
file->driver_priv = file_priv;
|
||||||
file_priv->i915 = i915;
|
file_priv->i915 = i915;
|
||||||
|
|
Loading…
Add table
Reference in a new issue