From patchwork Sun May 29 23:12:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tormod Volden X-Patchwork-Id: 828742 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4TNCkHe021415 for ; Sun, 29 May 2011 23:13:07 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A86F99EFF6 for ; Sun, 29 May 2011 16:12:45 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ww0-f43.google.com (mail-ww0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id D71E59E73F for ; Sun, 29 May 2011 16:12:34 -0700 (PDT) Received: by wwb17 with SMTP id 17so2841043wwb.12 for ; Sun, 29 May 2011 16:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=jbG4zR7+jE4GQ/SuzaAYED9lEEZTZbKyKzdxEjiUtqM=; b=aO3gxawQqND0rOjMlYeMV6k5oOY2ClSrLZKKkj5pniDCSuzPgXOc4stopseifqJol1 qKD9PaCNafsZeT56JyG8ZnXYBbAZszhKVIBN8V8Nm5JN4oC65VImr/ILHSGu86NFUIh6 Ma8cymMxE/CVtbZCt4TpiNQznphBlSS8hF9+o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=utTqhJW213MYAmzTCBSfAspYm3fF1k367hE5GPuxnEL+D3foLihhh1aEw2d4pq9qtP MOYRKFhX1LgRDur6VL4ltM3UAoYgi2tmNLF6xSldPh5Vnr8bzAqvdlpAvX1pgAxYNeqG feuPUMDuAihmAkOCW438mbx1r2J/IW9ONyAo8= Received: by 10.216.135.131 with SMTP id u3mr1824658wei.71.1306710753810; Sun, 29 May 2011 16:12:33 -0700 (PDT) Received: from localhost.localdomain (80-219-113-251.dclient.hispeed.ch [80.219.113.251]) by mx.google.com with ESMTPS id ej7sm2665331wbb.2.2011.05.29.16.12.32 (version=SSLv3 cipher=OTHER); Sun, 29 May 2011 16:12:33 -0700 (PDT) From: Tormod Volden To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Compare only lower 32 bits of framebuffer map offsets Date: Mon, 30 May 2011 01:12:30 +0200 Message-Id: <1306710750-31992-1-git-send-email-lists.tormod@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: Cc: Dave Airlie X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 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-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 29 May 2011 23:13:07 +0000 (UTC) From: Tormod Volden Drivers using multiple framebuffers got broken by commit 41c2e75e60200a860a74b7c84a6375c105e7437f which ignored the framebuffer (or register) map offset when looking for existing maps. The rationale was that the kernel-userspace ABI is fixed at a 32-bit offset, so the real offsets could not always be handed over for comparison. Instead of ignoring the offset we will compare the lower 32 bit. Drivers using multiple framebuffers should just make sure that the lower 32 bit are different. The existing drivers in question are practically limited to 32-bit systems so that should be fine for them. It is assumed that current drivers always specify a correct framebuffer map offset, even if this offset was ignored since above commit. So this patch should not change anything for drivers using only one framebuffer. Drivers needing multiple framebuffers with 64-bit map offsets will need to cook up something, for instance keeping an ID in the lower bits, which is to be aligned away when it comes to using the offset. Signed-off-by: Tormod Volden --- What about this idea? (Untested patch) Regards, Tormod drivers/gpu/drm/drm_bufs.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index 3e257a5..b4224eb 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -46,10 +46,11 @@ static struct drm_map_list *drm_find_matching_map(struct drm_device *dev, list_for_each_entry(entry, &dev->maplist, head) { /* * Because the kernel-userspace ABI is fixed at a 32-bit offset - * while PCI resources may live above that, we ignore the map - * offset for maps of type _DRM_FRAMEBUFFER or _DRM_REGISTERS. - * It is assumed that each driver will have only one resource of - * each type. + * while PCI resources may live above that, we only compare the + * lower 32 bits of the map offset for maps of type + * _DRM_FRAMEBUFFER or _DRM_REGISTERS. + * It is assumed that if a driver have more than one resource + * of each type, the lower 32 bits are different. */ if (!entry->map || map->type != entry->map->type || @@ -61,7 +62,9 @@ static struct drm_map_list *drm_find_matching_map(struct drm_device *dev, break; case _DRM_REGISTERS: case _DRM_FRAME_BUFFER: - return entry; + if ((entry->map->offset & 0xffffffff) == + (map->offset & 0xffffffff)) + return entry; default: /* Make gcc happy */ ; }