Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp546172pxb; Tue, 12 Apr 2022 07:54:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqHWsTgE6hjKxr9WWKAMqnMu+YP6JnoqoU1+AjEFzv/Rej6sPtwimu7UIJ1IML0lsEZNdr X-Received: by 2002:a17:906:7314:b0:6df:839f:af7 with SMTP id di20-20020a170906731400b006df839f0af7mr34922569ejc.65.1649775295381; Tue, 12 Apr 2022 07:54:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649775295; cv=none; d=google.com; s=arc-20160816; b=udAAk66qHaWlVXqwEo14U0VaJPG9aNm3m792It3Bmdu0xrDtLUmokuMGxBw630cOzH dp8uEgZ2LHEBrrg9woYO9yqDrNZruDgFbEOJ1gvP2nJd0KH0w7GY0FKQLOmd/8t9F8yJ purIApotSr66OOJdRo/wO1LpTvkpfhkDxyI+XPKuOCNTi7YqTSieZWvq2fAvdSt2sSEB ksfLhHZ1j1g6d7dEVluNKqx/pvNoS7zMMS3lKawJHp0UjWgB7r12Am5ApTtUGQgUJFh6 M9ZokgFy+IE7v33bAeoKCNpskI7fYekLEYZpd6mIykdl/VrF/YY00HbNYpg1w4JAaSz/ FlVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P801MHSMIJ8zMXMY8+mcyG8xeSC+3L6IYt0IuaHhm30=; b=U4aeuLmNaYgZ0QqPVXcJESKy37fn8Hym+l181MII/l+xB6lzaM9OkFk579wIHyeFP5 BmUlSLtk+EaYhOjPYm1B/H6Z3e6RkxvebJP7+w0dhNruevt6rcN+p9K1RJE/ceQ78RoY cSG/s9T2fH3XQPiD/6TxVD/CSNyCzogLszPNlo/PW81C0s9ejDLPHY878rD7kLcPaE7Z qDom9DBKWMknR3pc9OG0A5TFUfqW5cWS7aARjuvncRz4YWhgWCswS4x3UGTfnw1Svany WNQxjuubwzhkc0HSthqSg+N8vnu0ySnjZM9Eb8anQ1kgREUk8hnDtemZnO020z8AuYnJ htnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="ZfozwM/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ey2-20020a1709070b8200b006df76385bc2si5526434ejc.98.2022.04.12.07.54.27; Tue, 12 Apr 2022 07:54:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="ZfozwM/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350321AbiDKWDK (ORCPT + 99 others); Mon, 11 Apr 2022 18:03:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350384AbiDKWCn (ORCPT ); Mon, 11 Apr 2022 18:02:43 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7201CB25 for ; Mon, 11 Apr 2022 15:00:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id D792A1F43C8A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1649714426; bh=isR8z997diym4El61jLlrCRI0NqP4AALskkuO0PNVVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZfozwM/HK56q10iKKu5vijkB8jdQhCiLnu0RjdNLKEEE+vf+aMn0/WSBDd0LJemTJ 4x6e6EDkGtKdqnenPJ/JSIuSy6Bo8zjjz/lHzYYsG+iGiHBGsA3jGfdeps3w3KFyfk giknpGGCGO5K59+dxZKDN0Ec2Dlh7tJtmHdME4XBxil9KL9HPsbBxMO0AGnqp8iL3q qAyo7o4Y++ZrTba4PnDbrJNhB5ecNpFXgvbioGs6irG85Ew34g7xjR0u2KNNfqNhr6 DDpay9Q1nK/mYCPYmTMVuH9g/1aHiCzbCkkra+Yu1WTToPgtLyzS2Qfzav4iuQT+oL Vcn77bJ8Zv/gw== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Gustavo Padovan , Daniel Stone , virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko Subject: [PATCH v3 06/15] drm/virtio: Simplify error handling of virtio_gpu_object_create() Date: Tue, 12 Apr 2022 00:59:28 +0300 Message-Id: <20220411215937.281655-7-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220411215937.281655-1-dmitry.osipenko@collabora.com> References: <20220411215937.281655-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Change the order of SHMEM initialization and reservation locking to make code cleaner a tad and to prepare to transitioning of the common GEM SHMEM code to use the GEM's reservation lock instead of the shmem.page_lock. There is no need to lock reservation during allocation of the SHMEM pages because the lock is needed only to avoid racing with the async host-side allocation. Hence we can safely move the SHMEM initialization out of the reservation lock. Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/virtio/virtgpu_object.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index 21c19cdedce0..18f70ef6b4d0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -236,6 +236,10 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, bo->dumb = params->dumb; + ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); + if (ret != 0) + goto err_put_id; + if (fence) { ret = -ENOMEM; objs = virtio_gpu_array_alloc(1); @@ -248,15 +252,6 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, goto err_put_objs; } - ret = virtio_gpu_object_shmem_init(vgdev, bo, &ents, &nents); - if (ret != 0) { - if (fence) - virtio_gpu_array_unlock_resv(objs); - virtio_gpu_array_put_free(objs); - virtio_gpu_free_object(&shmem_obj->base); - return ret; - } - if (params->blob) { if (params->blob_mem == VIRTGPU_BLOB_MEM_GUEST) bo->guest_blob = true; -- 2.35.1