Skip to content

Commit

Permalink
Merge tag 'drm-misc-fixes-2022-06-23' of git://anongit.freedesktop.or…
Browse files Browse the repository at this point in the history
…g/drm/drm-misc into drm-fixes

Multiple fixes in sun4i for suspend, DDC, DMA setup; A rework of vc4 to
properly split the driver between hardware capabilities that wasn't done
properly causing multiple crashes; and a panel quirk for Aya Neo Next

Signed-off-by: Dave Airlie <[email protected]>

From: Maxime Ripard <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/20220623064152.ubjmnpj7tdejdcw6@houat
  • Loading branch information
airlied committed Jun 23, 2022
2 parents 382cf35 + 85016f6 commit 0a86b0d
Show file tree
Hide file tree
Showing 20 changed files with 503 additions and 162 deletions.
6 changes: 6 additions & 0 deletions drivers/gpu/drm/drm_panel_orientation_quirks.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ static const struct dmi_system_id orientation_data[] = {
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "AYA NEO 2021"),
},
.driver_data = (void *)&lcd800x1280_rightside_up,
}, { /* AYA NEO NEXT */
.matches = {
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AYANEO"),
DMI_MATCH(DMI_BOARD_NAME, "NEXT"),
},
.driver_data = (void *)&lcd800x1280_rightside_up,
}, { /* Chuwi HiBook (CWI514) */
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "Hampoo"),
Expand Down
12 changes: 11 additions & 1 deletion drivers/gpu/drm/sun4i/sun4i_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <linux/component.h>
#include <linux/dma-mapping.h>
#include <linux/kfifo.h>
#include <linux/module.h>
#include <linux/of_graph.h>
Expand Down Expand Up @@ -73,7 +74,6 @@ static int sun4i_drv_bind(struct device *dev)
goto free_drm;
}

dev_set_drvdata(dev, drm);
drm->dev_private = drv;
INIT_LIST_HEAD(&drv->frontend_list);
INIT_LIST_HEAD(&drv->engine_list);
Expand Down Expand Up @@ -114,6 +114,8 @@ static int sun4i_drv_bind(struct device *dev)

drm_fbdev_generic_setup(drm, 32);

dev_set_drvdata(dev, drm);

return 0;

finish_poll:
Expand All @@ -130,6 +132,7 @@ static void sun4i_drv_unbind(struct device *dev)
{
struct drm_device *drm = dev_get_drvdata(dev);

dev_set_drvdata(dev, NULL);
drm_dev_unregister(drm);
drm_kms_helper_poll_fini(drm);
drm_atomic_helper_shutdown(drm);
Expand Down Expand Up @@ -367,6 +370,13 @@ static int sun4i_drv_probe(struct platform_device *pdev)

INIT_KFIFO(list.fifo);

/*
* DE2 and DE3 cores actually supports 40-bit addresses, but
* driver does not.
*/
dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
dma_set_max_seg_size(&pdev->dev, UINT_MAX);

for (i = 0;; i++) {
struct device_node *pipeline = of_parse_phandle(np,
"allwinner,pipelines",
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/sun4i/sun4i_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static bool sun4i_layer_format_mod_supported(struct drm_plane *plane,
struct sun4i_layer *layer = plane_to_sun4i_layer(plane);

if (IS_ERR_OR_NULL(layer->backend->frontend))
sun4i_backend_format_is_supported(format, modifier);
return sun4i_backend_format_is_supported(format, modifier);

return sun4i_backend_format_is_supported(format, modifier) ||
sun4i_frontend_format_is_supported(format, modifier);
Expand Down
54 changes: 4 additions & 50 deletions drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,34 +93,10 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
return crtcs;
}

static int sun8i_dw_hdmi_find_connector_pdev(struct device *dev,
struct platform_device **pdev_out)
{
struct platform_device *pdev;
struct device_node *remote;

remote = of_graph_get_remote_node(dev->of_node, 1, -1);
if (!remote)
return -ENODEV;

if (!of_device_is_compatible(remote, "hdmi-connector")) {
of_node_put(remote);
return -ENODEV;
}

pdev = of_find_device_by_node(remote);
of_node_put(remote);
if (!pdev)
return -ENODEV;

*pdev_out = pdev;
return 0;
}

static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
void *data)
{
struct platform_device *pdev = to_platform_device(dev), *connector_pdev;
struct platform_device *pdev = to_platform_device(dev);
struct dw_hdmi_plat_data *plat_data;
struct drm_device *drm = data;
struct device_node *phy_node;
Expand Down Expand Up @@ -167,30 +143,16 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
return dev_err_probe(dev, PTR_ERR(hdmi->regulator),
"Couldn't get regulator\n");

ret = sun8i_dw_hdmi_find_connector_pdev(dev, &connector_pdev);
if (!ret) {
hdmi->ddc_en = gpiod_get_optional(&connector_pdev->dev,
"ddc-en", GPIOD_OUT_HIGH);
platform_device_put(connector_pdev);

if (IS_ERR(hdmi->ddc_en)) {
dev_err(dev, "Couldn't get ddc-en gpio\n");
return PTR_ERR(hdmi->ddc_en);
}
}

ret = regulator_enable(hdmi->regulator);
if (ret) {
dev_err(dev, "Failed to enable regulator\n");
goto err_unref_ddc_en;
return ret;
}

gpiod_set_value(hdmi->ddc_en, 1);

ret = reset_control_deassert(hdmi->rst_ctrl);
if (ret) {
dev_err(dev, "Could not deassert ctrl reset control\n");
goto err_disable_ddc_en;
goto err_disable_regulator;
}

ret = clk_prepare_enable(hdmi->clk_tmds);
Expand Down Expand Up @@ -245,12 +207,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
clk_disable_unprepare(hdmi->clk_tmds);
err_assert_ctrl_reset:
reset_control_assert(hdmi->rst_ctrl);
err_disable_ddc_en:
gpiod_set_value(hdmi->ddc_en, 0);
err_disable_regulator:
regulator_disable(hdmi->regulator);
err_unref_ddc_en:
if (hdmi->ddc_en)
gpiod_put(hdmi->ddc_en);

return ret;
}
Expand All @@ -264,11 +222,7 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,
sun8i_hdmi_phy_deinit(hdmi->phy);
clk_disable_unprepare(hdmi->clk_tmds);
reset_control_assert(hdmi->rst_ctrl);
gpiod_set_value(hdmi->ddc_en, 0);
regulator_disable(hdmi->regulator);

if (hdmi->ddc_en)
gpiod_put(hdmi->ddc_en);
}

static const struct component_ops sun8i_dw_hdmi_ops = {
Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <drm/bridge/dw_hdmi.h>
#include <drm/drm_encoder.h>
#include <linux/clk.h>
#include <linux/gpio/consumer.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
Expand Down Expand Up @@ -193,7 +192,6 @@ struct sun8i_dw_hdmi {
struct regulator *regulator;
const struct sun8i_dw_hdmi_quirks *quirks;
struct reset_control *rst_ctrl;
struct gpio_desc *ddc_en;
};

extern struct platform_driver sun8i_hdmi_phy_driver;
Expand Down
62 changes: 54 additions & 8 deletions drivers/gpu/drm/vc4/vc4_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo)
{
struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);

if (WARN_ON_ONCE(vc4->is_vc5))
return;

mutex_lock(&vc4->purgeable.lock);
list_add_tail(&bo->size_head, &vc4->purgeable.list);
vc4->purgeable.num++;
Expand All @@ -259,6 +262,9 @@ static void vc4_bo_remove_from_purgeable_pool_locked(struct vc4_bo *bo)
{
struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);

if (WARN_ON_ONCE(vc4->is_vc5))
return;

/* list_del_init() is used here because the caller might release
* the purgeable lock in order to acquire the madv one and update the
* madv status.
Expand Down Expand Up @@ -387,6 +393,9 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size)
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_bo *bo;

if (WARN_ON_ONCE(vc4->is_vc5))
return ERR_PTR(-ENODEV);

bo = kzalloc(sizeof(*bo), GFP_KERNEL);
if (!bo)
return ERR_PTR(-ENOMEM);
Expand All @@ -413,6 +422,9 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
struct drm_gem_cma_object *cma_obj;
struct vc4_bo *bo;

if (WARN_ON_ONCE(vc4->is_vc5))
return ERR_PTR(-ENODEV);

if (size == 0)
return ERR_PTR(-EINVAL);

Expand Down Expand Up @@ -471,19 +483,20 @@ struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t unaligned_size,
return bo;
}

int vc4_dumb_create(struct drm_file *file_priv,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
int vc4_bo_dumb_create(struct drm_file *file_priv,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_bo *bo = NULL;
int ret;

if (args->pitch < min_pitch)
args->pitch = min_pitch;
if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

if (args->size < args->pitch * args->height)
args->size = args->pitch * args->height;
ret = vc4_dumb_fixup_args(args);
if (ret)
return ret;

bo = vc4_bo_create(dev, args->size, false, VC4_BO_TYPE_DUMB);
if (IS_ERR(bo))
Expand Down Expand Up @@ -601,8 +614,12 @@ static void vc4_bo_cache_time_work(struct work_struct *work)

int vc4_bo_inc_usecnt(struct vc4_bo *bo)
{
struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
int ret;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

/* Fast path: if the BO is already retained by someone, no need to
* check the madv status.
*/
Expand Down Expand Up @@ -637,6 +654,11 @@ int vc4_bo_inc_usecnt(struct vc4_bo *bo)

void vc4_bo_dec_usecnt(struct vc4_bo *bo)
{
struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);

if (WARN_ON_ONCE(vc4->is_vc5))
return;

/* Fast path: if the BO is still retained by someone, no need to test
* the madv value.
*/
Expand Down Expand Up @@ -756,6 +778,9 @@ int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
struct vc4_bo *bo = NULL;
int ret;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

ret = vc4_grab_bin_bo(vc4, vc4file);
if (ret)
return ret;
Expand All @@ -779,9 +804,13 @@ int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct drm_vc4_mmap_bo *args = data;
struct drm_gem_object *gem_obj;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

gem_obj = drm_gem_object_lookup(file_priv, args->handle);
if (!gem_obj) {
DRM_DEBUG("Failed to look up GEM BO %d\n", args->handle);
Expand All @@ -805,6 +834,9 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
struct vc4_bo *bo = NULL;
int ret;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

if (args->size == 0)
return -EINVAL;

Expand Down Expand Up @@ -875,11 +907,15 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
int vc4_set_tiling_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct drm_vc4_set_tiling *args = data;
struct drm_gem_object *gem_obj;
struct vc4_bo *bo;
bool t_format;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

if (args->flags != 0)
return -EINVAL;

Expand Down Expand Up @@ -918,10 +954,14 @@ int vc4_set_tiling_ioctl(struct drm_device *dev, void *data,
int vc4_get_tiling_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
struct vc4_dev *vc4 = to_vc4_dev(dev);
struct drm_vc4_get_tiling *args = data;
struct drm_gem_object *gem_obj;
struct vc4_bo *bo;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

if (args->flags != 0 || args->modifier != 0)
return -EINVAL;

Expand All @@ -948,6 +988,9 @@ int vc4_bo_cache_init(struct drm_device *dev)
struct vc4_dev *vc4 = to_vc4_dev(dev);
int i;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

/* Create the initial set of BO labels that the kernel will
* use. This lets us avoid a bunch of string reallocation in
* the kernel's draw and BO allocation paths.
Expand Down Expand Up @@ -1007,6 +1050,9 @@ int vc4_label_bo_ioctl(struct drm_device *dev, void *data,
struct drm_gem_object *gem_obj;
int ret = 0, label;

if (WARN_ON_ONCE(vc4->is_vc5))
return -ENODEV;

if (!args->len)
return -EINVAL;

Expand Down
Loading

0 comments on commit 0a86b0d

Please sign in to comment.