From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id A031B6ED13 for ; Thu, 12 Dec 2019 10:37:09 +0000 (UTC) Date: Thu, 12 Dec 2019 16:06:08 +0530 From: Ramalingam C Message-ID: <20191212103608.GA10488@intel.com> References: <20191211141054.21455-1-anshuman.gupta@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191211141054.21455-1-anshuman.gupta@intel.com> Subject: Re: [igt-dev] [PATCH i-g-t] tests/kms_content_protection: Fix uevent subtest List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To: Anshuman Gupta Cc: igt-dev@lists.freedesktop.org List-ID: On 2019-12-11 at 19:40:54 +0530, Anshuman Gupta wrote: > uevent hdcp subtest was failing because hdcp_event() > has been called with NULL udev_monitor, which was > causing udev_monitor_receive_device() to return a > NULL udev. > > Cc: Ramalingam C > Signed-off-by: Anshuman Gupta > --- > tests/kms_content_protection.c | 43 +++++++++++++--------------------- > 1 file changed, 16 insertions(+), 27 deletions(-) > > diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c > index e676b60b..a7dd786b 100644 > --- a/tests/kms_content_protection.c > +++ b/tests/kms_content_protection.c > @@ -165,10 +165,16 @@ static void hdcp_udev_fini(struct udev_monitor *uevent_monitor, > udev_unref(udev); > } > > -static int hdcp_udev_init(struct udev_monitor *uevent_monitor, > - struct udev *udev) As we discussed offline, we could take struct udev_monitor **, struct udev ** and int *udev_fd as parameter and fill them after successful init. Else return the error code. -Ram > +#define MAX_EVENTS 10 > +static bool wait_for_hdcp_event(uint32_t conn_id, uint32_t prop_id, > + uint32_t timeout_mSec) > { > - int ret = -EINVAL; > + struct udev_monitor *uevent_monitor = NULL; > + struct udev *udev = NULL; > + int udev_fd, epoll_fd; > + struct epoll_event event, events[MAX_EVENTS]; > + bool ret = false; > + int err; > > udev = udev_new(); > if (!udev) { > @@ -182,46 +188,29 @@ static int hdcp_udev_init(struct udev_monitor *uevent_monitor, > goto out; > } > > - ret = udev_monitor_filter_add_match_subsystem_devtype(uevent_monitor, > + err = udev_monitor_filter_add_match_subsystem_devtype(uevent_monitor, > "drm", > "drm_minor"); > - if (ret < 0) { > + if (err < 0) { > igt_info("failed to filter for drm events\n"); > goto out; > } > > - ret = udev_monitor_enable_receiving(uevent_monitor); > - if (ret < 0) { > + err = udev_monitor_enable_receiving(uevent_monitor); > + if (err < 0) { > igt_info("failed to enable udev event reception\n"); > goto out; > } > > - return udev_monitor_get_fd(uevent_monitor); > - > -out: > - hdcp_udev_fini(uevent_monitor, udev); > - return ret; > -} > - > -#define MAX_EVENTS 10 > -static bool wait_for_hdcp_event(uint32_t conn_id, uint32_t prop_id, > - uint32_t timeout_mSec) > -{ > + udev_fd = udev_monitor_get_fd(uevent_monitor); > > - struct udev_monitor *uevent_monitor = NULL; > - struct udev *udev = NULL; > - int udev_fd, epoll_fd; > - struct epoll_event event, events[MAX_EVENTS]; > - bool ret = false; > - > - udev_fd = hdcp_udev_init(uevent_monitor, udev); > if (udev_fd < 0) > return false; > > epoll_fd = epoll_create1(0); > if (epoll_fd == -1) { > igt_info("Failed to create epoll fd. %d\n", epoll_fd); > - goto out_ep_create; > + goto out; > } > > event.events = EPOLLIN | EPOLLERR; > @@ -238,7 +227,7 @@ static bool wait_for_hdcp_event(uint32_t conn_id, uint32_t prop_id, > out_ep_ctl: > if (close(epoll_fd)) > igt_info("failed to close the epoll fd\n"); > -out_ep_create: > +out: > hdcp_udev_fini(uevent_monitor, udev); > return ret; > } > -- > 2.24.0 > _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev