From patchwork Sat Jul 22 09:53:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gmeiner X-Patchwork-Id: 9858039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AFBE600F5 for ; Sat, 22 Jul 2017 09:55:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85B92285ED for ; Sat, 22 Jul 2017 09:55:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A9B5285F5; Sat, 22 Jul 2017 09:55:12 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 3DD7F285ED for ; Sat, 22 Jul 2017 09:55:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4B1DA6E0E2; Sat, 22 Jul 2017 09:55:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC0D26E0A9; Sat, 22 Jul 2017 09:55:07 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id c24so10220052wra.2; Sat, 22 Jul 2017 02:55:07 -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; bh=wKIXB0kPz8FiH9/LoZ0g9lWURPVN5LP8KiYysqPUfmA=; b=pXs9YqA6d46ql4tVFE5b62Xmrrm++EuRY5Ha1nl+g50mMLfzFsB2KL9rqPJv0KyeLV Naf9Jup6hw1cAdBbc/JWu4IZtzUqurxEIwG506SZk5uOsquiqV6F3iPoLSNyUTaww8MC YCsK0qyiEweVUP9xB4STIFoUiIsexsD7cwAmepm4f/RV24dAe7I5CKNqSTaudi3X7Ttu BYAboaiKmPO+LsU2liBY8q0DbJ1xPEctdQ62uJ5BcjBoP9QWMZKJV/0MQ6Dd5mhA1EpQ PcyLFvqdFrdS9L/UrGyLyxOndvbZcD5ILDrxY80JJAUclqDTGIfx/tDUbYshHZiP00ld ttBQ== 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; bh=wKIXB0kPz8FiH9/LoZ0g9lWURPVN5LP8KiYysqPUfmA=; b=e7kTmUcr0vuGGppqSDvSPfJ6+hJkXi6NfcpuymcwXXjkXvLkG8AHtzCYCmNaRGMH8F Hgrofu1ucQO1xEu0GAJv2dpX+Y+GtbUipvm2oBS+bkZbxUu7iHCeMxtr5Xhl0UL2nxtu lIIdKAjwcmVR2uXIS0NrqKLM+o/LVk/L05NKDI580bS0RPvJf/+YGe2olnbfJ7YbdvO7 XxAxq+OeHJU2PrwbLKnZdeXvN5eXrYFzvWS7L18O07EQGrl74nwBrND6m06LxvvbBdKQ aaGKRALwtyNiHtxn+Duv/qBpYWx0SeOMvqiSiYACJjEoOkr9uK5d8kGgSH8+Dh8pAWfc /4hg== X-Gm-Message-State: AIVw111Tq1PEPEoXVsIXXDMIqP+5Xs1wuNVFiAljK/4Z6beckfWQuaaf RhcNMPKMrjIKV7de X-Received: by 10.223.154.3 with SMTP id z3mr8603630wrb.252.1500717306360; Sat, 22 Jul 2017 02:55:06 -0700 (PDT) Received: from cp720.fritz.box (91-114-193-248.adsl.highway.telekom.at. [91.114.193.248]) by smtp.gmail.com with ESMTPSA id z192sm2544673wmz.44.2017.07.22.02.55.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jul 2017 02:55:05 -0700 (PDT) From: Christian Gmeiner To: dri-devel@lists.freedesktop.org Subject: [PATCH V2 02/23] drm/etnaviv: make it possible to allocate multiple events Date: Sat, 22 Jul 2017 11:53:02 +0200 Message-Id: <20170722095323.9964-3-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170722095323.9964-1-christian.gmeiner@gmail.com> References: <20170722095323.9964-1-christian.gmeiner@gmail.com> Cc: linux+etnaviv@armlinux.org.uk, etnaviv@lists.freedesktop.org, cphealy@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This makes it possible to allocate multiple events under the event spinlock. This change is needed to support 'sync'-points. Signed-off-by: Christian Gmeiner --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index fa9c7bd98e9c..ab108b0ed573 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1137,10 +1137,12 @@ int etnaviv_gpu_fence_sync_obj(struct etnaviv_gem_object *etnaviv_obj, * event management: */ -static unsigned int event_alloc(struct etnaviv_gpu *gpu) +static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events, + unsigned int *events) { unsigned long ret, flags; - unsigned int event; + unsigned used, i; + int err = 0; ret = wait_for_completion_timeout(&gpu->event_free, msecs_to_jiffies(10 * 10000)); @@ -1149,16 +1151,24 @@ static unsigned int event_alloc(struct etnaviv_gpu *gpu) spin_lock_irqsave(&gpu->event_spinlock, flags); - /* find first free event */ - event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS); - if (event < ETNA_NR_EVENTS) + /* are there enough free events? */ + used = bitmap_weight(gpu->event_bitmap, ETNA_NR_EVENTS); + if (used + nr_events > ETNA_NR_EVENTS) { + err = -EBUSY; + goto out; + } + + for (i = 0; i < nr_events; i++) { + int event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS); + + events[i] = event; set_bit(event, gpu->event_bitmap); - else - event = ~0U; + } +out: spin_unlock_irqrestore(&gpu->event_spinlock, flags); - return event; + return err; } static void event_free(struct etnaviv_gpu *gpu, unsigned int event) @@ -1327,10 +1337,9 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu, * */ - event = event_alloc(gpu); - if (unlikely(event == ~0U)) { + ret = event_alloc(gpu, 1, &event); + if (!ret) { DRM_ERROR("no free event\n"); - ret = -EBUSY; goto out_pm_put; }