From patchwork Thu Oct 10 11:29:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 3015431 Return-Path: X-Original-To: patchwork-intel-gfx@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 DD22D9F243 for ; Thu, 10 Oct 2013 11:30:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E02D2030D for ; Thu, 10 Oct 2013 11:30:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id EE04020270 for ; Thu, 10 Oct 2013 11:30:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC650E680A for ; Thu, 10 Oct 2013 04:30:23 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com [74.125.83.51]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FC70E6884 for ; Thu, 10 Oct 2013 04:29:49 -0700 (PDT) Received: by mail-ee0-f51.google.com with SMTP id c1so1074907eek.10 for ; Thu, 10 Oct 2013 04:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=JvUFkd7+4hDSMva1oKv0Xtw3ZiWKYL55vyTBSOnYFes=; b=dlpNj51Vf9QykkDZKusbwzIzh+hWNi3g2Md8kZlWx6y/Gu1iHFnSKRLVioqJB+oeVC +XOzizefpS533iw16xtYhU7VTdkPTw7VM3pypQyu84soLYqW0YXkgeuiIjdEB+oEMeWG ZntJQHHk+jtiJCUcQ4qVG+hGZqMGeO32Ro0Fg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=JvUFkd7+4hDSMva1oKv0Xtw3ZiWKYL55vyTBSOnYFes=; b=hPQZ5D3ieHEwI0xyabauwZpGzP21NvD8tOxAOhxRuFZnvkffT8LyklxW0Ok2PVJ+4Z +k6LhERWYgzcvrbJSc96j7SsqbUYDQ8lLtoU8UMRr+C6BaLIWg/SuSzDJLBny0UcJae6 23xcEDwqKHYMXmLVhg1pmuMQwOxO33ZyMs4FJDytVYHk4mlCKcAinO4HuNSz6zhDY4yZ 2MxEm1X/myer/oiN1fUXygKI0BJ/VeLgV5wgbTq/vu45LfvzTeNPPEIY00bqToCiE8s5 F2zc/DI4XyGHboe+Jh9iNeQIcDLiHrAVwQ1fiG7DiGzlDISmA+vY7ucxxXbyTWOMSnjo 2Xpw== X-Gm-Message-State: ALoCoQkZ+Z8qIqiVlVjvHsoJ1M+6T3kdlJxXl1JAa2PnDN+5QK5geyM06uGz5rD6AYmh9DNr2iKj X-Received: by 10.14.4.1 with SMTP id 1mr20004033eei.21.1381404588447; Thu, 10 Oct 2013 04:29:48 -0700 (PDT) Received: from hummel.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id j7sm100537041eeo.15.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Oct 2013 04:29:47 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Thu, 10 Oct 2013 13:29:37 +0200 Message-Id: <1381404577-29984-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <20131010085652.GI13047@intel.com> References: <20131010085652.GI13047@intel.com> MIME-Version: 1.0 Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH] drm/i915: Use unsigned long for obj->user_pin_count X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 At least on linux sizeof(long) == sizeof(void*) and the thinking is that you can grab about as many references as there's memory. Doesn't really matter, just a bit of OCD since the fixed size data type in a pure in-kernel datastructure look off. v2: Ville asked for an overflow check since no one prevents userspace from incrementing the pin count forever. Cc: Ville Syrjälä Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 7fa017b..f39a6b8 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1567,7 +1567,7 @@ struct drm_i915_gem_object { unsigned long *bit_17; /** User space pin count and filp owning the pin */ - uint32_t user_pin_count; + unsigned long user_pin_count; struct drm_file *pin_filp; /** for phy allocated objects */ diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 71dd030..e8271d3 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -3929,6 +3929,11 @@ i915_gem_pin_ioctl(struct drm_device *dev, void *data, goto out; } + if (obj->user_pin_count == UINT_MAX) { + ret = -EBUSY; + goto out; + } + if (obj->user_pin_count == 0) { ret = i915_gem_obj_ggtt_pin(obj, args->alignment, true, false); if (ret)