Skip to content

Commit eb7bac3

Browse files
committed
Merge tag 'drm-misc-fixes-2022-05-13' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
Multiple fixes to fbdev to address a regression at unregistration, an iommu detection improvement for nouveau, a memory leak fix for nouveau, pointer dereference fix for dma_buf_file_release(), and a build breakage fix for vc4 Signed-off-by: Dave Airlie <[email protected]> From: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20220513073044.ymayac7x7bzatrt7@houat
2 parents 30c60ba + 6fed53d commit eb7bac3

File tree

9 files changed

+38
-16
lines changed

9 files changed

+38
-16
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,17 +543,17 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
543543
file->f_mode |= FMODE_LSEEK;
544544
dmabuf->file = file;
545545

546-
ret = dma_buf_stats_setup(dmabuf);
547-
if (ret)
548-
goto err_sysfs;
549-
550546
mutex_init(&dmabuf->lock);
551547
INIT_LIST_HEAD(&dmabuf->attachments);
552548

553549
mutex_lock(&db_list.lock);
554550
list_add(&dmabuf->list_node, &db_list.head);
555551
mutex_unlock(&db_list.lock);
556552

553+
ret = dma_buf_stats_setup(dmabuf);
554+
if (ret)
555+
goto err_sysfs;
556+
557557
return dmabuf;
558558

559559
err_sysfs:

drivers/gpu/drm/nouveau/nouveau_backlight.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ static bool
4646
nouveau_get_backlight_name(char backlight_name[BL_NAME_SIZE],
4747
struct nouveau_backlight *bl)
4848
{
49-
const int nb = ida_simple_get(&bl_ida, 0, 0, GFP_KERNEL);
50-
if (nb < 0 || nb >= 100)
49+
const int nb = ida_alloc_max(&bl_ida, 99, GFP_KERNEL);
50+
51+
if (nb < 0)
5152
return false;
5253
if (nb > 0)
5354
snprintf(backlight_name, BL_NAME_SIZE, "nv_backlight%d", nb);
@@ -414,7 +415,7 @@ nouveau_backlight_init(struct drm_connector *connector)
414415
nv_encoder, ops, &props);
415416
if (IS_ERR(bl->dev)) {
416417
if (bl->id >= 0)
417-
ida_simple_remove(&bl_ida, bl->id);
418+
ida_free(&bl_ida, bl->id);
418419
ret = PTR_ERR(bl->dev);
419420
goto fail_alloc;
420421
}
@@ -442,7 +443,7 @@ nouveau_backlight_fini(struct drm_connector *connector)
442443
return;
443444

444445
if (bl->id >= 0)
445-
ida_simple_remove(&bl_ida, bl->id);
446+
ida_free(&bl_ida, bl->id);
446447

447448
backlight_device_unregister(bl->dev);
448449
nv_conn->backlight = NULL;

drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev)
123123

124124
mutex_init(&tdev->iommu.mutex);
125125

126-
if (iommu_present(&platform_bus_type)) {
126+
if (device_iommu_mapped(dev)) {
127127
tdev->iommu.domain = iommu_domain_alloc(&platform_bus_type);
128128
if (!tdev->iommu.domain)
129129
goto error;

drivers/gpu/drm/vc4/vc4_hdmi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <drm/drm_scdc_helper.h>
3939
#include <linux/clk.h>
4040
#include <linux/component.h>
41+
#include <linux/gpio/consumer.h>
4142
#include <linux/i2c.h>
4243
#include <linux/of_address.h>
4344
#include <linux/of_gpio.h>

drivers/video/fbdev/core/fbmem.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,10 +1434,7 @@ fb_release(struct inode *inode, struct file *file)
14341434
__acquires(&info->lock)
14351435
__releases(&info->lock)
14361436
{
1437-
struct fb_info * const info = file_fb_info(file);
1438-
1439-
if (!info)
1440-
return -ENODEV;
1437+
struct fb_info * const info = file->private_data;
14411438

14421439
lock_fb_info(info);
14431440
if (info->fbops->fb_release)

drivers/video/fbdev/core/fbsysfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ void framebuffer_release(struct fb_info *info)
8080
{
8181
if (!info)
8282
return;
83+
84+
if (WARN_ON(refcount_read(&info->count)))
85+
return;
86+
8387
kfree(info->apertures);
8488
kfree(info);
8589
}

drivers/video/fbdev/efifb.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ static void efifb_show_boot_graphics(struct fb_info *info)
243243
static inline void efifb_show_boot_graphics(struct fb_info *info) {}
244244
#endif
245245

246+
/*
247+
* fb_ops.fb_destroy is called by the last put_fb_info() call at the end
248+
* of unregister_framebuffer() or fb_release(). Do any cleanup here.
249+
*/
246250
static void efifb_destroy(struct fb_info *info)
247251
{
248252
if (efifb_pci_dev)
@@ -254,10 +258,13 @@ static void efifb_destroy(struct fb_info *info)
254258
else
255259
memunmap(info->screen_base);
256260
}
261+
257262
if (request_mem_succeeded)
258263
release_mem_region(info->apertures->ranges[0].base,
259264
info->apertures->ranges[0].size);
260265
fb_dealloc_cmap(&info->cmap);
266+
267+
framebuffer_release(info);
261268
}
262269

263270
static const struct fb_ops efifb_ops = {
@@ -620,9 +627,9 @@ static int efifb_remove(struct platform_device *pdev)
620627
{
621628
struct fb_info *info = platform_get_drvdata(pdev);
622629

630+
/* efifb_destroy takes care of info cleanup */
623631
unregister_framebuffer(info);
624632
sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
625-
framebuffer_release(info);
626633

627634
return 0;
628635
}

drivers/video/fbdev/simplefb.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ struct simplefb_par {
8484
static void simplefb_clocks_destroy(struct simplefb_par *par);
8585
static void simplefb_regulators_destroy(struct simplefb_par *par);
8686

87+
/*
88+
* fb_ops.fb_destroy is called by the last put_fb_info() call at the end
89+
* of unregister_framebuffer() or fb_release(). Do any cleanup here.
90+
*/
8791
static void simplefb_destroy(struct fb_info *info)
8892
{
8993
struct simplefb_par *par = info->par;
@@ -94,6 +98,8 @@ static void simplefb_destroy(struct fb_info *info)
9498
if (info->screen_base)
9599
iounmap(info->screen_base);
96100

101+
framebuffer_release(info);
102+
97103
if (mem)
98104
release_mem_region(mem->start, resource_size(mem));
99105
}
@@ -545,8 +551,8 @@ static int simplefb_remove(struct platform_device *pdev)
545551
{
546552
struct fb_info *info = platform_get_drvdata(pdev);
547553

554+
/* simplefb_destroy takes care of info cleanup */
548555
unregister_framebuffer(info);
549-
framebuffer_release(info);
550556

551557
return 0;
552558
}

drivers/video/fbdev/vesafb.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
179179
return err;
180180
}
181181

182+
/*
183+
* fb_ops.fb_destroy is called by the last put_fb_info() call at the end
184+
* of unregister_framebuffer() or fb_release(). Do any cleanup here.
185+
*/
182186
static void vesafb_destroy(struct fb_info *info)
183187
{
184188
struct vesafb_par *par = info->par;
@@ -188,6 +192,8 @@ static void vesafb_destroy(struct fb_info *info)
188192
if (info->screen_base)
189193
iounmap(info->screen_base);
190194
release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
195+
196+
framebuffer_release(info);
191197
}
192198

193199
static struct fb_ops vesafb_ops = {
@@ -484,10 +490,10 @@ static int vesafb_remove(struct platform_device *pdev)
484490
{
485491
struct fb_info *info = platform_get_drvdata(pdev);
486492

493+
/* vesafb_destroy takes care of info cleanup */
487494
unregister_framebuffer(info);
488495
if (((struct vesafb_par *)(info->par))->region)
489496
release_region(0x3c0, 32);
490-
framebuffer_release(info);
491497

492498
return 0;
493499
}

0 commit comments

Comments
 (0)