From patchwork Sat Sep 19 19:37:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11787269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 04A886CA for ; Sat, 19 Sep 2020 19:36:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 949E721741 for ; Sat, 19 Sep 2020 19:36:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CvFnInfC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 949E721741 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 155CE6E06B; Sat, 19 Sep 2020 19:36:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id A2B7F6E04B for ; Sat, 19 Sep 2020 19:36:38 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id x123so5672517pfc.7 for ; Sat, 19 Sep 2020 12:36:38 -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=7VsdxD+1OUY1iuOfImGtGZsxp93pIxtgiAELnGBIf8o=; b=CvFnInfCybqLqP+tNr86/LOeDZ/1iIdJWcGulCo/xLwBSujQolgiXW2EBmO/2FJa44 S3tFBmDs4uSgRkDRTT3Knknj/t/JDLT1Wt7bqwCKVBr5KSpWpAf6qV6yZPL05aWUSr43 gc0hH8x8d9qI8v00skwhTHs6B5IjgZ+XAavj1OnrhDMS4IXWNrlyKw3gVv3wGl7mJBU7 u0Rn70DNl3/7jqM041w07g1NIZKyaYQrAZPH0yGqVGVPDlJ3Z3vkeg/Ndc9gDw0yJf8l RkoMibyK7xtSzcVVZbBP0YsbfvHUT5DW27eIwRaUVCUht9GRLJcvmXbnIfSZdrXS9NEt YbfQ== 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=7VsdxD+1OUY1iuOfImGtGZsxp93pIxtgiAELnGBIf8o=; b=ZtWLozfvW72Y/qqPehH9zywY4QOQw/vtgJAXm6HjJufN+uBSBsRkffJz4K012BXDUN +lp8w8Z3I4/JJ0UptDWpMi+tPALaW9CVg7pI1+tRll/PP4CE0NAiJUVHr1zcQEXfM8A9 N+jpI7MmOs3H2NYbOnGj3/X138oNHAnZWrTrLvv2CK8fFuzlhjKByWjBrBChNSmTwmhN j1ynlPN0p01DV0NXcsWEtJ+T3kmPzP0X2KedV6fMWPgdbjRC3f+hhz0lb7GpL3KkN2Ka Pi4CfQzII95x4cIiSQi1T+VFx4JUhY6lYuEVc/b6Hzoh7Oa9Upt5YVXv+VJ3bSJUKly8 7yPQ== X-Gm-Message-State: AOAM530OlQfGiCoUIfer1RHgOsoVTHGWbYij1mvgRSS7y6KxoGHRPfWJ wy1GDd5OXFs7tU2DV9ko3S4nZYlgJqM= X-Google-Smtp-Source: ABdhPJz7NMJRNRuLfpWgnHbyS2MqLZ6mQ9iOw/mKZIE7oo1Gcm9Lw1ACSLLPOoArQXAbYQ7Ovip9xg== X-Received: by 2002:a63:4b1c:: with SMTP id y28mr26589970pga.53.1600544197645; Sat, 19 Sep 2020 12:36:37 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id k27sm6778575pgb.12.2020.09.19.12.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 12:36:36 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm/crtc: Introduce per-crtc kworker Date: Sat, 19 Sep 2020 12:37:24 -0700 Message-Id: <20200919193727.2093945-2-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919193727.2093945-1-robdclark@gmail.com> References: <20200919193727.2093945-1-robdclark@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Peter Zijlstra , linux-arm-msm@vger.kernel.org, open list , timmurray@google.com, David Airlie , Thomas Zimmermann , Tejun Heo Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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..8964a3732bca 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 Sat Sep 19 19:37:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11787273 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 657F3112C for ; Sat, 19 Sep 2020 19:36:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2D5EC2076B for ; Sat, 19 Sep 2020 19:36:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lg7Ubyu9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D5EC2076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DB4A26E492; Sat, 19 Sep 2020 19:36:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57ECE6E04B for ; Sat, 19 Sep 2020 19:36:41 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id t14so5528558pgl.10 for ; Sat, 19 Sep 2020 12:36:41 -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=lg7Ubyu9WAKxfdBXsHIE0fpkFazRYiZBfqd7ekL+E3pANQ48iJwjSskg8Eb9/Ipxum vvea2HDVe246HhZnx09J5sw/zvLq+X/chYapub84dru4tTYVy5R6QlX8GixKSFMagOqr SiDjzfINE3Gr2AYrazENBJHXI+Xn+YIRbwOlharJlTl5xZXu9vm38MHB1s4zUFuB4X4w sskrIy020y6bFI7vAwFVJ1MBDQ8yjM9uudCvs1Vou9g4OTbf5XR0romkoa4Qu00sItUw Bs/0LoQsCfY349hIqWWmcPkKqQYRpNNjg2x6zMmr1m78mxkQkWqa7pQQL9OI+pbzk/bc iXcQ== 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=d4TOEM9d+x52wY2vVaeH5pUFSMEzFTRGvxY3tLZu0Ok/2pBwNsryV4ttwoHb0Nc0F/ rtcQQGPNQYrBxvjDXmSzEWN+O0dghLojzbLjwUcQqqSUOjykg8gpD4SJaQ0Lx4MH6QHb AyGyoiyv61ZPk0US5YssRgrLZfreUxbR+kx2QdOK5qk0DX7I1FQ+/roRN8fpOCEPcxi+ zbAyhw8yOXFePAkP+RE5v4A1DXGytIQM4SCIHt7mwMYebMRcVQl8gRpzTGQWFsfOu5GB rpCN5EtcI8W6svvSLWTVK0Z0zuCWMkV1y60mSEmPLhyBer8QbBW5saEiVIroOBJce7Gc TeUA== X-Gm-Message-State: AOAM533miv3Km9f34Tc/B3qTDHfzU9X2nXkhIyrf+FxkzZ/D3f2k52bD Y5Q7/5nUZa/8apfx4LFCasYj7L2FNE0= X-Google-Smtp-Source: ABdhPJw1pkeptMx0qD+T+XhkQAyHm1sDInLhYFcOAYQh5gmEsV+WcdgYPL5u/76isoo3XZIVFAt6Xg== X-Received: by 2002:a65:6088:: with SMTP id t8mr26953418pgu.404.1600544200308; Sat, 19 Sep 2020 12:36:40 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id q5sm7477198pfn.172.2020.09.19.12.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 12:36:39 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/atomic: Use kthread worker for nonblocking commits Date: Sat, 19 Sep 2020 12:37:25 -0700 Message-Id: <20200919193727.2093945-3-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919193727.2093945-1-robdclark@gmail.com> References: <20200919193727.2093945-1-robdclark@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Peter Zijlstra , linux-arm-msm@vger.kernel.org, open list , timmurray@google.com, David Airlie , Thomas Zimmermann , Tejun Heo Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Sat Sep 19 19:37:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 11787275 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87E2914F6 for ; Sat, 19 Sep 2020 19:36:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 57A212076B for ; Sat, 19 Sep 2020 19:36:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bWddSScf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 57A212076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6DB26E497; Sat, 19 Sep 2020 19:36:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC0306E04B for ; Sat, 19 Sep 2020 19:36:43 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id l126so5681575pfd.5 for ; Sat, 19 Sep 2020 12:36:43 -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=cz3MnrW/mJzyctlymUyWoTIJkRv3ezzf3mEZP0SmMCc=; b=bWddSScf1bWFPRhW6WecOQmNRxQaBf06VKxgQbFRmOH2Gcxc3JH8SijbEnA/bg6AtR yN65G1n4Aa2Kq1xbXOMae8JrslAkaTloea8e1WNE06FnlVCQOny/MfVTJecquEEhUR5l 35xy82QxVRXD8KDrVGX1yu43ioP/U4PnoEQqkHcy5XdAGDJ/vLOf5bssCZsSI33KgWAd Q5orqzjeDiFHHiNbN1cgS5AhUqlfFLc1Bi2OTfwK6HoxKvnudJ6BZcfqCvRA641o/h/E NvSclidqFfGSlHzzTtOK0QnmoDJXR2LOPkti7B6R631rdW1SzJqAz0Hig3A2zWnh3AfX vxbg== 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=cz3MnrW/mJzyctlymUyWoTIJkRv3ezzf3mEZP0SmMCc=; b=FhJYKD9to/QAPBqQl2HbeC17c//NA7o2/CbBMVcwQgxYZXBKjtXDP9T4dX7fUDHI7M LSg2i83R3ZFemMmPq2dGApcG0AVcvAd5wg8Ea7Mb8PdcnfY5mPv7iHqVyTULLtZ76ngY cSnlNC/E8uRILfjVux7zu0poMpNcFKra/vZwHgJVqwPSl4VbylCammEyh+6xTnhXIgzk fSXw221PWfKqCh6ebJ/DjPg2/iOrpoGfn3eG+H14b0Jbf/M2tVIbY/6WTy4a2C3u4exF Xmj7Ti6eN7OZRfbuWOayIXASiGQ/LuMFo7dJyu8XUT8+4r4SFyZl69uACHjGq1lvtrVz eojg== X-Gm-Message-State: AOAM532lYW2iue4Wgz6L9fjLlixIhb6E18VlFTD+HoczJKug5emt84XO BpcuyYB6jquzM1LQGAtoyzQUTnQK2Zc= X-Google-Smtp-Source: ABdhPJw+vtacEen6pTi/AqQnzZ6gWSrh4XqeDmeglhq9agdea9OvtcIoe+1yvJ4aeIw0n1414ksGOg== X-Received: by 2002:a65:4c08:: with SMTP id u8mr32482992pgq.340.1600544202772; Sat, 19 Sep 2020 12:36:42 -0700 (PDT) Received: from localhost ([2601:1c0:5200:a6:307:a401:7b76:c6e5]) by smtp.gmail.com with ESMTPSA id i8sm6312553pjv.43.2020.09.19.12.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Sep 2020 12:36:41 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm: Add a client-cap to set scheduling mode Date: Sat, 19 Sep 2020 12:37:26 -0700 Message-Id: <20200919193727.2093945-4-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200919193727.2093945-1-robdclark@gmail.com> References: <20200919193727.2093945-1-robdclark@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Peter Zijlstra , linux-arm-msm@vger.kernel.org, open list , timmurray@google.com, David Airlie , Thomas Zimmermann , Tejun Heo Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Rob Clark Add DRM_CLIENT_CAP_SCHED_MODE so that userspace can control the scheduling mode for nonblocking atomic commits. Userspace such as android, which treats the display pipeline as realtime (SCHED_FIFO) should set DRM_CLIENT_CAP_SCHED_FIFO to prevent userspace components of the display pipeline (like surfaceflinger) from preempting atomic commit_work. This cap may only be set by the drm master, after setting the DRM_CLIENT_CAP_ATOMIC cap. The scheduling mode is returned to default (SCHED_NORMAL) after master is dropped. Signed-off-by: Rob Clark --- drivers/gpu/drm/drm_auth.c | 4 ++++ drivers/gpu/drm/drm_crtc.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/drm_ioctl.c | 13 +++++++++++++ include/drm/drm_crtc.h | 2 ++ include/uapi/drm/drm.h | 13 +++++++++++++ 5 files changed, 58 insertions(+) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index f2d46b7ac6f9..217f422389f9 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -335,6 +336,9 @@ void drm_master_release(struct drm_file *file_priv) drm_lease_revoke(master); } + if (drm_core_check_feature(dev, DRIVER_ATOMIC) && file_priv->is_master) + drm_crtc_set_sched_mode(dev, DRM_CLIENT_CAP_SCHED_NORMAL); + /* drop the master reference held by the file priv */ if (file_priv->master) drm_master_put(&file_priv->master); diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 4f7c0bfce0a3..02f2be0b1700 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -93,6 +93,32 @@ struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx) } EXPORT_SYMBOL(drm_crtc_from_index); +/** + * drm_crtc_set_sched_mode: + * @dev: DRM device + * @mode: one of DRM_CLIENT_CAP_SCHED_x + * + * Set the scheduling mode for per-CRTC kthread workers. This controls + * whether nonblocking atomic commits will run with SCHED_NORMAL or + * SCHED_FIFO (rt) priority. + */ +void drm_crtc_set_sched_mode(struct drm_device *dev, int mode) +{ + struct drm_crtc *crtc; + + drm_for_each_crtc(crtc, dev) { + switch (mode) { + case DRM_CLIENT_CAP_SCHED_NORMAL: + /* zero is default nice value for kthreads: */ + sched_set_normal(crtc->worker->task, 0); + break; + case DRM_CLIENT_CAP_SCHED_FIFO: + sched_set_fifo(crtc->worker->task); + break; + } + } +} + int drm_crtc_force_disable(struct drm_crtc *crtc) { struct drm_mode_set set = { diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 789ee65ac1f5..44920621571c 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -362,6 +362,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) return -EINVAL; file_priv->writeback_connectors = req->value; break; + case DRM_CLIENT_CAP_SCHED_MODE: + if (!file_priv->is_master) + return -EPERM; + if (!file_priv->atomic) + return -EOPNOTSUPP; + switch (req->value) { + case DRM_CLIENT_CAP_SCHED_NORMAL: + case DRM_CLIENT_CAP_SCHED_FIFO: + drm_crtc_set_sched_mode(dev, req->value); + return 0; + default: + return -EINVAL; + } default: return -EINVAL; } diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 8964a3732bca..6dd4d01b7191 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -1245,6 +1245,8 @@ static inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc) int drm_mode_set_config_internal(struct drm_mode_set *set); struct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); +void drm_crtc_set_sched_mode(struct drm_device *dev, int mode); + /** * drm_crtc_find - look up a CRTC object from its ID * @dev: DRM device diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 808b48a93330..989e007ef608 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -698,6 +698,19 @@ struct drm_get_cap { */ #define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5 +/** + * DRM_CLIENT_CAP_SCHED_MODE + * + * Allow userspace to control the scheduling parameters for nonblocking + * commit. The default is SCHED_NORMAL/CFS. Userspace using SCHED_FIFO + * in the rendering/display pipeline should use DRM_CLIENT_CAP_SCHED_FIFO + * to prevent userspace portions of the display pipeline from preempting + * nonblocking commit_work. + */ +#define DRM_CLIENT_CAP_SCHED_MODE 6 +# define DRM_CLIENT_CAP_SCHED_NORMAL 0 +# define DRM_CLIENT_CAP_SCHED_FIFO 1 + /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap { __u64 capability;