From patchwork Thu Jun 30 20:00:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12902136 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 D9DFEC43334 for ; Thu, 30 Jun 2022 20:01:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89A6412B03E; Thu, 30 Jun 2022 20:01:36 +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 4118812B038 for ; Thu, 30 Jun 2022 20:01:29 +0000 (UTC) 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 77BE46601970; Thu, 30 Jun 2022 21:01:27 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1656619288; bh=agNXiubhmlWUmhyiQk+T0pYhjXgAeStRlj8Az7MpTQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JuBi+bZrxnpFbtWnBwe1kxV/vDW7SljTqNoClO+PIyMibkOeIUNxMRB2m132KNaBP n3Knbr6COwq8PyG2Yq6gaN/76DBNUtQ2JdsUpYWoyjdZn9iemz1nzStqcMJGhigPfn SlEgCTCVJY4LqqHeDqnzaB1GbRKxej8WPMVpAGP8lU3ef2dqEBDln6kI/ehK/A3vip eroO3ZsJzzAVufygpD2ACtvqfkp5gMl8eqjShmBt/zrn64nirKyY8Oh3pSt8qNKKEW inHPvUNQvDUNc6WAFrr/l7G7B79aVQFud2oC+5ZV2llDA9ZDEPhFplptyeqb5gkkzs IZN42CPRz5gOQ== From: Dmitry Osipenko To: David Airlie , Daniel Vetter , Maxime Ripard , Thomas Zimmermann Subject: [PATCH v7 1/2] drm/shmem-helper: Add missing vunmap on error Date: Thu, 30 Jun 2022 23:00:57 +0300 Message-Id: <20220630200058.1883506-2-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630200058.1883506-1-dmitry.osipenko@collabora.com> References: <20220630200058.1883506-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: Dmitry Osipenko , kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The vmapping of dma-buf may succeed, but DRM SHMEM rejects the IOMEM mapping, and thus, drm_gem_shmem_vmap_locked() should unvmap the IOMEM before erroring out. Cc: stable@vger.kernel.org Fixes: 49a3f51dfeee ("drm/gem: Use struct dma_buf_map in GEM vmap ops and convert GEM backends") Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 8ad0e02991ca..904fc893c905 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -302,6 +302,7 @@ static int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem, ret = dma_buf_vmap(obj->import_attach->dmabuf, map); if (!ret) { if (WARN_ON(map->is_iomem)) { + dma_buf_vunmap(obj->import_attach->dmabuf, map); ret = -EIO; goto err_put_pages; } From patchwork Thu Jun 30 20:00:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12902135 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 1293CC433EF for ; Thu, 30 Jun 2022 20:01:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4365C12B041; Thu, 30 Jun 2022 20:01:36 +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 EFBEE12B038 for ; Thu, 30 Jun 2022 20:01:29 +0000 (UTC) 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 3FCAA6601990; Thu, 30 Jun 2022 21:01:28 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1656619288; bh=HwmkBPNhPApyOEwuuFz69Z60ML1iqlmrU4nLETa7AOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hkeXakVDFUb7ix7WQZ8g5bOdSo9OagrsMg5puZVG27sC7D8gyFCtnSxjsR61Lvi/N REowR9ewtzUA6i06pWvsvk8MYifoAr1OEoQE23HQ04k1CwCJZXWDmKDA1D6uWcP8IV /mEESj1wkhSq9v9pAr0fqv829Uwf+77enZUCW9EY8s6xNNx8VpcN0ycffMQVst/6gx RkP0NW+II1y8sXQeJteacBDAJdHFJKfT7yEotJkedU0zT12BtNkkaImmRtyk11Xlpm nSY1gO4sZg2i+KnDL5X0zKnjZrbOuQEdmRQvCFle/uDKHDBLZaOcCX26ZCDE3mzoQo nA0xGyIZ/pqYQ== From: Dmitry Osipenko To: David Airlie , Daniel Vetter , Maxime Ripard , Thomas Zimmermann Subject: [PATCH v7 2/2] drm/shmem-helper: Correct doc-comment of drm_gem_shmem_get_sg_table() Date: Thu, 30 Jun 2022 23:00:58 +0300 Message-Id: <20220630200058.1883506-3-dmitry.osipenko@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630200058.1883506-1-dmitry.osipenko@collabora.com> References: <20220630200058.1883506-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: Dmitry Osipenko , kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_gem_shmem_get_sg_table() never returns NULL on error, but a ERR_PTR. Correct the doc comment which says that it returns NULL on error. Acked-by: Thomas Zimmermann Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_gem_shmem_helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c index 904fc893c905..0b526657fbea 100644 --- a/drivers/gpu/drm/drm_gem_shmem_helper.c +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c @@ -663,7 +663,8 @@ EXPORT_SYMBOL(drm_gem_shmem_print_info); * drm_gem_shmem_get_pages_sgt() instead. * * Returns: - * A pointer to the scatter/gather table of pinned pages or NULL on failure. + * A pointer to the scatter/gather table of pinned pages or an ERR_PTR()-encoded + * error code on failure. */ struct sg_table *drm_gem_shmem_get_sg_table(struct drm_gem_shmem_object *shmem) { @@ -689,7 +690,8 @@ EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table); * drm_gem_shmem_get_sg_table() should not be directly called by drivers. * * Returns: - * A pointer to the scatter/gather table of pinned pages or errno on failure. + * A pointer to the scatter/gather table of pinned pages or an ERR_PTR()-encoded + * error code on failure. */ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_shmem_object *shmem) {