From patchwork Sun Sep 24 13:15:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Gmeiner X-Patchwork-Id: 9967983 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 AF679602D8 for ; Sun, 24 Sep 2017 13:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A102D28C23 for ; Sun, 24 Sep 2017 13:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95EF228C26; Sun, 24 Sep 2017 13:16:01 +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 4D94128C23 for ; Sun, 24 Sep 2017 13:16:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BA276E147; Sun, 24 Sep 2017 13:16:00 +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 5D1506E13B; Sun, 24 Sep 2017 13:15:57 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id n64so2990800wrb.2; Sun, 24 Sep 2017 06:15:57 -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=oEI92bDxwGd7g1En7kjbnxvQ+TGGonbs7Su2M02UVTA=; b=kqdsws39DAMDHcHGZAZLLP5fzC3U5WlOcTYNGWCPlYkxeACi6cqvv7dH369Xc1oy3R TGJwxM5bLGuPdLTSWd+KpZbOm/ZQQVWsfIxoM1kJPeeO4MzTIPVDkf+6LoFsFMhcWuNS pk0UQDfY2QAFKS/SyJfXccXkRv4x3JuXZnAaazcz7JI7K/uc++3emMoxajMpd5SEqVu9 3xncwB8Uw255XwOkZRd93PediZ852CdMqlfaRnez+MTOi1QQ9fM2eDF8PcXUs4XBsWZb TwBkffc7Zi7/Tb/aMsnUyfg3EQkmDn/3lXt76Zqg/s6T6gr5pw1OCkvxoqzY0cJD5aXN VoSQ== 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=oEI92bDxwGd7g1En7kjbnxvQ+TGGonbs7Su2M02UVTA=; b=e4d3GM5zGpddfXSTshIaIXHy2ReFiVEIZ2V5F8Wl2MYV6skwPwNgkSORQg5l8XAxGc qZI/LsxvBKhld1xyuzRh5N90srkjZd1HxAy8W9WsWQx1TQ5zn3Rm/mAaZXPES+lZW/kV rQXbn2PZquDDnGk92kLnimUyeQv1QwMqJhpJgnBLGZDvpU0ncu4I2dkBeHig9cd5Fham q02X6gtQ+D9DADUnHM7DlTBg5qGTByIwyugRcXgINXwJa/FYAFtgoLpLaCTMV5GbvQ8w TGp3PsfKkJVD3WA+A0xcRiK2I9KJtSNBcj/+wgDHKJI1EQVQol9MuYk8n0+OCrOPd3Vf wlRA== X-Gm-Message-State: AHPjjUgFs5rggWFUKV+byko1entbMLNraqkgFI8ny4RvHrJ3YwjG5JUs QJYdRHRZUPPLe0hJ+6O4uBDqxg== X-Google-Smtp-Source: AOwi7QA1op829wSZPD4XdOscl3zTev55fdbmdKZU9nHUat2Ri5G9z1han96P4bDIUdH59cYEyeVy5Q== X-Received: by 10.223.141.235 with SMTP id o98mr3513654wrb.242.1506258955715; Sun, 24 Sep 2017 06:15:55 -0700 (PDT) Received: from localhost.localdomain (194-166-231-209.adsl.highway.telekom.at. [194.166.231.209]) by smtp.gmail.com with ESMTPSA id z51sm5748304wrz.80.2017.09.24.06.15.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Sep 2017 06:15:54 -0700 (PDT) From: Christian Gmeiner To: dri-devel@lists.freedesktop.org Subject: [PATCH V5 02/25] drm/etnaviv: make it possible to allocate multiple events Date: Sun, 24 Sep 2017 15:15:20 +0200 Message-Id: <20170924131543.4066-3-christian.gmeiner@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170924131543.4066-1-christian.gmeiner@gmail.com> References: <20170924131543.4066-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 --- 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; }