Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp941419iog; Thu, 30 Jun 2022 13:22:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ssQChEZS0Mq2Yb7+9mhw+RhY3MDlHEuVqSlVtdgIZf1xtQF0AnbtLO/a7SSDi5Fk4MuRqT X-Received: by 2002:a05:6402:50f:b0:435:7996:e90f with SMTP id m15-20020a056402050f00b004357996e90fmr13925227edv.110.1656620553075; Thu, 30 Jun 2022 13:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656620553; cv=none; d=google.com; s=arc-20160816; b=DbpX8PlaveQn+uPzwzXrdSVvjtnOIblgrpsjhAlAGPQn+ofwwdrO/9pHQRovboEB+t GxgF023Yp4DOlbl8HKpHymMooSMmYWoCxQg7noclirsd+W8e6wbHjC44pnKLAEVez5dV tyR6AtgMMhxmBQKFG80DoUFjzxFV0ZZ4POohPGXV8aH7a+duxtrp+sZ2BlLst7VcwZxt jzEzJbgrcs1iJWqY9O4UbeIf06xYiK8Ndr4rz+xfVoTAlT24Dx4uVoNbO0DRNvPOQu58 fgdArmnae84k3QCUnZniRpgTP9HMcT3Fas9P+dLMphsMciNKe454MzXohxBGKBMbYyub HgEQ== 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=nCk3GrfP2IkpHHEZfyXs/+JCIYa1Ny6d8+lIuadiEWo=; b=Q15O/M+Gx7sCfGdSrzqkm8dO24j7AK5nhu8JNzdsiAwZNkJM8e8Qp072R7D09VS2p1 11TyPag8lWR6KTPNx4tNns6y+zDqT6vDfgwRxO/DsfhANKb2RHUOaaTKDNdUtzW6arOz Fm3M2pnBsshyTtmzBbTkAJcqY3aRHAidpntkMpnP/N6gnnK6Yx02M3Mc91VykiW1dCPU NWEL6ZMhqVNSng4PiTN1sMs5IyPN5NRhKerMzht+R92++da4CL0PfybsiCtgrHPqNxvy 67a8H+2a/5Hs2EfSRIbO1MrdgNwM45XUwOhGb7G1BaMu1VQVaLeTjyZjVSwxeTcq//L+ kj8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=PcceCuOz; 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 y11-20020a056402270b00b00435c0205537si14667705edd.29.2022.06.30.13.22.04; Thu, 30 Jun 2022 13:22:33 -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=PcceCuOz; 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 S237105AbiF3UIM (ORCPT + 99 others); Thu, 30 Jun 2022 16:08:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237051AbiF3UIB (ORCPT ); Thu, 30 Jun 2022 16:08:01 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF94F4507E for ; Thu, 30 Jun 2022 13:08:00 -0700 (PDT) Received: from dimapc.. (109-252-118-164.nat.spd-mgts.ru [109.252.118.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8C9AD66019E3; Thu, 30 Jun 2022 21:07:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1656619679; bh=mv/tj0+YDxNaJUXU178nX/xm0YQreC8O65A745IOwIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcceCuOztM0G2p5mtXgLSnZuL0vqVoO9HS468cbI/zUsqJsb111UiJyKWU/6n3/dD n8vAPLjlaTGrpGLzefRX3y7UTpx24vQQFcViitSiqx69ckMSh/SQhDjAfNdaNLluyn buMkejUvIqGmzEc0l6ifMyX79sjctMpxWLlzyc5dbz3InTAciS4c/omInZmnJ57C1B XL5Af6dwF5ljhvMv+yKW3tBcumVmuL62RVmmxgWxELgSfLR3VFdLSM3WW8Ve5UDw1S wga3bPeXngP5q4vMNIOTMdPWB9C6yBXdEiY0E5rD9IHVWxiRTScoyKJwvLaPKHT5oc wZRiqGub5SMyw== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Thomas Zimmermann , Emil Velikov , Robin Murphy , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Dmitry Osipenko , kernel@collabora.com Subject: [PATCH v7 6/9] drm/virtio: Simplify error handling of virtio_gpu_object_create() Date: Thu, 30 Jun 2022 23:07:23 +0300 Message-Id: <20220630200726.1884320-7-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630200726.1884320-1-dmitry.osipenko@collabora.com> References: <20220630200726.1884320-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_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 and to prepare for 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 75a159df0af6..62b4d075cfac 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -235,6 +235,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); @@ -247,15 +251,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.36.1