From patchwork Tue Apr 18 13:46:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9685525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A76F602C2 for ; Tue, 18 Apr 2017 13:46:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C1CA2838E for ; Tue, 18 Apr 2017 13:46:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40180283A6; Tue, 18 Apr 2017 13:46:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CA8FB2838E for ; Tue, 18 Apr 2017 13:46:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC7438929C; Tue, 18 Apr 2017 13:46:19 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-oi0-x241.google.com (mail-oi0-x241.google.com [IPv6:2607:f8b0:4003:c06::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A7888929C for ; Tue, 18 Apr 2017 13:46:19 +0000 (UTC) Received: by mail-oi0-x241.google.com with SMTP id a189so10090774oib.0 for ; Tue, 18 Apr 2017 06:46:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=MPYso0BUg3HVsa1EdKvXmwxnHjiSO7HvzO0mOjo12+M=; b=sMvFjWprN+J+5jsV7Y9NE3ZJuU3Fgm09n8vUvmIdsG4X54t4ACO3JK1km5r2clsFlI C8LQwaZcUKHT8V0Q2IYluVe/FwcWtUCqTvQc/a4bvF1muTduuDcXLxOZR5I6/sc7Fs7j B2akLXxntbm8+gD4P4krTEE/f4DzGUl/9bpSJAe6M6Y5aabOGQsQiLY0UMGB8e6NQX5D 88yhzlna9boBmrlM42V//Z/6WYQDltmkuzDUD3Ah2QQoE9PV5S12ZeFseExp9C9whdb0 IltxDypYpJcJNnlH7cu2wNK4e5y9NFGBIituf4d2RZAp2PECiRIiTiXVF6rSwjdGWd/4 womA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=MPYso0BUg3HVsa1EdKvXmwxnHjiSO7HvzO0mOjo12+M=; b=bdmdT17Z5gO1Z0Up6V5ycdB7aGMTSlCFNSQTJwXanYe/b+oVepsUd2E34hMgdvS1bS rlKKaZZh7Gq2aMqNaUPKj1ghFIACa1tUrr51W53fAYk6wwcIeMGFFuW/jM56nRx++koy a2EO3ZV5hYgGyRqDzzL7FQBL9qjyg6J/uYAD0RztGtmB4tF4Ra+Pd+xGVKsMtECg1azc 3GfvRcvUhkln2Yys2Cbnnehzq/wp5xiyrpIluBzJ74GYDKjvLj5hvQT3eGfEgpG/a7OQ MHnf8qZC3TCJ0LI6VbMomZHptoil47lwyJmITL63LKeRgkFLHKNtebmxmxzUxB2CBh18 Dj4Q== X-Gm-Message-State: AN3rC/6ltX/u91dghAdUptRPrfzQojKlz3cb259wpj3k6WoGYq6UuBpo RxCER751skVHkq12/QLtIgciLwt7Fg== X-Received: by 10.202.75.83 with SMTP id y80mr7123121oia.113.1492523178532; Tue, 18 Apr 2017 06:46:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.20.240 with HTTP; Tue, 18 Apr 2017 06:46:18 -0700 (PDT) In-Reply-To: <20170418131240.23613-1-chris@chris-wilson.co.uk> References: <20170418131240.23613-1-chris@chris-wilson.co.uk> From: Arnd Bergmann Date: Tue, 18 Apr 2017 15:46:18 +0200 X-Google-Sender-Auth: eool0V9rbIih7aa7iSrOWsQ0PPs Message-ID: To: Chris Wilson Cc: intel-gfx@lists.freedesktop.org, Matthew Auld Subject: Re: [Intel-gfx] [PATCH] drm/i915/selftests: Allocate inode/file dynamically X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Apr 18, 2017 at 3:12 PM, Chris Wilson wrote: > Avoid having too large a stack by creating the fake struct inode/file on > the heap instead. > > drivers/gpu/drm/i915/selftests/mock_drm.c: In function 'mock_file': > drivers/gpu/drm/i915/selftests/mock_drm.c:46:1: error: the frame size of 1328 bytes is larger than 1280 bytes [-Werror=frame-larger-than=] > drivers/gpu/drm/i915/selftests/mock_drm.c: In function 'mock_file_free': > drivers/gpu/drm/i915/selftests/mock_drm.c:54:1: error: the frame size of 1312 bytes is larger than 1280 bytes [-Werror=frame-larger-than=] > > Reported-by: Arnd Bergmann > Fixes: 66d9cb5d805a ("drm/i915: Mock the GEM device for self-testing") > Signed-off-by: Chris Wilson > Cc: Joonas Lahtinen > Cc: Tvrtko Ursulin > Cc: Matthew Auld > Cc: Arnd Bergmann This is clearly an improvement over the current state and it gets rid of the warning, so I'm fine with this getting merged. Acked-by: Arnd Bergmann A nicer solution might be a wrapper around drm_open_helper() that does not require a file pointer like this (completely untested, probably wrong) patch would: @@ -268,7 +281,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) } #endif - return 0; + return priv; out_close: if (dev->driver->postclose) @@ -280,8 +293,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) drm_gem_release(dev, priv); put_pid(priv->pid); kfree(priv); - filp->private_data = NULL; - return ret; + return ERR_PTR(ret); } static void drm_events_release(struct drm_file *file_priv) If anyone cares more about that than I do, this could be a follow-up patch. Arnd diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index 3783b659cd38..4956c3945e7e 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -189,25 +189,38 @@ static int drm_cpu_valid(void) */ static int drm_open_helper(struct file *filp, struct drm_minor *minor) { - struct drm_device *dev = minor->dev; struct drm_file *priv; int ret; if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ + + priv = drm_open_dev(minor); + ret = PTR_ERR_OR_ZERO(priv); + if (ret) + return ret; + + filp->private_data = priv; + priv->filp = filp; +} + +struct drm_file *drm_open_dev(struct drm_minor *minor) +{ + struct drm_device *dev = minor->dev; + struct drm_file *priv; + int ret; + if (!drm_cpu_valid()) - return -EINVAL; + return ERR_PTR(-EINVAL); if (dev->switch_power_state != DRM_SWITCH_POWER_ON && dev->switch_power_state != DRM_SWITCH_POWER_DYNAMIC_OFF) - return -EINVAL; + return ERR_PTR(-EINVAL); DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor->index); priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) - return -ENOMEM; + return ERR_PTR(-ENOMEM); - filp->private_data = priv; - priv->filp = filp; priv->pid = get_pid(task_pid(current)); priv->minor = minor;