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 83A63CD8CB5 for ; Tue, 10 Oct 2023 19:43:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2559510E127; Tue, 10 Oct 2023 19:43:50 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 728FC10E127 for ; Tue, 10 Oct 2023 19:43:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696967028; x=1728503028; h=message-id:date:subject:to:cc:references:from: in-reply-to:mime-version; bh=Yzgs/5op/Lp7P0wwQv0Y3aC4xX38FhQvqqC7d8F/E+M=; b=XQ2e8LOo5oPRYs0Yk1Q/Lc/VGX033APbf1rfB/vtI2E7kbhNz6yNdqcH CXeGkEDO+gQDFEnHjvko0hV3fZXodnu2AOq2Pc12nX2+qJzSzVZHaX31W SYtWAAH8MY4zqhRjEIqye2QYtl4ylF5kDKscjwtZ+Io0Y09B5ube8RBiC R9NiB0ce7zhCEAK9F8jwaI7ddprVE9tR9M6xE7ByhSd+g8542QU1wsi0V 1aeYDZC6PggZ3KPSbJ0qdeO2/7IQAKofM44gVzT481xWeWd75Q0xfly4n saJOFMASaTWfAUXR+hmEh8X/B/6bTcvfH93s9nhGPTDPOdrqEfsR7CtEf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="363846231" X-IronPort-AV: E=Sophos;i="6.03,213,1694761200"; d="scan'208,217";a="363846231" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 12:43:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="703421583" X-IronPort-AV: E=Sophos;i="6.03,213,1694761200"; d="scan'208,217";a="703421583" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga003.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 10 Oct 2023 12:43:47 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 10 Oct 2023 12:43:47 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) 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.32 via Frontend Transport; Tue, 10 Oct 2023 12:43:47 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.41) 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.32; Tue, 10 Oct 2023 12:43:46 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TCTK7BOUf4r8gKVVsQhk7bWL9tcDGjnE5QK0SaNgFNJ5DxpV2IEm4RdQjqTqiyOcicHUienhjUjilPZO0uK+RXKc9EIgLb9DP6BUcbCILwvHUCtOfHtp851kheK54lInCDWx+1RuBAne6hTw/m+MuR40oQdxL1FPIrigmI6PU4lJEXN2JssCXydd36bU9wPJ4qCxgYWE/EuaJD8PWpQ+6gTuWUFKvMSDiQx9yxqG3MX69zlbmkjfEL1pKJX+XR6hLJs4evsRSMjmPOCVX2s/UHPbpkpoWYWT5IfPtUOe/9pvZSykIoTAl2o5oxWiYdOAR+Jc7TXiSxL+Ft4U9Xm0dg== 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=r+afB8JU5Cpx1nIqayNkfhlw1b/p3HWhwa2cImeBsPU=; b=d6QR7NOFXsqwmASFVRhels8fZ4w89RE3/LbV6GQmje4kIfwKYDxsadn/DfgpoOg7f1Nkn+ekjjmy3UuaTbd9CNffYWl0sNTbMP5s74WO6GMdisgCOJOZw2RnPXd6waDi0BZmj3HanSzygqYGmL4Y9gxtKSPVr356LN3EsKaHPejJp1a2F1q6SHqFbm56oKaB9FAoXrch4IS3a4j7GhgtfJV9dgQqjWAantw6qMfYPfzEFgmIArQXlWbbnqE95lOSCJVr9c1Oyn5PjeyMeHkALHJzvPXVbxggB7eVUe8ljMTQa8vQouQGKZGn9zRBMEEc8vZ3LE1lJYDN9/axV+YbAw== 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 BY5PR11MB3911.namprd11.prod.outlook.com (2603:10b6:a03:18d::29) by PH8PR11MB6707.namprd11.prod.outlook.com (2603:10b6:510:1c6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Tue, 10 Oct 2023 19:43:44 +0000 Received: from BY5PR11MB3911.namprd11.prod.outlook.com ([fe80::a782:6fec:8d96:27b5]) by BY5PR11MB3911.namprd11.prod.outlook.com ([fe80::a782:6fec:8d96:27b5%6]) with mapi id 15.20.6863.032; Tue, 10 Oct 2023 19:43:44 +0000 Content-Type: multipart/alternative; boundary="------------RHiJ3Wg0VrhQTue2Qv4ZxbTb" Message-ID: <63d543d9-dc9c-483e-ade5-80e540e7533f@intel.com> Date: Tue, 10 Oct 2023 12:43:41 -0700 User-Agent: Mozilla Thunderbird Content-Language: en-GB To: Jonathan Cavitt , References: <20231010150244.2021420-1-jonathan.cavitt@intel.com> <20231010150244.2021420-3-jonathan.cavitt@intel.com> From: John Harrison In-Reply-To: <20231010150244.2021420-3-jonathan.cavitt@intel.com> X-ClientProxiedBy: MW4PR04CA0138.namprd04.prod.outlook.com (2603:10b6:303:84::23) To BY5PR11MB3911.namprd11.prod.outlook.com (2603:10b6:a03:18d::29) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR11MB3911:EE_|PH8PR11MB6707:EE_ X-MS-Office365-Filtering-Correlation-Id: 378eedc2-4ca8-4786-5b36-08dbc9c93665 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eBw8o2ib1phO0HnxJQ8eIUZeIiUtT+pv3ETZaHBW/lV2KgKlNt7KMOlnEc7HxRfIvr8XtU7nmK3i9mu4wPEkUHf61CtnVqLIGd3tRxQJ4emrmCgo+XxrHU/AKZT5JxYOuhcbxW5xl3W3k0VaaTpxxWaHBg4DMxUKUH+DJpjTe7mt1UkvKN4O50qu+P56Gh0UC31I+xqU7+5YPTbTCqjEhVqtvhtEM0LI7W31qRyD3tm7VJNfCtF+S0OkdERz3s4H07bwSEvS8SGflnKOp5a2JbDXSkdLYFmgprQcu395qOle5sE3VWKzIMduGld53Wmc7iUFQrBRommQqNnVjBGAYkMXgWbbQcjNEpXdloJoJUn1Uql3gby14SH4xK0V3vW814/hTiDf2x+9kGomjJX8ianfR00HSLwanrP5bNAnpzMAwP8ailV4cS+Tkep9/CfG8g7qgnzv+1sdXGaDa72HIEt+MUlfB/NdhOk/oPXidgHjjnj2EDHPuqjqulU1Ucwba9gi6zyxYZA9f2kAYDzrdnOIuouw8OUzt2ZAqz6G3ya1f1lQx5IkszgMYejBaiBUVTG/5qpVF/rKsuqRatpgKoVYur62DZpCjo2B2eGm9S4zJJ5y93cgaW+Usq9Yd0K8gV6zr8JXfegOqhkeDnSang== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR11MB3911.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(346002)(376002)(39860400002)(366004)(396003)(230922051799003)(186009)(64100799003)(451199024)(1800799009)(82960400001)(2906002)(66899024)(8676002)(8936002)(5660300002)(4326008)(86362001)(36756003)(31696002)(478600001)(31686004)(6486002)(83380400001)(6512007)(33964004)(26005)(53546011)(6666004)(6506007)(2616005)(316002)(66476007)(41300700001)(38100700002)(66556008)(66946007)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N1M3R0JJOHF4aGZFZVJiTnZCMGc1S2tITWkyZnR4YWdHOHAxZXhXb1JVYmFN?= =?utf-8?B?V0luU2RrOUM5WTNCWnI3alBCMDFvb3drK0FRcXFKaS9oZ0kxazBNekwxMEZR?= =?utf-8?B?a3JHcTRkSUlnd1V3bGF4Tm1Oblh2c0FtNDZtTC96K2VFbHdlcXdkbzA1Q05v?= =?utf-8?B?NWN3SkU4V1VCL2E1MUYvc3IwU3R6UUw4dWlMallobFY1YUtIZDdXSkJwS2Rr?= =?utf-8?B?RjM4U0E3Q3lFNkpFQ0E0blRSZldMdlRJaDAxNXhDTThaMDFOMVdaWGVENHdv?= =?utf-8?B?aGdObGpNRXVTR1NYQTBtVHlRM3YvdkF2UUh6RnJYOFRiRVhXaUJmbUZBejZB?= =?utf-8?B?Q011cG9DdkRwd1dCbHZwMHpYU3drbGhaUmhta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S1FYZHBZTzVM?= =?utf-8?B?c1E9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 378eedc2-4ca8-4786-5b36-08dbc9c93665 X-MS-Exchange-CrossTenant-AuthSource: BY5PR11MB3911.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 19:43:44.2974 (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: l03se64eM7ZgT8xBjDnNFxSdiQAOoOu5xe5ae9lmC4cNwv3V3e4nTEfs8MtHb7HIU5jE8yUgfnG8EI0jUp0q9zP12EDaXWGvgKhjPFhd97c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR11MB6707 X-OriginatorOrg: intel.com Subject: Re: [Intel-gfx] [PATCH v10 2/7] drm/i915/guc: Add CT size delay helper 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: janusz.krzysztofik@intel.com, andi.shyti@intel.com, matthew.d.roper@intel.com, saurabhg.gupta@intel.com, chris.p.wilson@linux.intel.com, nirmoy.das@intel.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" --------------RHiJ3Wg0VrhQTue2Qv4ZxbTb Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit On 10/10/2023 08:02, Jonathan Cavitt wrote: > Add a helper function to the GuC CT buffer that reports the expected > time to process all outstanding requests. As of now, there is no > functionality to check number of requests in the buffer, so the helper > function just reports 2 seconds, or 1ms per request up to the maximum > number of requests the CT buffer can store. > > Suggested-by: John Harrison > Signed-off-by: Jonathan Cavitt > --- > drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h > index 58e42901ff498..36afc1ce9fabd 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h > @@ -120,6 +120,19 @@ static inline bool intel_guc_ct_enabled(struct intel_guc_ct *ct) > return ct->enabled; > } > > +/* > + * GuC has a timeout of 1ms for a TLB invalidation response from GAM. On a > + * timeout GuC drops the request and has no mechanism to notify the host about > + * the timeout. There is also no mechanism for determining the number of > + * outstanding requests in the CT buffer. Ergo, keep a larger timeout that accounts > + * for this individual timeout and the max number of outstanding requests that > + * can be queued in CT buffer. > + */ This feels like the wrong wording. TLB invalidations aren't even close to the slowest thing that goes through the CT buffer. And the description about dropping failed requests and such is irrelevant to the implementation/purpose of this helper. That is specific detail about one single use case of the helper. That might be the only user at this point but the intention is that other parts of the driver will be updated to call this as well rather than hard coding their own timeouts as they currently do. I would suggest: Some H2G commands involve a synchronous response that the driver needs to wait for. In such cases, a timeout is required to prevent the driver from waiting forever in the case of an error (either no error response is defined in the protocol or something has died and requires a reset). The specific command may be defined as having a time bound response but the CT is a queue and that time guarantee only starts from the point when the command reaches the head of the queue and is processed by GuC. Ideally there would be a helper to report the progress of a given command through the CT. However, that would require a significant amount of work in the CT layer. In the meantime, provide a reasonable estimation of the worst case latency it should take for the entire queue to drain. And therefore, how long a caller should wait before giving up on their request. The current estimate is based on empirical measurement of a test that fills the buffer with context creation and destruction requests as they seem to be the slowest operation. > +static inline long intel_guc_ct_expected_delay(struct intel_guc_ct *ct) This is not the 'expected' delay but the worst case maximum delay. Also, no need to force the callers to know about ct structures. They presumably have a intel_guc structure if they are sending H2G messages, and that is all you should need to know about. Having said that, the implementation isn't currently accessing any stored data, so why bother with a parameter at all? > +{ > + return HZ * 2; Also, this needs to be based on the buffer size so that if the size were to increase then the time would as well. My thought would be: long intel_guc_ct_max_queue_time_jiffies(void) {     /*      * A 4KB buffer full of context destroy commands takes a little over a second to process      * so bump that to 2s to be super safe.      */     return (CTB_H2G_BUFFER_SIZE * HZ) / SZ_2K; } John. > +} > + > #define INTEL_GUC_CT_SEND_NB BIT(31) > #define INTEL_GUC_CT_SEND_G2H_DW_SHIFT 0 > #define INTEL_GUC_CT_SEND_G2H_DW_MASK (0xff << INTEL_GUC_CT_SEND_G2H_DW_SHIFT) --------------RHiJ3Wg0VrhQTue2Qv4ZxbTb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit On 10/10/2023 08:02, Jonathan Cavitt wrote:
Add a helper function to the GuC CT buffer that reports the expected
time to process all outstanding requests.  As of now, there is no
functionality to check number of requests in the buffer, so the helper
function just reports 2 seconds, or 1ms per request up to the maximum
number of requests the CT buffer can store.

Suggested-by: John Harrison <john.c.harrison@intel.com>
Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
---
 drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h
index 58e42901ff498..36afc1ce9fabd 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.h
@@ -120,6 +120,19 @@ static inline bool intel_guc_ct_enabled(struct intel_guc_ct *ct)
 	return ct->enabled;
 }
 
+/*
+ * GuC has a timeout of 1ms for a TLB invalidation response from GAM.  On a
+ * timeout GuC drops the request and has no mechanism to notify the host about
+ * the timeout.  There is also no mechanism for determining the number of
+ * outstanding requests in the CT buffer.  Ergo, keep a larger timeout that accounts
+ * for this individual timeout and the max number of outstanding requests that
+ * can be queued in CT buffer.
+ */
This feels like the wrong wording. TLB invalidations aren't even close to the slowest thing that goes through the CT buffer. And the description about dropping failed requests and such is irrelevant to the implementation/purpose of this helper. That is specific detail about one single use case of the helper. That might be the only user at this point but the intention is that other parts of the driver will be updated to call this as well rather than hard coding their own timeouts as they currently do.

I would suggest:
Some H2G commands involve a synchronous response that the driver needs to wait for. In such cases, a timeout is required to prevent the driver from waiting forever in the case of an error (either no error response is defined in the protocol or something has died and requires a reset). The specific command may be defined as having a time bound response but the CT is a queue and that time guarantee only starts from the point when the command reaches the head of the queue and is processed by GuC.

Ideally there would be a helper to report the progress of a given command through the CT. However, that would require a significant amount of work in the CT layer. In the meantime, provide a reasonable estimation of the worst case latency it should take for the entire queue to drain. And therefore, how long a caller should wait before giving up on their request. The current estimate is based on empirical measurement of a test that fills the buffer with context creation and destruction requests as they seem to be the slowest operation.

+static inline long intel_guc_ct_expected_delay(struct intel_guc_ct *ct)
This is not the 'expected' delay but the worst case maximum delay. Also, no need to force the callers to know about ct structures. They presumably have a intel_guc structure if they are sending H2G messages, and that is all you should need to know about. Having said that, the implementation isn't currently accessing any stored data, so why bother with a parameter at all?

+{
+	return HZ * 2;
Also, this needs to be based on the buffer size so that if the size were to increase then the time would as well.

My thought would be:
long intel_guc_ct_max_queue_time_jiffies(void) {
    /*
     * A 4KB buffer full of context destroy commands takes a little over a second to process
     * so bump that to 2s to be super safe.
     */
    return (CTB_H2G_BUFFER_SIZE * HZ) / SZ_2K;
}
John.


+}
+
 #define INTEL_GUC_CT_SEND_NB		BIT(31)
 #define INTEL_GUC_CT_SEND_G2H_DW_SHIFT	0
 #define INTEL_GUC_CT_SEND_G2H_DW_MASK	(0xff << INTEL_GUC_CT_SEND_G2H_DW_SHIFT)

--------------RHiJ3Wg0VrhQTue2Qv4ZxbTb--