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 7806CC30653 for ; Tue, 25 Jun 2024 19:59:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2619910E725; Tue, 25 Jun 2024 19:59:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="NdDbP8+n"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7170D10E725 for ; Tue, 25 Jun 2024 19:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719345549; x=1750881549; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=aanOV4xIA/gqIaL9udw+yTDT16yAT+7Z5g57ypVBjlY=; b=NdDbP8+nl+8Ke8gxNfklEICy7+Cg+R6j9ZhnvVgTZoODHXpcE7zX0+iQ KikEZJkx0E/x4b0gHOkOk9UpvgNhTBzFON4K/wX3p7drXwkOsARh+0/C5 ZCBAv9XfpC8mobpkxEtW/UHdyTvPc6+zB+Q+Qql5VmyG3govCRGMekzWi E8n1kxouluA9LuONVgMWmvv14lPF6s/CXfuDRfUjMQICOzoQwv06BFkRF +wjpcGOvVFGyjIbMhZZLrfjRw4ALzxPSCAZYIpdC307/FbnAv6YSXti+Y MIaxWS1KPvDh1u1Wg75NDwQKwFYjJ96vaeuCMfVuOb/t8MS9OyWgGOT9g w==; X-CSE-ConnectionGUID: A+nTlJm3RmC4jKDZ7JmH5A== X-CSE-MsgGUID: vs06YhnNQDuAQFKjF9AhKg== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="27528090" X-IronPort-AV: E=Sophos;i="6.08,264,1712646000"; d="scan'208";a="27528090" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 12:59:08 -0700 X-CSE-ConnectionGUID: pDjWZCRJRRit9mwBjR6KHg== X-CSE-MsgGUID: wZKtarrmTw2QAWAptS1D3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,264,1712646000"; d="scan'208";a="43737233" Received: from orsosgc001.jf.intel.com ([10.165.21.138]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 12:59:09 -0700 From: Ashutosh Dixit To: intel-xe@lists.freedesktop.org Subject: [PATCH 1/2] drm/xe/oa: Allow stream enable/disable functions to return error Date: Tue, 25 Jun 2024 12:59:03 -0700 Message-ID: <20240625195904.757272-2-ashutosh.dixit@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625195904.757272-1-ashutosh.dixit@intel.com> References: <20240625195904.757272-1-ashutosh.dixit@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Stream enable/disable functions previously had void return because failure during function execution was not possible. This will change when we introduce functionality to disable preemption on the stream exec queue. Therefore, in preparation for this functionality, prepare this code to be able to handle error returns. Signed-off-by: Ashutosh Dixit --- drivers/gpu/drm/xe/xe_oa.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c index 9263ae9a864e..a68659fd5386 100644 --- a/drivers/gpu/drm/xe/xe_oa.c +++ b/drivers/gpu/drm/xe/xe_oa.c @@ -1013,24 +1013,26 @@ static void xe_oa_stream_disable(struct xe_oa_stream *stream) hrtimer_cancel(&stream->poll_check_timer); } -static void xe_oa_enable_locked(struct xe_oa_stream *stream) +static int xe_oa_enable_locked(struct xe_oa_stream *stream) { if (stream->enabled) - return; - - stream->enabled = true; + return 0; xe_oa_stream_enable(stream); + + stream->enabled = true; + return 0; } -static void xe_oa_disable_locked(struct xe_oa_stream *stream) +static int xe_oa_disable_locked(struct xe_oa_stream *stream) { if (!stream->enabled) - return; - - stream->enabled = false; + return 0; xe_oa_stream_disable(stream); + + stream->enabled = false; + return 0; } static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg) @@ -1105,11 +1107,9 @@ static long xe_oa_ioctl_locked(struct xe_oa_stream *stream, { switch (cmd) { case DRM_XE_PERF_IOCTL_ENABLE: - xe_oa_enable_locked(stream); - return 0; + return xe_oa_enable_locked(stream); case DRM_XE_PERF_IOCTL_DISABLE: - xe_oa_disable_locked(stream); - return 0; + return xe_oa_disable_locked(stream); case DRM_XE_PERF_IOCTL_CONFIG: return xe_oa_config_locked(stream, arg); case DRM_XE_PERF_IOCTL_STATUS: @@ -1432,19 +1432,25 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa, if (ret) goto err_free; + if (!param->disabled) { + ret = xe_oa_enable_locked(stream); + if (ret) + goto err_destroy; + } + stream_fd = anon_inode_getfd("[xe_oa]", &xe_oa_fops, stream, 0); if (stream_fd < 0) { ret = stream_fd; - goto err_destroy; + goto err_disable; } - if (!param->disabled) - xe_oa_enable_locked(stream); - /* Hold a reference on the drm device till stream_fd is released */ drm_dev_get(&stream->oa->xe->drm); return stream_fd; +err_disable: + if (!param->disabled) + xe_oa_disable_locked(stream); err_destroy: xe_oa_stream_destroy(stream); err_free: -- 2.41.0