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 997F0C4167B for ; Tue, 28 Nov 2023 09:30:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 669AE10E469; Tue, 28 Nov 2023 09:30:56 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4880B10E469 for ; Tue, 28 Nov 2023 09:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701163854; x=1732699854; h=message-id:date:subject:to:cc:references:from: in-reply-to:mime-version; bh=PNowf5GJeaXTr8UEa6XFd4unkwhtZRcRdWNIGPwvV2I=; b=e+D6HZ2GqnxBuWvViy/W45SltKgQQokLhcL4ER63OS8gcDekgQnEqOQL jKffJhSVxkmHj5sbqzK1UKclrbwcW5ZDK3LeaqX8J7SERarnDxyghrra8 74ajHCgkANrf5Juc7aL0S4u1OaKJ8Ix2VyizrRqC2KSrHDqZ1j53ZnclX n26lJIJmwVonz5L2/QRITEExWaOaHgYoGG7QmY2Kq9hW4L7ZTzdzcOJ9y GMUzPe47MEw+SJxZ+ng0veDqe1NIlV2TKV7AhlQoNHzK6gUBjyxOoDJaz RmGsmLIIOU0bU5wfwf0STcih4mye2UTW/ONXiBhdXg6pFtGA8Nu9X4kmG Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="390042652" X-IronPort-AV: E=Sophos;i="6.04,233,1695711600"; d="scan'208,217";a="390042652" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 01:30:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="941859741" X-IronPort-AV: E=Sophos;i="6.04,233,1695711600"; d="scan'208,217";a="941859741" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 28 Nov 2023 01:30:52 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 28 Nov 2023 01:30:52 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Tue, 28 Nov 2023 01:30:52 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Tue, 28 Nov 2023 01:30:52 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LnSqvTi5/vMw9igu3VBVbXstUO8bfZIzEgkMUEZ6Tvdy9fpAR/V8mjF9KQSv8UNig4k+wrdtzc9xdoafDRFuHAfRH46blHfcZrKhC/z2aZc33zzrye4a0ZkBBcwNtVANi5a/VfCYfRS12ytUg9Unek1RViIPvpjvMlMmYLKZgT05qtuBOlOwJhf/sEGChHHk0T9gkg1dJ+FXrPca2D0u33axJHi2E5HVpgi7x7dsq+ELMyuGOJzP5vs3z0cNqHf95Bo8qDeQBwLN8mk4aQ/3Qrq8cG+48ZiCc6cOx/jpO2rsKUvKC8a3MySnf0JwTNqXMuI8ajnQZLYkpAMc0fTwNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BvzTuHRUhegGUp3MmDB/cBRP1MRVw84VqTP0VIacTlo=; b=NIbKazfshS5zfPmMb0G2/af32eRuJ6pt7ZI5uoPoeBkiICX7KfHYup+hoEUJkFRM6ZdfRXvPE1/2vjQuSfQWME1rmiULsYfIUdr2GxDxYLyWVegIDdZIGXeGbiOdm0BK3xnhX99VdHvzQM64i8U18wXdfpwOPwT3J7BogseLCOa09DPYZxaOKR4vELM2JG4Zk70TBtXUqND9JfQUDjt5I0paIoXMuMTyEg6wtbem6F2BDRUD5BmeuvktwEaaZga8f67bBYvppfnOgTiBubdw8fE9OdQsfZ8s0nhvy5/5AlRFWz0ANAFwDg9kkNj5TEX6MSKQIrR0dIDF3dIn1zFYUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5293.namprd11.prod.outlook.com (2603:10b6:5:390::20) by SA1PR11MB5802.namprd11.prod.outlook.com (2603:10b6:806:235::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Tue, 28 Nov 2023 09:30:49 +0000 Received: from DM4PR11MB5293.namprd11.prod.outlook.com ([fe80::e480:1717:8a53:1406]) by DM4PR11MB5293.namprd11.prod.outlook.com ([fe80::e480:1717:8a53:1406%6]) with mapi id 15.20.7025.022; Tue, 28 Nov 2023 09:30:49 +0000 Content-Type: multipart/alternative; boundary="------------XLDNTLe0oNLCIkM3nehhwaZy" Message-ID: Date: Tue, 28 Nov 2023 15:00:41 +0530 User-Agent: Mozilla Thunderbird Beta To: "Zeng, Oak" , "intel-xe@lists.freedesktop.org" References: <20231122042142.6648-1-krishnaiah.bommu@intel.com> Content-Language: en-US From: "Bommu, Krishnaiah" In-Reply-To: X-ClientProxiedBy: BM1P287CA0002.INDP287.PROD.OUTLOOK.COM (2603:1096:b00:40::13) To DM4PR11MB5293.namprd11.prod.outlook.com (2603:10b6:5:390::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB5293:EE_|SA1PR11MB5802:EE_ X-MS-Office365-Filtering-Correlation-Id: b2fe9a2c-7224-4cb2-fad5-08dbeff4b4ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bEINhsfD+Az7MjJpHzNY08qoR3Pc5LdfYSLc0k+aHcYSBuwfjDqQQwHwjZS4173YHN3js9M6O2krStMbGFMIBB8hzeO3ihJJ/D5whRIdKxxlTGpUuvXLvCILtgX1K5eaOb0KBYQOj6xVgrUmphsnf7ppHRnYVcsPNTsaDW0K3P2vKCnU4z2rRUhXOVlXT6SL3CAO4XbBSapg17soF4yi01/cdSqwYhOCAfipxBudxdyj5eFdObyl5CDIFEcXPwPigFOSe1IyP+ovDZb/poa5zeBBplcPWws3zU5kdy4fXXkXSZINLpbk4egZtURgg5xIs2mESHI17Cljb/cIijgjAFLSOf0YzKzaeQEEeOoU9e1a1aAg9uEdmXM/0zn90ZOIEtrz6ARKLtt4YtGMgvm6t24COcS2P1bnJ8xomdLWXhkysvXuwP1MPLSAkc4EkUUVivhd+fx1RqEeiGG4GLc1sIqYWNLMeN2hCzSIc23Jz4ckBcn/wOpycnQ8TpFRQJnlVNWQ4ia2SaR6Ed8AyLm26UHe5xPE5DgWFPnY2g4Mg490JgI1VirMTQfA1Myx6AhuTyp32S6J5RCxjtY2l76lBBoQXbqKIIrDPRRRiZGIscegSCDy+nzb/psxNxQMYAqEAvN6GDxSiaapR43n8B3dqA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB5293.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(39860400002)(366004)(136003)(346002)(396003)(376002)(230922051799003)(451199024)(64100799003)(186009)(1800799012)(41300700001)(31686004)(4326008)(30864003)(2906002)(8936002)(8676002)(53546011)(6506007)(6666004)(2616005)(86362001)(33964004)(31696002)(6512007)(316002)(66476007)(66556008)(66946007)(54906003)(5660300002)(478600001)(6486002)(26005)(36756003)(110136005)(83380400001)(38100700002)(107886003)(82960400001)(45980500001)(43740500002)(559001)(579004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cjh2ays5OGxKVXdBckZTb3VqdG9tU3hLU3F3WjczRHQwTVB3UWIzZHl6NXNh?= =?utf-8?B?dTc3eVdNempGN0xzaEU5dnFTMVZlbHl1NTNRbnU4ZUtORW9adm5uS2hCb0ps?= =?utf-8?B?eTNmcTVTbUg0MUdkMi9FVVNibTlIZjFDVkQ4cDBMUHg2RFc5ZWNWdGo4V1B0?= =?utf-8?B?K0Fyd1Y3VmU2am5tOTZtT2diVGcwZnJTL2hod0FleTdMYVRGRytDMXE1QXhn?= =?utf-8?B?d3RYejJ2OE80YTFhS3hYVDlOY2h6Mk0rb0RLbUFFYXB5ZmNEMmh4YkZEZVIx?= =?utf-8?B?a2dldzNGTE16WWhldEVrM3M1d3RROE12cFlkcmtxVXdFOWRuN2paK1dTUk0w?= =?utf-8?B?aktrdnROZW4vWFBxTzRXdjNBQ2RwN05jbEpLV3VYSml3Z2NlbDZXYTB6QzU3?= =?utf-8?B?VGxQN1grT3VwZEtOU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a2c-7224-4cb2-fad5-08dbeff4b4ec X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5293.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2023 09:30:49.3796 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5RGDeokiWFj1CSaJj8UuL1HZlzBmU7a7ITVtwBmUh+1W8gN5TtYnw5//rTSKONCDefbO3kwSZ5eEHW7DHtzhJehZ2MU/ZG5mvNwwq69LRt8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB5802 X-OriginatorOrg: intel.com Subject: Re: [Intel-xe] [PATCH v2] RFC: drm/xe: Return correct error code for xe_wait_user_fence_ioctl 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" --------------XLDNTLe0oNLCIkM3nehhwaZy Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit Thank you Oak for review, I am writing IGT of this change, I will send the new patch after testing with addressing your comments. Regards, Krishna. On 24-11-2023 23:48, Zeng, Oak wrote: > This version seems good to me. See two small comments inline. > > Oak > >> -----Original Message----- >> From: Bommu, Krishnaiah >> Sent: Tuesday, November 21, 2023 11:22 PM >> To:intel-xe@lists.freedesktop.org >> Cc: Bommu, Krishnaiah; Zeng, Oak >> ; Kempczynski, Zbigniew >> ; Brost, Matthew >> >> Subject: [PATCH v2] RFC: drm/xe: Return correct error code for >> xe_wait_user_fence_ioctl >> >> return correct error code if exec_queue is reset/engine is hung >> remove the num_engines/instances members from drm_xe_wait_user_fence >> structure >> and add a exec_queue_id member > You also added a reset_status interface to exec_q_ops, need to mention it in description. Or if you want, I think this internal interface change can be a separate patch in this series. A small patch each only do one simple thing always help people to review. > >> v2: Addressed the review comments >> >> Need to validated the changes >> >> Signed-off-by: Bommu Krishnaiah >> Cc: Oak Zeng >> Cc: Kempczynski Zbigniew >> Cc: Matthew Brost >> --- >> drivers/gpu/drm/xe/xe_exec_queue_types.h | 2 + >> drivers/gpu/drm/xe/xe_execlist.c | 7 +++ >> drivers/gpu/drm/xe/xe_guc_submit.c | 13 +++++ >> drivers/gpu/drm/xe/xe_wait_user_fence.c | 60 +++++------------------- >> include/uapi/drm/xe_drm.h | 13 +---- >> 5 files changed, 37 insertions(+), 58 deletions(-) >> >> diff --git a/drivers/gpu/drm/xe/xe_exec_queue_types.h >> b/drivers/gpu/drm/xe/xe_exec_queue_types.h >> index 5ba47a5cfdbd..84ccf7242247 100644 >> --- a/drivers/gpu/drm/xe/xe_exec_queue_types.h >> +++ b/drivers/gpu/drm/xe/xe_exec_queue_types.h >> @@ -206,6 +206,8 @@ struct xe_exec_queue_ops { >> * signalled when this function is called. >> */ >> void (*resume)(struct xe_exec_queue *q); >> + /** @reset_status: check exec queue reset status */ >> + bool (*reset_status)(struct xe_exec_queue *q); >> }; >> >> #endif >> diff --git a/drivers/gpu/drm/xe/xe_execlist.c >> b/drivers/gpu/drm/xe/xe_execlist.c >> index e8754adfc52a..3b390f047108 100644 >> --- a/drivers/gpu/drm/xe/xe_execlist.c >> +++ b/drivers/gpu/drm/xe/xe_execlist.c >> @@ -446,6 +446,12 @@ static void execlist_exec_queue_resume(struct >> xe_exec_queue *q) >> /* NIY */ >> } >> >> +static bool execlist_exec_queue_reset_status(struct xe_exec_queue *q) >> +{ >> + /* NIY */ >> + return false; >> +} >> + >> static const struct xe_exec_queue_ops execlist_exec_queue_ops = { >> .init = execlist_exec_queue_init, >> .kill = execlist_exec_queue_kill, >> @@ -457,6 +463,7 @@ static const struct xe_exec_queue_ops >> execlist_exec_queue_ops = { >> .suspend = execlist_exec_queue_suspend, >> .suspend_wait = execlist_exec_queue_suspend_wait, >> .resume = execlist_exec_queue_resume, >> + .reset_status = execlist_exec_queue_reset_status, >> }; >> >> int xe_execlist_init(struct xe_gt *gt) >> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c >> b/drivers/gpu/drm/xe/xe_guc_submit.c >> index 9e9e925c7353..e13792e49a67 100644 >> --- a/drivers/gpu/drm/xe/xe_guc_submit.c >> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c >> @@ -852,6 +852,10 @@ static void simple_error_capture(struct xe_exec_queue >> *q) >> static void xe_guc_exec_queue_trigger_cleanup(struct xe_exec_queue *q) >> { >> struct xe_guc *guc = exec_queue_to_guc(q); >> + struct xe_device *xe = guc_to_xe(guc); >> + >> + /** to wakeup xe_wait_user_fence ioctl if exec queue is reset */ >> + wake_up_all(&xe->ufence_wq); >> >> if (xe_exec_queue_is_lr(q)) >> queue_work(guc_to_gt(guc)->ordered_wq, &q->guc->lr_tdr); >> @@ -1392,6 +1396,14 @@ static void guc_exec_queue_resume(struct >> xe_exec_queue *q) >> guc_exec_queue_add_msg(q, msg, RESUME); >> } >> >> +static bool guc_exec_queue_reset_status(struct xe_exec_queue *q) >> +{ >> + if (exec_queue_registered(q)) > Do you really need this check? If a queue is not registered yet, how can it be reset? > > Oak > > >> + return exec_queue_reset(q); >> + >> + return false; >> +} >> + >> /* >> * All of these functions are an abstraction layer which other parts of XE can >> * use to trap into the GuC backend. All of these functions, aside from init, >> @@ -1409,6 +1421,7 @@ static const struct xe_exec_queue_ops >> guc_exec_queue_ops = { >> .suspend = guc_exec_queue_suspend, >> .suspend_wait = guc_exec_queue_suspend_wait, >> .resume = guc_exec_queue_resume, >> + .reset_status = guc_exec_queue_reset_status, >> }; >> >> static void guc_exec_queue_stop(struct xe_guc *guc, struct xe_exec_queue *q) >> diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c >> b/drivers/gpu/drm/xe/xe_wait_user_fence.c >> index 4d5c2555ce41..97af879ee923 100644 >> --- a/drivers/gpu/drm/xe/xe_wait_user_fence.c >> +++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c >> @@ -13,6 +13,7 @@ >> #include "xe_device.h" >> #include "xe_gt.h" >> #include "xe_macros.h" >> +#include "xe_exec_queue.h" >> >> static int do_compare(u64 addr, u64 value, u64 mask, u16 op) >> { >> @@ -58,27 +59,6 @@ static const enum xe_engine_class >> user_to_xe_engine_class[] = { >> [DRM_XE_ENGINE_CLASS_COMPUTE] = XE_ENGINE_CLASS_COMPUTE, >> }; >> >> -static int check_hw_engines(struct xe_device *xe, >> - struct drm_xe_engine_class_instance *eci, >> - int num_engines) >> -{ >> - int i; >> - >> - for (i = 0; i < num_engines; ++i) { >> - enum xe_engine_class user_class = >> - user_to_xe_engine_class[eci[i].engine_class]; >> - >> - if (eci[i].gt_id >= xe->info.tile_count) >> - return -EINVAL; >> - >> - if (!xe_gt_hw_engine(xe_device_get_gt(xe, eci[i].gt_id), >> - user_class, eci[i].engine_instance, true)) >> - return -EINVAL; >> - } >> - >> - return 0; >> -} >> - >> #define VALID_FLAGS (DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP | \ >> DRM_XE_UFENCE_WAIT_FLAG_ABSTIME) >> #define MAX_OP DRM_XE_UFENCE_WAIT_OP_LTE >> @@ -130,14 +110,12 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, >> void *data, >> struct drm_file *file) >> { >> struct xe_device *xe = to_xe_device(dev); >> + struct xe_file *xef = to_xe_file(file); >> DEFINE_WAIT_FUNC(w_wait, woken_wake_function); >> struct drm_xe_wait_user_fence *args = data; >> - struct drm_xe_engine_class_instance >> eci[XE_HW_ENGINE_MAX_INSTANCE]; >> - struct drm_xe_engine_class_instance __user *user_eci = >> - u64_to_user_ptr(args->instances); >> + struct xe_exec_queue *q = NULL; >> u64 addr = args->addr; >> int err; >> - bool no_engines = args->flags & >> DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP; >> long timeout; >> ktime_t start; >> >> @@ -151,35 +129,17 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, >> void *data, >> if (XE_IOCTL_DBG(xe, args->op > MAX_OP)) >> return -EINVAL; >> >> - if (XE_IOCTL_DBG(xe, no_engines && >> - (args->num_engines || args->instances))) >> - return -EINVAL; >> - >> - if (XE_IOCTL_DBG(xe, !no_engines && !args->num_engines)) >> - return -EINVAL; >> - >> if (XE_IOCTL_DBG(xe, addr & 0x7)) >> return -EINVAL; >> >> - if (XE_IOCTL_DBG(xe, args->num_engines > >> XE_HW_ENGINE_MAX_INSTANCE)) >> - return -EINVAL; >> - >> - if (!no_engines) { >> - err = copy_from_user(eci, user_eci, >> - sizeof(struct drm_xe_engine_class_instance) * >> - args->num_engines); >> - if (XE_IOCTL_DBG(xe, err)) >> - return -EFAULT; >> - >> - if (XE_IOCTL_DBG(xe, check_hw_engines(xe, eci, >> - args->num_engines))) >> - return -EINVAL; >> - } >> - >> timeout = to_jiffies_timeout(xe, args); >> >> start = ktime_get(); >> >> + q = xe_exec_queue_lookup(xef, args->exec_queue_id); >> + if (XE_IOCTL_DBG(xe, !q)) >> + return -ENOENT; >> + >> /* >> * FIXME: Very simple implementation at the moment, single wait queue >> * for everything. Could be optimized to have a wait queue for every >> @@ -202,6 +162,12 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev, >> void *data, >> break; >> } >> >> + if (q->ops->reset_status(q)) { >> + drm_info(&xe->drm, "exec gueue reset detected\n"); >> + err = -EIO; >> + break; >> + } >> + >> timeout = wait_woken(&w_wait, TASK_INTERRUPTIBLE, timeout); >> } >> remove_wait_queue(&xe->ufence_wq, &w_wait); >> diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h >> index 88f3aca02b08..ae2457dc30ad 100644 >> --- a/include/uapi/drm/xe_drm.h >> +++ b/include/uapi/drm/xe_drm.h >> @@ -962,17 +962,8 @@ struct drm_xe_wait_user_fence { >> */ >> __s64 timeout; >> >> - /** >> - * @num_engines: number of engine instances to wait on, must be zero >> - * when DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP set >> - */ >> - __u64 num_engines; >> - >> - /** >> - * @instances: user pointer to array of drm_xe_engine_class_instance to >> - * wait on, must be NULL when DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP >> set >> - */ >> - __u64 instances; >> + /** @exec_queue_id: exec_queue_id returned from >> xe_exec_queue_create_ioctl */ >> + __u32 exec_queue_id; >> >> /** @reserved: Reserved */ >> __u64 reserved[2]; >> -- >> 2.25.1 --------------XLDNTLe0oNLCIkM3nehhwaZy Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit

Thank you Oak for review, I am writing IGT of this change, I will send the new patch after testing with addressing your comments.


Regards,

Krishna.

On 24-11-2023 23:48, Zeng, Oak wrote:
This version seems good to me. See two small comments inline.

Oak 

-----Original Message-----
From: Bommu, Krishnaiah <krishnaiah.bommu@intel.com>
Sent: Tuesday, November 21, 2023 11:22 PM
To: intel-xe@lists.freedesktop.org
Cc: Bommu, Krishnaiah <krishnaiah.bommu@intel.com>; Zeng, Oak
<oak.zeng@intel.com>; Kempczynski, Zbigniew
<zbigniew.kempczynski@intel.com>; Brost, Matthew
<matthew.brost@intel.com>
Subject: [PATCH v2] RFC: drm/xe: Return correct error code for
xe_wait_user_fence_ioctl

return correct error code if exec_queue is reset/engine is hung
remove the num_engines/instances members from drm_xe_wait_user_fence
structure
and add a exec_queue_id member
You also added a reset_status interface to exec_q_ops, need to mention it in description. Or if you want, I think this internal interface change can be a separate patch in this series. A small patch each only do one simple thing always help people to review.

v2: Addressed the review comments

Need to validated the changes

Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Oak Zeng <oak.zeng@intel.com>
Cc: Kempczynski Zbigniew <Zbigniew.Kempczynski@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_exec_queue_types.h |  2 +
 drivers/gpu/drm/xe/xe_execlist.c         |  7 +++
 drivers/gpu/drm/xe/xe_guc_submit.c       | 13 +++++
 drivers/gpu/drm/xe/xe_wait_user_fence.c  | 60 +++++-------------------
 include/uapi/drm/xe_drm.h                | 13 +----
 5 files changed, 37 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_exec_queue_types.h
b/drivers/gpu/drm/xe/xe_exec_queue_types.h
index 5ba47a5cfdbd..84ccf7242247 100644
--- a/drivers/gpu/drm/xe/xe_exec_queue_types.h
+++ b/drivers/gpu/drm/xe/xe_exec_queue_types.h
@@ -206,6 +206,8 @@ struct xe_exec_queue_ops {
 	 * signalled when this function is called.
 	 */
 	void (*resume)(struct xe_exec_queue *q);
+	/** @reset_status: check exec queue reset status */
+	bool (*reset_status)(struct xe_exec_queue *q);
 };

 #endif
diff --git a/drivers/gpu/drm/xe/xe_execlist.c
b/drivers/gpu/drm/xe/xe_execlist.c
index e8754adfc52a..3b390f047108 100644
--- a/drivers/gpu/drm/xe/xe_execlist.c
+++ b/drivers/gpu/drm/xe/xe_execlist.c
@@ -446,6 +446,12 @@ static void execlist_exec_queue_resume(struct
xe_exec_queue *q)
 	/* NIY */
 }

+static bool execlist_exec_queue_reset_status(struct xe_exec_queue *q)
+{
+	 /* NIY */
+	 return false;
+}
+
 static const struct xe_exec_queue_ops execlist_exec_queue_ops = {
 	.init = execlist_exec_queue_init,
 	.kill = execlist_exec_queue_kill,
@@ -457,6 +463,7 @@ static const struct xe_exec_queue_ops
execlist_exec_queue_ops = {
 	.suspend = execlist_exec_queue_suspend,
 	.suspend_wait = execlist_exec_queue_suspend_wait,
 	.resume = execlist_exec_queue_resume,
+	.reset_status = execlist_exec_queue_reset_status,
 };

 int xe_execlist_init(struct xe_gt *gt)
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c
b/drivers/gpu/drm/xe/xe_guc_submit.c
index 9e9e925c7353..e13792e49a67 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -852,6 +852,10 @@ static void simple_error_capture(struct xe_exec_queue
*q)
 static void xe_guc_exec_queue_trigger_cleanup(struct xe_exec_queue *q)
 {
 	struct xe_guc *guc = exec_queue_to_guc(q);
+	struct xe_device *xe = guc_to_xe(guc);
+
+	/** to wakeup xe_wait_user_fence ioctl if exec queue is reset */
+	wake_up_all(&xe->ufence_wq);

 	if (xe_exec_queue_is_lr(q))
 		queue_work(guc_to_gt(guc)->ordered_wq, &q->guc->lr_tdr);
@@ -1392,6 +1396,14 @@ static void guc_exec_queue_resume(struct
xe_exec_queue *q)
 	guc_exec_queue_add_msg(q, msg, RESUME);
 }

+static bool guc_exec_queue_reset_status(struct xe_exec_queue *q)
+{
+	if (exec_queue_registered(q))
Do you really need this check? If a queue is not registered yet, how can it be reset?

Oak


+		return exec_queue_reset(q);
+
+	return false;
+}
+
 /*
  * All of these functions are an abstraction layer which other parts of XE can
  * use to trap into the GuC backend. All of these functions, aside from init,
@@ -1409,6 +1421,7 @@ static const struct xe_exec_queue_ops
guc_exec_queue_ops = {
 	.suspend = guc_exec_queue_suspend,
 	.suspend_wait = guc_exec_queue_suspend_wait,
 	.resume = guc_exec_queue_resume,
+	.reset_status = guc_exec_queue_reset_status,
 };

 static void guc_exec_queue_stop(struct xe_guc *guc, struct xe_exec_queue *q)
diff --git a/drivers/gpu/drm/xe/xe_wait_user_fence.c
b/drivers/gpu/drm/xe/xe_wait_user_fence.c
index 4d5c2555ce41..97af879ee923 100644
--- a/drivers/gpu/drm/xe/xe_wait_user_fence.c
+++ b/drivers/gpu/drm/xe/xe_wait_user_fence.c
@@ -13,6 +13,7 @@
 #include "xe_device.h"
 #include "xe_gt.h"
 #include "xe_macros.h"
+#include "xe_exec_queue.h"

 static int do_compare(u64 addr, u64 value, u64 mask, u16 op)
 {
@@ -58,27 +59,6 @@ static const enum xe_engine_class
user_to_xe_engine_class[] = {
 	[DRM_XE_ENGINE_CLASS_COMPUTE] = XE_ENGINE_CLASS_COMPUTE,
 };

-static int check_hw_engines(struct xe_device *xe,
-			    struct drm_xe_engine_class_instance *eci,
-			    int num_engines)
-{
-	int i;
-
-	for (i = 0; i < num_engines; ++i) {
-		enum xe_engine_class user_class =
-			user_to_xe_engine_class[eci[i].engine_class];
-
-		if (eci[i].gt_id >= xe->info.tile_count)
-			return -EINVAL;
-
-		if (!xe_gt_hw_engine(xe_device_get_gt(xe, eci[i].gt_id),
-				     user_class, eci[i].engine_instance, true))
-			return -EINVAL;
-	}
-
-	return 0;
-}
-
 #define VALID_FLAGS	(DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP | \
 			 DRM_XE_UFENCE_WAIT_FLAG_ABSTIME)
 #define MAX_OP		DRM_XE_UFENCE_WAIT_OP_LTE
@@ -130,14 +110,12 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev,
void *data,
 			     struct drm_file *file)
 {
 	struct xe_device *xe = to_xe_device(dev);
+	struct xe_file *xef = to_xe_file(file);
 	DEFINE_WAIT_FUNC(w_wait, woken_wake_function);
 	struct drm_xe_wait_user_fence *args = data;
-	struct drm_xe_engine_class_instance
eci[XE_HW_ENGINE_MAX_INSTANCE];
-	struct drm_xe_engine_class_instance __user *user_eci =
-		u64_to_user_ptr(args->instances);
+	struct xe_exec_queue *q = NULL;
 	u64 addr = args->addr;
 	int err;
-	bool no_engines = args->flags &
DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP;
 	long timeout;
 	ktime_t start;

@@ -151,35 +129,17 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev,
void *data,
 	if (XE_IOCTL_DBG(xe, args->op > MAX_OP))
 		return -EINVAL;

-	if (XE_IOCTL_DBG(xe, no_engines &&
-			 (args->num_engines || args->instances)))
-		return -EINVAL;
-
-	if (XE_IOCTL_DBG(xe, !no_engines && !args->num_engines))
-		return -EINVAL;
-
 	if (XE_IOCTL_DBG(xe, addr & 0x7))
 		return -EINVAL;

-	if (XE_IOCTL_DBG(xe, args->num_engines >
XE_HW_ENGINE_MAX_INSTANCE))
-		return -EINVAL;
-
-	if (!no_engines) {
-		err = copy_from_user(eci, user_eci,
-				     sizeof(struct drm_xe_engine_class_instance) *
-			     args->num_engines);
-		if (XE_IOCTL_DBG(xe, err))
-			return -EFAULT;
-
-		if (XE_IOCTL_DBG(xe, check_hw_engines(xe, eci,
-						      args->num_engines)))
-			return -EINVAL;
-	}
-
 	timeout = to_jiffies_timeout(xe, args);

 	start = ktime_get();

+	q = xe_exec_queue_lookup(xef, args->exec_queue_id);
+	if (XE_IOCTL_DBG(xe, !q))
+		return -ENOENT;
+
 	/*
 	 * FIXME: Very simple implementation at the moment, single wait queue
 	 * for everything. Could be optimized to have a wait queue for every
@@ -202,6 +162,12 @@ int xe_wait_user_fence_ioctl(struct drm_device *dev,
void *data,
 			break;
 		}

+		if (q->ops->reset_status(q)) {
+			drm_info(&xe->drm, "exec gueue reset detected\n");
+			err = -EIO;
+			break;
+		}
+
 		timeout = wait_woken(&w_wait, TASK_INTERRUPTIBLE, timeout);
 	}
 	remove_wait_queue(&xe->ufence_wq, &w_wait);
diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
index 88f3aca02b08..ae2457dc30ad 100644
--- a/include/uapi/drm/xe_drm.h
+++ b/include/uapi/drm/xe_drm.h
@@ -962,17 +962,8 @@ struct drm_xe_wait_user_fence {
 	 */
 	__s64 timeout;

-	/**
-	 * @num_engines: number of engine instances to wait on, must be zero
-	 * when DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP set
-	 */
-	__u64 num_engines;
-
-	/**
-	 * @instances: user pointer to array of drm_xe_engine_class_instance to
-	 * wait on, must be NULL when DRM_XE_UFENCE_WAIT_FLAG_SOFT_OP
set
-	 */
-	__u64 instances;
+	/** @exec_queue_id: exec_queue_id returned from
xe_exec_queue_create_ioctl */
+	__u32 exec_queue_id;

 	/** @reserved: Reserved */
 	__u64 reserved[2];
--
2.25.1

    
--------------XLDNTLe0oNLCIkM3nehhwaZy--