Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2366965pxb; Mon, 20 Sep 2021 20:17:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykYyrIRARTB9dIeilSj8NwDcCXIx91mXNZgsRU3ZC3IlT74CgnOVBueOzNU42r/Hzq5WCc X-Received: by 2002:a05:6e02:106:: with SMTP id t6mr19625829ilm.185.1632194277059; Mon, 20 Sep 2021 20:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632194277; cv=none; d=google.com; s=arc-20160816; b=n9NFYNEGCPb6LtvBsDjH5ZTWEtN3sEF+P4hj3hXWLCuxwISvbGEKGyYzlNbhp2Gq29 lIaKCHmDJ9wjrMzwHrlRntSXGXdivCYpUXu3wftpaMfcodwIU4j5WjOLKSQsbxqVO3mg Wx5DbLXj0Urpxq2xVyTvrHyQvRafALGf6jrLPwLGffwK/ofDB2t6el9x1JjCfmR0AZZ7 5bP7Iv623ez7X9goGY/gxD4V0iP+1uoo1I2XR1ZXTNSQuy4kOt/mSC14FkHNF9EsIM/B JWPoonmir6E29AmS0VzesXi+PkPmV7e503bavHPrZT0EOYZfqvgqKYFrVVBQc8Tu2L3S 2tyw== 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=D4S+AcvSp8mpiJ+suA97COggZgJYNJQAqJJ7LybolD8=; b=oVZbB7JuIru/Nvj1xF2+UYojK19wYaNrcaXr1I+h0uc34gWqLLjc3BtBUS+YgwJKV1 3SNsGaW5xfzM5tytX47H1BR3+yRvaRHpLHUUvvO0Ds+0cv0huVrpRrqNB+FpoLnYhg9D ZurDfd6RfkSnKUjAIrpCjXk3l1yzx4SGF0QXoC+eUj5PDjPXcHhgtV0w9FefbIocCwqC WPLYmBZGlfCEMYRYFpgSye9V4Z5KjvAWQHP6sUNEpq2vfaG/e2vmxD06ntTBwGGeMYon /VKsUVj9ptarE5kv2cMsKjwcnDlVdlEvuLPlB+0Wnb7cU99S5i9UmQrYALrkPK6kS1Zn GT9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=STF+yYHj; 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 c8si16068593ilu.80.2021.09.20.20.17.45; Mon, 20 Sep 2021 20:17:57 -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=STF+yYHj; 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 S1378212AbhITSXe (ORCPT + 99 others); Mon, 20 Sep 2021 14:23:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:38978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376430AbhITSQR (ORCPT ); Mon, 20 Sep 2021 14:16:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 43F5061A55; Mon, 20 Sep 2021 17:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158529; bh=MzHy2RxfiaBs1MVFQxvGZkOluiVwTMURU+s0HgqcKS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=STF+yYHjggXk84UXr/yOwcSiviGg7mtimscR034eU+2CcaKW1xoGY+qnmB2lnZs3e AQT/l4H9ZW/z7BRpMH1uO1iLJI1x+MevuINYxOr1JWAncsZDWnNvirDNd79NkI6kTM TAlMXg5n4xPrHhBOn6xr7y3KufA+zqlmH/oxBnjo= 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.4 199/260] drm/etnaviv: return context from etnaviv_iommu_context_get Date: Mon, 20 Sep 2021 18:43:37 +0200 Message-Id: <20210920163937.873148703@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@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 @@ -304,8 +304,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 @@ -534,8 +534,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 @@ -1307,12 +1307,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,