Skip to content

Commit cb6d406

Browse files
committed
Merge tag 'drm-misc-next-fixes-2020-04-09' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
A few DMA-related fixes, an OOB fix for virtio and a probe-related fix for analogix_dp Signed-off-by: Dave Airlie <[email protected]> From: Maxime Ripard <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 12ab316 + 152cce0 commit cb6d406

File tree

7 files changed

+95
-61
lines changed

7 files changed

+95
-61
lines changed

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
16521652
}
16531653

16541654
struct analogix_dp_device *
1655-
analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
1656-
struct analogix_dp_plat_data *plat_data)
1655+
analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
16571656
{
16581657
struct platform_device *pdev = to_platform_device(dev);
16591658
struct analogix_dp_device *dp;
@@ -1756,36 +1755,43 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
17561755
irq_flags, "analogix-dp", dp);
17571756
if (ret) {
17581757
dev_err(&pdev->dev, "failed to request irq\n");
1759-
goto err_disable_pm_runtime;
1758+
return ERR_PTR(ret);
17601759
}
17611760
disable_irq(dp->irq);
17621761

1762+
return dp;
1763+
}
1764+
EXPORT_SYMBOL_GPL(analogix_dp_probe);
1765+
1766+
int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
1767+
{
1768+
int ret;
1769+
17631770
dp->drm_dev = drm_dev;
17641771
dp->encoder = dp->plat_data->encoder;
17651772

17661773
dp->aux.name = "DP-AUX";
17671774
dp->aux.transfer = analogix_dpaux_transfer;
1768-
dp->aux.dev = &pdev->dev;
1775+
dp->aux.dev = dp->dev;
17691776

17701777
ret = drm_dp_aux_register(&dp->aux);
17711778
if (ret)
1772-
return ERR_PTR(ret);
1779+
return ret;
17731780

1774-
pm_runtime_enable(dev);
1781+
pm_runtime_enable(dp->dev);
17751782

17761783
ret = analogix_dp_create_bridge(drm_dev, dp);
17771784
if (ret) {
17781785
DRM_ERROR("failed to create bridge (%d)\n", ret);
17791786
goto err_disable_pm_runtime;
17801787
}
17811788

1782-
return dp;
1789+
return 0;
17831790

17841791
err_disable_pm_runtime:
1792+
pm_runtime_disable(dp->dev);
17851793

1786-
pm_runtime_disable(dev);
1787-
1788-
return ERR_PTR(ret);
1794+
return ret;
17891795
}
17901796
EXPORT_SYMBOL_GPL(analogix_dp_bind);
17911797

@@ -1802,10 +1808,15 @@ void analogix_dp_unbind(struct analogix_dp_device *dp)
18021808

18031809
drm_dp_aux_unregister(&dp->aux);
18041810
pm_runtime_disable(dp->dev);
1805-
clk_disable_unprepare(dp->clock);
18061811
}
18071812
EXPORT_SYMBOL_GPL(analogix_dp_unbind);
18081813

1814+
void analogix_dp_remove(struct analogix_dp_device *dp)
1815+
{
1816+
clk_disable_unprepare(dp->clock);
1817+
}
1818+
EXPORT_SYMBOL_GPL(analogix_dp_remove);
1819+
18091820
#ifdef CONFIG_PM
18101821
int analogix_dp_suspend(struct analogix_dp_device *dp)
18111822
{

drivers/gpu/drm/drm_prime.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -962,27 +962,40 @@ int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
962962
unsigned count;
963963
struct scatterlist *sg;
964964
struct page *page;
965-
u32 len, index;
965+
u32 page_len, page_index;
966966
dma_addr_t addr;
967+
u32 dma_len, dma_index;
967968

968-
index = 0;
969+
/*
970+
* Scatterlist elements contains both pages and DMA addresses, but
971+
* one shoud not assume 1:1 relation between them. The sg->length is
972+
* the size of the physical memory chunk described by the sg->page,
973+
* while sg_dma_len(sg) is the size of the DMA (IO virtual) chunk
974+
* described by the sg_dma_address(sg).
975+
*/
976+
page_index = 0;
977+
dma_index = 0;
969978
for_each_sg(sgt->sgl, sg, sgt->nents, count) {
970-
len = sg_dma_len(sg);
979+
page_len = sg->length;
971980
page = sg_page(sg);
981+
dma_len = sg_dma_len(sg);
972982
addr = sg_dma_address(sg);
973983

974-
while (len > 0) {
975-
if (WARN_ON(index >= max_entries))
984+
while (pages && page_len > 0) {
985+
if (WARN_ON(page_index >= max_entries))
976986
return -1;
977-
if (pages)
978-
pages[index] = page;
979-
if (addrs)
980-
addrs[index] = addr;
981-
987+
pages[page_index] = page;
982988
page++;
989+
page_len -= PAGE_SIZE;
990+
page_index++;
991+
}
992+
while (addrs && dma_len > 0) {
993+
if (WARN_ON(dma_index >= max_entries))
994+
return -1;
995+
addrs[dma_index] = addr;
983996
addr += PAGE_SIZE;
984-
len -= PAGE_SIZE;
985-
index++;
997+
dma_len -= PAGE_SIZE;
998+
dma_index++;
986999
}
9871000
}
9881001
return 0;

drivers/gpu/drm/exynos/exynos_dp.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,8 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
159159
struct drm_device *drm_dev = data;
160160
int ret;
161161

162-
dp->dev = dev;
163162
dp->drm_dev = drm_dev;
164163

165-
dp->plat_data.dev_type = EXYNOS_DP;
166-
dp->plat_data.power_on_start = exynos_dp_poweron;
167-
dp->plat_data.power_off = exynos_dp_poweroff;
168-
dp->plat_data.attach = exynos_dp_bridge_attach;
169-
dp->plat_data.get_modes = exynos_dp_get_modes;
170-
171164
if (!dp->plat_data.panel && !dp->ptn_bridge) {
172165
ret = exynos_dp_dt_parse_panel(dp);
173166
if (ret)
@@ -185,13 +178,11 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
185178

186179
dp->plat_data.encoder = encoder;
187180

188-
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
189-
if (IS_ERR(dp->adp)) {
181+
ret = analogix_dp_bind(dp->adp, dp->drm_dev);
182+
if (ret)
190183
dp->encoder.funcs->destroy(&dp->encoder);
191-
return PTR_ERR(dp->adp);
192-
}
193184

194-
return 0;
185+
return ret;
195186
}
196187

197188
static void exynos_dp_unbind(struct device *dev, struct device *master,
@@ -222,6 +213,7 @@ static int exynos_dp_probe(struct platform_device *pdev)
222213
if (!dp)
223214
return -ENOMEM;
224215

216+
dp->dev = dev;
225217
/*
226218
* We just use the drvdata until driver run into component
227219
* add function, and then we would set drvdata to null, so
@@ -247,16 +239,29 @@ static int exynos_dp_probe(struct platform_device *pdev)
247239

248240
/* The remote port can be either a panel or a bridge */
249241
dp->plat_data.panel = panel;
242+
dp->plat_data.dev_type = EXYNOS_DP;
243+
dp->plat_data.power_on_start = exynos_dp_poweron;
244+
dp->plat_data.power_off = exynos_dp_poweroff;
245+
dp->plat_data.attach = exynos_dp_bridge_attach;
246+
dp->plat_data.get_modes = exynos_dp_get_modes;
250247
dp->plat_data.skip_connector = !!bridge;
248+
251249
dp->ptn_bridge = bridge;
252250

253251
out:
252+
dp->adp = analogix_dp_probe(dev, &dp->plat_data);
253+
if (IS_ERR(dp->adp))
254+
return PTR_ERR(dp->adp);
255+
254256
return component_add(&pdev->dev, &exynos_dp_ops);
255257
}
256258

257259
static int exynos_dp_remove(struct platform_device *pdev)
258260
{
261+
struct exynos_dp_device *dp = platform_get_drvdata(pdev);
262+
259263
component_del(&pdev->dev, &exynos_dp_ops);
264+
analogix_dp_remove(dp->adp);
260265

261266
return 0;
262267
}

drivers/gpu/drm/rockchip/analogix_dp-rockchip.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,9 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
325325
void *data)
326326
{
327327
struct rockchip_dp_device *dp = dev_get_drvdata(dev);
328-
const struct rockchip_dp_chip_data *dp_data;
329328
struct drm_device *drm_dev = data;
330329
int ret;
331330

332-
dp_data = of_device_get_match_data(dev);
333-
if (!dp_data)
334-
return -ENODEV;
335-
336-
dp->data = dp_data;
337331
dp->drm_dev = drm_dev;
338332

339333
ret = rockchip_dp_drm_create_encoder(dp);
@@ -344,16 +338,9 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
344338

345339
dp->plat_data.encoder = &dp->encoder;
346340

347-
dp->plat_data.dev_type = dp->data->chip_type;
348-
dp->plat_data.power_on_start = rockchip_dp_poweron_start;
349-
dp->plat_data.power_off = rockchip_dp_powerdown;
350-
dp->plat_data.get_modes = rockchip_dp_get_modes;
351-
352-
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
353-
if (IS_ERR(dp->adp)) {
354-
ret = PTR_ERR(dp->adp);
341+
ret = analogix_dp_bind(dp->adp, drm_dev);
342+
if (ret)
355343
goto err_cleanup_encoder;
356-
}
357344

358345
return 0;
359346
err_cleanup_encoder:
@@ -368,8 +355,6 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
368355

369356
analogix_dp_unbind(dp->adp);
370357
dp->encoder.funcs->destroy(&dp->encoder);
371-
372-
dp->adp = ERR_PTR(-ENODEV);
373358
}
374359

375360
static const struct component_ops rockchip_dp_component_ops = {
@@ -380,10 +365,15 @@ static const struct component_ops rockchip_dp_component_ops = {
380365
static int rockchip_dp_probe(struct platform_device *pdev)
381366
{
382367
struct device *dev = &pdev->dev;
368+
const struct rockchip_dp_chip_data *dp_data;
383369
struct drm_panel *panel = NULL;
384370
struct rockchip_dp_device *dp;
385371
int ret;
386372

373+
dp_data = of_device_get_match_data(dev);
374+
if (!dp_data)
375+
return -ENODEV;
376+
387377
ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL);
388378
if (ret < 0)
389379
return ret;
@@ -394,20 +384,32 @@ static int rockchip_dp_probe(struct platform_device *pdev)
394384

395385
dp->dev = dev;
396386
dp->adp = ERR_PTR(-ENODEV);
387+
dp->data = dp_data;
397388
dp->plat_data.panel = panel;
389+
dp->plat_data.dev_type = dp->data->chip_type;
390+
dp->plat_data.power_on_start = rockchip_dp_poweron_start;
391+
dp->plat_data.power_off = rockchip_dp_powerdown;
392+
dp->plat_data.get_modes = rockchip_dp_get_modes;
398393

399394
ret = rockchip_dp_of_probe(dp);
400395
if (ret < 0)
401396
return ret;
402397

403398
platform_set_drvdata(pdev, dp);
404399

400+
dp->adp = analogix_dp_probe(dev, &dp->plat_data);
401+
if (IS_ERR(dp->adp))
402+
return PTR_ERR(dp->adp);
403+
405404
return component_add(dev, &rockchip_dp_component_ops);
406405
}
407406

408407
static int rockchip_dp_remove(struct platform_device *pdev)
409408
{
409+
struct rockchip_dp_device *dp = platform_get_drvdata(pdev);
410+
410411
component_del(&pdev->dev, &rockchip_dp_component_ops);
412+
analogix_dp_remove(dp->adp);
411413

412414
return 0;
413415
}

drivers/gpu/drm/virtio/virtgpu_object.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,17 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo)
123123
struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev,
124124
size_t size)
125125
{
126-
struct virtio_gpu_object *bo;
126+
struct virtio_gpu_object_shmem *shmem;
127+
struct drm_gem_shmem_object *dshmem;
127128

128-
bo = kzalloc(sizeof(*bo), GFP_KERNEL);
129-
if (!bo)
129+
shmem = kzalloc(sizeof(*shmem), GFP_KERNEL);
130+
if (!shmem)
130131
return NULL;
131132

132-
bo->base.base.funcs = &virtio_gpu_shmem_funcs;
133-
bo->base.map_cached = true;
134-
return &bo->base.base;
133+
dshmem = &shmem->base.base;
134+
dshmem->base.funcs = &virtio_gpu_shmem_funcs;
135+
dshmem->map_cached = true;
136+
return &dshmem->base;
135137
}
136138

137139
static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,

include/drm/bridge/analogix_dp.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ int analogix_dp_resume(struct analogix_dp_device *dp);
4242
int analogix_dp_suspend(struct analogix_dp_device *dp);
4343

4444
struct analogix_dp_device *
45-
analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
46-
struct analogix_dp_plat_data *plat_data);
45+
analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data);
46+
int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev);
4747
void analogix_dp_unbind(struct analogix_dp_device *dp);
48+
void analogix_dp_remove(struct analogix_dp_device *dp);
4849

4950
int analogix_dp_start_crc(struct drm_connector *connector);
5051
int analogix_dp_stop_crc(struct drm_connector *connector);

include/drm/drm_legacy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct drm_sg_mem {
136136
* Kernel side of a mapping
137137
*/
138138
struct drm_local_map {
139-
resource_size_t offset; /**< Requested physical address (0 for SAREA)*/
139+
dma_addr_t offset; /**< Requested physical address (0 for SAREA)*/
140140
unsigned long size; /**< Requested physical size (bytes) */
141141
enum drm_map_type type; /**< Type of memory to map */
142142
enum drm_map_flags flags; /**< Flags */

0 commit comments

Comments
 (0)