Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1396060imw; Tue, 5 Jul 2022 08:44:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uq3L6oyerbY/clTCSaiZPgKbusa//Nf11vwen9xxkY1GWNkv/TnSdGsBvrZA+RtcanHdnH X-Received: by 2002:a17:907:1c8d:b0:6f2:eb2:1cd6 with SMTP id nb13-20020a1709071c8d00b006f20eb21cd6mr33198784ejc.568.1657035841023; Tue, 05 Jul 2022 08:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657035841; cv=none; d=google.com; s=arc-20160816; b=KIHSbL8j7BpsAfHHF+pBpJVva3OCnCa19i1e9FHlbW3FInuAWvR+qA7SzGlHDxtZqd RxJ+UMeZXV408o/Svw61bSxEA9+qha7PjxH5Gc7O8H95ex0PZge+a7McgW62twINy2p+ KdZE3rn5SoUprimlQYSa8M8oJqntGb5c3dgeq+14f/neVNP1EwlClhAYpcq0O4OCmbwr OlfxETh+HKk5VbNTu4OcycPxxFVUe6I2zB82bf6cWOQ6gxXRZ7zm243x11cB1eTVi1i1 Liax1WTZIgsKFqzWMUlfUaBuFNLXLZaHGw3cyODIkpKHzjmGZk0qWhuKXpZXQ5S7lrZn t7mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=dkpN1b4wP9gTZUtEgRoxQX0uUzfu9gESHo4XVBhNNPA=; b=QUttX+iaKdVjRkwS6tDrsqbvmZvb9mBN3I5ZS/C+7/GOojX7KzuVXGZxG0o1Cf8YYD 1RG8KI+POsZHhy+xpNZSVKvTc9Ol7GI755zMI/gW4Witpnmux3+MEUCb5iWCNZOPp+kA 2ToD5Xfra9TdclH4OS/D1Eh6mMp4sZiNGKTiWsv2sKdC06HnoKN1GX2IkEoFgNUTBkZb 8JQGxiEgPA/CBqodb9ClniZKjBwjWhf+wbRkFCW7yu1bsnMVblkRIYsFJ8aYRbJelZkE s1SdTOpilWVFZJV8Re2W/+XE3C9qLY9hg2Z+/wP0IHV4djqgry+JF+wE3d+BsMuuK8g5 eRIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jtX3byuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg6-20020a170907970600b00726294f089fsi24559024ejc.229.2022.07.05.08.43.34; Tue, 05 Jul 2022 08:44:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jtX3byuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231194AbiGEPLW (ORCPT + 99 others); Tue, 5 Jul 2022 11:11:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbiGEPLF (ORCPT ); Tue, 5 Jul 2022 11:11:05 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36ED0CEF for ; Tue, 5 Jul 2022 08:10:21 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id d2so22228367ejy.1 for ; Tue, 05 Jul 2022 08:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=dkpN1b4wP9gTZUtEgRoxQX0uUzfu9gESHo4XVBhNNPA=; b=jtX3byuXyfc2mF/rBU1M4/i77Y3tRdz2XH46byqIsfIKKhOLkoBSf+LTlU7hrA6X2j 8iKu9cxdOL/P9b6KmRtmTaKvprIJ42mVGAdpNqhVtfAnpBOjqNtHWcfnTd9JOfMluq8V 3t1exD8XY3OfFVfq50fAeo620chL6sdXcvktq3qjgBgPHwRkEFXmlhFtILjfrXZ7fGPo 9FbxvE388pdW6PVWA7jDHcswPCzy/j0JPDhP/6OeXV7RewR9E/G+8J5C9H0gSaM3GiEl K80kZ8LmV8wNAJbNoZM+6zll2pSiw1hlxn0S+ZFqHHULCmt4KZXnUHUeQRnKzYDsKYYQ iG9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=dkpN1b4wP9gTZUtEgRoxQX0uUzfu9gESHo4XVBhNNPA=; b=4M6o90b91PcrZWo3AJOTnaCyp7rIgeMBMH9z3Wykc2/aLnVEsYr8hXbErEBG7IdLjT AT9T6PXGfZgw3cTwOibBotoexO8mOX9bw5Ow31kQdBMA3b4a9a5Dd+8dAOH+aaPtJvbH 9buUfZuj7TRJHZCWieNaJn/IoSVX5l3JNcJHCdtasXvoNR8dqoboluin5rTkCIGaS5qu 8ZEkY5rq0De9ohf8ePbbEQadGj0+q2rcx57rS1ZfRFkE07v8L6r0GCtZ+BAE8BgJo7n3 n73IesdPOD1kloU+Eli+F68GVWBeV+g+h7o85pUDYE7sPs/sQOldg3PcsDYNC3qn/lMr bk3g== X-Gm-Message-State: AJIora9XzVoqIDbt3/gxT2CvEYVlSLy3rhD590wUy9cBfFuDYDVqQ4S+ rXQk336Btdb3aju45kfEfefNrBrjFt9Ccfw0GBA= X-Received: by 2002:a17:906:5d0b:b0:726:a043:fcb4 with SMTP id g11-20020a1709065d0b00b00726a043fcb4mr35047447ejt.508.1657033819797; Tue, 05 Jul 2022 08:10:19 -0700 (PDT) MIME-Version: 1.0 References: <20220704134532.103876-1-andrealmeid@igalia.com> In-Reply-To: From: Alex Deucher Date: Tue, 5 Jul 2022 11:10:07 -0400 Message-ID: Subject: Re: [PATCH] drm/amdpgu/debugfs: Simplify some exit paths To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: =?UTF-8?Q?Andr=C3=A9_Almeida?= , Alex Deucher , Pan Xinhui , David Airlie , Daniel Vetter , Hawking Zhang , Tao Zhou , Felix Kuehling , Jack Xiao , amd-gfx list , Maling list - DRI developers , LKML , kernel-dev@igalia.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Applied. Thanks! On Mon, Jul 4, 2022 at 12:23 PM Christian K=C3=B6nig wrote: > > Am 04.07.22 um 15:45 schrieb Andr=C3=A9 Almeida: > > To avoid code repetition, unify the function exit path when possible. N= o > > functional changes. > > > > Signed-off-by: Andr=C3=A9 Almeida > > Acked-by: Christian K=C3=B6nig > > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 107 ++++++++-----------= - > > 1 file changed, 42 insertions(+), 65 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/= drm/amd/amdgpu/amdgpu_debugfs.c > > index f3ac7912c29c..f3b3c688e4e7 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > @@ -383,12 +383,8 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(struc= t file *f, char __user *buf, > > > > value =3D RREG32_PCIE(*pos); > > r =3D put_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - amdgpu_virt_disable_access_debugfs(adev); > > - return r; > > - } > > + if (r) > > + goto out; > > > > result +=3D 4; > > buf +=3D 4; > > @@ -396,11 +392,12 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(stru= ct file *f, char __user *buf, > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > - > > amdgpu_virt_disable_access_debugfs(adev); > > - return result; > > + return r; > > } > > > > /** > > @@ -441,12 +438,8 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(stru= ct file *f, const char __user > > uint32_t value; > > > > r =3D get_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - amdgpu_virt_disable_access_debugfs(adev); > > - return r; > > - } > > + if (r) > > + goto out; > > > > WREG32_PCIE(*pos, value); > > > > @@ -456,11 +449,12 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(str= uct file *f, const char __user > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > - > > amdgpu_virt_disable_access_debugfs(adev); > > - return result; > > + return r; > > } > > > > /** > > @@ -502,12 +496,8 @@ static ssize_t amdgpu_debugfs_regs_didt_read(struc= t file *f, char __user *buf, > > > > value =3D RREG32_DIDT(*pos >> 2); > > r =3D put_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - amdgpu_virt_disable_access_debugfs(adev); > > - return r; > > - } > > + if (r) > > + goto out; > > > > result +=3D 4; > > buf +=3D 4; > > @@ -515,11 +505,12 @@ static ssize_t amdgpu_debugfs_regs_didt_read(stru= ct file *f, char __user *buf, > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > - > > amdgpu_virt_disable_access_debugfs(adev); > > - return result; > > + return r; > > } > > > > /** > > @@ -560,12 +551,8 @@ static ssize_t amdgpu_debugfs_regs_didt_write(stru= ct file *f, const char __user > > uint32_t value; > > > > r =3D get_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - amdgpu_virt_disable_access_debugfs(adev); > > - return r; > > - } > > + if (r) > > + goto out; > > > > WREG32_DIDT(*pos >> 2, value); > > > > @@ -575,11 +562,12 @@ static ssize_t amdgpu_debugfs_regs_didt_write(str= uct file *f, const char __user > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > - > > amdgpu_virt_disable_access_debugfs(adev); > > - return result; > > + return r; > > } > > > > /** > > @@ -621,12 +609,8 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struct= file *f, char __user *buf, > > > > value =3D RREG32_SMC(*pos); > > r =3D put_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - amdgpu_virt_disable_access_debugfs(adev); > > - return r; > > - } > > + if (r) > > + goto out; > > > > result +=3D 4; > > buf +=3D 4; > > @@ -634,11 +618,12 @@ static ssize_t amdgpu_debugfs_regs_smc_read(struc= t file *f, char __user *buf, > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > - > > amdgpu_virt_disable_access_debugfs(adev); > > - return result; > > + return r; > > } > > > > /** > > @@ -679,12 +664,8 @@ static ssize_t amdgpu_debugfs_regs_smc_write(struc= t file *f, const char __user * > > uint32_t value; > > > > r =3D get_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - amdgpu_virt_disable_access_debugfs(adev); > > - return r; > > - } > > + if (r) > > + goto out; > > > > WREG32_SMC(*pos, value); > > > > @@ -694,11 +675,12 @@ static ssize_t amdgpu_debugfs_regs_smc_write(stru= ct file *f, const char __user * > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > - > > amdgpu_virt_disable_access_debugfs(adev); > > - return result; > > + return r; > > } > > > > /** > > @@ -1090,11 +1072,8 @@ static ssize_t amdgpu_debugfs_gfxoff_write(struc= t file *f, const char __user *bu > > uint32_t value; > > > > r =3D get_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - return r; > > - } > > + if (r) > > + goto out; > > > > amdgpu_gfx_off_ctrl(adev, value ? true : false); > > > > @@ -1104,10 +1083,12 @@ static ssize_t amdgpu_debugfs_gfxoff_write(stru= ct file *f, const char __user *bu > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > > > - return result; > > + return r; > > } > > > > > > @@ -1139,18 +1120,12 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struc= t file *f, char __user *buf, > > uint32_t value; > > > > r =3D amdgpu_get_gfx_off_status(adev, &value); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - return r; > > - } > > + if (r) > > + goto out; > > > > r =3D put_user(value, (uint32_t *)buf); > > - if (r) { > > - pm_runtime_mark_last_busy(adev_to_drm(adev)->dev)= ; > > - pm_runtime_put_autosuspend(adev_to_drm(adev)->dev= ); > > - return r; > > - } > > + if (r) > > + goto out; > > > > result +=3D 4; > > buf +=3D 4; > > @@ -1158,10 +1133,12 @@ static ssize_t amdgpu_debugfs_gfxoff_read(struc= t file *f, char __user *buf, > > size -=3D 4; > > } > > > > + r =3D result; > > +out: > > pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); > > pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); > > > > - return result; > > + return r; > > } > > > > static const struct file_operations amdgpu_debugfs_regs2_fops =3D { >