* [PATCH i-g-t] lib: don't abort if forcing the connector state fails
@ 2014-07-28 15:24 Thomas Wood
2014-07-28 15:34 ` Daniel Vetter
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Wood @ 2014-07-28 15:24 UTC (permalink / raw)
To: intel-gfx
Ensure tests using igt_enable_connectors can still run even if the
relevant debugfs files are not available.
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
lib/igt_kms.c | 19 ++++++++++++++-----
lib/igt_kms.h | 2 +-
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 20370a9..740b5dd 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -429,9 +429,11 @@ static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector,
* @state: state to force on @connector
*
* Force the specified state on the specified connector.
+ *
+ * Returns: true on success
*/
-void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
- kmstest_force_connector_state state)
+bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
+ enum kmstest_force_connector_state state)
{
char *path;
const char *value;
@@ -458,12 +460,15 @@ void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
debugfs_fd = open(path, O_WRONLY | O_TRUNC);
free(path);
- igt_assert(debugfs_fd != -1);
+ if (debugfs_fd == -1) {
+ return false;
+ }
ret = write(debugfs_fd, value, strlen(value));
close(debugfs_fd);
igt_assert(ret != -1);
+ return (ret == -1) ? false : true;
}
/**
@@ -1509,8 +1514,12 @@ void igt_enable_connectors(void)
continue;
/* just enable VGA for now */
- if (c->connector_type == DRM_MODE_CONNECTOR_VGA)
- kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON);
+ if (c->connector_type == DRM_MODE_CONNECTOR_VGA) {
+ if (!kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON))
+ igt_info("Unable to force state on %s-%d\n",
+ kmstest_connector_type_str(c->connector_type),
+ c->connector_type_id);
+ }
drmModeFreeConnector(c);
}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index fb0e66a..08b46ab 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -130,7 +130,7 @@ int kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
unsigned long crtc_idx_mask,
struct kmstest_connector_config *config);
-void kmstest_force_connector(int fd, drmModeConnector *connector,
+bool kmstest_force_connector(int fd, drmModeConnector *connector,
enum kmstest_force_connector_state state);
void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
const unsigned char *edid, size_t length);
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH i-g-t] lib: don't abort if forcing the connector state fails
2014-07-28 15:24 [PATCH i-g-t] lib: don't abort if forcing the connector state fails Thomas Wood
@ 2014-07-28 15:34 ` Daniel Vetter
2014-07-29 11:22 ` Chris Wilson
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2014-07-28 15:34 UTC (permalink / raw)
To: Thomas Wood; +Cc: intel-gfx
On Mon, Jul 28, 2014 at 04:24:49PM +0100, Thomas Wood wrote:
> Ensure tests using igt_enable_connectors can still run even if the
> relevant debugfs files are not available.
>
> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> ---
> lib/igt_kms.c | 19 ++++++++++++++-----
> lib/igt_kms.h | 2 +-
> 2 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 20370a9..740b5dd 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -429,9 +429,11 @@ static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector,
> * @state: state to force on @connector
> *
> * Force the specified state on the specified connector.
> + *
> + * Returns: true on success
> */
> -void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
> - kmstest_force_connector_state state)
> +bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
> + enum kmstest_force_connector_state state)
> {
> char *path;
> const char *value;
> @@ -458,12 +460,15 @@ void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
> debugfs_fd = open(path, O_WRONLY | O_TRUNC);
> free(path);
>
> - igt_assert(debugfs_fd != -1);
> + if (debugfs_fd == -1) {
> + return false;
> + }
Aside: We have some neat debugfs helpers in igt_debugfs.c. Might convert
over to them while at it.
-Daniel
>
> ret = write(debugfs_fd, value, strlen(value));
> close(debugfs_fd);
>
> igt_assert(ret != -1);
> + return (ret == -1) ? false : true;
> }
>
> /**
> @@ -1509,8 +1514,12 @@ void igt_enable_connectors(void)
> continue;
>
> /* just enable VGA for now */
> - if (c->connector_type == DRM_MODE_CONNECTOR_VGA)
> - kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON);
> + if (c->connector_type == DRM_MODE_CONNECTOR_VGA) {
> + if (!kmstest_force_connector(drm_fd, c, FORCE_CONNECTOR_ON))
> + igt_info("Unable to force state on %s-%d\n",
> + kmstest_connector_type_str(c->connector_type),
> + c->connector_type_id);
> + }
>
> drmModeFreeConnector(c);
> }
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index fb0e66a..08b46ab 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -130,7 +130,7 @@ int kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
> int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
> unsigned long crtc_idx_mask,
> struct kmstest_connector_config *config);
> -void kmstest_force_connector(int fd, drmModeConnector *connector,
> +bool kmstest_force_connector(int fd, drmModeConnector *connector,
> enum kmstest_force_connector_state state);
> void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
> const unsigned char *edid, size_t length);
> --
> 1.9.3
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH i-g-t] lib: don't abort if forcing the connector state fails
2014-07-28 15:34 ` Daniel Vetter
@ 2014-07-29 11:22 ` Chris Wilson
0 siblings, 0 replies; 3+ messages in thread
From: Chris Wilson @ 2014-07-29 11:22 UTC (permalink / raw)
To: Daniel Vetter; +Cc: intel-gfx, Thomas Wood
On Mon, Jul 28, 2014 at 05:34:55PM +0200, Daniel Vetter wrote:
> On Mon, Jul 28, 2014 at 04:24:49PM +0100, Thomas Wood wrote:
> > Ensure tests using igt_enable_connectors can still run even if the
> > relevant debugfs files are not available.
> >
> > Signed-off-by: Thomas Wood <thomas.wood@intel.com>
> > ---
> > lib/igt_kms.c | 19 ++++++++++++++-----
> > lib/igt_kms.h | 2 +-
> > 2 files changed, 15 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> > index 20370a9..740b5dd 100644
> > --- a/lib/igt_kms.c
> > +++ b/lib/igt_kms.c
> > @@ -429,9 +429,11 @@ static char* get_debugfs_connector_path(int drm_fd, drmModeConnector *connector,
> > * @state: state to force on @connector
> > *
> > * Force the specified state on the specified connector.
> > + *
> > + * Returns: true on success
> > */
> > -void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
> > - kmstest_force_connector_state state)
> > +bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
> > + enum kmstest_force_connector_state state)
> > {
> > char *path;
> > const char *value;
> > @@ -458,12 +460,15 @@ void kmstest_force_connector(int drm_fd, drmModeConnector *connector, enum
> > debugfs_fd = open(path, O_WRONLY | O_TRUNC);
> > free(path);
> >
> > - igt_assert(debugfs_fd != -1);
> > + if (debugfs_fd == -1) {
> > + return false;
> > + }
>
> Aside: We have some neat debugfs helpers in igt_debugfs.c. Might convert
> over to them while at it.
Aside: they are not that neat... :p I felt restricted that I couldn't open
the right debugfs for an fd I had - the assumption of the singleton is
too prescriptive.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-29 11:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-28 15:24 [PATCH i-g-t] lib: don't abort if forcing the connector state fails Thomas Wood
2014-07-28 15:34 ` Daniel Vetter
2014-07-29 11:22 ` Chris Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox