Skip to content

Commit 95983ae

Browse files
Ben Skeggsairlied
authored andcommitted
drm/nouveau/disp: add connector class
Will be used to provide more solid driver interfaces in general, but the immediate motivation is work towards fixing issues with handling hotplug/DP IRQ events. Its use is currently limited to where we support non-polled hotplug already (ie. any GPU since NV40ish era, where our DCB handling works well enough), until that gets cleaned up someday. v2: - use ?: (lyude) Signed-off-by: Ben Skeggs <[email protected]> Reviewed-by: Lyude Paul <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent 889fcbe commit 95983ae

File tree

15 files changed

+189
-4
lines changed

15 files changed

+189
-4
lines changed

drivers/gpu/drm/nouveau/include/nvif/class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define NVIF_CLASS_VMM_GP100 /* ifc00d.h */ 0x8000c00d
3434

3535
#define NVIF_CLASS_DISP /* if0010.h */ 0x80000010
36+
#define NVIF_CLASS_CONN /* if0011.h */ 0x80000011
3637
#define NVIF_CLASS_DISP_CHAN /* if0014.h */ 0x80000014
3738

3839
/* the below match nvidia-assigned (either in hw, or sw) class numbers */
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: MIT */
2+
#ifndef __NVIF_CONN_H__
3+
#define __NVIF_CONN_H__
4+
#include <nvif/object.h>
5+
struct nvif_disp;
6+
7+
struct nvif_conn {
8+
struct nvif_object object;
9+
};
10+
11+
int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *);
12+
void nvif_conn_dtor(struct nvif_conn *);
13+
#endif

drivers/gpu/drm/nouveau/include/nvif/disp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ struct nvif_device;
55

66
struct nvif_disp {
77
struct nvif_object object;
8+
unsigned long conn_mask;
89
};
910

1011
int nvif_disp_ctor(struct nvif_device *, const char *name, s32 oclass,

drivers/gpu/drm/nouveau/include/nvif/if0010.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
union nvif_disp_args {
66
struct nvif_disp_v0 {
77
__u8 version;
8-
__u8 pad01[7];
8+
__u8 pad01[3];
9+
__u32 conn_mask;
910
} v0;
1011
};
1112
#endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* SPDX-License-Identifier: MIT */
2+
#ifndef __NVIF_IF0011_H__
3+
#define __NVIF_IF0011_H__
4+
5+
union nvif_conn_args {
6+
struct nvif_conn_v0 {
7+
__u8 version;
8+
__u8 id; /* DCB connector table index. */
9+
__u8 pad02[6];
10+
} v0;
11+
};
12+
#endif

drivers/gpu/drm/nouveau/nouveau_connector.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ nouveau_connector_destroy(struct drm_connector *connector)
404404
drm_dp_cec_unregister_connector(&nv_connector->aux);
405405
kfree(nv_connector->aux.name);
406406
}
407+
nvif_conn_dtor(&nv_connector->conn);
407408
kfree(connector);
408409
}
409410

@@ -1388,6 +1389,15 @@ nouveau_connector_create(struct drm_device *dev,
13881389
drm_connector_init(dev, connector, funcs, type);
13891390
drm_connector_helper_add(connector, &nouveau_connector_helper_funcs);
13901391

1392+
if (nv_connector->dcb && (disp->disp.conn_mask & BIT(nv_connector->index))) {
1393+
ret = nvif_conn_ctor(&disp->disp, nv_connector->base.name, nv_connector->index,
1394+
&nv_connector->conn);
1395+
if (ret) {
1396+
kfree(nv_connector);
1397+
return ERR_PTR(ret);
1398+
}
1399+
}
1400+
13911401
connector->funcs->reset(connector);
13921402
nouveau_conn_attach_properties(connector);
13931403

drivers/gpu/drm/nouveau/nouveau_connector.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#ifndef __NOUVEAU_CONNECTOR_H__
2828
#define __NOUVEAU_CONNECTOR_H__
29-
29+
#include <nvif/conn.h>
3030
#include <nvif/notify.h>
3131

3232
#include <nvhw/class/cl507d.h>
@@ -123,6 +123,7 @@ struct nouveau_connector {
123123
u8 index;
124124
u8 *dcb;
125125

126+
struct nvif_conn conn;
126127
struct nvif_notify hpd;
127128

128129
struct drm_dp_aux aux;

drivers/gpu/drm/nouveau/nvif/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: MIT
22
nvif-y := nvif/object.o
33
nvif-y += nvif/client.o
4+
nvif-y += nvif/conn.o
45
nvif-y += nvif/device.o
56
nvif-y += nvif/disp.o
67
nvif-y += nvif/driver.o
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2021 Red Hat Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
#include <nvif/conn.h>
23+
#include <nvif/disp.h>
24+
#include <nvif/printf.h>
25+
26+
#include <nvif/class.h>
27+
#include <nvif/if0011.h>
28+
29+
void
30+
nvif_conn_dtor(struct nvif_conn *conn)
31+
{
32+
nvif_object_dtor(&conn->object);
33+
}
34+
35+
int
36+
nvif_conn_ctor(struct nvif_disp *disp, const char *name, int id, struct nvif_conn *conn)
37+
{
38+
struct nvif_conn_v0 args;
39+
int ret;
40+
41+
args.version = 0;
42+
args.id = id;
43+
44+
ret = nvif_object_ctor(&disp->object, name ?: "nvifConn", id, NVIF_CLASS_CONN,
45+
&args, sizeof(args), &conn->object);
46+
NVIF_ERRON(ret, &disp->object, "[NEW conn id:%d]", id);
47+
return ret;
48+
}

drivers/gpu/drm/nouveau/nvif/disp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,10 @@ nvif_disp_ctor(struct nvif_device *device, const char *name, s32 oclass, struct
6969
ret = nvif_object_ctor(&device->object, name ?: "nvifDisp", 0,
7070
disps[cid].oclass, &args, sizeof(args), &disp->object);
7171
NVIF_ERRON(ret, &device->object, "[NEW disp%04x]", disps[cid].oclass);
72-
return ret;
72+
if (ret)
73+
return ret;
74+
75+
NVIF_DEBUG(&disp->object, "[NEW] conn_mask:%08x", args.conn_mask);
76+
disp->conn_mask = args.conn_mask;
77+
return 0;
7378
}

0 commit comments

Comments
 (0)