Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2353388pxb; Mon, 20 Sep 2021 19:51:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4qy2phttqMQVMFNW2qrqTHscxfa/A+BBJUyRf/1GyVoD4NNJJwGFjeLdLF+QFYgLfnDwC X-Received: by 2002:a17:907:2bdb:: with SMTP id gv27mr31474044ejc.483.1632192693763; Mon, 20 Sep 2021 19:51:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192693; cv=none; d=google.com; s=arc-20160816; b=dkP6AM04wrZGK8SClLlgnLpIktfKojfFKsUT5UYGTD60ZWL6JeEmDEkrbQo+M1yi1a 9EerQ7JpqHI32/k4c6HZQipjPFZv/Gtsal/S0lZ89Q9MizxxP/KD9iyN05Q3bH82cWl9 DEmvzxonNrXoWJvUlMg5JWsbj7nU3jnI8t6YkbJj+g1x8MDi7Xief4fdOc2OBY1AKvWZ TepDFbSlA2KXVQVZFA7FsGPjTAZf9bW3VfHWJf1joqfkIqzTAf4CHh+W2zlQTLLse/U1 nN0Eh9rQwGmQB+OJY2fRoTOTurFv8BFetoRMYlZ4uZQTi7In+g0iLaWA9RtlNP3RWs7V Jfeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b/FO0EyXzrYbipfUaHgbPGg/EDjEVn/7cqEQ3BpTXdQ=; b=f9cZE9p8j/B4k5Mrmr1u2I3jCREQiRBOY6UXpct0iSwfOwTdirZqK9gF7yEq4jWaNS c0w+tx1eJPzagjfEQ6dcsd55SiOyVru0KXjFSHtPodT9CqHmqy6ERmUgxUIOaSa3tolQ 5Z2GsqgYh8mqQ4N1Epbyf5cXrAavm2co6HOItJW/FJ8RzidAswZN4ne0BCKFk1p5hFO+ S+l7atG5+X315kgbZz4578xkFoO3f3E+p0KE9Tk/bhZPJmViKgDelbWVzzOiO/SvcuYn f5YgQKWaOQ//9vylDXLxVR7Sl1QRKGmz/z6G3C3xGFEZwI8FPIWqCyq4QGFhGgTHUJRT bBeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jMgkKwAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si18462866edj.623.2021.09.20.19.51.10; Mon, 20 Sep 2021 19:51:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jMgkKwAV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381968AbhITSoE (ORCPT + 99 others); Mon, 20 Sep 2021 14:44:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:55446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353268AbhITSiR (ORCPT ); Mon, 20 Sep 2021 14:38:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3E05261411; Mon, 20 Sep 2021 17:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158987; bh=EY4CsRbvm70G4HuhNf4gaYtW7p9yA2mLcifBqqEej3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jMgkKwAVrLHb+Uty3zpX37N2UArCew801boZSDEuOiP/tkmpWm7gdokzpdowYl66I 0zxYFRT7LopbN14Mw1AJL7aDI57YQVMXwACQmymzTZDX+lA4RT3yylE3+M1y12yCoW N0Nc+/zGRGi2726HXljrumoFzsj/3dzicU+/5Xhk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lucas Stach , Michael Walle , Marek Vasut , Christian Gmeiner Subject: [PATCH 5.14 024/168] drm/etnaviv: return context from etnaviv_iommu_context_get Date: Mon, 20 Sep 2021 18:42:42 +0200 Message-Id: <20210920163922.440358140@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lucas Stach commit 78edefc05e41352099ffb8f06f8d9b2d091e29cd upstream. Being able to have the refcount manipulation in an assignment makes it much easier to parse the code. Cc: stable@vger.kernel.org # 5.4 Signed-off-by: Lucas Stach Tested-by: Michael Walle Tested-by: Marek Vasut Reviewed-by: Christian Gmeiner Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/etnaviv/etnaviv_buffer.c | 3 +-- drivers/gpu/drm/etnaviv/etnaviv_gem.c | 3 +-- drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 3 +-- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 6 ++---- drivers/gpu/drm/etnaviv/etnaviv_mmu.h | 4 +++- 5 files changed, 8 insertions(+), 11 deletions(-) --- a/drivers/gpu/drm/etnaviv/etnaviv_buffer.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_buffer.c @@ -397,8 +397,7 @@ void etnaviv_buffer_queue(struct etnaviv if (switch_mmu_context) { struct etnaviv_iommu_context *old_context = gpu->mmu_context; - etnaviv_iommu_context_get(mmu_context); - gpu->mmu_context = mmu_context; + gpu->mmu_context = etnaviv_iommu_context_get(mmu_context); etnaviv_iommu_context_put(old_context); } --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -303,8 +303,7 @@ struct etnaviv_vram_mapping *etnaviv_gem list_del(&mapping->obj_node); } - etnaviv_iommu_context_get(mmu_context); - mapping->context = mmu_context; + mapping->context = etnaviv_iommu_context_get(mmu_context); mapping->use = 1; ret = etnaviv_iommu_map_gem(mmu_context, etnaviv_obj, --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c @@ -532,8 +532,7 @@ int etnaviv_ioctl_gem_submit(struct drm_ goto err_submit_objects; submit->ctx = file->driver_priv; - etnaviv_iommu_context_get(submit->ctx->mmu); - submit->mmu_context = submit->ctx->mmu; + submit->mmu_context = etnaviv_iommu_context_get(submit->ctx->mmu); submit->exec_state = args->exec_state; submit->flags = args->flags; --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1365,12 +1365,10 @@ struct dma_fence *etnaviv_gpu_submit(str } if (!gpu->mmu_context) { - etnaviv_iommu_context_get(submit->mmu_context); - gpu->mmu_context = submit->mmu_context; + gpu->mmu_context = etnaviv_iommu_context_get(submit->mmu_context); etnaviv_gpu_start_fe_idleloop(gpu); } else { - etnaviv_iommu_context_get(gpu->mmu_context); - submit->prev_mmu_context = gpu->mmu_context; + submit->prev_mmu_context = etnaviv_iommu_context_get(gpu->mmu_context); } if (submit->nr_pmrs) { --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.h @@ -105,9 +105,11 @@ void etnaviv_iommu_dump(struct etnaviv_i struct etnaviv_iommu_context * etnaviv_iommu_context_init(struct etnaviv_iommu_global *global, struct etnaviv_cmdbuf_suballoc *suballoc); -static inline void etnaviv_iommu_context_get(struct etnaviv_iommu_context *ctx) +static inline struct etnaviv_iommu_context * +etnaviv_iommu_context_get(struct etnaviv_iommu_context *ctx) { kref_get(&ctx->refcount); + return ctx; } void etnaviv_iommu_context_put(struct etnaviv_iommu_context *ctx); void etnaviv_iommu_restore(struct etnaviv_gpu *gpu,