From patchwork Mon Oct 21 22:33:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3080331 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2697F9F2B8 for ; Mon, 21 Oct 2013 23:28:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58BCA20373 for ; Mon, 21 Oct 2013 23:28:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 891432035D for ; Mon, 21 Oct 2013 23:28:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 794D9E6052 for ; Mon, 21 Oct 2013 16:28:27 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f179.google.com (mail-ea0-f179.google.com [209.85.215.179]) by gabe.freedesktop.org (Postfix) with ESMTP id C461DE6D12 for ; Mon, 21 Oct 2013 15:34:00 -0700 (PDT) Received: by mail-ea0-f179.google.com with SMTP id b10so3800081eae.38 for ; Mon, 21 Oct 2013 15:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EIyu2dROnJp0EzYPmXWNDuH416wMotGm9oKEsSfYIws=; b=A3bqqEjZfPzorIL/JEaoZy93D/m/TZoxni0SqwOj1K2xTOblXJ21csbFp8ZTp0vMNY skipEHkvTWZ6da171m3G0oD/HfoGaPKrEaS8JigcgKf+dTtx+y4g39tWFjheojL6+yUV W+eAVpMAQqBJ2zc+uDxC++J3/0MlH2oZ7GaKSGWTZL1Nbqk0PgvkeVLDeQ1lSPY3Ir72 sSUqKkohM9+X1jAOxwcF3fc0DpMz0rlRW8DKbbnmVRLfFussQ833tuaUIFFKfBdrRkHG sUmsMkmUNXKeL6ebNCdB1ax/rzd+mUPAlh2L+rEBGvBYLbTeLgSYzv49h3uxOyYN2phP x76w== X-Received: by 10.15.24.68 with SMTP id i44mr1123073eeu.87.1382394840172; Mon, 21 Oct 2013 15:34:00 -0700 (PDT) Received: from localhost.localdomain (stgt-5f718b64.pool.mediaWays.net. [95.113.139.100]) by mx.google.com with ESMTPSA id e13sm48972229eeu.4.2013.10.21.15.33.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Oct 2013 15:33:59 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [RFC v2 6/6] drm: zap mmaps for dead devices Date: Tue, 22 Oct 2013 00:33:28 +0200 Message-Id: <1382394808-20611-7-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.4.1 In-Reply-To: <1382394808-20611-1-git-send-email-dh.herrmann@gmail.com> References: <1382394808-20611-1-git-send-email-dh.herrmann@gmail.com> Cc: linux-kernel@vger.kernel.org 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.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Once a DRM device is unregistered, user-space must not access any existing mmaps, anymore. As we cannot rely on this, we now zap all of them in drm_dev_unregister(). Any driver which wants to support that needs to protect their fault() and mmap() handlers via drm_dev_get_active(), otherwise users can create new mmaps after/during drm_dev_unregister(). Signed-off-by: David Herrmann --- drivers/gpu/drm/drm_stub.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index e363b72..274a005 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -602,6 +602,10 @@ void drm_dev_unregister(struct drm_device *dev) drm_dev_shutdown(dev); + /* zap all memory mappings (drm_global_mutex must not be locked) */ + if (dev->dev_mapping) + unmap_mapping_range(dev->dev_mapping, 0, LLONG_MAX, 1); + /* We cannot hold drm_global_mutex during drm_dev_shutdown() as it might * dead-lock. Hence, there's a small race between drm_dev_shutdown() and * us locking drm_global_mutex which drm_release() might trigger. To fix