Skip to content

Commit 7f7a479

Browse files
committed
Merge tag 'drm-misc-fixes-2020-09-09' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
drm-misc-fixes for v5.9-rc5: - Fix double free in virtio. - Add missing put_device in sun4i, and other fixes. - Small ingenic fixes. - Handle sun4i alpha on lowest plane correctly. - Remove output->enabled from virtio, as it should use crtc_state. - Fix tve200 enable/disable. - Documentation fix. - Fix virtio unblank. Signed-off-by: Dave Airlie <[email protected]> From: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 7bf23bf + fc7f148 commit 7f7a479

File tree

13 files changed

+71
-29
lines changed

13 files changed

+71
-29
lines changed

Documentation/driver-api/dma-buf.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ DMA Fence uABI/Sync File
179179
:internal:
180180

181181
Indefinite DMA Fences
182-
~~~~~~~~~~~~~~~~~~~~
182+
~~~~~~~~~~~~~~~~~~~~~
183183

184184
At various times &dma_fence with an indefinite time until dma_fence_wait()
185185
finishes have been proposed. Examples include:

drivers/dma-buf/dma-buf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ static __poll_t dma_buf_poll(struct file *file, poll_table *poll)
316316
* name of the dma-buf if the same piece of memory is used for multiple
317317
* purpose between different devices.
318318
*
319-
* @dmabuf [in] dmabuf buffer that will be renamed.
320-
* @buf: [in] A piece of userspace memory that contains the name of
321-
* the dma-buf.
319+
* @dmabuf: [in] dmabuf buffer that will be renamed.
320+
* @buf: [in] A piece of userspace memory that contains the name of
321+
* the dma-buf.
322322
*
323323
* Returns 0 on success. If the dma-buf buffer is already attached to
324324
* devices, return -EBUSY.

drivers/dma-buf/dma-fence-chain.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ EXPORT_SYMBOL(dma_fence_chain_ops);
222222
* @chain: the chain node to initialize
223223
* @prev: the previous fence
224224
* @fence: the current fence
225+
* @seqno: the sequence number to use for the fence chain
225226
*
226227
* Initialize a new chain node and either start a new chain or add the node to
227228
* the existing chain of the previous fence.

drivers/gpu/drm/ingenic/ingenic-drm-drv.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static void ingenic_drm_unbind_all(void *d)
673673
component_unbind_all(priv->dev, &priv->drm);
674674
}
675675

676-
static int ingenic_drm_bind(struct device *dev)
676+
static int ingenic_drm_bind(struct device *dev, bool has_components)
677677
{
678678
struct platform_device *pdev = to_platform_device(dev);
679679
const struct jz_soc_info *soc_info;
@@ -808,7 +808,7 @@ static int ingenic_drm_bind(struct device *dev)
808808
return ret;
809809
}
810810

811-
if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU)) {
811+
if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && has_components) {
812812
ret = component_bind_all(dev, drm);
813813
if (ret) {
814814
if (ret != -EPROBE_DEFER)
@@ -939,6 +939,11 @@ static int ingenic_drm_bind(struct device *dev)
939939
return ret;
940940
}
941941

942+
static int ingenic_drm_bind_with_components(struct device *dev)
943+
{
944+
return ingenic_drm_bind(dev, true);
945+
}
946+
942947
static int compare_of(struct device *dev, void *data)
943948
{
944949
return dev->of_node == data;
@@ -957,7 +962,7 @@ static void ingenic_drm_unbind(struct device *dev)
957962
}
958963

959964
static const struct component_master_ops ingenic_master_ops = {
960-
.bind = ingenic_drm_bind,
965+
.bind = ingenic_drm_bind_with_components,
961966
.unbind = ingenic_drm_unbind,
962967
};
963968

@@ -968,16 +973,15 @@ static int ingenic_drm_probe(struct platform_device *pdev)
968973
struct device_node *np;
969974

970975
if (!IS_ENABLED(CONFIG_DRM_INGENIC_IPU))
971-
return ingenic_drm_bind(dev);
976+
return ingenic_drm_bind(dev, false);
972977

973978
/* IPU is at port address 8 */
974979
np = of_graph_get_remote_node(dev->of_node, 8, 0);
975-
if (!np) {
976-
dev_err(dev, "Unable to get IPU node\n");
977-
return -EINVAL;
978-
}
980+
if (!np)
981+
return ingenic_drm_bind(dev, false);
979982

980983
drm_of_component_match_add(dev, &match, compare_of, np);
984+
of_node_put(np);
981985

982986
return component_master_add_with_match(dev, &ingenic_master_ops, match);
983987
}

drivers/gpu/drm/sun4i/sun4i_backend.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,7 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine,
589589

590590
/* We can't have an alpha plane at the lowest position */
591591
if (!backend->quirks->supports_lowest_plane_alpha &&
592-
(plane_states[0]->fb->format->has_alpha ||
593-
(plane_states[0]->alpha != DRM_BLEND_ALPHA_OPAQUE)))
592+
(plane_states[0]->alpha != DRM_BLEND_ALPHA_OPAQUE))
594593
return -EINVAL;
595594

596595
for (i = 1; i < num_planes; i++) {
@@ -995,7 +994,6 @@ static const struct sun4i_backend_quirks sun6i_backend_quirks = {
995994

996995
static const struct sun4i_backend_quirks sun7i_backend_quirks = {
997996
.needs_output_muxing = true,
998-
.supports_lowest_plane_alpha = true,
999997
};
1000998

1001999
static const struct sun4i_backend_quirks sun8i_a33_backend_quirks = {

drivers/gpu/drm/sun4i/sun4i_tcon.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,14 +1433,18 @@ static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon,
14331433
if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP) &&
14341434
encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
14351435
ret = sun8i_tcon_top_set_hdmi_src(&pdev->dev, id);
1436-
if (ret)
1436+
if (ret) {
1437+
put_device(&pdev->dev);
14371438
return ret;
1439+
}
14381440
}
14391441

14401442
if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP)) {
14411443
ret = sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
1442-
if (ret)
1444+
if (ret) {
1445+
put_device(&pdev->dev);
14431446
return ret;
1447+
}
14441448
}
14451449

14461450
return 0;

drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi,
889889
regmap_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(0),
890890
sun6i_dsi_dcs_build_pkt_hdr(dsi, msg));
891891

892-
bounce = kzalloc(msg->tx_len + sizeof(crc), GFP_KERNEL);
892+
bounce = kzalloc(ALIGN(msg->tx_len + sizeof(crc), 4), GFP_KERNEL);
893893
if (!bounce)
894894
return -ENOMEM;
895895

@@ -900,7 +900,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi,
900900
memcpy((u8 *)bounce + msg->tx_len, &crc, sizeof(crc));
901901
len += sizeof(crc);
902902

903-
regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, len);
903+
regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, DIV_ROUND_UP(len, 4));
904904
regmap_write(dsi->regs, SUN6I_DSI_CMD_CTL_REG, len + 4 - 1);
905905
kfree(bounce);
906906

drivers/gpu/drm/sun4i/sun8i_vi_layer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int sun8i_vi_layer_update_coord(struct sun8i_mixer *mixer, int channel,
211211
return 0;
212212
}
213213

214-
static bool sun8i_vi_layer_get_csc_mode(const struct drm_format_info *format)
214+
static u32 sun8i_vi_layer_get_csc_mode(const struct drm_format_info *format)
215215
{
216216
if (!format->is_yuv)
217217
return SUN8I_CSC_MODE_OFF;

drivers/gpu/drm/tve200/tve200_display.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/version.h>
1515
#include <linux/dma-buf.h>
1616
#include <linux/of_graph.h>
17+
#include <linux/delay.h>
1718

1819
#include <drm/drm_fb_cma_helper.h>
1920
#include <drm/drm_fourcc.h>
@@ -130,9 +131,25 @@ static void tve200_display_enable(struct drm_simple_display_pipe *pipe,
130131
struct drm_connector *connector = priv->connector;
131132
u32 format = fb->format->format;
132133
u32 ctrl1 = 0;
134+
int retries;
133135

134136
clk_prepare_enable(priv->clk);
135137

138+
/* Reset the TVE200 and wait for it to come back online */
139+
writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4);
140+
for (retries = 0; retries < 5; retries++) {
141+
usleep_range(30000, 50000);
142+
if (readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET)
143+
continue;
144+
else
145+
break;
146+
}
147+
if (retries == 5 &&
148+
readl(priv->regs + TVE200_CTRL_4) & TVE200_CTRL_4_RESET) {
149+
dev_err(drm->dev, "can't get hardware out of reset\n");
150+
return;
151+
}
152+
136153
/* Function 1 */
137154
ctrl1 |= TVE200_CTRL_CSMODE;
138155
/* Interlace mode for CCIR656: parameterize? */
@@ -230,8 +247,9 @@ static void tve200_display_disable(struct drm_simple_display_pipe *pipe)
230247

231248
drm_crtc_vblank_off(crtc);
232249

233-
/* Disable and Power Down */
250+
/* Disable put into reset and Power Down */
234251
writel(0, priv->regs + TVE200_CTRL);
252+
writel(TVE200_CTRL_4_RESET, priv->regs + TVE200_CTRL_4);
235253

236254
clk_disable_unprepare(priv->clk);
237255
}
@@ -279,6 +297,8 @@ static int tve200_display_enable_vblank(struct drm_simple_display_pipe *pipe)
279297
struct drm_device *drm = crtc->dev;
280298
struct tve200_drm_dev_private *priv = drm->dev_private;
281299

300+
/* Clear any IRQs and enable */
301+
writel(0xFF, priv->regs + TVE200_INT_CLR);
282302
writel(TVE200_INT_V_STATUS, priv->regs + TVE200_INT_EN);
283303
return 0;
284304
}

drivers/gpu/drm/virtio/virtgpu_display.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ static void virtio_gpu_crtc_mode_set_nofb(struct drm_crtc *crtc)
9797
static void virtio_gpu_crtc_atomic_enable(struct drm_crtc *crtc,
9898
struct drm_crtc_state *old_state)
9999
{
100-
struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
101-
102-
output->enabled = true;
103100
}
104101

105102
static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
@@ -111,7 +108,6 @@ static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
111108

112109
virtio_gpu_cmd_set_scanout(vgdev, output->index, 0, 0, 0, 0, 0);
113110
virtio_gpu_notify(vgdev);
114-
output->enabled = false;
115111
}
116112

117113
static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
@@ -123,6 +119,17 @@ static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
123119
static void virtio_gpu_crtc_atomic_flush(struct drm_crtc *crtc,
124120
struct drm_crtc_state *old_state)
125121
{
122+
struct virtio_gpu_output *output = drm_crtc_to_virtio_gpu_output(crtc);
123+
124+
/*
125+
* virtio-gpu can't do modeset and plane update operations
126+
* independent from each other. So the actual modeset happens
127+
* in the plane update callback, and here we just check
128+
* whenever we must force the modeset.
129+
*/
130+
if (drm_atomic_crtc_needs_modeset(crtc->state)) {
131+
output->needs_modeset = true;
132+
}
126133
}
127134

128135
static const struct drm_crtc_helper_funcs virtio_gpu_crtc_helper_funcs = {

0 commit comments

Comments
 (0)