Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2696942pxb; Sun, 24 Apr 2022 23:44:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHp0gc2uSsl9BcfOnIM4cdjTx8XTxO+PuZQAcDpgItCyMgZmRy1ZgTvpzQMYQt1fwPCzg2 X-Received: by 2002:a17:902:f688:b0:15d:22e2:5834 with SMTP id l8-20020a170902f68800b0015d22e25834mr505448plg.166.1650869049988; Sun, 24 Apr 2022 23:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650869049; cv=none; d=google.com; s=arc-20160816; b=VhKcO0GuoEuR/88vMhsDSk0f3EHGIF/9wY80xNvs25wfgMMCOp7hyz5raIbqOv5cYg ZsTPcV1no4t8yWtBQ3a3tH28XhFMkVg6hdPgCRZcTeGSZP1D+MuZjpirAU2wITx7Io6a +BwMPb+dPrChWa21jSs+u/N5Etm5pu1tof8BRTyR1dGuyFlXsUt5bOgqUkp4NcXEukk/ tbngHeTkaQidkQnJMoU1laO1AMCKIr6HyOzHzhQz//d4uZUuE/FSyfo+MxN2OeUvG32k yHJxv2VXj5LQJHc6o+ITi6DYFuxxfvRCIdLeN9WhLJ3JI3CbnHRvfy8OHEnBdWp1RbBr M5/Q== 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=H5WHMgrrTR/dNKpLl5cIbbEUi9MLiNqQnlNTOPwIXpLutBLu/EVqsd0t0s0D+0J9w7 x+Mg4umddvtJ3dKD+lkUxZ0bs+ICWoQGrVy1ATLpH1Q6BFUkiJwiD3rfzLk+uNa+mvcg e0pysvau/ikfnsmTR87Kg7LoZUTiQXSPL/VXOx+QMR3hBmnMAp6XEopjsaqH4bhXg22Q NpBJUGIKeYYTAc2hTQDgSxrHSbF/QRw42gfaNl987KEQiwSluxhwjXgM9W3hf56Xuur4 uS0hTzvWPQyGYXSQwVj6SIdn7VwBHiiiKmdQf0OJPTi+L4est6CLHa3Y2CW9eQ/OJbJU iRAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=L+QwIJb6; 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 t5-20020a632245000000b0039d82c5e0b8si15809759pgm.340.2022.04.24.23.43.56; Sun, 24 Apr 2022 23:44:09 -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=L+QwIJb6; 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 S238066AbiDXTIT (ORCPT + 99 others); Sun, 24 Apr 2022 15:08:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237762AbiDXTHu (ORCPT ); Sun, 24 Apr 2022 15:07:50 -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 436FE13976C for ; Sun, 24 Apr 2022 12:04:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dmitry.osipenko) with ESMTPSA id 3167A1F44DAC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1650827088; bh=isR8z997diym4El61jLlrCRI0NqP4AALskkuO0PNVVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L+QwIJb6w2n/XAAyRKeNsAXld9L8radrHbzJxg1vTHMCpHDTWtMtFNHWoQ5xQb+JK IY2YE7R2q1qJyQIrIRCtwgIhvWntrMkf7xi2Nc63J2+qVGR6KVJuFM/6+QA7L9l/Gf +iDMcLWpxouqnCj0xrC3bUaqL8EQqG7mIb73TgGWTf/Ubxp5F1ZRLBBQh4Wj9UtIhN sfh3bdXZYKe1Ogc0aL1ZeIPqh9m+uVGQB4SSa6vPdMMi2ZCa7OsbUT0uyvEgYk+Ga3 p7xkY9kUeMtGXyS257JuFEZ5HPkxnXuKLX9NK0oE7Hyj70ikqdjo1lQLQrLfzEtCks Ll3rN7RdLF9UQ== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Daniel Almeida , Gert Wollny , Gustavo Padovan , Daniel Stone , Tomeu Vizoso , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Steven Price , Alyssa Rosenzweig , Rob Clark , Emil Velikov , Robin Murphy , Qiang Yu , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , Dmitry Osipenko Subject: [PATCH v5 07/17] drm/virtio: Simplify error handling of virtio_gpu_object_create() Date: Sun, 24 Apr 2022 22:04:14 +0300 Message-Id: <20220424190424.540501-8-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220424190424.540501-1-dmitry.osipenko@collabora.com> References: <20220424190424.540501-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, UNPARSEABLE_RELAY,URIBL_BLOCKED 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