From patchwork Wed Sep 30 21:17:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 249834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC2C1C4741F for ; Wed, 30 Sep 2020 21:16:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8244420789 for ; Wed, 30 Sep 2020 21:16:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DSvNOsY8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730660AbgI3VQO (ORCPT ); Wed, 30 Sep 2020 17:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbgI3VQN (ORCPT ); Wed, 30 Sep 2020 17:16:13 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CD58C061755; Wed, 30 Sep 2020 14:16:13 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 7so1935132pgm.11; Wed, 30 Sep 2020 14:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sZW+8qKOp3m43EfWZLNpJYe1y36F8PokgEJuoCHampY=; b=DSvNOsY80NqlhtrpB6F4YIGtNeFRvcqI6Qi9dvCdoIgoXmCRKCfOk5Z+jEO4dNARk4 EU1x5GkkcDXojG2N/B2HvMfc9/jT0ajyGH+xbjaCX9z4ad6qmeMjfZelwlEQkSzztvW0 3x3/tWU03NS9gCfXzkAdrl12JATRE+QoU8UHqf2uJ0GLEYpC0Yj6oQIAIRTN3bifMTNA jbys/un2T6JWNzKetHOLZCcgITrgjeJzqxed/KOusEJc/BdPYM4NEykXI8MrBDaY9oBZ QqBeJrDbu7mYwMl4/JOnX2EbysOQJd114vKdiweNyRb2wfbpmUT2FWcdjeS5uWrdr2fH 0Aaw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=sZW+8qKOp3m43EfWZLNpJYe1y36F8PokgEJuoCHampY=; b=N2Zto2PBSoVdQgwXPz7rtHh66ox0bPUFgeUamc32goZN4AjqbG59N+GUoqEB9oqbgN 0DU6bU2qxP9AiLpK5YMGBYNsk80Cz19rpvHl4VftIeIZL1HDiTku4lG032HQVI5+sitH +KWM+ZgP+8BdnUz2Fc63Ve3+lHZrA4wRtMHPwxlW9S/gX33THBqWOEmssdLOMkANXnoq FgFiVztULXlisqJfq2jgVSuMo4i4KZeEz8DRuIzb7qF2ltvC7Zbecr2AQh+8tFX8LqRh WHgIib7RDfdTMnk3ET+ZIJH0K7NS/8ux5518InjQLZ2AgZW2YA9V30G1NcY5Zf/wIDHf 7YZg== X-Gm-Message-State: AOAM533cf76Vep4khQSz4LZBHdLqgQTMUiCDF33AitmjkZFqkHfUl9yZ NHogiMV0exrfv0AB0ok6CXs= X-Google-Smtp-Source: ABdhPJxsFSNjgHpDzNtq4wVwgWANkelu4M73iefGHxOFIlorIu5tIYxVaPZjytP/ZipCAPyGNUuPpw== X-Received: by 2002:aa7:8bd4:0:b029:13c:1611:6538 with SMTP id s20-20020aa78bd40000b029013c16116538mr1354483pfd.10.1601500573113; Wed, 30 Sep 2020 14:16:13 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id u6sm3134612pjy.37.2020.09.30.14.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 14:16:12 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, Tejun Heo , timmurray@google.com, Daniel Vetter , Qais Yousef , Rob Clark , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/3] drm/crtc: Introduce per-crtc kworker Date: Wed, 30 Sep 2020 14:17:20 -0700 Message-Id: <20200930211723.3028059-2-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930211723.3028059-1-robdclark@gmail.com> References: <20200930211723.3028059-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark This will be used for non-block atomic commits. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_crtc.c | 11 +++++++++++ include/drm/drm_crtc.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index aecdd7ea26dc..4f7c0bfce0a3 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -326,6 +326,14 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, config->prop_out_fence_ptr, 0); drm_object_attach_property(&crtc->base, config->prop_vrr_enabled, 0); + + crtc->worker = kthread_create_worker(0, "%s-worker", crtc->name); + if (IS_ERR(crtc->worker)) { + drm_mode_object_unregister(dev, &crtc->base); + ret = PTR_ERR(crtc->worker); + crtc->worker = NULL; + return ret; + } } return 0; @@ -366,6 +374,9 @@ void drm_crtc_cleanup(struct drm_crtc *crtc) kfree(crtc->name); + if (crtc->worker) + kthread_destroy_worker(crtc->worker); + memset(crtc, 0, sizeof(*crtc)); } EXPORT_SYMBOL(drm_crtc_cleanup); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 59b51a09cae6..dfdb04619b0d 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -1172,6 +1173,13 @@ struct drm_crtc { * Initialized via drm_self_refresh_helper_init(). */ struct drm_self_refresh_data *self_refresh_data; + + /** + * @worker: + * + * Per-CRTC worker for nonblock atomic commits. + */ + struct kthread_worker *worker; }; /** From patchwork Wed Sep 30 21:17:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 292553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B7CFC4363D for ; Wed, 30 Sep 2020 21:16:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 39CF12075F for ; Wed, 30 Sep 2020 21:16:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cCQpDwdZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730221AbgI3VQW (ORCPT ); Wed, 30 Sep 2020 17:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbgI3VQQ (ORCPT ); Wed, 30 Sep 2020 17:16:16 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4013DC061755; Wed, 30 Sep 2020 14:16:16 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id k8so2187132pfk.2; Wed, 30 Sep 2020 14:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZcEhH3LkJwJxm1/YqfDogAmQdhcYfaMPXbiNt/rTvIg=; b=cCQpDwdZb0pK722MSI5vjiBihKBpkBYoKbO9i9WYCp65PrcPU0SZJt/3DyayvVaYsJ zfjL3bYcgY48wx/138a6xBdmhUSBFkbtA6YRCIBL3/i7plw3nGxmSZNirfsfyUJ3NUgD clTIPjDvPeI94WZhyTANXSWFUU6DE+KLXk3hsbrUA1JrRivzv0fKsgNI5CIO0FiTHAfo VTuS0Vi34MlydR5o31Zl4B2Ou46i9225PQtDhUR1R8wFC87kWMN/q5lhOotBIiz+lMdk 24Dwt7vy63yhY5gOgFA8f2qCqGlelgmvkBvbyHj8os4I14vWsBjzdFkJFxH+P1orQ/Wz 089g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZcEhH3LkJwJxm1/YqfDogAmQdhcYfaMPXbiNt/rTvIg=; b=WNqyfS/rgLPD5o3I6ptDsIatMPSACeZYTRYeolyvjFPAk8J09tgKmw2YdTjOzSI299 6uOu+hW9xIraCmIc4h5xBrAED7whl5ofHd8BkQ8Z2WX+tyh+6J9haAONJvUcr1eq4bHk CaK39FCFDF5agqsHE03wu8NEZV1rSYVyApst1Aj33dHeEK1aWbB2BhvXdJV0AtArmAtE 2DSYeqKKYH2n5GpJZa2kM14VU8VAl8NGlqKceURHl6J7lU2DdwF2/+mg2uNvMNxkYQpN OhmZVYBxkLd+HiaDZCvS3y85yI6PITvWgGRcnRkCdg2+VhMazIw4yZNtry3UQgEl4I9c sHrQ== X-Gm-Message-State: AOAM533/QgtaVXh4umxLEtiUK2vUyhY1hEryERB05+QN16/oqmqQQUje SzY3Ph1bsBEiFPYBIwVvvY0= X-Google-Smtp-Source: ABdhPJxD11GEuDlHb0wKRQjVyEr8sh2uooNCpmemjI0OxxWDrhF/698+aqsFJ+xX8mM5791oIxfpYw== X-Received: by 2002:aa7:939b:0:b029:142:2501:35f1 with SMTP id t27-20020aa7939b0000b0290142250135f1mr4294458pfe.81.1601500575753; Wed, 30 Sep 2020 14:16:15 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id a2sm3467427pfk.201.2020.09.30.14.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 14:16:14 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, Tejun Heo , timmurray@google.com, Daniel Vetter , Qais Yousef , Rob Clark , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 2/3] drm/atomic: Use kthread worker for nonblocking commits Date: Wed, 30 Sep 2020 14:17:21 -0700 Message-Id: <20200930211723.3028059-3-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930211723.3028059-1-robdclark@gmail.com> References: <20200930211723.3028059-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark This will allow us to more easily switch scheduling rules based on what userspace wants. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_atomic_helper.c | 13 ++++++++---- include/drm/drm_atomic.h | 31 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 9e1ad493e689..75eeec5e7b10 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1659,11 +1659,11 @@ static void commit_tail(struct drm_atomic_state *old_state) drm_atomic_state_put(old_state); } -static void commit_work(struct work_struct *work) +static void commit_work(struct kthread_work *work) { struct drm_atomic_state *state = container_of(work, struct drm_atomic_state, - commit_work); + commit_kwork); commit_tail(state); } @@ -1797,6 +1797,7 @@ int drm_atomic_helper_commit(struct drm_device *dev, struct drm_atomic_state *state, bool nonblock) { + struct kthread_worker *worker = NULL; int ret; if (state->async_update) { @@ -1814,7 +1815,7 @@ int drm_atomic_helper_commit(struct drm_device *dev, if (ret) return ret; - INIT_WORK(&state->commit_work, commit_work); + kthread_init_work(&state->commit_kwork, commit_work); ret = drm_atomic_helper_prepare_planes(dev, state); if (ret) @@ -1857,8 +1858,12 @@ int drm_atomic_helper_commit(struct drm_device *dev, */ drm_atomic_state_get(state); + if (nonblock) - queue_work(system_unbound_wq, &state->commit_work); + worker = drm_atomic_pick_worker(state); + + if (worker) + kthread_queue_work(worker, &state->commit_kwork); else commit_tail(state); diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index d07c851d255b..8d0ee19953df 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h @@ -373,8 +373,18 @@ struct drm_atomic_state { * * Work item which can be used by the driver or helpers to execute the * commit without blocking. + * + * This is deprecated, use commit_kwork. */ struct work_struct commit_work; + + /** + * @commit_kwork: + * + * Work item which can be used by the driver or helpers to execute the + * commit without blocking. + */ + struct kthread_work commit_kwork; }; void __drm_crtc_commit_free(struct kref *kref); @@ -954,6 +964,27 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (new_obj_state) = (__state)->private_objs[__i].new_state, 1); \ (__i)++) +/** + * drm_atomic_pick_worker - helper to get kworker to use for nonblocking commit + * @state: the &drm_atomic_state for the commit + * + * Pick an appropriate worker for a given atomic update. The first CRTC + * invovled in the atomic update is used to pick the worker, to prevent + * serializing multiple pageflips / atomic-updates on indenpendent CRTCs. + */ +static inline struct kthread_worker * +drm_atomic_pick_worker(const struct drm_atomic_state *state) +{ + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + unsigned i; + + for_each_new_crtc_in_state(state, crtc, crtc_state, i) + return crtc->worker; + + return NULL; +} + /** * drm_atomic_crtc_needs_modeset - compute combined modeset need * @state: &drm_crtc_state for the CRTC From patchwork Wed Sep 30 21:17:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 249833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFCEFC4727C for ; Wed, 30 Sep 2020 21:16:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A502420759 for ; Wed, 30 Sep 2020 21:16:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qA0BKeGO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730723AbgI3VQX (ORCPT ); Wed, 30 Sep 2020 17:16:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730695AbgI3VQS (ORCPT ); Wed, 30 Sep 2020 17:16:18 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADA58C0613D0; Wed, 30 Sep 2020 14:16:18 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id t14so1939786pgl.10; Wed, 30 Sep 2020 14:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2U/fjg//jswj3Yudi2Db1uBr5ff+2io2dnuoLW/qR0A=; b=qA0BKeGOCvBF9bL80rgHz360wFyWQUEkiHm4zDy+G1Vi2O18MzTYl4/04CVlt8FHMb 7mOK9eG8CD5gzFIeVmFNyVVZGTZpx0EIsMHkCHoJNO782DwRYy1Vm12N7Dy47k9CTnHM pTCaeZhi4OF0dOqujGlBpf+cf4xCQnevxhOztZC2hXzlVLX1cN+ZQqdMXFtXlsVKmD2O 1IiwohPL5VpKhw6nGriSvKODwJ+g7dCmaHjOWXhCiTx+7w9CWmLoRVk7mHXL4bnQ2LtC QM3oKuE3lfL84CDD+Mv+vWcDMce0nLwUsNUQBEC7aE3rVBZhNf0HcmavkdkvKzipiAQY LX4w== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=2U/fjg//jswj3Yudi2Db1uBr5ff+2io2dnuoLW/qR0A=; b=epKIQ5VOoIDV9XaFfGYvWym/e2XXcIVmJLDxnP9FXRdtPQhXFdg68+J3mmlcvD7Js5 bbDaGJcLbZ5t6IwcPryH3yXOWVqiZi3BJXXo3aF0f1mJzaFQkOCkWUZ0NbpWbq6EGkKu DBbAKZACwrrhGB2SYm81G+nNrvBuXd8qOIfat9potk4nvxWVqmPV5Nbp/J0huByMhipb jK2gWzdiEA5Ufsiukx2tBkJLoyvyjQVia38i4PCH/eweu0u7MfDZnZrth2ynKWA16OEv 4YHnN2eRLqyP7A6z2dEeCiY2i+CVU2iAlvSkaCcFrrMrivGnYwaWf8LvHUEN2QTGrtXs aOzg== X-Gm-Message-State: AOAM530Ewam7T08BRGDMSLS4/Qq6tnXTE0sLN45khZ38WM5brF4AQkdB WSC+ALesFmYXUkfvH0Uw1RU= X-Google-Smtp-Source: ABdhPJwTRuxYSLgbeUmLAYi4ke/Rev9ysHOLICTOKEacpnjGaRU4LkJop3kZqCMXI2Gd88aZDrdvSw== X-Received: by 2002:a17:902:d888:b029:d0:cb2d:f274 with SMTP id b8-20020a170902d888b02900d0cb2df274mr3965422plz.13.1601500578174; Wed, 30 Sep 2020 14:16:18 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id n2sm3609064pfe.208.2020.09.30.14.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 14:16:17 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, Tejun Heo , timmurray@google.com, Daniel Vetter , Qais Yousef , Rob Clark , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 3/3] drm: Expose CRTC's kworker task id Date: Wed, 30 Sep 2020 14:17:22 -0700 Message-Id: <20200930211723.3028059-4-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200930211723.3028059-1-robdclark@gmail.com> References: <20200930211723.3028059-1-robdclark@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark This will allow userspace to control the scheduling policy and priority. In particular if the userspace half of the display pipeline is SCHED_FIFO then it will want to use the same scheduling policy and an appropriate priority to ensure that it is not preempting commit_work. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_crtc.c | 3 +++ drivers/gpu/drm/drm_mode_config.c | 14 ++++++++++++++ drivers/gpu/drm/drm_mode_object.c | 4 ++++ include/drm/drm_mode_config.h | 9 +++++++++ include/drm/drm_property.h | 9 +++++++++ 5 files changed, 39 insertions(+) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 4f7c0bfce0a3..1828853542dc 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -334,6 +334,9 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, crtc->worker = NULL; return ret; } + + drm_object_attach_property(&crtc->base, + config->kwork_tid_property, 0); } return 0; diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index f1affc1bb679..b11a1fc8ed0d 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -215,6 +215,13 @@ static const struct drm_prop_enum_list drm_plane_type_enum_list[] = { { DRM_PLANE_TYPE_CURSOR, "Cursor" }, }; +static int get_kwork_tid(struct drm_mode_object *obj, uint64_t *val) +{ + struct drm_crtc *crtc = obj_to_crtc(obj); + *val = task_pid_vnr(crtc->worker->task); + return 0; +} + static int drm_mode_create_standard_properties(struct drm_device *dev) { struct drm_property *prop; @@ -371,6 +378,13 @@ static int drm_mode_create_standard_properties(struct drm_device *dev) return -ENOMEM; dev->mode_config.modifiers_property = prop; + prop = drm_property_create_range(dev, DRM_MODE_PROP_ATOMIC, + "KWORK_TID", 0, UINT_MAX); + if (!prop) + return -ENOMEM; + prop->get_value = get_kwork_tid; + dev->mode_config.kwork_tid_property = prop; + return 0; } diff --git a/drivers/gpu/drm/drm_mode_object.c b/drivers/gpu/drm/drm_mode_object.c index db05f386a709..1a4df65baf0f 100644 --- a/drivers/gpu/drm/drm_mode_object.c +++ b/drivers/gpu/drm/drm_mode_object.c @@ -285,6 +285,7 @@ int drm_object_property_set_value(struct drm_mode_object *obj, WARN_ON(drm_drv_uses_atomic_modeset(property->dev) && !(property->flags & DRM_MODE_PROP_IMMUTABLE)); + WARN_ON(property->get_value); for (i = 0; i < obj->properties->count; i++) { if (obj->properties->properties[i] == property) { @@ -303,6 +304,9 @@ static int __drm_object_property_get_value(struct drm_mode_object *obj, { int i; + if (property->get_value) + return property->get_value(obj, val); + /* read-only properties bypass atomic mechanism and still store * their value in obj->properties->values[].. mostly to avoid * having to deal w/ EDID and similar props in atomic paths: diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index c2d3d71d133c..7244df926a6d 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -926,6 +926,15 @@ struct drm_mode_config { */ struct drm_property *modifiers_property; + /** + * @kwork_tid_property: CRTC property to expose the task-id of the per- + * CRTC kthread-worker, used for non-block atomic commit. This is exposed + * to userspace, to allow userspace to control the scheduling policy and + * priority, as this is a decision that depends on how userspace structures + * it's rendering pipeline. + */ + struct drm_property *kwork_tid_property; + /* cursor size */ uint32_t cursor_width, cursor_height; diff --git a/include/drm/drm_property.h b/include/drm/drm_property.h index 4a0a80d658c7..6843be6aa3ec 100644 --- a/include/drm/drm_property.h +++ b/include/drm/drm_property.h @@ -188,6 +188,15 @@ struct drm_property { * enum and bitmask values. */ struct list_head enum_list; + + /** + * @get_value: accessor to get current value for "virtual" properties + * + * For properties with dynamic values, where it is for whatever reason + * not feasible to keep updated with drm_object_property_set_value(), + * this callback can be used to retrieve the current value on demand. + */ + int (*get_value)(struct drm_mode_object *obj, uint64_t *val); }; /**