From d17685260b8533a599429eaaf682db78a1f6758e Mon Sep 17 00:00:00 2001 From: Zhen Lei Date: Tue, 11 May 2021 17:04:33 +0800 Subject: [PATCH 01/18] drm/panfrost: Remove redundant error printing in panfrost_device_init() When devm_ioremap_resource() fails, a clear enough error message will be printed by its subfunction __devm_ioremap_resource(). The error information contains the device name, failure cause, and possibly resource information. Therefore, remove the error printing here to simplify code and reduce the binary size. Reported-by: Hulk Robot Signed-off-by: Zhen Lei Reviewed-by: Steven Price Signed-off-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20210511090433.4396-1-thunder.leizhen@huawei.com --- drivers/gpu/drm/panfrost/panfrost_device.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index fbcf5edbe367..125ed973feaa 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -238,7 +238,6 @@ int panfrost_device_init(struct panfrost_device *pfdev) res = platform_get_resource(pfdev->pdev, IORESOURCE_MEM, 0); pfdev->iomem = devm_ioremap_resource(pfdev->dev, res); if (IS_ERR(pfdev->iomem)) { - dev_err(pfdev->dev, "failed to ioremap iomem\n"); err = PTR_ERR(pfdev->iomem); goto out_pm_domain; } From 68b433fe6937cfa3f8975d18643d5956254edd6a Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Mon, 29 Mar 2021 18:50:45 +0100 Subject: [PATCH 02/18] drm/ingenic: Switch IPU plane to type OVERLAY It should have been an OVERLAY from the beginning. The documentation stipulates that there should be an unique PRIMARY plane per CRTC. Fixes: fc1acf317b01 ("drm/ingenic: Add support for the IPU") Cc: # 5.8+ Signed-off-by: Paul Cercueil Acked-by: Simon Ser Link: https://patchwork.freedesktop.org/patch/msgid/20210329175046.214629-2-paul@crapouillou.net --- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 11 +++++------ drivers/gpu/drm/ingenic/ingenic-ipu.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c index 29742ec5ab95..09225b770bb8 100644 --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c @@ -419,7 +419,7 @@ static void ingenic_drm_plane_enable(struct ingenic_drm *priv, unsigned int en_bit; if (priv->soc_info->has_osd) { - if (plane->type == DRM_PLANE_TYPE_PRIMARY) + if (plane != &priv->f0) en_bit = JZ_LCD_OSDC_F1EN; else en_bit = JZ_LCD_OSDC_F0EN; @@ -434,7 +434,7 @@ void ingenic_drm_plane_disable(struct device *dev, struct drm_plane *plane) unsigned int en_bit; if (priv->soc_info->has_osd) { - if (plane->type == DRM_PLANE_TYPE_PRIMARY) + if (plane != &priv->f0) en_bit = JZ_LCD_OSDC_F1EN; else en_bit = JZ_LCD_OSDC_F0EN; @@ -461,8 +461,7 @@ void ingenic_drm_plane_config(struct device *dev, ingenic_drm_plane_enable(priv, plane); - if (priv->soc_info->has_osd && - plane->type == DRM_PLANE_TYPE_PRIMARY) { + if (priv->soc_info->has_osd && plane != &priv->f0) { switch (fourcc) { case DRM_FORMAT_XRGB1555: ctrl |= JZ_LCD_OSDCTRL_RGB555; @@ -510,7 +509,7 @@ void ingenic_drm_plane_config(struct device *dev, } if (priv->soc_info->has_osd) { - if (plane->type == DRM_PLANE_TYPE_PRIMARY) { + if (plane != &priv->f0) { xy_reg = JZ_REG_LCD_XYP1; size_reg = JZ_REG_LCD_SIZE1; } else { @@ -561,7 +560,7 @@ static void ingenic_drm_plane_atomic_update(struct drm_plane *plane, height = newstate->src_h >> 16; cpp = newstate->fb->format->cpp[0]; - if (!priv->soc_info->has_osd || plane->type == DRM_PLANE_TYPE_OVERLAY) + if (!priv->soc_info->has_osd || plane == &priv->f0) hwdesc = &priv->dma_hwdescs->hwdesc_f0; else hwdesc = &priv->dma_hwdescs->hwdesc_f1; diff --git a/drivers/gpu/drm/ingenic/ingenic-ipu.c b/drivers/gpu/drm/ingenic/ingenic-ipu.c index 5ae6adab8306..3b1091e7c0cd 100644 --- a/drivers/gpu/drm/ingenic/ingenic-ipu.c +++ b/drivers/gpu/drm/ingenic/ingenic-ipu.c @@ -767,7 +767,7 @@ static int ingenic_ipu_bind(struct device *dev, struct device *master, void *d) err = drm_universal_plane_init(drm, plane, 1, &ingenic_ipu_plane_funcs, soc_info->formats, soc_info->num_formats, - NULL, DRM_PLANE_TYPE_PRIMARY, NULL); + NULL, DRM_PLANE_TYPE_OVERLAY, NULL); if (err) { dev_err(dev, "Failed to init plane: %i\n", err); return err; From bfba94162ba7b1ab28bf78ccab8808c4a000fd8f Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 12 May 2021 20:55:27 +0200 Subject: [PATCH 03/18] drm/nouveau: Remove invalid reference to struct drm_device.pdev The pdev field got removed from struct drm_device recently. Replace the invalid reference with an upcast from the struct's dev field. Signed-off-by: Thomas Zimmermann Reviewed-by: Dave Airlie Reported-by: Stephen Rothwell Fixes: b347e04452ff ("drm: Remove pdev field from struct drm_device") Cc: Thomas Zimmermann Cc: Maxime Ripard Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Link: https://patchwork.freedesktop.org/patch/msgid/20210512185527.26050-1-tzimmermann@suse.de --- drivers/gpu/drm/nouveau/nouveau_connector.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 7f38788a6c2b..2a298c171d4d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -460,7 +460,8 @@ nouveau_connector_of_detect(struct drm_connector *connector) struct drm_device *dev = connector->dev; struct nouveau_connector *nv_connector = nouveau_connector(connector); struct nouveau_encoder *nv_encoder; - struct device_node *cn, *dn = pci_device_to_OF_node(dev->pdev); + struct pci_dev *pdev = to_pci_dev(dev->dev); + struct device_node *cn, *dn = pci_device_to_OF_node(pdev); if (!dn || !((nv_encoder = find_encoder(connector, DCB_OUTPUT_TMDS)) || From d84680d359378a79664fa840cd144ba0f715968d Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 12 May 2021 16:34:59 -0700 Subject: [PATCH 04/18] drm: simpledrm: print resource info using '%pr' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit struct resource start and end fields are not always long long, so using %llx to print them can cause build warnings (below). Fix these by using the special "%pr" for printing struct resource info. ../drivers/gpu/drm/tiny/simpledrm.c: In function ‘simpledrm_device_init_mm’: ../include/drm/drm_print.h:412:32: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘resource_size_t {aka unsigned int}’ [-Wformat=] ../drivers/gpu/drm/tiny/simpledrm.c:533:54: note: format string is defined here drm_err(dev, "could not acquire memory range [0x%llx:0x%llx]: error %d\n", ~~~^ %x ../include/drm/drm_print.h:412:32: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘resource_size_t {aka unsigned int}’ [-Wformat=] ../drivers/gpu/drm/tiny/simpledrm.c:533:61: note: format string is defined here drm_err(dev, "could not acquire memory range [0x%llx:0x%llx]: error %d\n", ~~~^ %x Fixes: 4aae79f77e3a ("drm/simpledrm: Acquire memory aperture for framebuffer") Signed-off-by: Randy Dunlap Cc: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org Signed-off-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/20210512233459.19534-1-rdunlap@infradead.org --- drivers/gpu/drm/tiny/simpledrm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index 2bdb477d9326..00e118c6e2e8 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -530,8 +530,8 @@ static int simpledrm_device_init_mm(struct simpledrm_device *sdev) ret = devm_aperture_acquire_from_firmware(dev, mem->start, resource_size(mem)); if (ret) { - drm_err(dev, "could not acquire memory range [0x%llx:0x%llx]: error %d\n", - mem->start, mem->end, ret); + drm_err(dev, "could not acquire memory range %pr: error %d\n", + mem, ret); return ret; } From 858aa5a4be22368f8d0e8ace7dc0b5ffb62bbdbc Mon Sep 17 00:00:00 2001 From: Zou Wei Date: Thu, 13 May 2021 16:46:04 +0800 Subject: [PATCH 05/18] drm/aperture: Fix missing unlock on error in devm_aperture_acquire() Add the missing unlock before return from function devm_aperture_acquire() in the error handling case. Signed-off-by: Zou Wei Signed-off-by: Thomas Zimmermann Reported-by: Hulk Robot Fixes: 730e7992dc1b ("drm/aperture: Add infrastructure for aperture ownership") Cc: Thomas Zimmermann Cc: Daniel Vetter Cc: Maxime Ripard Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Link: https://patchwork.freedesktop.org/patch/msgid/1620895564-52367-1-git-send-email-zou_wei@huawei.com --- drivers/gpu/drm/drm_aperture.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_aperture.c b/drivers/gpu/drm/drm_aperture.c index 33bf018c3bdf..9335d9d6cf9a 100644 --- a/drivers/gpu/drm/drm_aperture.c +++ b/drivers/gpu/drm/drm_aperture.c @@ -164,13 +164,17 @@ static int devm_aperture_acquire(struct drm_device *dev, list_for_each(pos, &drm_apertures) { ap = container_of(pos, struct drm_aperture, lh); - if (overlap(base, end, ap->base, ap->base + ap->size)) + if (overlap(base, end, ap->base, ap->base + ap->size)) { + mutex_unlock(&drm_apertures_lock); return -EBUSY; + } } ap = devm_kzalloc(dev->dev, sizeof(*ap), GFP_KERNEL); - if (!ap) + if (!ap) { + mutex_unlock(&drm_apertures_lock); return -ENOMEM; + } ap->dev = dev; ap->base = base; From 0ff9bf9f3e0ce212aabea84365575466039e8c46 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 12 May 2021 21:30:51 +0100 Subject: [PATCH 06/18] drm: simpledrm: Fix use after free issues There are two occurrances where objects are being free'd via a put call and yet they are being referenced after this. Fix these by adding in the missing continue statement so that the put on the end of the loop is skipped over. Signed-off-by: Colin Ian King Signed-off-by: Thomas Zimmermann Addresses-Coverity: ("Use after free") Fixes: 11e8f5fd223b ("drm: Add simpledrm driver") Link: https://patchwork.freedesktop.org/patch/msgid/20210512203051.299026-1-colin.king@canonical.com --- drivers/gpu/drm/tiny/simpledrm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index 00e118c6e2e8..f72ca3a1c2d4 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -298,6 +298,7 @@ static int simpledrm_device_init_clocks(struct simpledrm_device *sdev) drm_err(dev, "failed to enable clock %u: %d\n", i, ret); clk_put(clock); + continue; } sdev->clks[i] = clock; } @@ -415,6 +416,7 @@ static int simpledrm_device_init_regulators(struct simpledrm_device *sdev) drm_err(dev, "failed to enable regulator %u: %d\n", i, ret); regulator_put(regulator); + continue; } sdev->regulators[i++] = regulator; From a7f0849682b75b6d50f07c70090443eebd90218c Mon Sep 17 00:00:00 2001 From: David M Nieto Date: Thu, 13 May 2021 10:45:38 -0700 Subject: [PATCH 07/18] drm/amdgpu: free resources on fence usage query Free the resources if the fence needs to be ignored during the ratio calculation Reviewed-by: Alex Deucher Signed-off-by: David M Nieto Signed-off-by: Alex Deucher Link: https://patchwork.freedesktop.org/patch/msgid/20210513174539.27409-1-david.nieto@amd.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 01fe60fedcbe..9036c93b4a0c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -669,11 +669,15 @@ void amdgpu_ctx_fence_time(struct amdgpu_ctx *ctx, struct amdgpu_ctx_entity *cen if (!fence) continue; s_fence = to_drm_sched_fence(fence); - if (!dma_fence_is_signaled(&s_fence->scheduled)) + if (!dma_fence_is_signaled(&s_fence->scheduled)) { + dma_fence_put(fence); continue; + } t1 = s_fence->scheduled.timestamp; - if (t1 >= now) + if (!ktime_before(t1, now)) { + dma_fence_put(fence); continue; + } if (dma_fence_is_signaled(&s_fence->finished) && s_fence->finished.timestamp < now) *total += ktime_sub(s_fence->finished.timestamp, t1); From 5c439c38f5fb8fd16b65af4d5bc4618d1ec9bca3 Mon Sep 17 00:00:00 2001 From: David M Nieto Date: Thu, 13 May 2021 10:45:39 -0700 Subject: [PATCH 08/18] drm/amdgpu: fix fence calculation (v2) The proper metric for fence utilization over several contexts is an harmonic mean, but such calculation is prohibitive in kernel space, so the code approximates it. Because the approximation diverges when one context has a very small ratio compared with the other context, this change filter out ratios smaller that 0.01% v2: make the fence calculation static and initialize variables within that function v3: Fix warnings (Alex) Reviewed-by: Alex Deucher Signed-off-by: David M Nieto Signed-off-by: Alex Deucher Link: https://patchwork.freedesktop.org/patch/msgid/20210513174539.27409-2-david.nieto@amd.com --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 19 ++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 3 +-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c index 9036c93b4a0c..fc83445fbc40 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c @@ -652,12 +652,14 @@ void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr) mutex_destroy(&mgr->lock); } -void amdgpu_ctx_fence_time(struct amdgpu_ctx *ctx, struct amdgpu_ctx_entity *centity, - ktime_t *total, ktime_t *max) +static void amdgpu_ctx_fence_time(struct amdgpu_ctx *ctx, + struct amdgpu_ctx_entity *centity, ktime_t *total, ktime_t *max) { ktime_t now, t1; uint32_t i; + *total = *max = 0; + now = ktime_get(); for (i = 0; i < amdgpu_sched_jobs; i++) { struct dma_fence *fence; @@ -703,11 +705,22 @@ ktime_t amdgpu_ctx_mgr_fence_usage(struct amdgpu_ctx_mgr *mgr, uint32_t hwip, idp = &mgr->ctx_handles; mutex_lock(&mgr->lock); idr_for_each_entry(idp, ctx, id) { + ktime_t ttotal, tmax; + if (!ctx->entities[hwip][idx]) continue; centity = ctx->entities[hwip][idx]; - amdgpu_ctx_fence_time(ctx, centity, &total, &max); + amdgpu_ctx_fence_time(ctx, centity, &ttotal, &tmax); + + /* Harmonic mean approximation diverges for very small + * values. If ratio < 0.01% ignore + */ + if (AMDGPU_CTX_FENCE_USAGE_MIN_RATIO(tmax, ttotal)) + continue; + + total = ktime_add(total, ttotal); + max = ktime_after(tmax, max) ? tmax : max; } mutex_unlock(&mgr->lock); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h index 10dcf59a5c6b..14db16bc3322 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h @@ -30,6 +30,7 @@ struct drm_file; struct amdgpu_fpriv; #define AMDGPU_MAX_ENTITY_NUM 4 +#define AMDGPU_CTX_FENCE_USAGE_MIN_RATIO(max, total) ((max) > 16384ULL*(total)) struct amdgpu_ctx_entity { uint64_t sequence; @@ -89,6 +90,4 @@ long amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr, long timeout); void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr); ktime_t amdgpu_ctx_mgr_fence_usage(struct amdgpu_ctx_mgr *mgr, uint32_t hwip, uint32_t idx, uint64_t *elapsed); -void amdgpu_ctx_fence_time(struct amdgpu_ctx *ctx, struct amdgpu_ctx_entity *centity, - ktime_t *total, ktime_t *max); #endif From e3c2f1870af43fc95f6fe141537f5142c5fe4717 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Wed, 17 Mar 2021 14:05:42 +1100 Subject: [PATCH 09/18] drm/i915: Merge fix for "drm: Switch to %p4cc format modifier" Signed-off-by: Stephen Rothwell Signed-off-by: Thomas Zimmermann Fixes: 92f1d09ca4ed ("drm: Switch to %p4cc format modifier") Cc: Sakari Ailus Cc: Petr Mladek Cc: Andy Shevchenko Cc: dri-devel@lists.freedesktop.org Link: https://lore.kernel.org/dri-devel/20210514115307.4364aff9@canb.auug.org.au/T/#macc61d4e0b17ca0da2b26aae8fbbcbf47324da13 --- drivers/gpu/drm/i915/display/skl_universal_plane.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c index 7ffd7b570b54..538682f882b1 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c @@ -1082,7 +1082,6 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state, struct drm_i915_private *dev_priv = to_i915(plane->base.dev); const struct drm_framebuffer *fb = plane_state->hw.fb; unsigned int rotation = plane_state->hw.rotation; - struct drm_format_name_buf format_name; if (!fb) return 0; @@ -1130,9 +1129,8 @@ static int skl_plane_check_fb(const struct intel_crtc_state *crtc_state, case DRM_FORMAT_XVYU12_16161616: case DRM_FORMAT_XVYU16161616: drm_dbg_kms(&dev_priv->drm, - "Unsupported pixel format %s for 90/270!\n", - drm_get_format_name(fb->format->format, - &format_name)); + "Unsupported pixel format %p4cc for 90/270!\n", + &fb->format->format); return -EINVAL; default: break; From a7a596cd31151b08ad0273af3665dac8c0b93842 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 21 Apr 2021 13:28:52 +0800 Subject: [PATCH 10/18] dt-bindings: gpu: mali-bifrost: Add Mediatek MT8183 Define a compatible string for the Mali Bifrost GPU found in Mediatek's MT8183 SoCs. Signed-off-by: Nicolas Boichat Reviewed-by: Rob Herring Signed-off-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20210421132841.v13.1.Ie74d3355761aab202d4825ac6f66d990bba0130e@changeid --- .../bindings/gpu/arm,mali-bifrost.yaml | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml index 894ba217ab32..0f73f436bea7 100644 --- a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml +++ b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml @@ -17,6 +17,7 @@ properties: items: - enum: - amlogic,meson-g12a-mali + - mediatek,mt8183-mali - realtek,rtd1619-mali - rockchip,px30-mali - const: arm,mali-bifrost # Mali Bifrost GPU model/revision is fully discoverable @@ -41,10 +42,13 @@ properties: mali-supply: true + sram-supply: true + operating-points-v2: true power-domains: - maxItems: 1 + minItems: 1 + maxItems: 3 resets: maxItems: 2 @@ -89,6 +93,30 @@ allOf: then: required: - resets + - if: + properties: + compatible: + contains: + const: mediatek,mt8183-mali + then: + properties: + power-domains: + minItems: 3 + power-domain-names: + items: + - const: core0 + - const: core1 + - const: core2 + + required: + - sram-supply + - power-domains + - power-domain-names + else: + properties: + power-domains: + maxItems: 1 + sram-supply: false examples: - | From 09da3191827f2fd326205fb58881838e6ea36fb7 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 21 Apr 2021 13:28:54 +0800 Subject: [PATCH 11/18] drm/panfrost: devfreq: Disable devfreq when num_supplies > 1 GPUs with more than a single regulator (e.g. G72 on MT8183) will require platform-specific handling for devfreq, for 2 reasons: 1. The opp core (drivers/opp/core.c:_generic_set_opp_regulator) does not support multiple regulators, so we'll need custom handlers. 2. Generally, platforms with 2 regulators have platform-specific constraints on how the voltages should be set (e.g. minimum/maximum voltage difference between them), so we should not just create generic handlers that simply change the voltages without taking care of those constraints. Disable devfreq for now on those GPUs. Signed-off-by: Nicolas Boichat Reviewed-by: Tomeu Vizoso Reviewed-by: Steven Price Signed-off-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20210421132841.v13.3.I3af068abe30c9c85cabc4486385c52e56527a509@changeid --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 47d27e54a34f..3644652f726f 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -92,6 +92,15 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct thermal_cooling_device *cooling; struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; + if (pfdev->comp->num_supplies > 1) { + /* + * GPUs with more than 1 supply require platform-specific handling: + * continue without devfreq + */ + DRM_DEV_INFO(dev, "More than 1 supply is not supported yet\n"); + return 0; + } + ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names, pfdev->comp->num_supplies); if (ret) { From 1275e41753683f992177d74f450437f1a3be33c0 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 21 Apr 2021 13:28:55 +0800 Subject: [PATCH 12/18] drm/panfrost: Add mt8183-mali compatible string Add support for MT8183's G72 Bifrost. Signed-off-by: Nicolas Boichat Reviewed-by: Tomeu Vizoso Reviewed-by: Steven Price Signed-off-by: Steven Price Link: https://patchwork.freedesktop.org/patch/msgid/20210421132841.v13.4.I5f6b04431828ec9c3e41e65f3337cec6a127480d@changeid --- drivers/gpu/drm/panfrost/panfrost_drv.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c index 83a461bdeea8..ca07098a6141 100644 --- a/drivers/gpu/drm/panfrost/panfrost_drv.c +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c @@ -665,6 +665,15 @@ static const struct panfrost_compatible amlogic_data = { .vendor_quirk = panfrost_gpu_amlogic_quirk, }; +const char * const mediatek_mt8183_supplies[] = { "mali", "sram" }; +const char * const mediatek_mt8183_pm_domains[] = { "core0", "core1", "core2" }; +static const struct panfrost_compatible mediatek_mt8183_data = { + .num_supplies = ARRAY_SIZE(mediatek_mt8183_supplies), + .supply_names = mediatek_mt8183_supplies, + .num_pm_domains = ARRAY_SIZE(mediatek_mt8183_pm_domains), + .pm_domain_names = mediatek_mt8183_pm_domains, +}; + static const struct of_device_id dt_match[] = { /* Set first to probe before the generic compatibles */ { .compatible = "amlogic,meson-gxm-mali", @@ -681,6 +690,7 @@ static const struct of_device_id dt_match[] = { { .compatible = "arm,mali-t860", .data = &default_data, }, { .compatible = "arm,mali-t880", .data = &default_data, }, { .compatible = "arm,mali-bifrost", .data = &default_data, }, + { .compatible = "mediatek,mt8183-mali", .data = &mediatek_mt8183_data }, {} }; MODULE_DEVICE_TABLE(of, dt_match); From 2f70cbf79e3ffa65ab2faeec9ba7e6e587e6cad9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 14 May 2021 15:49:30 +0100 Subject: [PATCH 13/18] drm/vmwgfx: Fix memory allocation check and a leak of object fifo The allocation of fifo is lacking an allocation failure check, so fix this by adding one. In the case where fifo->static_buffer fails to be allocated the error return path neglects to kfree the fifo object. Fix this by adding in the missing kfree. Kudos to Dan Carpenter for spotting the missing kzalloc failure check. Addresses-Coverity: ("Resource leak") Fixes: 2cd80dbd3551 ("drm/vmwgfx: Add basic support for SVGA3") Signed-off-by: Colin Ian King Signed-off-by: Zack Rusin Link: https://patchwork.freedesktop.org/patch/msgid/20210514144930.89813-1-colin.king@canonical.com --- drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c index 027d7d504e78..9c89189a226d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmd.c @@ -105,10 +105,14 @@ struct vmw_fifo_state *vmw_fifo_create(struct vmw_private *dev_priv) return NULL; fifo = kzalloc(sizeof(*fifo), GFP_KERNEL); + if (!fifo) + return ERR_PTR(-ENOMEM); fifo->static_buffer_size = VMWGFX_FIFO_STATIC_SIZE; fifo->static_buffer = vmalloc(fifo->static_buffer_size); - if (unlikely(fifo->static_buffer == NULL)) + if (unlikely(fifo->static_buffer == NULL)) { + kfree(fifo); return ERR_PTR(-ENOMEM); + } fifo->dynamic_buffer = NULL; fifo->reserved_size = 0; From 527a9471878e619add51825640a76d9777218445 Mon Sep 17 00:00:00 2001 From: Qiheng Lin Date: Fri, 14 May 2021 16:28:12 +0800 Subject: [PATCH 14/18] drm/vmwgfx: Fix return value check in vmw_setup_pci_resources() In case of error, the function devm_ioremap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. After that, the error code -ENOMEM should be returned. Reported-by: Hulk Robot Signed-off-by: Qiheng Lin Signed-off-by: Zack Rusin Link: https://patchwork.freedesktop.org/patch/msgid/20210514082812.1697-1-linqiheng@huawei.com --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 5cf3a5bf539f..6f5ea00973e0 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -719,10 +719,10 @@ static int vmw_setup_pci_resources(struct vmw_private *dev, dev->rmmio = devm_ioremap(dev->drm.dev, rmmio_start, rmmio_size); - if (IS_ERR(dev->rmmio)) { + if (!dev->rmmio) { DRM_ERROR("Failed mapping registers mmio memory.\n"); pci_release_regions(pdev); - return PTR_ERR(dev->rmmio); + return -ENOMEM; } } else if (pci_id == VMWGFX_PCI_ID_SVGA2) { dev->io_start = pci_resource_start(pdev, 0); From 9c6f19421c935db05c414bdbb3645375cd600f8d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 15 May 2021 12:53:15 +0300 Subject: [PATCH 15/18] drm: simpledrm: fix a potential NULL dereference The drm_format_info() function returns NULL if the format is unsupported, but the simplefb_get_validated_format() is expected to return error pointers. If we propagate the NULL return then it will lead to a NULL dereference in the callers. Swap the NULL and trade it in for an ERR_PTR(-EINVAL). Fixes: 11e8f5fd223b ("drm: Add simpledrm driver") Signed-off-by: Dan Carpenter Signed-off-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/YJ+aC47XX58ICXax@mwanda --- drivers/gpu/drm/tiny/simpledrm.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c index f72ca3a1c2d4..4f605c5fe856 100644 --- a/drivers/gpu/drm/tiny/simpledrm.c +++ b/drivers/gpu/drm/tiny/simpledrm.c @@ -72,6 +72,7 @@ simplefb_get_validated_format(struct drm_device *dev, const char *format_name) static const struct simplefb_format formats[] = SIMPLEFB_FORMATS; const struct simplefb_format *fmt = formats; const struct simplefb_format *end = fmt + ARRAY_SIZE(formats); + const struct drm_format_info *info; if (!format_name) { drm_err(dev, "simplefb: missing framebuffer format\n"); @@ -79,8 +80,12 @@ simplefb_get_validated_format(struct drm_device *dev, const char *format_name) } while (fmt < end) { - if (!strcmp(format_name, fmt->name)) - return drm_format_info(fmt->fourcc); + if (!strcmp(format_name, fmt->name)) { + info = drm_format_info(fmt->fourcc); + if (!info) + return ERR_PTR(-EINVAL); + return info; + } ++fmt; } From 76fb351126f1be4f4c339920b84268740d84d2e1 Mon Sep 17 00:00:00 2001 From: Yang Yingliang Date: Thu, 13 May 2021 15:19:18 +0800 Subject: [PATCH 16/18] drm: correct function name drm_legacy_ctxbitmap_flush() Fix the following make W=1 kernel build warning: drivers/gpu/drm/drm_context.c:136: warning: expecting prototype for drm_ctxbitmap_flush(). Prototype was for drm_legacy_ctxbitmap_flush() instead Signed-off-by: Yang Yingliang Signed-off-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/20210513071918.1728535-1-yangyingliang@huawei.com --- drivers/gpu/drm/drm_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c index 54e3c513d6a5..c6e6a3e7219a 100644 --- a/drivers/gpu/drm/drm_context.c +++ b/drivers/gpu/drm/drm_context.c @@ -124,7 +124,7 @@ void drm_legacy_ctxbitmap_cleanup(struct drm_device * dev) } /** - * drm_ctxbitmap_flush() - Flush all contexts owned by a file + * drm_legacy_ctxbitmap_flush() - Flush all contexts owned by a file * @dev: DRM device to operate on * @file: Open file to flush contexts for * From 8d0b1fe81e18eb66a2d4406386760795fe0d77d9 Mon Sep 17 00:00:00 2001 From: Zou Wei Date: Wed, 12 May 2021 14:45:55 +0800 Subject: [PATCH 17/18] drm/bridge: lt9611: Add missing MODULE_DEVICE_TABLE This patch adds missing MODULE_DEVICE_TABLE definition which generates correct modalias for automatic loading of this driver when it is built as an external module. Reported-by: Hulk Robot Signed-off-by: Zou Wei Reviewed-by: Robert Foss Signed-off-by: Robert Foss Link: https://patchwork.freedesktop.org/patch/msgid/1620801955-19188-1-git-send-email-zou_wei@huawei.com --- drivers/gpu/drm/bridge/lontium-lt9611.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/bridge/lontium-lt9611.c index e8eb8deb444b..29b1ce2140ab 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611.c @@ -1215,6 +1215,7 @@ static struct i2c_device_id lt9611_id[] = { { "lontium,lt9611", 0 }, {} }; +MODULE_DEVICE_TABLE(i2c, lt9611_id); static const struct of_device_id lt9611_match_table[] = { { .compatible = "lontium,lt9611" }, From 30039405ac25665119ff7bc944d33b136ef1c8a9 Mon Sep 17 00:00:00 2001 From: Lukas Bulwahn Date: Mon, 17 May 2021 12:16:48 +0200 Subject: [PATCH 18/18] MAINTAINERS: repair reference in DRM DRIVER FOR SIMPLE FRAMEBUFFERS Commit 11e8f5fd223b ("drm: Add simpledrm driver") adds the file ./drivers/gpu/drm/tiny/simpledrm.c, but refers to the file ./drivers/gpu/drm/tiny/simplekms.c with the new MAINTAINERS section DRM DRIVER FOR SIMPLE FRAMEBUFFERS. Hence, ./scripts/get_maintainer.pl --self-test=patterns complains: warning: no file matches F: drivers/gpu/drm/tiny/simplekms.c Repair the file entry by referring to the right location. Signed-off-by: Lukas Bulwahn Signed-off-by: Thomas Zimmermann Link: https://patchwork.freedesktop.org/patch/msgid/20210517101648.29906-1-lukas.bulwahn@gmail.com --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 871808decbf1..41f2b2b85b6d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5875,7 +5875,7 @@ M: Thomas Zimmermann L: dri-devel@lists.freedesktop.org S: Maintained T: git git://anongit.freedesktop.org/drm/drm-misc -F: drivers/gpu/drm/tiny/simplekms.c +F: drivers/gpu/drm/tiny/simpledrm.c DRM DRIVER FOR SIS VIDEO CARDS S: Orphan / Obsolete