From patchwork Tue Mar 15 17:56:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Nicolai_H=C3=A4hnle?= X-Patchwork-Id: 8591041 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 78DFAC0553 for ; Tue, 15 Mar 2016 17:57:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B03B20304 for ; Tue, 15 Mar 2016 17:57:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D4DF5202F0 for ; Tue, 15 Mar 2016 17:57:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B78F06E7AB; Tue, 15 Mar 2016 17:57:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yw0-x231.google.com (mail-yw0-x231.google.com [IPv6:2607:f8b0:4002:c05::231]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4AC198910C for ; Tue, 15 Mar 2016 17:57:12 +0000 (UTC) Received: by mail-yw0-x231.google.com with SMTP id h129so30875769ywb.1 for ; Tue, 15 Mar 2016 10:57:12 -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:mime-version :content-transfer-encoding; bh=tlmTVFYG1gZYzSmsGT8kmrnSvSs4Y9846Jl1IHdBBK4=; b=tRSTNvQWhoesBqyaEj0zVxke8kazARM82mwcrueGBipvUXeK1ZTcZTPdT6g7uDxzdd FGJXTpZKyi6RY2g8cWdVfPZvuUZJW7pXbezEjef3PGVVhSF0eFDDjRnE0BbRSd/BVD93 WmJLZ1KVv5E7/nV++k6OkC5Q8llObZoFf1YxVxfqqNZfLN6GGRKo+QYUMoJ/XQf3rhcb YaM68rEDT1YD147ub26jFk2wsQOLpHbMN1l6S8Ex9zHMoVKOzZUzj7stbc21kivDasvc 0FLfs2qPJWpTPX6UXFfptAvSRPBGl6gytq9772jNMW2/mvaxXq5Jdc8xhyxVFHU4jnFv wVvw== 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:mime-version :content-transfer-encoding; bh=tlmTVFYG1gZYzSmsGT8kmrnSvSs4Y9846Jl1IHdBBK4=; b=CfCmqOz3cKfBiFja9q01j4M3rVh7VLXP3wCnkIVlzthBluJ3TUc0DABHpAxObdgFjC ubEqwE8N8R9Rshc59HDc3NBXxFZVA8jHuHQbUJKcQRivzxWizGPIv3+3l5tBKxe2sYDo 0QgC1tz/pR0StoQjRLX3pmiwVIpXH8ms+4TvQq74NTbQYZI+Ssn+kk/mC2UJTibZZ5HZ jEz0p6nJhiPY9lXuROvrnioCxuslYkMn2iKKIOctEsPSaE4cttxrzyIWwWjoy2r89NBu KTmEEFUWAITmZpbqTVde5JFORNq5T6rD/qpH2EO0EcBuhPBR1A4NaDk1F79nogKkjWx+ ijrQ== X-Gm-Message-State: AD7BkJJlgyLJ39+iS5unOHlzsZGxAfNmeWH0j+NQ99K8T9ISRdnkQ81rqVjA7sQsrG3ueg== X-Received: by 10.13.239.68 with SMTP id y65mr15450002ywe.230.1458064626142; Tue, 15 Mar 2016 10:57:06 -0700 (PDT) Received: from auriga.local ([190.43.129.182]) by smtp.gmail.com with ESMTPSA id w127sm17852622ywd.13.2016.03.15.10.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 Mar 2016 10:57:05 -0700 (PDT) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/radeon: hold reference to fences in radeon_sa_bo_new (3.17 and older) Date: Tue, 15 Mar 2016 12:56:45 -0500 Message-Id: <1458064605-668-1-git-send-email-nhaehnle@gmail.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 Cc: stable@vger.kernel.org, =?UTF-8?q?Nicolai=20H=C3=A4hnle?= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 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 From: Nicolai Hähnle [Backport of upstream commit f6ff4f67cdf8455d0a4226eeeaf5af17c37d05eb, with an additional NULL pointer guard that is required for kernels 3.17 and older. To be precise, any kernel that does *not* have commit 954605ca3 "drm/radeon: use common fence implementation for fences, v4" requires this additional NULL pointer guard.] An arbitrary amount of time can pass between spin_unlock and radeon_fence_wait_any, so we need to ensure that nobody frees the fences from under us. Based on the analogous fix for amdgpu. Signed-off-by: Nicolai Hähnle Reviewed-by: Christian König (v1 + fix) Tested-by: Lutz Euler Cc: stable@vger.kernel.org --- drivers/gpu/drm/radeon/radeon_sa.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_sa.c b/drivers/gpu/drm/radeon/radeon_sa.c index c507896..7d11901 100644 --- a/drivers/gpu/drm/radeon/radeon_sa.c +++ b/drivers/gpu/drm/radeon/radeon_sa.c @@ -349,8 +349,15 @@ int radeon_sa_bo_new(struct radeon_device *rdev, /* see if we can skip over some allocations */ } while (radeon_sa_bo_next_hole(sa_manager, fences, tries)); + for (i = 0; i < RADEON_NUM_RINGS; ++i) { + if (fences[i]) + radeon_fence_ref(fences[i]); + } + spin_unlock(&sa_manager->wq.lock); r = radeon_fence_wait_any(rdev, fences, false); + for (i = 0; i < RADEON_NUM_RINGS; ++i) + radeon_fence_unref(&fences[i]); spin_lock(&sa_manager->wq.lock); /* if we have nothing to wait for block */ if (r == -ENOENT) {