From patchwork Fri Dec 8 18:30:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10104621 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 3ECCD60235 for ; Mon, 11 Dec 2017 10:22:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2814A29534 for ; Mon, 11 Dec 2017 10:22:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CFA329537; Mon, 11 Dec 2017 10:22:13 +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 D79D729534 for ; Mon, 11 Dec 2017 10:22:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D600C6E13D; Mon, 11 Dec 2017 10:21:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3410C6E951 for ; Fri, 8 Dec 2017 18:30:47 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id z34so11616701wrz.10 for ; Fri, 08 Dec 2017 10:30:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=TO9SVc0if3sK4K2uNgGtSSYwfskoP/hqVMUgTyo4Fh8=; b=k1j9Cs5oTabIUtO8NQWPpx5GiD/A4Lq1jPMTwMTDMgJconvJWfxffSo2X4klU/FkUa kWIpPmHiPdgCPErigYtogGZ08PMgBVw2r0WoueJB275Zk6iKs5D7Q8PDsQUhhn3EY70K f1iFpJUWRYmfC9AOt2vfOE0VQzsGvC2B7/DS8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TO9SVc0if3sK4K2uNgGtSSYwfskoP/hqVMUgTyo4Fh8=; b=dNLjBJa1DjmHf0ZskO/dr4+70VL5I4O+tDKloVEct2ltbCirwY2Qb0O2xNJonwS8dQ DKkbr4TZzJ1m3Cf1tQO/PpvqNx8r7xN85Ni+rUdz2acUEPJnihgsmsnzM1tuMlCFQHE5 hvikX4WgL2jXZDo2nPiiSn1+8lZZFgZ7wO8b+eGvz3qmFYeUduiuhol45zV5jv5fnBBu 6eivRQw+ORF5Ufsoa0VPPPvqaulSOfbKKWQkV60wdH+EntjERErnX7SV2Ze2T4lGvS4w 08J+pWYCJSvEKnfcONpvDE71+28zhc7p+Qo/FihKT16n7ntUf7IPWP5k8lCzSoeEMKcb H0+w== X-Gm-Message-State: AJaThX5vrUplNXkwt4/P5zvshK4WfOVIBzMMRXDbwTu9UExLzq0BEMO5 58c8qRXQFZ+NeG5DcJDGql56Bw== X-Google-Smtp-Source: AGs4zMZAGSIiY1/t596pKQN7YQKRoD/2jijRoxTEu3tffW8bIicFbor7h6jY7TbRt4pM7F2jbInAzA== X-Received: by 10.223.130.17 with SMTP id 17mr26428807wrb.131.1512757845819; Fri, 08 Dec 2017 10:30:45 -0800 (PST) Received: from localhost.localdomain ([160.171.158.223]) by smtp.gmail.com with ESMTPSA id f132sm2135884wmf.17.2017.12.08.10.30.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Dec 2017 10:30:44 -0800 (PST) From: Ard Biesheuvel To: bskeggs@redhat.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/nouveau/imem/nv50: fix incorrect use of refcount API Date: Fri, 8 Dec 2017 18:30:34 +0000 Message-Id: <20171208183034.9027-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 X-Mailman-Approved-At: Mon, 11 Dec 2017 10:21:20 +0000 Cc: daniel.thompson@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Commit be55287aa5b ("drm/nouveau/imem/nv50: embed nvkm_instobj directly into nv04_instobj") introduced some new calls to the refcount api to the nv50 mapping code. In one particular instance, it does the following: if (!refcount_inc_not_zero(&iobj->maps)) { ... refcount_inc(&iobj->maps); } i.e., it calls refcount_inc() to increment the refcount when it is known to be zero, which is explicitly forbidden by the API. Instead, use refcount_set() to set it to 1. Signed-off-by: Ard Biesheuvel --- Apologies if this was already found and fixed. I don't usually follow the DRM or nouveau mailing lists. drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c index 1ba7289684aa..db48a1daca0c 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c @@ -249,7 +249,7 @@ nv50_instobj_acquire(struct nvkm_memory *memory) iobj->base.memory.ptrs = &nv50_instobj_fast; else iobj->base.memory.ptrs = &nv50_instobj_slow; - refcount_inc(&iobj->maps); + refcount_set(&iobj->maps, 1); } mutex_unlock(&imem->subdev.mutex);