Commit 32dd9236 authored by Ben Skeggs's avatar Ben Skeggs Committed by Dave Airlie

drm/nouveau/disp: add conn method to query HPD pin status

And use it to bail early in DP detection and avoid futile AUX transactions.

This could be used on other connector types too in theory, but it's not
something we've ever done before and I'd rather not risk breaking working
systems without looking into it more closely.

It's safe for DP though.  We already do this by checking an AUX register
that contains HPD status and aborting the transaction.  However, this is
much deeper in the stack - after taking various mutexes, poking HW for no
good reason, and making a mess in debug logs.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 95983aea
...@@ -10,4 +10,9 @@ struct nvif_conn { ...@@ -10,4 +10,9 @@ struct nvif_conn {
int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *); int nvif_conn_ctor(struct nvif_disp *, const char *name, int id, struct nvif_conn *);
void nvif_conn_dtor(struct nvif_conn *); void nvif_conn_dtor(struct nvif_conn *);
#define NVIF_CONN_HPD_STATUS_UNSUPPORTED 0 /* negative if query fails */
#define NVIF_CONN_HPD_STATUS_NOT_PRESENT 1
#define NVIF_CONN_HPD_STATUS_PRESENT 2
int nvif_conn_hpd_status(struct nvif_conn *);
#endif #endif
...@@ -9,4 +9,15 @@ union nvif_conn_args { ...@@ -9,4 +9,15 @@ union nvif_conn_args {
__u8 pad02[6]; __u8 pad02[6];
} v0; } v0;
}; };
#define NVIF_CONN_V0_HPD_STATUS 0x00000000
union nvif_conn_hpd_status_args {
struct nvif_conn_hpd_status_v0 {
__u8 version;
__u8 support;
__u8 present;
__u8 pad03[5];
} v0;
};
#endif #endif
...@@ -107,7 +107,7 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector, ...@@ -107,7 +107,7 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
struct nv50_mstm *mstm = nv_encoder->dp.mstm; struct nv50_mstm *mstm = nv_encoder->dp.mstm;
enum drm_connector_status status; enum drm_connector_status status;
u8 *dpcd = nv_encoder->dp.dpcd; u8 *dpcd = nv_encoder->dp.dpcd;
int ret = NOUVEAU_DP_NONE; int ret = NOUVEAU_DP_NONE, hpd;
/* If we've already read the DPCD on an eDP device, we don't need to /* If we've already read the DPCD on an eDP device, we don't need to
* reread it as it won't change * reread it as it won't change
...@@ -133,6 +133,16 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector, ...@@ -133,6 +133,16 @@ nouveau_dp_detect(struct nouveau_connector *nv_connector,
} }
} }
/* Check status of HPD pin before attempting an AUX transaction that
* would result in a number of (futile) retries on a connector which
* has no display plugged.
*
* TODO: look into checking this before probing I2C to detect DVI/HDMI
*/
hpd = nvif_conn_hpd_status(&nv_connector->conn);
if (hpd == NVIF_CONN_HPD_STATUS_NOT_PRESENT)
goto out;
status = nouveau_dp_probe_dpcd(nv_connector, nv_encoder); status = nouveau_dp_probe_dpcd(nv_connector, nv_encoder);
if (status == connector_status_disconnected) if (status == connector_status_disconnected)
goto out; goto out;
......
...@@ -26,6 +26,20 @@ ...@@ -26,6 +26,20 @@
#include <nvif/class.h> #include <nvif/class.h>
#include <nvif/if0011.h> #include <nvif/if0011.h>
int
nvif_conn_hpd_status(struct nvif_conn *conn)
{
struct nvif_conn_hpd_status_v0 args;
int ret;
args.version = 0;
ret = nvif_mthd(&conn->object, NVIF_CONN_V0_HPD_STATUS, &args, sizeof(args));
NVIF_ERRON(ret, &conn->object, "[HPD_STATUS] support:%d present:%d",
args.support, args.present);
return ret ? ret : !!args.support + !!args.present;
}
void void
nvif_conn_dtor(struct nvif_conn *conn) nvif_conn_dtor(struct nvif_conn *conn)
{ {
......
...@@ -86,6 +86,7 @@ nvkm_conn_ctor(struct nvkm_disp *disp, int index, struct nvbios_connE *info, ...@@ -86,6 +86,7 @@ nvkm_conn_ctor(struct nvkm_disp *disp, int index, struct nvbios_connE *info,
conn->disp = disp; conn->disp = disp;
conn->index = index; conn->index = index;
conn->info = *info; conn->info = *info;
conn->info.hpd = DCB_GPIO_UNUSED;
CONN_DBG(conn, "type %02x loc %d hpd %02x dp %x di %x sr %x lcdid %x", CONN_DBG(conn, "type %02x loc %d hpd %02x dp %x di %x sr %x lcdid %x",
info->type, info->location, info->hpd, info->dp, info->type, info->location, info->hpd, info->dp,
...@@ -100,11 +101,12 @@ nvkm_conn_ctor(struct nvkm_disp *disp, int index, struct nvbios_connE *info, ...@@ -100,11 +101,12 @@ nvkm_conn_ctor(struct nvkm_disp *disp, int index, struct nvbios_connE *info,
ret = nvkm_gpio_find(gpio, 0, info->hpd, DCB_GPIO_UNUSED, &func); ret = nvkm_gpio_find(gpio, 0, info->hpd, DCB_GPIO_UNUSED, &func);
if (ret) { if (ret) {
CONN_ERR(conn, "func %02x lookup failed, %d", CONN_ERR(conn, "func %02x lookup failed, %d", info->hpd, ret);
info->hpd, ret);
return; return;
} }
conn->info.hpd = func.line;
ret = nvkm_notify_init(NULL, &gpio->event, nvkm_conn_hpd, ret = nvkm_notify_init(NULL, &gpio->event, nvkm_conn_hpd,
true, &(struct nvkm_gpio_ntfy_req) { true, &(struct nvkm_gpio_ntfy_req) {
.mask = NVKM_GPIO_TOGGLED, .mask = NVKM_GPIO_TOGGLED,
......
...@@ -22,8 +22,50 @@ ...@@ -22,8 +22,50 @@
#define nvkm_uconn(p) container_of((p), struct nvkm_conn, object) #define nvkm_uconn(p) container_of((p), struct nvkm_conn, object)
#include "conn.h" #include "conn.h"
#include <subdev/gpio.h>
#include <nvif/if0011.h> #include <nvif/if0011.h>
static int
nvkm_uconn_mthd_hpd_status(struct nvkm_conn *conn, void *argv, u32 argc)
{
struct nvkm_gpio *gpio = conn->disp->engine.subdev.device->gpio;
union nvif_conn_hpd_status_args *args = argv;
if (argc != sizeof(args->v0) || args->v0.version != 0)
return -ENOSYS;
args->v0.support = gpio && conn->info.hpd != DCB_GPIO_UNUSED;
args->v0.present = 0;
if (args->v0.support) {
int ret = nvkm_gpio_get(gpio, 0, DCB_GPIO_UNUSED, conn->info.hpd);
if (WARN_ON(ret < 0)) {
args->v0.support = false;
return 0;
}
args->v0.present = ret;
}
return 0;
}
static int
nvkm_uconn_mthd(struct nvkm_object *object, u32 mthd, void *argv, u32 argc)
{
struct nvkm_conn *conn = nvkm_uconn(object);
switch (mthd) {
case NVIF_CONN_V0_HPD_STATUS: return nvkm_uconn_mthd_hpd_status(conn, argv, argc);
default:
break;
}
return -EINVAL;
}
static void * static void *
nvkm_uconn_dtor(struct nvkm_object *object) nvkm_uconn_dtor(struct nvkm_object *object)
{ {
...@@ -39,6 +81,7 @@ nvkm_uconn_dtor(struct nvkm_object *object) ...@@ -39,6 +81,7 @@ nvkm_uconn_dtor(struct nvkm_object *object)
static const struct nvkm_object_func static const struct nvkm_object_func
nvkm_uconn = { nvkm_uconn = {
.dtor = nvkm_uconn_dtor, .dtor = nvkm_uconn_dtor,
.mthd = nvkm_uconn_mthd,
}; };
int int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment