Skip to content

Commit 5502d1f

Browse files
committed
Merge tag 'drm-misc-fixes-2023-05-24' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
drm-misc-fixes for v6.4-rc4: - A few non-trivial fixes to qaic. - Fix drmm_mutex_init always using same lock class. - Fix pl111 fb depth. - Fix uninitialised gamma lut in mgag200. - Add Aya Neo Air Plus quirk. - Trivial null check removal in scheduler. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/d19f748c-2c5b-8140-5b05-a8282dfef73e@linux.intel.com
2 parents 13aa38f + e997c21 commit 5502d1f

File tree

12 files changed

+109
-101
lines changed

12 files changed

+109
-101
lines changed

drivers/accel/qaic/qaic_control.c

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -997,14 +997,34 @@ static void *msg_xfer(struct qaic_device *qdev, struct wrapper_list *wrappers, u
997997
struct xfer_queue_elem elem;
998998
struct wire_msg *out_buf;
999999
struct wrapper_msg *w;
1000+
long ret = -EAGAIN;
1001+
int xfer_count = 0;
10001002
int retry_count;
1001-
long ret;
10021003

10031004
if (qdev->in_reset) {
10041005
mutex_unlock(&qdev->cntl_mutex);
10051006
return ERR_PTR(-ENODEV);
10061007
}
10071008

1009+
/* Attempt to avoid a partial commit of a message */
1010+
list_for_each_entry(w, &wrappers->list, list)
1011+
xfer_count++;
1012+
1013+
for (retry_count = 0; retry_count < QAIC_MHI_RETRY_MAX; retry_count++) {
1014+
if (xfer_count <= mhi_get_free_desc_count(qdev->cntl_ch, DMA_TO_DEVICE)) {
1015+
ret = 0;
1016+
break;
1017+
}
1018+
msleep_interruptible(QAIC_MHI_RETRY_WAIT_MS);
1019+
if (signal_pending(current))
1020+
break;
1021+
}
1022+
1023+
if (ret) {
1024+
mutex_unlock(&qdev->cntl_mutex);
1025+
return ERR_PTR(ret);
1026+
}
1027+
10081028
elem.seq_num = seq_num;
10091029
elem.buf = NULL;
10101030
init_completion(&elem.xfer_done);
@@ -1038,16 +1058,9 @@ static void *msg_xfer(struct qaic_device *qdev, struct wrapper_list *wrappers, u
10381058
list_for_each_entry(w, &wrappers->list, list) {
10391059
kref_get(&w->ref_count);
10401060
retry_count = 0;
1041-
retry:
10421061
ret = mhi_queue_buf(qdev->cntl_ch, DMA_TO_DEVICE, &w->msg, w->len,
10431062
list_is_last(&w->list, &wrappers->list) ? MHI_EOT : MHI_CHAIN);
10441063
if (ret) {
1045-
if (ret == -EAGAIN && retry_count++ < QAIC_MHI_RETRY_MAX) {
1046-
msleep_interruptible(QAIC_MHI_RETRY_WAIT_MS);
1047-
if (!signal_pending(current))
1048-
goto retry;
1049-
}
1050-
10511064
qdev->cntl_lost_buf = true;
10521065
kref_put(&w->ref_count, free_wrapper);
10531066
mutex_unlock(&qdev->cntl_mutex);
@@ -1249,7 +1262,7 @@ static int qaic_manage(struct qaic_device *qdev, struct qaic_user *usr, struct m
12491262

12501263
int qaic_manage_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
12511264
{
1252-
struct qaic_manage_msg *user_msg;
1265+
struct qaic_manage_msg *user_msg = data;
12531266
struct qaic_device *qdev;
12541267
struct manage_msg *msg;
12551268
struct qaic_user *usr;
@@ -1258,6 +1271,9 @@ int qaic_manage_ioctl(struct drm_device *dev, void *data, struct drm_file *file_
12581271
int usr_rcu_id;
12591272
int ret;
12601273

1274+
if (user_msg->len > QAIC_MANAGE_MAX_MSG_LENGTH)
1275+
return -EINVAL;
1276+
12611277
usr = file_priv->driver_priv;
12621278

12631279
usr_rcu_id = srcu_read_lock(&usr->qddev_lock);
@@ -1275,13 +1291,6 @@ int qaic_manage_ioctl(struct drm_device *dev, void *data, struct drm_file *file_
12751291
return -ENODEV;
12761292
}
12771293

1278-
user_msg = data;
1279-
1280-
if (user_msg->len > QAIC_MANAGE_MAX_MSG_LENGTH) {
1281-
ret = -EINVAL;
1282-
goto out;
1283-
}
1284-
12851294
msg = kzalloc(QAIC_MANAGE_MAX_MSG_LENGTH + sizeof(*msg), GFP_KERNEL);
12861295
if (!msg) {
12871296
ret = -ENOMEM;

drivers/accel/qaic/qaic_data.c

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ static int qaic_gem_object_mmap(struct drm_gem_object *obj, struct vm_area_struc
591591
struct qaic_bo *bo = to_qaic_bo(obj);
592592
unsigned long offset = 0;
593593
struct scatterlist *sg;
594-
int ret;
594+
int ret = 0;
595595

596596
if (obj->import_attach)
597597
return -EINVAL;
@@ -663,6 +663,10 @@ int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
663663
if (args->pad)
664664
return -EINVAL;
665665

666+
size = PAGE_ALIGN(args->size);
667+
if (size == 0)
668+
return -EINVAL;
669+
666670
usr = file_priv->driver_priv;
667671
usr_rcu_id = srcu_read_lock(&usr->qddev_lock);
668672
if (!usr->qddev) {
@@ -677,12 +681,6 @@ int qaic_create_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *fi
677681
goto unlock_dev_srcu;
678682
}
679683

680-
size = PAGE_ALIGN(args->size);
681-
if (size == 0) {
682-
ret = -EINVAL;
683-
goto unlock_dev_srcu;
684-
}
685-
686684
bo = qaic_alloc_init_bo();
687685
if (IS_ERR(bo)) {
688686
ret = PTR_ERR(bo);
@@ -926,8 +924,8 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
926924
{
927925
struct qaic_attach_slice_entry *slice_ent;
928926
struct qaic_attach_slice *args = data;
927+
int rcu_id, usr_rcu_id, qdev_rcu_id;
929928
struct dma_bridge_chan *dbc;
930-
int usr_rcu_id, qdev_rcu_id;
931929
struct drm_gem_object *obj;
932930
struct qaic_device *qdev;
933931
unsigned long arg_size;
@@ -936,6 +934,22 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
936934
struct qaic_bo *bo;
937935
int ret;
938936

937+
if (args->hdr.count == 0)
938+
return -EINVAL;
939+
940+
arg_size = args->hdr.count * sizeof(*slice_ent);
941+
if (arg_size / args->hdr.count != sizeof(*slice_ent))
942+
return -EINVAL;
943+
944+
if (args->hdr.size == 0)
945+
return -EINVAL;
946+
947+
if (!(args->hdr.dir == DMA_TO_DEVICE || args->hdr.dir == DMA_FROM_DEVICE))
948+
return -EINVAL;
949+
950+
if (args->data == 0)
951+
return -EINVAL;
952+
939953
usr = file_priv->driver_priv;
940954
usr_rcu_id = srcu_read_lock(&usr->qddev_lock);
941955
if (!usr->qddev) {
@@ -950,43 +964,11 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
950964
goto unlock_dev_srcu;
951965
}
952966

953-
if (args->hdr.count == 0) {
954-
ret = -EINVAL;
955-
goto unlock_dev_srcu;
956-
}
957-
958-
arg_size = args->hdr.count * sizeof(*slice_ent);
959-
if (arg_size / args->hdr.count != sizeof(*slice_ent)) {
960-
ret = -EINVAL;
961-
goto unlock_dev_srcu;
962-
}
963-
964967
if (args->hdr.dbc_id >= qdev->num_dbc) {
965968
ret = -EINVAL;
966969
goto unlock_dev_srcu;
967970
}
968971

969-
if (args->hdr.size == 0) {
970-
ret = -EINVAL;
971-
goto unlock_dev_srcu;
972-
}
973-
974-
if (!(args->hdr.dir == DMA_TO_DEVICE || args->hdr.dir == DMA_FROM_DEVICE)) {
975-
ret = -EINVAL;
976-
goto unlock_dev_srcu;
977-
}
978-
979-
dbc = &qdev->dbc[args->hdr.dbc_id];
980-
if (dbc->usr != usr) {
981-
ret = -EINVAL;
982-
goto unlock_dev_srcu;
983-
}
984-
985-
if (args->data == 0) {
986-
ret = -EINVAL;
987-
goto unlock_dev_srcu;
988-
}
989-
990972
user_data = u64_to_user_ptr(args->data);
991973

992974
slice_ent = kzalloc(arg_size, GFP_KERNEL);
@@ -1013,9 +995,21 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
1013995

1014996
bo = to_qaic_bo(obj);
1015997

998+
if (bo->sliced) {
999+
ret = -EINVAL;
1000+
goto put_bo;
1001+
}
1002+
1003+
dbc = &qdev->dbc[args->hdr.dbc_id];
1004+
rcu_id = srcu_read_lock(&dbc->ch_lock);
1005+
if (dbc->usr != usr) {
1006+
ret = -EINVAL;
1007+
goto unlock_ch_srcu;
1008+
}
1009+
10161010
ret = qaic_prepare_bo(qdev, bo, &args->hdr);
10171011
if (ret)
1018-
goto put_bo;
1012+
goto unlock_ch_srcu;
10191013

10201014
ret = qaic_attach_slicing_bo(qdev, bo, &args->hdr, slice_ent);
10211015
if (ret)
@@ -1025,6 +1019,7 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
10251019
dma_sync_sgtable_for_cpu(&qdev->pdev->dev, bo->sgt, args->hdr.dir);
10261020

10271021
bo->dbc = dbc;
1022+
srcu_read_unlock(&dbc->ch_lock, rcu_id);
10281023
drm_gem_object_put(obj);
10291024
srcu_read_unlock(&qdev->dev_lock, qdev_rcu_id);
10301025
srcu_read_unlock(&usr->qddev_lock, usr_rcu_id);
@@ -1033,6 +1028,8 @@ int qaic_attach_slice_bo_ioctl(struct drm_device *dev, void *data, struct drm_fi
10331028

10341029
unprepare_bo:
10351030
qaic_unprepare_bo(qdev, bo);
1031+
unlock_ch_srcu:
1032+
srcu_read_unlock(&dbc->ch_lock, rcu_id);
10361033
put_bo:
10371034
drm_gem_object_put(obj);
10381035
free_slice_ent:
@@ -1316,7 +1313,6 @@ static int __qaic_execute_bo_ioctl(struct drm_device *dev, void *data, struct dr
13161313
received_ts = ktime_get_ns();
13171314

13181315
size = is_partial ? sizeof(*pexec) : sizeof(*exec);
1319-
13201316
n = (unsigned long)size * args->hdr.count;
13211317
if (args->hdr.count == 0 || n / args->hdr.count != size)
13221318
return -EINVAL;
@@ -1665,6 +1661,9 @@ int qaic_wait_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file
16651661
int rcu_id;
16661662
int ret;
16671663

1664+
if (args->pad != 0)
1665+
return -EINVAL;
1666+
16681667
usr = file_priv->driver_priv;
16691668
usr_rcu_id = srcu_read_lock(&usr->qddev_lock);
16701669
if (!usr->qddev) {
@@ -1679,11 +1678,6 @@ int qaic_wait_bo_ioctl(struct drm_device *dev, void *data, struct drm_file *file
16791678
goto unlock_dev_srcu;
16801679
}
16811680

1682-
if (args->pad != 0) {
1683-
ret = -EINVAL;
1684-
goto unlock_dev_srcu;
1685-
}
1686-
16871681
if (args->dbc_id >= qdev->num_dbc) {
16881682
ret = -EINVAL;
16891683
goto unlock_dev_srcu;
@@ -1855,6 +1849,11 @@ void wakeup_dbc(struct qaic_device *qdev, u32 dbc_id)
18551849
dbc->usr = NULL;
18561850
empty_xfer_list(qdev, dbc);
18571851
synchronize_srcu(&dbc->ch_lock);
1852+
/*
1853+
* Threads holding channel lock, may add more elements in the xfer_list.
1854+
* Flush out these elements from xfer_list.
1855+
*/
1856+
empty_xfer_list(qdev, dbc);
18581857
}
18591858

18601859
void release_dbc(struct qaic_device *qdev, u32 dbc_id)

drivers/accel/qaic/qaic_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ static void qaic_destroy_drm_device(struct qaic_device *qdev, s32 partition_id)
262262

263263
static int qaic_mhi_probe(struct mhi_device *mhi_dev, const struct mhi_device_id *id)
264264
{
265+
u16 major = -1, minor = -1;
265266
struct qaic_device *qdev;
266-
u16 major, minor;
267267
int ret;
268268

269269
/*

drivers/gpu/drm/drm_managed.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,28 +264,10 @@ void drmm_kfree(struct drm_device *dev, void *data)
264264
}
265265
EXPORT_SYMBOL(drmm_kfree);
266266

267-
static void drmm_mutex_release(struct drm_device *dev, void *res)
267+
void __drmm_mutex_release(struct drm_device *dev, void *res)
268268
{
269269
struct mutex *lock = res;
270270

271271
mutex_destroy(lock);
272272
}
273-
274-
/**
275-
* drmm_mutex_init - &drm_device-managed mutex_init()
276-
* @dev: DRM device
277-
* @lock: lock to be initialized
278-
*
279-
* Returns:
280-
* 0 on success, or a negative errno code otherwise.
281-
*
282-
* This is a &drm_device-managed version of mutex_init(). The initialized
283-
* lock is automatically destroyed on the final drm_dev_put().
284-
*/
285-
int drmm_mutex_init(struct drm_device *dev, struct mutex *lock)
286-
{
287-
mutex_init(lock);
288-
289-
return drmm_add_action_or_reset(dev, drmm_mutex_release, lock);
290-
}
291-
EXPORT_SYMBOL(drmm_mutex_init);
273+
EXPORT_SYMBOL(__drmm_mutex_release);

drivers/gpu/drm/drm_panel_orientation_quirks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ static const struct dmi_system_id orientation_data[] = {
179179
}, { /* AYA NEO AIR */
180180
.matches = {
181181
DMI_EXACT_MATCH(DMI_SYS_VENDOR, "AYANEO"),
182-
DMI_MATCH(DMI_BOARD_NAME, "AIR"),
182+
DMI_MATCH(DMI_PRODUCT_NAME, "AIR"),
183183
},
184184
.driver_data = (void *)&lcd1080x1920_leftside_up,
185185
}, { /* AYA NEO NEXT */

drivers/gpu/drm/mgag200/mgag200_mode.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,11 @@ void mgag200_crtc_helper_atomic_enable(struct drm_crtc *crtc, struct drm_atomic_
642642
if (funcs->pixpllc_atomic_update)
643643
funcs->pixpllc_atomic_update(crtc, old_state);
644644

645+
if (crtc_state->gamma_lut)
646+
mgag200_crtc_set_gamma(mdev, format, crtc_state->gamma_lut->data);
647+
else
648+
mgag200_crtc_set_gamma_linear(mdev, format);
649+
645650
mgag200_enable_display(mdev);
646651

647652
if (funcs->enable_vidrst)

drivers/gpu/drm/pl111/pl111_display.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pl111_mode_valid(struct drm_simple_display_pipe *pipe,
5353
{
5454
struct drm_device *drm = pipe->crtc.dev;
5555
struct pl111_drm_dev_private *priv = drm->dev_private;
56-
u32 cpp = priv->variant->fb_bpp / 8;
56+
u32 cpp = DIV_ROUND_UP(priv->variant->fb_depth, 8);
5757
u64 bw;
5858

5959
/*

drivers/gpu/drm/pl111/pl111_drm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct drm_minor;
114114
* extensions to the control register
115115
* @formats: array of supported pixel formats on this variant
116116
* @nformats: the length of the array of supported pixel formats
117-
* @fb_bpp: desired bits per pixel on the default framebuffer
117+
* @fb_depth: desired depth per pixel on the default framebuffer
118118
*/
119119
struct pl111_variant_data {
120120
const char *name;
@@ -126,7 +126,7 @@ struct pl111_variant_data {
126126
bool st_bitmux_control;
127127
const u32 *formats;
128128
unsigned int nformats;
129-
unsigned int fb_bpp;
129+
unsigned int fb_depth;
130130
};
131131

132132
struct pl111_drm_dev_private {

0 commit comments

Comments
 (0)