Commit cb6d4066 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'drm-misc-next-fixes-2020-04-09' of...

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: default avatarDave Airlie <airlied@redhat.com>

From: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20200409091424.cfpqqbqjxtkgnfme@gilmour.lan
parents 12ab316c 152cce00
...@@ -1652,8 +1652,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux, ...@@ -1652,8 +1652,7 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
} }
struct analogix_dp_device * struct analogix_dp_device *
analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
struct analogix_dp_plat_data *plat_data)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
struct analogix_dp_device *dp; struct analogix_dp_device *dp;
...@@ -1756,22 +1755,30 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, ...@@ -1756,22 +1755,30 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
irq_flags, "analogix-dp", dp); irq_flags, "analogix-dp", dp);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to request irq\n"); dev_err(&pdev->dev, "failed to request irq\n");
goto err_disable_pm_runtime; return ERR_PTR(ret);
} }
disable_irq(dp->irq); disable_irq(dp->irq);
return dp;
}
EXPORT_SYMBOL_GPL(analogix_dp_probe);
int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
{
int ret;
dp->drm_dev = drm_dev; dp->drm_dev = drm_dev;
dp->encoder = dp->plat_data->encoder; dp->encoder = dp->plat_data->encoder;
dp->aux.name = "DP-AUX"; dp->aux.name = "DP-AUX";
dp->aux.transfer = analogix_dpaux_transfer; dp->aux.transfer = analogix_dpaux_transfer;
dp->aux.dev = &pdev->dev; dp->aux.dev = dp->dev;
ret = drm_dp_aux_register(&dp->aux); ret = drm_dp_aux_register(&dp->aux);
if (ret) if (ret)
return ERR_PTR(ret); return ret;
pm_runtime_enable(dev); pm_runtime_enable(dp->dev);
ret = analogix_dp_create_bridge(drm_dev, dp); ret = analogix_dp_create_bridge(drm_dev, dp);
if (ret) { if (ret) {
...@@ -1779,13 +1786,12 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, ...@@ -1779,13 +1786,12 @@ analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
goto err_disable_pm_runtime; goto err_disable_pm_runtime;
} }
return dp; return 0;
err_disable_pm_runtime: err_disable_pm_runtime:
pm_runtime_disable(dp->dev);
pm_runtime_disable(dev); return ret;
return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(analogix_dp_bind); EXPORT_SYMBOL_GPL(analogix_dp_bind);
...@@ -1802,10 +1808,15 @@ void analogix_dp_unbind(struct analogix_dp_device *dp) ...@@ -1802,10 +1808,15 @@ void analogix_dp_unbind(struct analogix_dp_device *dp)
drm_dp_aux_unregister(&dp->aux); drm_dp_aux_unregister(&dp->aux);
pm_runtime_disable(dp->dev); pm_runtime_disable(dp->dev);
clk_disable_unprepare(dp->clock);
} }
EXPORT_SYMBOL_GPL(analogix_dp_unbind); EXPORT_SYMBOL_GPL(analogix_dp_unbind);
void analogix_dp_remove(struct analogix_dp_device *dp)
{
clk_disable_unprepare(dp->clock);
}
EXPORT_SYMBOL_GPL(analogix_dp_remove);
#ifdef CONFIG_PM #ifdef CONFIG_PM
int analogix_dp_suspend(struct analogix_dp_device *dp) int analogix_dp_suspend(struct analogix_dp_device *dp)
{ {
......
...@@ -962,27 +962,40 @@ int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, ...@@ -962,27 +962,40 @@ int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
unsigned count; unsigned count;
struct scatterlist *sg; struct scatterlist *sg;
struct page *page; struct page *page;
u32 len, index; u32 page_len, page_index;
dma_addr_t addr; dma_addr_t addr;
u32 dma_len, dma_index;
index = 0; /*
* Scatterlist elements contains both pages and DMA addresses, but
* one shoud not assume 1:1 relation between them. The sg->length is
* the size of the physical memory chunk described by the sg->page,
* while sg_dma_len(sg) is the size of the DMA (IO virtual) chunk
* described by the sg_dma_address(sg).
*/
page_index = 0;
dma_index = 0;
for_each_sg(sgt->sgl, sg, sgt->nents, count) { for_each_sg(sgt->sgl, sg, sgt->nents, count) {
len = sg_dma_len(sg); page_len = sg->length;
page = sg_page(sg); page = sg_page(sg);
dma_len = sg_dma_len(sg);
addr = sg_dma_address(sg); addr = sg_dma_address(sg);
while (len > 0) { while (pages && page_len > 0) {
if (WARN_ON(index >= max_entries)) if (WARN_ON(page_index >= max_entries))
return -1; return -1;
if (pages) pages[page_index] = page;
pages[index] = page;
if (addrs)
addrs[index] = addr;
page++; page++;
page_len -= PAGE_SIZE;
page_index++;
}
while (addrs && dma_len > 0) {
if (WARN_ON(dma_index >= max_entries))
return -1;
addrs[dma_index] = addr;
addr += PAGE_SIZE; addr += PAGE_SIZE;
len -= PAGE_SIZE; dma_len -= PAGE_SIZE;
index++; dma_index++;
} }
} }
return 0; return 0;
......
...@@ -159,15 +159,8 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -159,15 +159,8 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
struct drm_device *drm_dev = data; struct drm_device *drm_dev = data;
int ret; int ret;
dp->dev = dev;
dp->drm_dev = drm_dev; dp->drm_dev = drm_dev;
dp->plat_data.dev_type = EXYNOS_DP;
dp->plat_data.power_on_start = exynos_dp_poweron;
dp->plat_data.power_off = exynos_dp_poweroff;
dp->plat_data.attach = exynos_dp_bridge_attach;
dp->plat_data.get_modes = exynos_dp_get_modes;
if (!dp->plat_data.panel && !dp->ptn_bridge) { if (!dp->plat_data.panel && !dp->ptn_bridge) {
ret = exynos_dp_dt_parse_panel(dp); ret = exynos_dp_dt_parse_panel(dp);
if (ret) if (ret)
...@@ -185,13 +178,11 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) ...@@ -185,13 +178,11 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
dp->plat_data.encoder = encoder; dp->plat_data.encoder = encoder;
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data); ret = analogix_dp_bind(dp->adp, dp->drm_dev);
if (IS_ERR(dp->adp)) { if (ret)
dp->encoder.funcs->destroy(&dp->encoder); dp->encoder.funcs->destroy(&dp->encoder);
return PTR_ERR(dp->adp);
}
return 0; return ret;
} }
static void exynos_dp_unbind(struct device *dev, struct device *master, static void exynos_dp_unbind(struct device *dev, struct device *master,
...@@ -222,6 +213,7 @@ static int exynos_dp_probe(struct platform_device *pdev) ...@@ -222,6 +213,7 @@ static int exynos_dp_probe(struct platform_device *pdev)
if (!dp) if (!dp)
return -ENOMEM; return -ENOMEM;
dp->dev = dev;
/* /*
* We just use the drvdata until driver run into component * We just use the drvdata until driver run into component
* add function, and then we would set drvdata to null, so * add function, and then we would set drvdata to null, so
...@@ -247,16 +239,29 @@ static int exynos_dp_probe(struct platform_device *pdev) ...@@ -247,16 +239,29 @@ static int exynos_dp_probe(struct platform_device *pdev)
/* The remote port can be either a panel or a bridge */ /* The remote port can be either a panel or a bridge */
dp->plat_data.panel = panel; dp->plat_data.panel = panel;
dp->plat_data.dev_type = EXYNOS_DP;
dp->plat_data.power_on_start = exynos_dp_poweron;
dp->plat_data.power_off = exynos_dp_poweroff;
dp->plat_data.attach = exynos_dp_bridge_attach;
dp->plat_data.get_modes = exynos_dp_get_modes;
dp->plat_data.skip_connector = !!bridge; dp->plat_data.skip_connector = !!bridge;
dp->ptn_bridge = bridge; dp->ptn_bridge = bridge;
out: out:
dp->adp = analogix_dp_probe(dev, &dp->plat_data);
if (IS_ERR(dp->adp))
return PTR_ERR(dp->adp);
return component_add(&pdev->dev, &exynos_dp_ops); return component_add(&pdev->dev, &exynos_dp_ops);
} }
static int exynos_dp_remove(struct platform_device *pdev) static int exynos_dp_remove(struct platform_device *pdev)
{ {
struct exynos_dp_device *dp = platform_get_drvdata(pdev);
component_del(&pdev->dev, &exynos_dp_ops); component_del(&pdev->dev, &exynos_dp_ops);
analogix_dp_remove(dp->adp);
return 0; return 0;
} }
......
...@@ -325,15 +325,9 @@ static int rockchip_dp_bind(struct device *dev, struct device *master, ...@@ -325,15 +325,9 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
void *data) void *data)
{ {
struct rockchip_dp_device *dp = dev_get_drvdata(dev); struct rockchip_dp_device *dp = dev_get_drvdata(dev);
const struct rockchip_dp_chip_data *dp_data;
struct drm_device *drm_dev = data; struct drm_device *drm_dev = data;
int ret; int ret;
dp_data = of_device_get_match_data(dev);
if (!dp_data)
return -ENODEV;
dp->data = dp_data;
dp->drm_dev = drm_dev; dp->drm_dev = drm_dev;
ret = rockchip_dp_drm_create_encoder(dp); ret = rockchip_dp_drm_create_encoder(dp);
...@@ -344,16 +338,9 @@ static int rockchip_dp_bind(struct device *dev, struct device *master, ...@@ -344,16 +338,9 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
dp->plat_data.encoder = &dp->encoder; dp->plat_data.encoder = &dp->encoder;
dp->plat_data.dev_type = dp->data->chip_type; ret = analogix_dp_bind(dp->adp, drm_dev);
dp->plat_data.power_on_start = rockchip_dp_poweron_start; if (ret)
dp->plat_data.power_off = rockchip_dp_powerdown;
dp->plat_data.get_modes = rockchip_dp_get_modes;
dp->adp = analogix_dp_bind(dev, dp->drm_dev, &dp->plat_data);
if (IS_ERR(dp->adp)) {
ret = PTR_ERR(dp->adp);
goto err_cleanup_encoder; goto err_cleanup_encoder;
}
return 0; return 0;
err_cleanup_encoder: err_cleanup_encoder:
...@@ -368,8 +355,6 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master, ...@@ -368,8 +355,6 @@ static void rockchip_dp_unbind(struct device *dev, struct device *master,
analogix_dp_unbind(dp->adp); analogix_dp_unbind(dp->adp);
dp->encoder.funcs->destroy(&dp->encoder); dp->encoder.funcs->destroy(&dp->encoder);
dp->adp = ERR_PTR(-ENODEV);
} }
static const struct component_ops rockchip_dp_component_ops = { static const struct component_ops rockchip_dp_component_ops = {
...@@ -380,10 +365,15 @@ static const struct component_ops rockchip_dp_component_ops = { ...@@ -380,10 +365,15 @@ static const struct component_ops rockchip_dp_component_ops = {
static int rockchip_dp_probe(struct platform_device *pdev) static int rockchip_dp_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
const struct rockchip_dp_chip_data *dp_data;
struct drm_panel *panel = NULL; struct drm_panel *panel = NULL;
struct rockchip_dp_device *dp; struct rockchip_dp_device *dp;
int ret; int ret;
dp_data = of_device_get_match_data(dev);
if (!dp_data)
return -ENODEV;
ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL); ret = drm_of_find_panel_or_bridge(dev->of_node, 1, 0, &panel, NULL);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -394,7 +384,12 @@ static int rockchip_dp_probe(struct platform_device *pdev) ...@@ -394,7 +384,12 @@ static int rockchip_dp_probe(struct platform_device *pdev)
dp->dev = dev; dp->dev = dev;
dp->adp = ERR_PTR(-ENODEV); dp->adp = ERR_PTR(-ENODEV);
dp->data = dp_data;
dp->plat_data.panel = panel; dp->plat_data.panel = panel;
dp->plat_data.dev_type = dp->data->chip_type;
dp->plat_data.power_on_start = rockchip_dp_poweron_start;
dp->plat_data.power_off = rockchip_dp_powerdown;
dp->plat_data.get_modes = rockchip_dp_get_modes;
ret = rockchip_dp_of_probe(dp); ret = rockchip_dp_of_probe(dp);
if (ret < 0) if (ret < 0)
...@@ -402,12 +397,19 @@ static int rockchip_dp_probe(struct platform_device *pdev) ...@@ -402,12 +397,19 @@ static int rockchip_dp_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dp); platform_set_drvdata(pdev, dp);
dp->adp = analogix_dp_probe(dev, &dp->plat_data);
if (IS_ERR(dp->adp))
return PTR_ERR(dp->adp);
return component_add(dev, &rockchip_dp_component_ops); return component_add(dev, &rockchip_dp_component_ops);
} }
static int rockchip_dp_remove(struct platform_device *pdev) static int rockchip_dp_remove(struct platform_device *pdev)
{ {
struct rockchip_dp_device *dp = platform_get_drvdata(pdev);
component_del(&pdev->dev, &rockchip_dp_component_ops); component_del(&pdev->dev, &rockchip_dp_component_ops);
analogix_dp_remove(dp->adp);
return 0; return 0;
} }
......
...@@ -123,15 +123,17 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo) ...@@ -123,15 +123,17 @@ bool virtio_gpu_is_shmem(struct virtio_gpu_object *bo)
struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev, struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev,
size_t size) size_t size)
{ {
struct virtio_gpu_object *bo; struct virtio_gpu_object_shmem *shmem;
struct drm_gem_shmem_object *dshmem;
bo = kzalloc(sizeof(*bo), GFP_KERNEL); shmem = kzalloc(sizeof(*shmem), GFP_KERNEL);
if (!bo) if (!shmem)
return NULL; return NULL;
bo->base.base.funcs = &virtio_gpu_shmem_funcs; dshmem = &shmem->base.base;
bo->base.map_cached = true; dshmem->base.funcs = &virtio_gpu_shmem_funcs;
return &bo->base.base; dshmem->map_cached = true;
return &dshmem->base;
} }
static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev, static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
......
...@@ -42,9 +42,10 @@ int analogix_dp_resume(struct analogix_dp_device *dp); ...@@ -42,9 +42,10 @@ int analogix_dp_resume(struct analogix_dp_device *dp);
int analogix_dp_suspend(struct analogix_dp_device *dp); int analogix_dp_suspend(struct analogix_dp_device *dp);
struct analogix_dp_device * struct analogix_dp_device *
analogix_dp_bind(struct device *dev, struct drm_device *drm_dev, analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data);
struct analogix_dp_plat_data *plat_data); int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev);
void analogix_dp_unbind(struct analogix_dp_device *dp); void analogix_dp_unbind(struct analogix_dp_device *dp);
void analogix_dp_remove(struct analogix_dp_device *dp);
int analogix_dp_start_crc(struct drm_connector *connector); int analogix_dp_start_crc(struct drm_connector *connector);
int analogix_dp_stop_crc(struct drm_connector *connector); int analogix_dp_stop_crc(struct drm_connector *connector);
......
...@@ -136,7 +136,7 @@ struct drm_sg_mem { ...@@ -136,7 +136,7 @@ struct drm_sg_mem {
* Kernel side of a mapping * Kernel side of a mapping
*/ */
struct drm_local_map { struct drm_local_map {
resource_size_t offset; /**< Requested physical address (0 for SAREA)*/ dma_addr_t offset; /**< Requested physical address (0 for SAREA)*/
unsigned long size; /**< Requested physical size (bytes) */ unsigned long size; /**< Requested physical size (bytes) */
enum drm_map_type type; /**< Type of memory to map */ enum drm_map_type type; /**< Type of memory to map */
enum drm_map_flags flags; /**< Flags */ enum drm_map_flags flags; /**< Flags */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment