Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp209222imw; Fri, 15 Jul 2022 01:19:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ve/Ict38WzUXlysWOQ3BesDCZZK3jGvZD+AYxFOcE2KD2lPGl6uhgLzFNd4LA3htJsanwV X-Received: by 2002:a17:907:28d4:b0:72b:47ca:e37a with SMTP id en20-20020a17090728d400b0072b47cae37amr12552643ejc.378.1657873141557; Fri, 15 Jul 2022 01:19:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1657873141; cv=pass; d=google.com; s=arc-20160816; b=BrO3m85KnMbhFn06wYMSX3U1q4YR8RjhmkutHZj6El+yyQAiXzcucwXK+E3xCssZWT B1pOFwGNErRXrUwIAh/QKssNmIZrwJMgcZotMuMWx89vEEwi+e9lQ0Z+SOpcyr6kBW7o SWYH41/4ByAtt0BHUrW4jWBZ6vIjQq89/J4tQz/bLxP4lg4qHyGtxQr28wB7gg1+r97V 0C/WqKVIHEAnSXhaRJ5P4Abg6f294ZCFlM4LrWMzkusk4cXffAAa34w/bhg4Z+E2gwNl Ooe4BIbBBz+QN3Ysz78gdcbRa0uNzPCFz9gCcKdO8rgjfCX9JVX2wM9hn/sKDUPHyLv3 ZM8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=u7bwDf0qM/tQuy+789QAkidbPdSab2SEqKFy5qDE2ow=; b=IhCTGuByPhdzmbwW/vyc/1Lwwbtdi70ee+ALhAq5/X8B7l/OhLg8qWvlNggcI6uUPu /UtttF1G2NVyghwuYeRYwOPMxCVSxSvfA2hpu0OveaTAJSO414zxRCnGHqvYwYi6t8O2 SqBeOwa79Z3eJRcZPh4kjzBzEstuxOt1Q9C+n4501Jja17B2GLnSQtd9bb2S5is9/9CV CYi7mpkgTLr27Hu6qQExlljWmbWPSbWT9TiexlukKYZpGdfp9UFhYkxZIJ/djfM4mexf pabs8ykZ6WRjVYeDV4sP5LLF8xBiDQ1LJ95zZiyaewn5vnr5Fvv2hbRw6u3RSW2/i2Mo Bwbw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=AzygjbT2; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056402355400b0043a85d7d1basi4296939edd.471.2022.07.15.01.18.22; Fri, 15 Jul 2022 01:19:01 -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=@amd.com header.s=selector1 header.b=AzygjbT2; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231852AbiGOHb1 (ORCPT + 99 others); Fri, 15 Jul 2022 03:31:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiGOHbZ (ORCPT ); Fri, 15 Jul 2022 03:31:25 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2069.outbound.protection.outlook.com [40.107.220.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7517B371; Fri, 15 Jul 2022 00:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lRqZAAfux1nyiMlhkGz1oQeyvfRyYYjd33GPEv9FF+ULuaViZwz30JNm7RWjAP9RlX7TCWvsFiThN2MCAOJY6QnLLEUGWWt77pOfXG8xugPhSlxUpzyIrnbvjcIaLSyK0LVS6Z62rmRJcMN6HMgmYTltwt73NJfHDkmM4tajewuIqDpJCo8kyf+OGT8XXTeInJDdg+OAr9iSfdT4K3ozOWKcZIB8PWuNf4tv6PwNv5GC8bfXED8r4P9TQicw2j1xKj9Kk5uzk4WrpN23V7nXbLzgk6eHOup7Jr7yBYcae7ueslmqLiblmhy6UTimH4kC7789gpU9nqXemjB+Qlaffg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u7bwDf0qM/tQuy+789QAkidbPdSab2SEqKFy5qDE2ow=; b=oOm3FKNsRcTWb+lYjZJqDvOEdz8OCUqlWKvHgYJbjF3yItja9u1XnxDY+PaF8pDT9D+jqPUf6aHQqGsunKQ7jYDvSvjoIjp2htDMzbyMppU86loepYIxXBEox22y3IzXglq4SZ8r9XbqzYXLv7qdeh7WS6up1ZPb92xXVFlq5om1F8WX/xhqjkc3fGV067KAas4HeEqj5DhXylGREr0kBd+j150E+ca0jJYdJqlUTp3KNGqMecYm2dVUCU8UzKcIDsTtfxKVQIKUOr1GMO3lus9/AVRLUMZEe62/vz5/4MasZZMdykSq9gNYtD+9MK4eCY3RhaE+x38JMoBzkNyynA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u7bwDf0qM/tQuy+789QAkidbPdSab2SEqKFy5qDE2ow=; b=AzygjbT2i+TV3XGyRZYsuV1GO/G63GmnWwAibfhtq3f0MLOXA1XRYc+eUyw04L9G37waAxBNMjAQ9t7zZxHF2vPKVfmPfYS/8ymWBREtiYqat/TIBXGQKNDUy74hCQXwvGEXxvhBPR2tPUB9pO8+BJ9aRkowQUHIPcgpPZDH2y0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by DM6PR12MB4338.namprd12.prod.outlook.com (2603:10b6:5:2a2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.14; Fri, 15 Jul 2022 07:31:21 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::905:1701:3b51:7e39]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::905:1701:3b51:7e39%2]) with mapi id 15.20.5438.013; Fri, 15 Jul 2022 07:31:21 +0000 Message-ID: <138407a9-e97f-001e-6e87-e5d92a55c8e8@amd.com> Date: Fri, 15 Jul 2022 09:31:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v1 2/6] drm/gem: Take reservation lock for vmap/vunmap operations Content-Language: en-US To: Dmitry Osipenko , 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 Clark , Sumit Semwal , "Pan, Xinhui" , Thierry Reding , Tomasz Figa , Marek Szyprowski , Mauro Carvalho Chehab , Alex Deucher , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , =?UTF-8?Q?Thomas_Hellstr=c3=b6m?= , Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dmitry Osipenko , linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, kernel@collabora.com, virtualization@lists.linux-foundation.org, spice-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20220715005244.42198-1-dmitry.osipenko@collabora.com> <20220715005244.42198-3-dmitry.osipenko@collabora.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20220715005244.42198-3-dmitry.osipenko@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR3P281CA0096.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a1::8) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4804b5a-7352-469f-3eaa-08da663403b0 X-MS-TrafficTypeDiagnostic: DM6PR12MB4338:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: y9BIhgcKhrwO2Wi+KpxBTiMCjT2gE7YIfKVQu71l+MYSa2zWeH+fEYE+jchr5RyzUK8DdPAH6exQ9SGMh60dOTIuByPUoJW3Hkq5ckMHswmw5QWYJcSXZhbA8BOKnECX+fHvxG9vrPtVRk4d20L4y2m71iDSHdvarvaGxlCZShGF2z/YrXDa1Rt7R+ld0/vRwFt6TFczwZgfHwYsHZRLeSCsBT2zAbGFC5d5RLh/pCQ/BSp4DJ9IbaAK/sG1mc0j7njP+Mg2ubudzGN57JsJ2/cnKgowhbT7VOvj+lG1kAQCbFePIaVFPJIwCSBOJCfiNkMwhEKcFG9vIYI4LqXLRaLzI5CCiDg4nB/ZofO7AlqeucoRu/TKA34JH6Dfc+tj+/MR9yDbI/RqJrFLeOui3Azivm2yPwQ5STE0n0n3wIEhLAjurvL4XT6eJRbaLjWbovPsWux1RAmKGSMNDLn3ws8foThus52yetfrp/rVCyYk20x/5RHAR3Phr5OF1DzGiTyPj6qUJEJTsCP7nxvxUfoar5mLdV6BV516F7MZmrCJ79kOYrDW3wJ2nsaLJHCnglcQnlCGZJUzn5xxZrMnnqxdFNfVF2RqmNZLEUi96PDJcLvndhFPKvriSkyenQpizDImPWgfVGYoQt2rCXT7YxEkuYZOAJoVsWGSfeBAySrbWJcmV88ooq04wC+XIvYkUf1E3Zj+JEW42PwF61jIntAj1/fMOE+t0gKRnd2vigC5AG/M+IW+lHiJM52RiHu+xZvndxieb7gWjs+ZR1G2HuhJnn+zzD7H235PsconYTmbyVrkWUyE3qj0s6tb9PO23TrmOg0wpm2SXOvGskqMZqUXcAnar1Cf3Ib2PmSW7q8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(39860400002)(346002)(366004)(136003)(316002)(41300700001)(83380400001)(6666004)(2906002)(31696002)(86362001)(478600001)(110136005)(2616005)(6506007)(6486002)(186003)(6512007)(36756003)(7416002)(5660300002)(38100700002)(7406005)(66476007)(4326008)(8936002)(8676002)(66556008)(31686004)(66946007)(921005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MU9tVHpqUFZMQ2h6Z2NEQlFC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hNGE4Y01EUkRzWllxWE8zcFU3dTVzUTFOd2kvd2Z6K0JLWlJzQ2xzVkdt?= =?utf-8?B?QjVLK040ZVE4UU5yWFVEVElOOEZTbjhnWHYyV1pTdXRqWUV2WmtPelgzSEQv?= =?utf-8?B?cFl1RTEvdUZORzBudU1vUzN0U09SbVFGdkw4b2xLdHl0UVBjanEzb09LWjVI?= =?utf-8?B?b3d6bFM1NXF3cS9valNpMHlXdVI3VTF5TXQrQVZmQVZ4clJ2L0N5dDJvb09Z?= =?utf-8?B?aW1CQkg1RXYrV09jMHoyK1NJZWdpNzhHekgySlByNjhlREpFM3E5OVNLZ0pE?= =?utf-8?B?c3ZGMEJDbHJ4L2ZOVGZQNnJ0a3c1L3VPS3Bkb3o3bm1jU01ZMEU4V3RqSXR2?= =?utf-8?Q?bZJsAarfJw11WK3HN8PWk+Vs08qIqcpBc49hznLHfovR?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4804b5a-7352-469f-3eaa-08da663403b0 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2022 07:31:21.3654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sIVSt/Kz3qpSEQ1FdbHocGr+ZKk3MC6frNNvwEg1e45w/VcWB6JgRx5nl94FwCDU X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4338 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 Am 15.07.22 um 02:52 schrieb Dmitry Osipenko: > The new common dma-buf locking convention will require buffer importers > to hold the reservation lock around mapping operations. Make DRM GEM core > to take the lock around the vmapping operations and update QXL and i915 > drivers to use the locked functions for the case where DRM core now holds > the lock. This patch prepares DRM core and drivers to transition to the > common dma-buf locking convention where vmapping of exported GEMs will > be done under the held reservation lock. Oh ^^ That looks like a bug fix to me! At least drm_gem_ttm_vmap() and drm_gem_ttm_vunmap() already expected that they are called with the reservation lock held. Otherwise you could mess up internal structures in the TTM buffer object while vmapping it. I will take a deeper look at this. Regards, Christian. > > Signed-off-by: Dmitry Osipenko > --- > drivers/gpu/drm/drm_client.c | 4 +-- > drivers/gpu/drm/drm_gem.c | 28 ++++++++++++++++++++ > drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 ++--- > drivers/gpu/drm/drm_prime.c | 4 +-- > drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 2 +- > drivers/gpu/drm/qxl/qxl_object.c | 17 ++++++------ > drivers/gpu/drm/qxl/qxl_prime.c | 4 +-- > include/drm/drm_gem.h | 3 +++ > 8 files changed, 50 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c > index 2b230b4d6942..fbcb1e995384 100644 > --- a/drivers/gpu/drm/drm_client.c > +++ b/drivers/gpu/drm/drm_client.c > @@ -323,7 +323,7 @@ drm_client_buffer_vmap(struct drm_client_buffer *buffer, > * fd_install step out of the driver backend hooks, to make that > * final step optional for internal users. > */ > - ret = drm_gem_vmap(buffer->gem, map); > + ret = drm_gem_vmap_unlocked(buffer->gem, map); > if (ret) > return ret; > > @@ -345,7 +345,7 @@ void drm_client_buffer_vunmap(struct drm_client_buffer *buffer) > { > struct iosys_map *map = &buffer->map; > > - drm_gem_vunmap(buffer->gem, map); > + drm_gem_vunmap_unlocked(buffer->gem, map); > } > EXPORT_SYMBOL(drm_client_buffer_vunmap); > > diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c > index eb0c2d041f13..9769c33cad99 100644 > --- a/drivers/gpu/drm/drm_gem.c > +++ b/drivers/gpu/drm/drm_gem.c > @@ -1155,6 +1155,8 @@ void drm_gem_print_info(struct drm_printer *p, unsigned int indent, > > int drm_gem_pin(struct drm_gem_object *obj) > { > + dma_resv_assert_held(obj->resv); > + > if (obj->funcs->pin) > return obj->funcs->pin(obj); > else > @@ -1163,6 +1165,8 @@ int drm_gem_pin(struct drm_gem_object *obj) > > void drm_gem_unpin(struct drm_gem_object *obj) > { > + dma_resv_assert_held(obj->resv); > + > if (obj->funcs->unpin) > obj->funcs->unpin(obj); > } > @@ -1171,6 +1175,8 @@ int drm_gem_vmap(struct drm_gem_object *obj, struct iosys_map *map) > { > int ret; > > + dma_resv_assert_held(obj->resv); > + > if (!obj->funcs->vmap) > return -EOPNOTSUPP; > > @@ -1186,6 +1192,8 @@ EXPORT_SYMBOL(drm_gem_vmap); > > void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map) > { > + dma_resv_assert_held(obj->resv); > + > if (iosys_map_is_null(map)) > return; > > @@ -1197,6 +1205,26 @@ void drm_gem_vunmap(struct drm_gem_object *obj, struct iosys_map *map) > } > EXPORT_SYMBOL(drm_gem_vunmap); > > +int drm_gem_vmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map) > +{ > + int ret; > + > + dma_resv_lock(obj->resv, NULL); > + ret = drm_gem_vmap(obj, map); > + dma_resv_unlock(obj->resv); > + > + return ret; > +} > +EXPORT_SYMBOL(drm_gem_vmap_unlocked); > + > +void drm_gem_vunmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map) > +{ > + dma_resv_lock(obj->resv, NULL); > + drm_gem_vunmap(obj, map); > + dma_resv_unlock(obj->resv); > +} > +EXPORT_SYMBOL(drm_gem_vunmap_unlocked); > + > /** > * drm_gem_lock_reservations - Sets up the ww context and acquires > * the lock on an array of GEM objects. > diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c > index 880a4975507f..e35e224e6303 100644 > --- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c > +++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c > @@ -354,7 +354,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct iosys_map *map, > ret = -EINVAL; > goto err_drm_gem_vunmap; > } > - ret = drm_gem_vmap(obj, &map[i]); > + ret = drm_gem_vmap_unlocked(obj, &map[i]); > if (ret) > goto err_drm_gem_vunmap; > } > @@ -376,7 +376,7 @@ int drm_gem_fb_vmap(struct drm_framebuffer *fb, struct iosys_map *map, > obj = drm_gem_fb_get_obj(fb, i); > if (!obj) > continue; > - drm_gem_vunmap(obj, &map[i]); > + drm_gem_vunmap_unlocked(obj, &map[i]); > } > return ret; > } > @@ -403,7 +403,7 @@ void drm_gem_fb_vunmap(struct drm_framebuffer *fb, struct iosys_map *map) > continue; > if (iosys_map_is_null(&map[i])) > continue; > - drm_gem_vunmap(obj, &map[i]); > + drm_gem_vunmap_unlocked(obj, &map[i]); > } > } > EXPORT_SYMBOL(drm_gem_fb_vunmap); > diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c > index b75ef1756873..1bd234fd21a5 100644 > --- a/drivers/gpu/drm/drm_prime.c > +++ b/drivers/gpu/drm/drm_prime.c > @@ -678,7 +678,7 @@ int drm_gem_dmabuf_vmap(struct dma_buf *dma_buf, struct iosys_map *map) > { > struct drm_gem_object *obj = dma_buf->priv; > > - return drm_gem_vmap(obj, map); > + return drm_gem_vmap_unlocked(obj, map); > } > EXPORT_SYMBOL(drm_gem_dmabuf_vmap); > > @@ -694,7 +694,7 @@ void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, struct iosys_map *map) > { > struct drm_gem_object *obj = dma_buf->priv; > > - drm_gem_vunmap(obj, map); > + drm_gem_vunmap_unlocked(obj, map); > } > EXPORT_SYMBOL(drm_gem_dmabuf_vunmap); > > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c > index 5ecea7df98b1..cc54a5b1d6ae 100644 > --- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c > +++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c > @@ -72,7 +72,7 @@ static int i915_gem_dmabuf_vmap(struct dma_buf *dma_buf, > struct drm_i915_gem_object *obj = dma_buf_to_obj(dma_buf); > void *vaddr; > > - vaddr = i915_gem_object_pin_map_unlocked(obj, I915_MAP_WB); > + vaddr = i915_gem_object_pin_map(obj, I915_MAP_WB); > if (IS_ERR(vaddr)) > return PTR_ERR(vaddr); > > diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c > index 695d9308d1f0..06a58dad5f5c 100644 > --- a/drivers/gpu/drm/qxl/qxl_object.c > +++ b/drivers/gpu/drm/qxl/qxl_object.c > @@ -168,9 +168,16 @@ int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map) > bo->map_count++; > goto out; > } > - r = ttm_bo_vmap(&bo->tbo, &bo->map); > + > + r = __qxl_bo_pin(bo); > if (r) > return r; > + > + r = ttm_bo_vmap(&bo->tbo, &bo->map); > + if (r) { > + __qxl_bo_unpin(bo); > + return r; > + } > bo->map_count = 1; > > /* TODO: Remove kptr in favor of map everywhere. */ > @@ -192,12 +199,6 @@ int qxl_bo_vmap(struct qxl_bo *bo, struct iosys_map *map) > if (r) > return r; > > - r = __qxl_bo_pin(bo); > - if (r) { > - qxl_bo_unreserve(bo); > - return r; > - } > - > r = qxl_bo_vmap_locked(bo, map); > qxl_bo_unreserve(bo); > return r; > @@ -247,6 +248,7 @@ void qxl_bo_vunmap_locked(struct qxl_bo *bo) > return; > bo->kptr = NULL; > ttm_bo_vunmap(&bo->tbo, &bo->map); > + __qxl_bo_unpin(bo); > } > > int qxl_bo_vunmap(struct qxl_bo *bo) > @@ -258,7 +260,6 @@ int qxl_bo_vunmap(struct qxl_bo *bo) > return r; > > qxl_bo_vunmap_locked(bo); > - __qxl_bo_unpin(bo); > qxl_bo_unreserve(bo); > return 0; > } > diff --git a/drivers/gpu/drm/qxl/qxl_prime.c b/drivers/gpu/drm/qxl/qxl_prime.c > index 142d01415acb..9169c26357d3 100644 > --- a/drivers/gpu/drm/qxl/qxl_prime.c > +++ b/drivers/gpu/drm/qxl/qxl_prime.c > @@ -59,7 +59,7 @@ int qxl_gem_prime_vmap(struct drm_gem_object *obj, struct iosys_map *map) > struct qxl_bo *bo = gem_to_qxl_bo(obj); > int ret; > > - ret = qxl_bo_vmap(bo, map); > + ret = qxl_bo_vmap_locked(bo, map); > if (ret < 0) > return ret; > > @@ -71,5 +71,5 @@ void qxl_gem_prime_vunmap(struct drm_gem_object *obj, > { > struct qxl_bo *bo = gem_to_qxl_bo(obj); > > - qxl_bo_vunmap(bo); > + qxl_bo_vunmap_locked(bo); > } > diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h > index 87cffc9efa85..bf3700415229 100644 > --- a/include/drm/drm_gem.h > +++ b/include/drm/drm_gem.h > @@ -420,4 +420,7 @@ void drm_gem_unlock_reservations(struct drm_gem_object **objs, int count, > int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev, > u32 handle, u64 *offset); > > +int drm_gem_vmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map); > +void drm_gem_vunmap_unlocked(struct drm_gem_object *obj, struct iosys_map *map); > + > #endif /* __DRM_GEM_H__ */