From patchwork Wed Jul 17 13:07:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egbert Eich X-Patchwork-Id: 2828600 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BDB81C0AB2 for ; Wed, 17 Jul 2013 13:21:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 98FAD201CA for ; Wed, 17 Jul 2013 13:21:12 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 724E9201C1 for ; Wed, 17 Jul 2013 13:21:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64092E6F09 for ; Wed, 17 Jul 2013 06:21:11 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 51C114358E for ; Wed, 17 Jul 2013 06:08:01 -0700 (PDT) Received: from debian (p5DCF2FCF.dip0.t-ipconnect.de [93.207.47.207]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0MZOEH-1UjI3H1FwD-00Kura; Wed, 17 Jul 2013 15:07:50 +0200 Received: from sles11.fritz.box (sles11.fritz.box [192.168.178.22]) by debian (Postfix) with ESMTP id 3E9B113C7C; Wed, 17 Jul 2013 15:07:47 +0200 (CEST) From: Egbert Eich To: dri-devel@lists.freedesktop.org Subject: [PATCH 10/16] drm/mgag200: Invalidate page tables when pinning a BO Date: Wed, 17 Jul 2013 15:07:23 +0200 Message-Id: <1374066449-21714-11-git-send-email-eich@suse.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1374066449-21714-1-git-send-email-eich@suse.com> References: <1374066449-21714-1-git-send-email-eich@suse.com> X-Provags-ID: V02:K0:k9os5eiAv1px49FN5CB2qgcRXbA+NxGElmngARtfGy2 erauaCqY7xIbZ5gyXDhZPrkDsRyDOzO/OgkBssypra6lLvZgZZ 87sJjcWj6l5aVqfRvpMfrN7NbtAhQj1/Pb6RG5gloXIJcmYiDZ A4/RKtxxwvkxa9LM7aGjYxwiDkLcpJlMSLWYQDCC/aj26C0jsm UnSVwxbcl9HTMgVoLpabu0u1Z5AS0JPjjBB/orWS/aTAZL+eKi Hg+P2/Babw5XNbkih/k5dhiUGt91DI6rC1v+/sidepnIM/ehy/ Xb2rPVNnXP0d9ll5WI4lvBNGiJsn99ol7lXr9+MUuDvdfI7RbD 2z3P9SNglo5p97ASwryzxTm3CZ6myUkqmF0QEE3h5 Cc: Dave Airlie , Christopher Harvey , Mathieu Larouche , Egbert Eich X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a BO gets pinned the placement may get changed. If the memory is mapped into user space and user space has already accessed the mapped range the page tables are set up but now point to the wrong memory. A call to ttm_bo_unmap_virtual() will invalidate all page tables of all mappings of this BO. When user space accesses this memory again we will receive a page fault and are able to set up the page tables to point to the correct physical memory. Signed-off-by: Egbert Eich --- drivers/gpu/drm/mgag200/mgag200_ttm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c index 3a2e5e2..8ceeb0c 100644 --- a/drivers/gpu/drm/mgag200/mgag200_ttm.c +++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c @@ -321,6 +321,7 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align, mgabo->gem.driver_private = NULL; mgabo->bo.bdev = &mdev->ttm.bdev; + mgabo->bo.bdev->dev_mapping = dev->dev_mapping; mgag200_ttm_placement(mgabo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM); @@ -359,6 +360,7 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr) if (ret) return ret; } + ttm_bo_unmap_virtual(&bo->bo); bo->pin_count++; if (gpu_addr) *gpu_addr = mgag200_bo_gpu_offset(bo);