From patchwork Tue Sep 12 15:11:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gmeiner X-Patchwork-Id: 9949385 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 565C56024A for ; Tue, 12 Sep 2017 15:12:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47E8F2850D for ; Tue, 12 Sep 2017 15:12:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C62A2859A; Tue, 12 Sep 2017 15:12:33 +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 F072B2850D for ; Tue, 12 Sep 2017 15:12:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 236026E670; Tue, 12 Sep 2017 15:12:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id CF0EC6E670; Tue, 12 Sep 2017 15:12:30 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id n64so6405701wrb.2; Tue, 12 Sep 2017 08:12:30 -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=IfctV4Ied35Rc7buWJn+rBQsqxJOW+1DIlmByJnrXNM=; b=tC+5G/NAjIW2I7XyCxC237pwfuTSrGOsL5jm1Wh52Vhf/3My672UVkrrtINWM0Px3I BZfPVL7g7Gy39SZeGPs2IiAUiYXpB18TC441bqme/XM8qwapGQiKoTNeajviHAME4Mzq njp4TVXqPMFoCBeUhq2ppYbCs9DtRFxR0TQiVq5s1Zy4KiiuR0a/N0mZBI8Xc/JwiWJw QVn9TD3QKlC94TMrdDo6E8aguWWh0EhPbMsfXeG7TIQeM0MrEt4iZQrau5J4Q5KrFVAS gHCkba4s9OKNRuihFPgjL6fyAhuyTY71lsH5MIt6r2MGuFN616k+sTjyVCO0P4uZXhQV xXww== 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=IfctV4Ied35Rc7buWJn+rBQsqxJOW+1DIlmByJnrXNM=; b=fJkGHsmjeny+IaET2Is6ftf+5XyoHu6f675Z5Zi8Wl9XYgboR9rhd1atXfEgfU4q54 6BfEtKraCmXd+UTVB8xVGbT1GGF6NPGzyL2GEmGXaNT2Jv/4NxgrEbdPdAKeryJrqO6K LrgJ9gJurGBQZZ7yJtkPL/yKd4LT7smn9coLy7B0/guk5pHYHK38EAUiz4l6RkdxmBAf cuctjXERcinMUPEIFIJqoSi8OjuffqH0xBOERpmKxM+VxwMQrsw+1usTMISrTFZsHBja 1gfGVzOGwYf5cdhU+S0gh6cY6y+nZQP20MO8vuyqKn/5CA5wvm8BC4siH21S63UuQYAU ZCAg== X-Gm-Message-State: AHPjjUhNQ65nWWTwNQvdwnRp+3aZoJVikNVd6l4LsbLfPca5aNSquGbU aZnGsyeMvTqFkF9Q X-Google-Smtp-Source: ADKCNb510orJ/hKHIlqpHDrPq9BMgqmWCJRtXusb5Gx1lM9gCjB9RcqXWtvsRe5FGB1hwEwBx0ZHGw== X-Received: by 10.223.182.137 with SMTP id j9mr12430102wre.150.1505229149144; Tue, 12 Sep 2017 08:12:29 -0700 (PDT) Received: from localhost.localdomain (91-115-35-97.adsl.highway.telekom.at. [91.115.35.97]) by smtp.gmail.com with ESMTPSA id 110sm6593819wra.39.2017.09.12.08.12.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Sep 2017 08:12:28 -0700 (PDT) From: Christian Gmeiner To: dri-devel@lists.freedesktop.org Subject: [PATCH V4 02/23] drm/etnaviv: make it possible to allocate multiple events Date: Tue, 12 Sep 2017 17:11:34 +0200 Message-Id: <20170912151155.4603-3-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170912151155.4603-1-christian.gmeiner@gmail.com> References: <20170912151155.4603-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. Changes v2 -> v3: - wait for the completion of all events - use 10sec timeout regardless of the number of events - removed validation if there are enough free events - fixed return value evaluation of event_alloc(..) in etnaviv_gpu_submit(..) Signed-off-by: Christian Gmeiner !fixup Signed-off-by: Christian Gmeiner --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 47 +++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index fa9c7bd98e9c..d3b7e665eca9 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1137,28 +1137,44 @@ 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 long flags, timeout = msecs_to_jiffies(10 * 10000); + unsigned i, acquired = 0; - ret = wait_for_completion_timeout(&gpu->event_free, - msecs_to_jiffies(10 * 10000)); - if (!ret) - dev_err(gpu->dev, "wait_for_completion_timeout failed"); + for (i = 0; i < nr_events; i++) { + unsigned long ret; + + ret = wait_for_completion_timeout(&gpu->event_free, timeout); + + if (!ret) { + dev_err(gpu->dev, "wait_for_completion_timeout failed"); + goto out; + } + + acquired++; + timeout = ret; + } 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) + 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; + } spin_unlock_irqrestore(&gpu->event_spinlock, flags); - return event; + return 0; + +out: + for (i = 0; i < acquired; i++) + complete(&gpu->event_free); + + return -EBUSY; } static void event_free(struct etnaviv_gpu *gpu, unsigned int event) @@ -1327,10 +1343,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; }