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: 121236 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp989815qgn; Fri, 8 Dec 2017 10:30:50 -0800 (PST) X-Google-Smtp-Source: AGs4zMaCIACPKvNPFfa/+dA+LezxBTfVKcX/E3b3ATNWr48L8MEQfXv3bV98iqj3TgpTwpGSbFG3 X-Received: by 10.159.214.148 with SMTP id n20mr10139927plp.101.1512757850712; Fri, 08 Dec 2017 10:30:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512757850; cv=none; d=google.com; s=arc-20160816; b=rqRag+VYKfTGKNyu3I1kwgYB5yGtzFi9xkbc6HaY08H5uHKHQzI+B0sWtZ9jzkKwbR vW3e++Ll0meVuYPVwa6OlTGn8EZqwzYfyryTXACwKdyDNQ05ij8rUp5fN1mnO2trjnTt DAKzTs2yECruIbffYW9INlEGfBUy2LM4RkTY7U6/Afj2eJWFQeUyAIYi8Yqqn+kGyNOU qyG58OEgyA6YWDcZ4aSMKiCmqglUV5wRD0+nsahw7lBU7hhhxikcvVp6vSw9WBiC+u85 qQMOPVMvRA+xCGUaKaY9IfUUbyaa1r8x3HKTmBxBNp03aSjW+S7bNnwyuu0xfpMqyWIz Do7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=TO9SVc0if3sK4K2uNgGtSSYwfskoP/hqVMUgTyo4Fh8=; b=Up8QFeHJL7FH+fZ1e2dKeeVb1jm189ey08HWs7n9OGzIXGGjk/nrUabC6O0FH2Xnyh 7kgCF8Cx1BzfqRd3AkZIPg2+ftfjxvpSXxVuQHVa+JpRqGA0vLKLGEKY+0JfxSi9IsKn HuyGYkxYhlP02QQvoiTZht/w+ylRX/IVI2KukavfqRth9oU3uW79ZGjUVD5DD8n4ysbt n6VQO2lngPlVDap/efAfCCRSNoDtv+yEDmSZCW76xVkiDdzVCUVyjSf8PYSEZOS22gcd xqlD2fnzk23YO+LYRvQDW7igwVlDO7VWf36ZyYwc/JnL6TyFO6jGgo/Xp1SSLgaTGR3x 71Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k1j9Cs5o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si6516995pfn.413.2017.12.08.10.30.49; Fri, 08 Dec 2017 10:30:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k1j9Cs5o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752645AbdLHSas (ORCPT + 18 others); Fri, 8 Dec 2017 13:30:48 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36665 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752003AbdLHSar (ORCPT ); Fri, 8 Dec 2017 13:30:47 -0500 Received: by mail-wr0-f196.google.com with SMTP id v105so11647178wrc.3 for ; Fri, 08 Dec 2017 10:30:46 -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=d2i2zKL1iX4rfOQF2l8ojac+/BBZLTT3hyBF1+qveb0S/+0qerJQAjaLm3RKcRmNQ9 g8+JDswmWT5Dvm6ElArCvAxRpYeNRQ4ug+OmoSVT1JhOxDZSnylrjveFRhR4sbUV8B98 UM1oJYXG9NihoORiQP97rdZTE0NZuNQtfFUX3mfCGuILkpUtfzSdOTObkaVZmyXDpL1f oKODUB98mQsrOsgZqeQgJNc63GJJDlrU5BcHOhKWaLgfkUGmlbNbjLC7tM3Mb5We/Os6 yHAx7i3EndiKZc0xwBxqF3XPcwE6sQNJ04eLwamVkOEiu1Oq6yeAAAR4aursEHrYocNv 26AA== X-Gm-Message-State: AJaThX5FKh6Z/F0ZzUFQhzhcBN551DiJdfBKb6LsVcOAYHw0uyme6Kok 6xIa4eyrIy5fdkd9MqrCWMZZYQ== 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 Cc: daniel.thompson@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.11.0 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);