Skip to content

Commit 750643a

Browse files
committed
Merge tag 'drm-misc-fixes-2021-06-10' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
One fix for snu4i that prevents it from probing, two locking fixes for ttm and drm_auth, one off-by-x1000 fix for mcde and a fix for vc4 to prevent an out-of-bounds access. Signed-off-by: Dave Airlie <[email protected]> From: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20210610171653.lqsoadxrhdk73cdy@gilmour
2 parents 43f44f5 + c336a5e commit 750643a

File tree

9 files changed

+80
-26
lines changed

9 files changed

+80
-26
lines changed

drivers/gpu/drm/drm_auth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,10 @@ int drm_master_open(struct drm_file *file_priv)
314314
void drm_master_release(struct drm_file *file_priv)
315315
{
316316
struct drm_device *dev = file_priv->minor->dev;
317-
struct drm_master *master = file_priv->master;
317+
struct drm_master *master;
318318

319319
mutex_lock(&dev->master_mutex);
320+
master = file_priv->master;
320321
if (file_priv->magic)
321322
idr_remove(&file_priv->master->magic_map, file_priv->magic);
322323

drivers/gpu/drm/drm_ioctl.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,18 @@ int drm_getunique(struct drm_device *dev, void *data,
118118
struct drm_file *file_priv)
119119
{
120120
struct drm_unique *u = data;
121-
struct drm_master *master = file_priv->master;
121+
struct drm_master *master;
122122

123-
mutex_lock(&master->dev->master_mutex);
123+
mutex_lock(&dev->master_mutex);
124+
master = file_priv->master;
124125
if (u->unique_len >= master->unique_len) {
125126
if (copy_to_user(u->unique, master->unique, master->unique_len)) {
126-
mutex_unlock(&master->dev->master_mutex);
127+
mutex_unlock(&dev->master_mutex);
127128
return -EFAULT;
128129
}
129130
}
130131
u->unique_len = master->unique_len;
131-
mutex_unlock(&master->dev->master_mutex);
132+
mutex_unlock(&dev->master_mutex);
132133

133134
return 0;
134135
}

drivers/gpu/drm/mcde/mcde_dsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static void mcde_dsi_setup_video_mode(struct mcde_dsi *d,
577577
* porches and sync.
578578
*/
579579
/* (ps/s) / (pixels/s) = ps/pixels */
580-
pclk = DIV_ROUND_UP_ULL(1000000000000, mode->clock);
580+
pclk = DIV_ROUND_UP_ULL(1000000000000, (mode->clock * 1000));
581581
dev_dbg(d->dev, "picoseconds between two pixels: %llu\n",
582582
pclk);
583583

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
209209
goto err_disable_clk_tmds;
210210
}
211211

212-
ret = sun8i_hdmi_phy_probe(hdmi, phy_node);
212+
ret = sun8i_hdmi_phy_get(hdmi, phy_node);
213213
of_node_put(phy_node);
214214
if (ret) {
215215
dev_err(dev, "Couldn't get the HDMI PHY\n");
@@ -242,7 +242,6 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
242242

243243
cleanup_encoder:
244244
drm_encoder_cleanup(encoder);
245-
sun8i_hdmi_phy_remove(hdmi);
246245
err_disable_clk_tmds:
247246
clk_disable_unprepare(hdmi->clk_tmds);
248247
err_assert_ctrl_reset:
@@ -263,7 +262,6 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,
263262
struct sun8i_dw_hdmi *hdmi = dev_get_drvdata(dev);
264263

265264
dw_hdmi_unbind(hdmi->hdmi);
266-
sun8i_hdmi_phy_remove(hdmi);
267265
clk_disable_unprepare(hdmi->clk_tmds);
268266
reset_control_assert(hdmi->rst_ctrl);
269267
gpiod_set_value(hdmi->ddc_en, 0);
@@ -320,7 +318,32 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = {
320318
.of_match_table = sun8i_dw_hdmi_dt_ids,
321319
},
322320
};
323-
module_platform_driver(sun8i_dw_hdmi_pltfm_driver);
321+
322+
static int __init sun8i_dw_hdmi_init(void)
323+
{
324+
int ret;
325+
326+
ret = platform_driver_register(&sun8i_dw_hdmi_pltfm_driver);
327+
if (ret)
328+
return ret;
329+
330+
ret = platform_driver_register(&sun8i_hdmi_phy_driver);
331+
if (ret) {
332+
platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver);
333+
return ret;
334+
}
335+
336+
return ret;
337+
}
338+
339+
static void __exit sun8i_dw_hdmi_exit(void)
340+
{
341+
platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver);
342+
platform_driver_unregister(&sun8i_hdmi_phy_driver);
343+
}
344+
345+
module_init(sun8i_dw_hdmi_init);
346+
module_exit(sun8i_dw_hdmi_exit);
324347

325348
MODULE_AUTHOR("Jernej Skrabec <[email protected]>");
326349
MODULE_DESCRIPTION("Allwinner DW HDMI bridge");

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,15 @@ struct sun8i_dw_hdmi {
195195
struct gpio_desc *ddc_en;
196196
};
197197

198+
extern struct platform_driver sun8i_hdmi_phy_driver;
199+
198200
static inline struct sun8i_dw_hdmi *
199201
encoder_to_sun8i_dw_hdmi(struct drm_encoder *encoder)
200202
{
201203
return container_of(encoder, struct sun8i_dw_hdmi, encoder);
202204
}
203205

204-
int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node);
205-
void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi);
206+
int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node);
206207

207208
void sun8i_hdmi_phy_init(struct sun8i_hdmi_phy *phy);
208209
void sun8i_hdmi_phy_set_ops(struct sun8i_hdmi_phy *phy,

drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <linux/delay.h>
77
#include <linux/of_address.h>
8+
#include <linux/of_platform.h>
89

910
#include "sun8i_dw_hdmi.h"
1011

@@ -597,10 +598,30 @@ static const struct of_device_id sun8i_hdmi_phy_of_table[] = {
597598
{ /* sentinel */ }
598599
};
599600

600-
int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
601+
int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
602+
{
603+
struct platform_device *pdev = of_find_device_by_node(node);
604+
struct sun8i_hdmi_phy *phy;
605+
606+
if (!pdev)
607+
return -EPROBE_DEFER;
608+
609+
phy = platform_get_drvdata(pdev);
610+
if (!phy)
611+
return -EPROBE_DEFER;
612+
613+
hdmi->phy = phy;
614+
615+
put_device(&pdev->dev);
616+
617+
return 0;
618+
}
619+
620+
static int sun8i_hdmi_phy_probe(struct platform_device *pdev)
601621
{
602622
const struct of_device_id *match;
603-
struct device *dev = hdmi->dev;
623+
struct device *dev = &pdev->dev;
624+
struct device_node *node = dev->of_node;
604625
struct sun8i_hdmi_phy *phy;
605626
struct resource res;
606627
void __iomem *regs;
@@ -704,7 +725,7 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
704725
clk_prepare_enable(phy->clk_phy);
705726
}
706727

707-
hdmi->phy = phy;
728+
platform_set_drvdata(pdev, phy);
708729

709730
return 0;
710731

@@ -728,9 +749,9 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node)
728749
return ret;
729750
}
730751

731-
void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi)
752+
static int sun8i_hdmi_phy_remove(struct platform_device *pdev)
732753
{
733-
struct sun8i_hdmi_phy *phy = hdmi->phy;
754+
struct sun8i_hdmi_phy *phy = platform_get_drvdata(pdev);
734755

735756
clk_disable_unprepare(phy->clk_mod);
736757
clk_disable_unprepare(phy->clk_bus);
@@ -744,4 +765,14 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi)
744765
clk_put(phy->clk_pll1);
745766
clk_put(phy->clk_mod);
746767
clk_put(phy->clk_bus);
768+
return 0;
747769
}
770+
771+
struct platform_driver sun8i_hdmi_phy_driver = {
772+
.probe = sun8i_hdmi_phy_probe,
773+
.remove = sun8i_hdmi_phy_remove,
774+
.driver = {
775+
.name = "sun8i-hdmi-phy",
776+
.of_match_table = sun8i_hdmi_phy_of_table,
777+
},
778+
};

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,10 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
11721172
if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked, NULL))
11731173
return -EBUSY;
11741174

1175-
if (!ttm_bo_get_unless_zero(bo)) {
1175+
if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) ||
1176+
bo->ttm->page_flags & TTM_PAGE_FLAG_SG ||
1177+
bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED ||
1178+
!ttm_bo_get_unless_zero(bo)) {
11761179
if (locked)
11771180
dma_resv_unlock(bo->base.resv);
11781181
return -EBUSY;

drivers/gpu/drm/ttm/ttm_device.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,8 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx,
143143

144144
for (j = 0; j < TTM_MAX_BO_PRIORITY; ++j) {
145145
list_for_each_entry(bo, &man->lru[j], lru) {
146-
uint32_t num_pages;
146+
uint32_t num_pages = PFN_UP(bo->base.size);
147147

148-
if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) ||
149-
bo->ttm->page_flags & TTM_PAGE_FLAG_SG ||
150-
bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED)
151-
continue;
152-
153-
num_pages = bo->ttm->num_pages;
154148
ret = ttm_bo_swapout(bo, ctx, gfp_flags);
155149
/* ttm_bo_swapout has dropped the lru_lock */
156150
if (!ret)

drivers/gpu/drm/vc4/vc4_kms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static void vc4_atomic_commit_tail(struct drm_atomic_state *state)
372372
if (!old_hvs_state->fifo_state[channel].in_use)
373373
continue;
374374

375-
ret = drm_crtc_commit_wait(old_hvs_state->fifo_state[i].pending_commit);
375+
ret = drm_crtc_commit_wait(old_hvs_state->fifo_state[channel].pending_commit);
376376
if (ret)
377377
drm_err(dev, "Timed out waiting for commit\n");
378378
}

0 commit comments

Comments
 (0)