From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 A76F2C433F5 for ; Wed, 22 Sep 2021 14:31:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D9466120C for ; Wed, 22 Sep 2021 14:31:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236155AbhIVOcp (ORCPT ); Wed, 22 Sep 2021 10:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236194AbhIVOco (ORCPT ); Wed, 22 Sep 2021 10:32:44 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD9E0C061756 for ; Wed, 22 Sep 2021 07:31:14 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id w17so7358784wrv.10 for ; Wed, 22 Sep 2021 07:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=6+ziFqfFy8tUj5gzWw86pYLxOc595Xo/AjkfAmBa908=; b=K67bSyxTp3ZCWesKPb97kyJAm3vnTIN17UBOtqFBWEV5azCeYOHHHhVlux5V0oR2j6 HbAAnVqAcX6k0GQXAe5oPRd8d5+YvMlK0QtRdtTWHmWMvGJj0oZOS6kpO881yrpPs12X Q0zPhcxDkxPlw5lB00MtlRIzjlZBiJOkVpRNuIF2AHXtAODNvmqKq1Frvy4eZ/aczBKh lEH1ETXwtO0jQg8eSmSXI7OBtNMR/NCe7T3e48Jqf8ztmSWvqZVAN1rVR4BYkNQ1bHwg aoPaFCPYECdPKrFGfEd4rH7FNOA33hx051yI8kMWhTT54PKAOr9XADHjgletpWicG3I8 IQlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6+ziFqfFy8tUj5gzWw86pYLxOc595Xo/AjkfAmBa908=; b=VAsmokg1tawOwQnLqCDsaNZvqIoKxALgHZ7Q7gzr99h9VAW3zEWpvsTfRllBFcv04W p9iqKE0MWl1vWQ+N/sjC9GRonsJCJJ1/mCEd2r2jPmzvahqsw7+5QokGL0YuXyhT8lN0 8uuG7wABoCLJk6hMfm86cK+HPb4HCJUhFwnIRpbhzKoHUddfuSc2EkFtMKbA4aefUxfB 9IjoUgHd/b8ALGNFlOihQpbKkc1rFe8ULDtgE+ImOcB1wg+xNt++2YWDJkB0NR3Otafl N9hDZseoBDAFKMm7bir0pKgs+4GgOxEAblYSvpVDmf3TlUEaJ0XfRBIxG9FrZT6MGCeQ GdBQ== X-Gm-Message-State: AOAM531bPjVecQbfJ55czYL+kH06ZcNwdj95D4/8WQNI/9HvbTtAuigx ecSsxcvLJNu6HeOQ+QL37jUac3hcMAg= X-Google-Smtp-Source: ABdhPJx+1fhNG4+4ei6QAwpCbb/RRpqC5TGiPZYBRWYQUFK2+/82eGkOvanY1qn8p5mJxdbPjVmGEg== X-Received: by 2002:adf:d21c:: with SMTP id j28mr1660105wrh.43.1632321073308; Wed, 22 Sep 2021 07:31:13 -0700 (PDT) Received: from [192.168.158.115] (ip-178-202-40-91.hsi09.unitymediagroup.de. [178.202.40.91]) by smtp.gmail.com with ESMTPSA id j21sm2348710wrd.48.2021.09.22.07.31.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Sep 2021 07:31:11 -0700 (PDT) Subject: Re: [PATCH 13/26] drm/i915: use the new iterator in i915_gem_busy_ioctl To: Tvrtko Ursulin , linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch References: <20210922091044.2612-1-christian.koenig@amd.com> <20210922091044.2612-14-christian.koenig@amd.com> <6b22cb75-6c41-db55-83f2-3eae87b585aa@linux.intel.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <2afbdc22-28a7-9a47-186c-f47b4f5aceab@gmail.com> Date: Wed, 22 Sep 2021 16:31:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <6b22cb75-6c41-db55-83f2-3eae87b585aa@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Am 22.09.21 um 12:21 schrieb Tvrtko Ursulin: > > On 22/09/2021 10:10, Christian König wrote: >> This makes the function much simpler since the complex >> retry logic is now handled else where. >> >> Signed-off-by: Christian König >> --- >>   drivers/gpu/drm/i915/gem/i915_gem_busy.c | 35 ++++++++++-------------- >>   1 file changed, 14 insertions(+), 21 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> b/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> index 6234e17259c1..313afb4a11c7 100644 >> --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> @@ -82,8 +82,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void >> *data, >>   { >>       struct drm_i915_gem_busy *args = data; >>       struct drm_i915_gem_object *obj; >> -    struct dma_resv_list *list; >> -    unsigned int seq; >> +    struct dma_resv_iter cursor; >> +    struct dma_fence *fence; >>       int err; >>         err = -ENOENT; >> @@ -109,27 +109,20 @@ i915_gem_busy_ioctl(struct drm_device *dev, >> void *data, >>        * to report the overall busyness. This is what the wait-ioctl >> does. >>        * >>        */ >> -retry: >> -    seq = raw_read_seqcount(&obj->base.resv->seq); >> - >> -    /* Translate the exclusive fence to the READ *and* WRITE engine */ >> -    args->busy = >> busy_check_writer(dma_resv_excl_fence(obj->base.resv)); >> - >> -    /* Translate shared fences to READ set of engines */ >> -    list = dma_resv_shared_list(obj->base.resv); >> -    if (list) { >> -        unsigned int shared_count = list->shared_count, i; >> - >> -        for (i = 0; i < shared_count; ++i) { >> -            struct dma_fence *fence = >> -                rcu_dereference(list->shared[i]); >> - >> +    args->busy = false; > > You can drop this line, especially since it is not a boolean. With that: I just realized that this won't work. We still need to initialize the return value when there is no fence at all in the resv object. > > Reviewed-by: Tvrtko Ursulin Does that still counts if I set args->busy to zero? Thanks, Christian. > > Regards, > > Tvrtko > >> +    dma_resv_iter_begin(&cursor, obj->base.resv, true); >> +    dma_resv_for_each_fence_unlocked(&cursor, fence) { >> +        if (dma_resv_iter_is_restarted(&cursor)) >> +            args->busy = 0; >> + >> +        if (dma_resv_iter_is_exclusive(&cursor)) >> +            /* Translate the exclusive fence to the READ *and* WRITE >> engine */ >> +            args->busy |= busy_check_writer(fence); >> +        else >> +            /* Translate shared fences to READ set of engines */ >>               args->busy |= busy_check_reader(fence); >> -        } >>       } >> - >> -    if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq)) >> -        goto retry; >> +    dma_resv_iter_end(&cursor); >>         err = 0; >>   out: >> From mboxrd@z Thu Jan 1 00:00:00 1970 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.1 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 981B4C433EF for ; Thu, 23 Sep 2021 11:57:52 +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 695B160F56 for ; Thu, 23 Sep 2021 11:57:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 695B160F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF36D6ED18; Thu, 23 Sep 2021 11:57:24 +0000 (UTC) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by gabe.freedesktop.org (Postfix) with ESMTPS id C49216EC07; Wed, 22 Sep 2021 14:31:14 +0000 (UTC) Received: by mail-wr1-x42c.google.com with SMTP id u18so7466934wrg.5; Wed, 22 Sep 2021 07:31:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=6+ziFqfFy8tUj5gzWw86pYLxOc595Xo/AjkfAmBa908=; b=K67bSyxTp3ZCWesKPb97kyJAm3vnTIN17UBOtqFBWEV5azCeYOHHHhVlux5V0oR2j6 HbAAnVqAcX6k0GQXAe5oPRd8d5+YvMlK0QtRdtTWHmWMvGJj0oZOS6kpO881yrpPs12X Q0zPhcxDkxPlw5lB00MtlRIzjlZBiJOkVpRNuIF2AHXtAODNvmqKq1Frvy4eZ/aczBKh lEH1ETXwtO0jQg8eSmSXI7OBtNMR/NCe7T3e48Jqf8ztmSWvqZVAN1rVR4BYkNQ1bHwg aoPaFCPYECdPKrFGfEd4rH7FNOA33hx051yI8kMWhTT54PKAOr9XADHjgletpWicG3I8 IQlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6+ziFqfFy8tUj5gzWw86pYLxOc595Xo/AjkfAmBa908=; b=7rM2IrvTerjVI0xGqyNVfv2fjmORZyyD3c4hYmKvdDk0C5+3SdQL21Dymqu+Y+5Nux JRWCzKq7r969h0MtAx3psmixYE07Uc3zKj6hUkvpGm40WBg6UKbwUUA1u8P+IklGHbO2 ue1i7dBeKbRQJCluc3ukIyA4G7lBNzdjOj8mBYWl6C2H/Zn7akBsrWZJRx8n6l7tp/ww u/Yh9WKKs6wEsGNO9MU/zP9qtbXxHfDeIUc14vg3B3JAx/F3hoDdEMtX7ObfgTjzmP20 aIWNUkHfTJboi49iTaUHycYCfXhaRmP5gl0t/Mketz8IuH3DnmctEZSGToXXm72os0SG fHLQ== X-Gm-Message-State: AOAM5316jbI2S5rackqrCqPaWBoU/5eAdwsT0zdiINTph2KsF1PoO+KW h2r11th3QcBoWMm4od63SUE= X-Google-Smtp-Source: ABdhPJx+1fhNG4+4ei6QAwpCbb/RRpqC5TGiPZYBRWYQUFK2+/82eGkOvanY1qn8p5mJxdbPjVmGEg== X-Received: by 2002:adf:d21c:: with SMTP id j28mr1660105wrh.43.1632321073308; Wed, 22 Sep 2021 07:31:13 -0700 (PDT) Received: from [192.168.158.115] (ip-178-202-40-91.hsi09.unitymediagroup.de. [178.202.40.91]) by smtp.gmail.com with ESMTPSA id j21sm2348710wrd.48.2021.09.22.07.31.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Sep 2021 07:31:11 -0700 (PDT) To: Tvrtko Ursulin , linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, intel-gfx@lists.freedesktop.org Cc: daniel@ffwll.ch References: <20210922091044.2612-1-christian.koenig@amd.com> <20210922091044.2612-14-christian.koenig@amd.com> <6b22cb75-6c41-db55-83f2-3eae87b585aa@linux.intel.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <2afbdc22-28a7-9a47-186c-f47b4f5aceab@gmail.com> Date: Wed, 22 Sep 2021 16:31:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <6b22cb75-6c41-db55-83f2-3eae87b585aa@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Mailman-Approved-At: Thu, 23 Sep 2021 11:57:22 +0000 Subject: Re: [Intel-gfx] [PATCH 13/26] drm/i915: use the new iterator in i915_gem_busy_ioctl X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Am 22.09.21 um 12:21 schrieb Tvrtko Ursulin: > > On 22/09/2021 10:10, Christian König wrote: >> This makes the function much simpler since the complex >> retry logic is now handled else where. >> >> Signed-off-by: Christian König >> --- >>   drivers/gpu/drm/i915/gem/i915_gem_busy.c | 35 ++++++++++-------------- >>   1 file changed, 14 insertions(+), 21 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> b/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> index 6234e17259c1..313afb4a11c7 100644 >> --- a/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> +++ b/drivers/gpu/drm/i915/gem/i915_gem_busy.c >> @@ -82,8 +82,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void >> *data, >>   { >>       struct drm_i915_gem_busy *args = data; >>       struct drm_i915_gem_object *obj; >> -    struct dma_resv_list *list; >> -    unsigned int seq; >> +    struct dma_resv_iter cursor; >> +    struct dma_fence *fence; >>       int err; >>         err = -ENOENT; >> @@ -109,27 +109,20 @@ i915_gem_busy_ioctl(struct drm_device *dev, >> void *data, >>        * to report the overall busyness. This is what the wait-ioctl >> does. >>        * >>        */ >> -retry: >> -    seq = raw_read_seqcount(&obj->base.resv->seq); >> - >> -    /* Translate the exclusive fence to the READ *and* WRITE engine */ >> -    args->busy = >> busy_check_writer(dma_resv_excl_fence(obj->base.resv)); >> - >> -    /* Translate shared fences to READ set of engines */ >> -    list = dma_resv_shared_list(obj->base.resv); >> -    if (list) { >> -        unsigned int shared_count = list->shared_count, i; >> - >> -        for (i = 0; i < shared_count; ++i) { >> -            struct dma_fence *fence = >> -                rcu_dereference(list->shared[i]); >> - >> +    args->busy = false; > > You can drop this line, especially since it is not a boolean. With that: I just realized that this won't work. We still need to initialize the return value when there is no fence at all in the resv object. > > Reviewed-by: Tvrtko Ursulin Does that still counts if I set args->busy to zero? Thanks, Christian. > > Regards, > > Tvrtko > >> +    dma_resv_iter_begin(&cursor, obj->base.resv, true); >> +    dma_resv_for_each_fence_unlocked(&cursor, fence) { >> +        if (dma_resv_iter_is_restarted(&cursor)) >> +            args->busy = 0; >> + >> +        if (dma_resv_iter_is_exclusive(&cursor)) >> +            /* Translate the exclusive fence to the READ *and* WRITE >> engine */ >> +            args->busy |= busy_check_writer(fence); >> +        else >> +            /* Translate shared fences to READ set of engines */ >>               args->busy |= busy_check_reader(fence); >> -        } >>       } >> - >> -    if (args->busy && read_seqcount_retry(&obj->base.resv->seq, seq)) >> -        goto retry; >> +    dma_resv_iter_end(&cursor); >>         err = 0; >>   out: >>