From patchwork Wed Apr 17 18:33:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bas Nieuwenhuizen X-Patchwork-Id: 10905835 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3C51C1515 for ; Wed, 17 Apr 2019 18:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2845C28A95 for ; Wed, 17 Apr 2019 18:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C24028B7D; Wed, 17 Apr 2019 18:35:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7226928B7B for ; Wed, 17 Apr 2019 18:35:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65CBE6E099; Wed, 17 Apr 2019 18:35:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9ED056E099 for ; Wed, 17 Apr 2019 18:35:55 +0000 (UTC) Received: by mail-ed1-x52f.google.com with SMTP id d13so21855641edr.5 for ; Wed, 17 Apr 2019 11:35:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vvIrJbghDmaz1x6wO2HBRSFqLQac7wWV+kPkczTfMLU=; b=IOnF7F0o4n2po1QbxISfZwyyXW10lJwf5fHVUQWdVVsP6IzP4iiYUtWFJwZVh4BI46 LEskp43ys2VzG1hNTyEiMdEVAznyhMslb96mM+8mvJd0PWf/W+Dh1W77lO5RAjg6xerG nmITXHgKlDwVkSeyiuO/Amwq1CXQ6QLFHvSFUeZOn4ho2aZBmwYnmfCLWnZaaLkX63+R lBlqBBMjXVuNY642fRDIDwMz6h5E7vwKzHPC/Wivj7Y+90HrmGYWpeG4J8OIyH01lyAr bC2K2CnUAKBGrjf58IR8XaqCDOYFtvZSYnmwWmJhF6q3c/bgCWLOCVlKPwUZ9f/KsVqX ENpQ== X-Gm-Message-State: APjAAAUwpyG+ca+I85cGmF/WC5Sl9dt1l/95eEj6lDa0dqTDWbJBvOta Gv2HrR4sFFexGE7zbPfQ2m4U2vpOmW4Vmw== X-Google-Smtp-Source: APXvYqyLwoBoCdVmtCkIO4mOMSI/CGKh12aSIt8jSAQSnETTBThoPL9ZaV3ih8WiKaQCWFagI7crbw== X-Received: by 2002:a50:f5c8:: with SMTP id x8mr29772848edm.144.1555526154021; Wed, 17 Apr 2019 11:35:54 -0700 (PDT) Received: from localhost.localdomain ([2a02:aa12:a77f:2000:7285:c2ff:fe4e:b21b]) by smtp.gmail.com with ESMTPSA id l3sm3777644edl.63.2019.04.17.11.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 11:35:53 -0700 (PDT) From: Bas Nieuwenhuizen To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm] amdgpu: Add context priority override function. Date: Wed, 17 Apr 2019 20:33:38 +0200 Message-Id: <20190417183338.23437-1-bas@basnieuwenhuizen.nl> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basnieuwenhuizen-nl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vvIrJbghDmaz1x6wO2HBRSFqLQac7wWV+kPkczTfMLU=; b=bteMCFGj8gQUt5nD7eDyCHJqoQQm1w3qlQOBZ4LmeKIgTieM99yMiMR4Cn1S5CclsM Si0bqDuE+b33LTn8lMV8zswsiJAqthcfOenkSQ+TFANt1wALy6kKzb8hYTAVAw0IqKbP BFJRhomgt0czJ4bqqBL9lfQwg2AiEIIbzV0HtKPoxDax1mTs4SZSmvBQbAv0p791duGC SaxKTeDRofeKvRjJ5I4OtWKOJ9V0jBZKVcHrzABLdNtaYE+8m8MpHwgY0DdBWA3skGnC oR1Fl53eBArWrGnswjpvsC2MqcWozZWL9S11fE8n+wsZESIASiB/OQxITGmF/mw8pWm1 RF4w== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This way we can override the priority of a single context using a master fd. Since we cannot usefully create an amdgpu device of a master fd without the fd deduplication kicking in this takes a plain fd. This can be used by e.g. radv to get high priority contexts using a master fd from the primary node or a lease. Reviewed-by: Samuel Pitoiset Reviewed-by: Andres Rodriguez Reviewed-by: Chunming Zhou --- amdgpu/amdgpu-symbol-check | 1 + amdgpu/amdgpu.h | 15 +++++++++++++++ amdgpu/amdgpu_cs.c | 25 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/amdgpu/amdgpu-symbol-check b/amdgpu/amdgpu-symbol-check index 96a44b40..4d806922 100755 --- a/amdgpu/amdgpu-symbol-check +++ b/amdgpu/amdgpu-symbol-check @@ -38,6 +38,7 @@ amdgpu_cs_create_syncobj2 amdgpu_cs_ctx_create amdgpu_cs_ctx_create2 amdgpu_cs_ctx_free +amdgpu_cs_ctx_override_priority amdgpu_cs_destroy_semaphore amdgpu_cs_destroy_syncobj amdgpu_cs_export_syncobj diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h index d6de3b8d..3d838e08 100644 --- a/amdgpu/amdgpu.h +++ b/amdgpu/amdgpu.h @@ -911,6 +911,21 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev, */ int amdgpu_cs_ctx_free(amdgpu_context_handle context); +/** + * Override the submission priority for the given context using a master fd. + * + * \param dev - \c [in] device handle + * \param context - \c [in] context handle for context id + * \param master_fd - \c [in] The master fd to authorize the override. + * \param priority - \c [in] The priority to assign to the context. + * + * \return 0 on success or a a negative Posix error code on failure. + */ +int amdgpu_cs_ctx_override_priority(amdgpu_device_handle dev, + amdgpu_context_handle context, + int master_fd, + unsigned priority); + /** * Query reset state for the specific GPU Context * diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 5bedf748..7ee844fb 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -142,6 +142,31 @@ drm_public int amdgpu_cs_ctx_free(amdgpu_context_handle context) return r; } +drm_public int amdgpu_cs_ctx_override_priority(amdgpu_device_handle dev, + amdgpu_context_handle context, + int master_fd, + unsigned priority) +{ + int r; + + if (!dev || !context || master_fd < 0) + return -EINVAL; + + union drm_amdgpu_sched args; + memset(&args, 0, sizeof(args)); + + args.in.op = AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE; + args.in.fd = dev->fd; + args.in.priority = priority; + args.in.ctx_id = context->id; + + r = drmCommandWrite(master_fd, DRM_AMDGPU_SCHED, &args, sizeof(args)); + if (r) + return r; + + return 0; +} + drm_public int amdgpu_cs_query_reset_state(amdgpu_context_handle context, uint32_t *state, uint32_t *hangs) {