mirror of
https://github.com/torvalds/linux.git
synced 2024-12-01 08:31:37 +00:00
f728a5ea27
The init order and resulting error handling in dma_buf_export was pretty messy. Subordinate objects like the file and the sysfs kernel objects were initializing and wiring itself up with the object in the wrong order resulting not only in complicating and partially incorrect error handling, but also in publishing only halve initialized DMA-buf objects. Clean this up thoughtfully by allocating the file independent of the DMA-buf object. Then allocate and initialize the DMA-buf object itself, before publishing it through sysfs. If everything works as expected the file is then connected with the DMA-buf object and publish it through debugfs. Also adds the missing dma_resv_fini() into the error handling. v2: add some missing changes to dma_bug_getfile() and a missing NULL check in dma_buf_file_release() Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com> Reviewed-by: T.J. Mercier <tjmercier@google.com> Acked-by: Sumit Semwal <sumit.semwal@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20221209071535.933698-1-christian.koenig@amd.com
36 lines
767 B
C
36 lines
767 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* DMA-BUF sysfs statistics.
|
|
*
|
|
* Copyright (C) 2021 Google LLC.
|
|
*/
|
|
|
|
#ifndef _DMA_BUF_SYSFS_STATS_H
|
|
#define _DMA_BUF_SYSFS_STATS_H
|
|
|
|
#ifdef CONFIG_DMABUF_SYSFS_STATS
|
|
|
|
int dma_buf_init_sysfs_statistics(void);
|
|
void dma_buf_uninit_sysfs_statistics(void);
|
|
|
|
int dma_buf_stats_setup(struct dma_buf *dmabuf, struct file *file);
|
|
|
|
void dma_buf_stats_teardown(struct dma_buf *dmabuf);
|
|
#else
|
|
|
|
static inline int dma_buf_init_sysfs_statistics(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void dma_buf_uninit_sysfs_statistics(void) {}
|
|
|
|
static inline int dma_buf_stats_setup(struct dma_buf *dmabuf, struct file *file)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline void dma_buf_stats_teardown(struct dma_buf *dmabuf) {}
|
|
#endif
|
|
#endif // _DMA_BUF_SYSFS_STATS_H
|