From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Fri, 13 May 2022 12:24:22 -0700 Message-ID: <87sfpd5j89.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Tvrtko Ursulin In-Reply-To: <20220513093128.1027997-1-tvrtko.ursulin@linux.intel.com> References: <20220513093128.1027997-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [igt-dev] [PATCH i-g-t] tests/core_hotunplug: Check sysfs reads after hotunplug List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org, Tvrtko Ursulin Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: On Fri, 13 May 2022 02:31:28 -0700, Tvrtko Ursulin wrote: > > From: Tvrtko Ursulin > > Leave some sysfs files open and attempt to read from them after hotunplug. A few minor comments below but otherwise LGTM: Reviewed-by: Ashutosh Dixit > Signed-off-by: Tvrtko Ursulin > Cc: Ashutosh Dixit > --- > tests/core_hotunplug.c | 62 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) > > diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c > index 02eae19e1e16..c3831541202d 100644 > --- a/tests/core_hotunplug.c > +++ b/tests/core_hotunplug.c > @@ -602,6 +602,59 @@ static void hotreplug_lateclose(struct hotunplug *priv) > igt_assert_f(healthcheck(priv, false), "%s\n", priv->failure); > } > > +static void hotunplug_sysfs(struct hotunplug *priv) > +{ > + int i915, sysfs; > + struct { > + int fd; > + const char *path; > + char buf[256]; > + } *item, items[] = { > + { .fd = -1, .path = "error" }, > + { .fd = -1, .path = "gt_act_freq_mhz" }, > + { .fd = -1, .path = "gt/gt0/rps_act_freq_mhz" }, > + { .fd = -1, .path = "gt/gt0/rc6_residency_ms" }, > + { .fd = -1, .path = "engine/rcs0/name" }, > + { .fd = -1, .path = "engine/bcs0/name" }, > + { .path = NULL }, > + }; > + unsigned int cnt = 0; > + > + pre_check(priv); > + > + i915 = local_drm_open_driver(false, "", " for hot unplug"); > + sysfs = igt_sysfs_open(i915); > + igt_require(sysfs >= 0); > + for (item = &items[0]; item->path; item++) { > + item->fd = openat(sysfs, item->path, O_RDONLY); > + cnt += item->fd >= 0; > + } > + close(sysfs); > + close_device(i915, " ", "sysfs open "); > + > + igt_require(cnt >= 3); igt_require(cnt) ? > + > + device_unplug(priv, "hot ", 60); Not sure what happens when there are child devices etc. Anyway it's being used elsewhere too so probably ok. Also maybe unbind (instead of remove) using driver_unbind() is sufficient? > + > + sleep(2); Device remove via sysfs: echo 1 > /sys/bus/pci/devices/0000\:03\:00.0/remove is most likely synchronous but anyway... > + > + for (item = &items[0]; item->path; item++) { > + ssize_t len; > + int err; > + > + if (item->fd < 0) > + continue; > + > + len = read(item->fd, item->buf, sizeof(item->buf)); > + err = len < 0 ? -errno : 0; > + close(item->fd); > + igt_debug("%s='%s' (%d)\n", item->path, item->buf, err); > + igt_assert_eq(err, -ENODEV); > + } > + > + igt_assert_f(healthcheck(priv, false), "%s\n", priv->failure); > +} > + > /* Main */ > > igt_main > @@ -735,6 +788,15 @@ igt_main > recover(&priv); > } > > + igt_subtest_group { > + igt_describe("Check if sysfs files left open can be safely accessed after hotunplug."); > + igt_subtest("hotunplug-sysfs") > + hotunplug_sysfs(&priv); > + > + igt_fixture > + recover(&priv); > + } > + > igt_fixture { > post_healthcheck(&priv); > > -- > 2.32.0 > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C96C8C433F5 for ; Fri, 13 May 2022 19:24:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27A5A10E662; Fri, 13 May 2022 19:24:25 +0000 (UTC) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC8F310E662; Fri, 13 May 2022 19:24:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652469863; x=1684005863; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=unxZYbH7ZYpvHE68lRIcW7wSQf9s1s3lqrzGixExpG4=; b=gHUsSHgK2HHG7+K3YXJMiVvvgPBQOW9kYbQBHD33rSKHxPRs/z7Xh/O5 MkTxzVDB1/hBEGcW1Vs2CbtZVDXtBtun/23IdM4IQd/tI8p69Pype/5jR xoQoWjUvEIyfNQFj6NiuOdokfliZjY0/tdmQBnu5tz5zkveNz5/2IztK6 taHlJ4Z8jAzY8OuunnO0jmroxY9s1joGahGnc8n1LlSPUf56on9mPGBPn d4WpR7sFN0ScwugMtovUIrDy0UXHRZ+MhnOmW73WbgsPyuoocq9i91bx+ gnN/ueOYiDclMBa+SIRTCLV91plW7OqtD0QDREQWoLwEv8rhbPnlO2tyj Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10346"; a="333422565" X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="333422565" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 12:24:23 -0700 X-IronPort-AV: E=Sophos;i="5.91,223,1647327600"; d="scan'208";a="543390440" Received: from adixit-mobl1.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.212.194.52]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2022 12:24:23 -0700 Date: Fri, 13 May 2022 12:24:22 -0700 Message-ID: <87sfpd5j89.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Tvrtko Ursulin In-Reply-To: <20220513093128.1027997-1-tvrtko.ursulin@linux.intel.com> References: <20220513093128.1027997-1-tvrtko.ursulin@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Intel-gfx] [PATCH i-g-t] tests/core_hotunplug: Check sysfs reads after hotunplug X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Fri, 13 May 2022 02:31:28 -0700, Tvrtko Ursulin wrote: > > From: Tvrtko Ursulin > > Leave some sysfs files open and attempt to read from them after hotunplug. A few minor comments below but otherwise LGTM: Reviewed-by: Ashutosh Dixit > Signed-off-by: Tvrtko Ursulin > Cc: Ashutosh Dixit > --- > tests/core_hotunplug.c | 62 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 62 insertions(+) > > diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c > index 02eae19e1e16..c3831541202d 100644 > --- a/tests/core_hotunplug.c > +++ b/tests/core_hotunplug.c > @@ -602,6 +602,59 @@ static void hotreplug_lateclose(struct hotunplug *priv) > igt_assert_f(healthcheck(priv, false), "%s\n", priv->failure); > } > > +static void hotunplug_sysfs(struct hotunplug *priv) > +{ > + int i915, sysfs; > + struct { > + int fd; > + const char *path; > + char buf[256]; > + } *item, items[] = { > + { .fd = -1, .path = "error" }, > + { .fd = -1, .path = "gt_act_freq_mhz" }, > + { .fd = -1, .path = "gt/gt0/rps_act_freq_mhz" }, > + { .fd = -1, .path = "gt/gt0/rc6_residency_ms" }, > + { .fd = -1, .path = "engine/rcs0/name" }, > + { .fd = -1, .path = "engine/bcs0/name" }, > + { .path = NULL }, > + }; > + unsigned int cnt = 0; > + > + pre_check(priv); > + > + i915 = local_drm_open_driver(false, "", " for hot unplug"); > + sysfs = igt_sysfs_open(i915); > + igt_require(sysfs >= 0); > + for (item = &items[0]; item->path; item++) { > + item->fd = openat(sysfs, item->path, O_RDONLY); > + cnt += item->fd >= 0; > + } > + close(sysfs); > + close_device(i915, " ", "sysfs open "); > + > + igt_require(cnt >= 3); igt_require(cnt) ? > + > + device_unplug(priv, "hot ", 60); Not sure what happens when there are child devices etc. Anyway it's being used elsewhere too so probably ok. Also maybe unbind (instead of remove) using driver_unbind() is sufficient? > + > + sleep(2); Device remove via sysfs: echo 1 > /sys/bus/pci/devices/0000\:03\:00.0/remove is most likely synchronous but anyway... > + > + for (item = &items[0]; item->path; item++) { > + ssize_t len; > + int err; > + > + if (item->fd < 0) > + continue; > + > + len = read(item->fd, item->buf, sizeof(item->buf)); > + err = len < 0 ? -errno : 0; > + close(item->fd); > + igt_debug("%s='%s' (%d)\n", item->path, item->buf, err); > + igt_assert_eq(err, -ENODEV); > + } > + > + igt_assert_f(healthcheck(priv, false), "%s\n", priv->failure); > +} > + > /* Main */ > > igt_main > @@ -735,6 +788,15 @@ igt_main > recover(&priv); > } > > + igt_subtest_group { > + igt_describe("Check if sysfs files left open can be safely accessed after hotunplug."); > + igt_subtest("hotunplug-sysfs") > + hotunplug_sysfs(&priv); > + > + igt_fixture > + recover(&priv); > + } > + > igt_fixture { > post_healthcheck(&priv); > > -- > 2.32.0 >