From patchwork Thu Sep 14 23:27:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 13386213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D8B32EEAA7C for ; Thu, 14 Sep 2023 23:29:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E87D110E5AF; Thu, 14 Sep 2023 23:29:20 +0000 (UTC) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by gabe.freedesktop.org (Postfix) with ESMTPS id DF58C10E5A9 for ; Thu, 14 Sep 2023 23:29:14 +0000 (UTC) Received: from workpc.. (109-252-153-31.dynamic.spd-mgts.ru [109.252.153.31]) (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 88FB26607355; Fri, 15 Sep 2023 00:29:12 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1694734153; bh=NYBZUXkwlnba9uS/DTRAc0OWLbbAgnC6TGMpLFWWzHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FESwGYWauB9XDkampwVrtcAARQwz/q5ArfDM/gjc0/eFIbRZwrm4BYzrX3SgAI+HI atAeblijs3Ca98BkeNuNUOffwt/bEamEQe1/wIexmpdLLnAT0caUrQTLsvqqaY5ToO 1wqoAuTIaJNGvI6aaizAgZlQ/ySdvIyAVAeXQHIQyBDZuuneLDG5Cfliy5HfuNHoyp ii2C3suH9aYRQzcaovq2tM30/et7ypoUW/mlATxK+K246U1ORytwv7fXr4dX9c0kKW JXHKK1tl5pceKSI7Gq5D4Uq57b5qkak0+uTuTYqBDHm1qUpf9poFbvjOj3CxvzoPej XYjNeuM7cIWNg== From: Dmitry Osipenko To: David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , =?utf-8?q?Christian_K=C3=B6nig?= , Qiang Yu , Steven Price , Boris Brezillon , Emma Anholt , Melissa Wen Subject: [PATCH v17 11/18] drm/shmem-helper: Improve drm_gem_shmem_vmap_locked() error handling Date: Fri, 15 Sep 2023 02:27:14 +0300 Message-ID: <20230914232721.408581-12-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230914232721.408581-1-dmitry.osipenko@collabora.com> References: <20230914232721.408581-1-dmitry.osipenko@collabora.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Remove error unwinding from drm_gem_shmem_vmap_locked() making error paths consistent for both dmabuf and non-dmabuf cases and improving readability of the code. Often it's preferred to do the explicit error unwinding, but this multi-path function is an exception. Suggested-by: Boris Brezillon Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index e1fcb5154209..8a8eab4d0332 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -334,7 +334,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, struct iosys_map *map) { struct drm_gem_object *obj = &shmem->base; - int ret = 0; + int ret; if (obj->import_attach) { ret = dma_buf_vmap(obj->import_attach->dmabuf, map); @@ -357,6 +357,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT, VM_MAP, prot); if (!shmem->vaddr) { + drm_gem_shmem_unpin_locked(shmem); ret = -ENOMEM; } else { iosys_map_set_vaddr(map, shmem->vaddr); @@ -364,16 +365,8 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, } } - if (ret) { + if (ret) drm_dbg_kms(obj->dev, "Failed to vmap pages, error %d\n", ret); - goto err_put_pages; - } - - return 0; - -err_put_pages: - if (!obj->import_attach) - drm_gem_shmem_unpin_locked(shmem); return ret; }