Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp242000rdf; Tue, 21 Nov 2023 01:01:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNY01zbQs4S6PBbePtQ0X8w8CSHr+Yer8mdo+xYrVp0y2oVY6qqJdtfnr5Ajhzs37+oC9z X-Received: by 2002:a05:6808:181e:b0:3b8:37ae:af40 with SMTP id bh30-20020a056808181e00b003b837aeaf40mr496312oib.9.1700557265380; Tue, 21 Nov 2023 01:01:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700557265; cv=none; d=google.com; s=arc-20160816; b=OxCPbX6kwvIiePNuhPRpxsh3AZIfmLX2MT/TuimuOpUGTgtBWgplIm7+7v6TPO07sk 3MGzd6KvcLjukVWbgLe6xqVmPOuA6DvJ3LVWRL1zHUksN2QhUo3M1HfnkFobLlVHf2L+ IATuW4Z8WbaDVzy/3aMfSMYz6QRiPSKlqsrT/oRdVCQjPU+CCMfcNS4rULbPjr5wBfAz r9PwuxSOy6Wvti/f8QQtFdcwB4Cf9ag+zrVRku22EX5dk8Ol/wK93g376aBvUIUGhGQ8 B8MxhEKgqgUsXWUnv2zM6I1Tf4jSeyoqpIwpsrig6Q85YmCywJVnC8/HpLTMYmMefYxF pFKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=jJ/AFKPeVxjAnYg0rcHdI79h+dhe0CVTx872xJ/48GQ=; fh=ctNem/nBkfs9ULUR5+tHT71FOS/gCEm510o040qXSz0=; b=u7Tmdh7zVTzjLafgtlwjk+ykdVKsxVMICeePKMJNK/L8Bk+sFxomnnITGX4aCeSvWz L5gjkqjwtdFkRQmnJcNpDr3I0wESvcbwCCY6KZf8G576U9vmseTdL4fG4BI+peJtMvPt 9Zvsdglzj/ZbSBuw/LelynFfCPDzK8t7Or07D4Lrmys2HEZWnvkkQwz8B9sQjkwGc7Xa rFHlAMdyEbQwYhBP0HIj/jXtCZ27wXJfBSDBhJm2GpSTSmqeQLjT33276HhxkZXYLmRL DcSg8pZ/ZrT2zHc1DhT07WLqqn3WcYwM631x7ngs5NtAD1hbcqvCWzOzJ8cSZqmpsRe7 dExQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AuZvg8VT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e14-20020a63ee0e000000b005bd0432d9b0si7184861pgi.100.2023.11.21.01.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 01:01:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=AuZvg8VT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2537E807E450; Tue, 21 Nov 2023 01:00:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbjKUJAD (ORCPT + 99 others); Tue, 21 Nov 2023 04:00:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjKUJAC (ORCPT ); Tue, 21 Nov 2023 04:00:02 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1DE195 for ; Tue, 21 Nov 2023 00:59:58 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1ca85ff26afso9393235ad.1 for ; Tue, 21 Nov 2023 00:59:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700557198; x=1701161998; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=jJ/AFKPeVxjAnYg0rcHdI79h+dhe0CVTx872xJ/48GQ=; b=AuZvg8VTWfmgmwopQCFIQRvNxKA0sNX5pYYAb0c0XKa4qfYvHUn2WnudDixiF/O0Ro oBbVo0KpT1+d74Ufvzm9vjJsYXQTqrE18BFbgcYNVRtYEGEwfg0eTtGn0ulLVOCyblDw v44TSAElUhLsuUEbC+GA8W5cEAkqnWbEfdWbsuP9z01/hgW4aknvuZiHNmVsMVFwulUM 0D4943ZGsEsVq2WnfBpoxZUzO4uxF9hFy3fjLF2Uv7gMuVmvGpd9lTlO/YD5r+LSw2BD gj1dRZaB9KENG4CE4Af/0vK0HGJN4i42RGqruH4K5y5tLszEy+V83n6qhghdaaAfalW2 hghg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700557198; x=1701161998; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jJ/AFKPeVxjAnYg0rcHdI79h+dhe0CVTx872xJ/48GQ=; b=jmTehNbsHI6yyu92UN9SgmqQwdmFMkqWTrxKowp9NKpxnrjBqxaVMk/Rf3D/XL0Mun pfhZP94gMq95UIOxpMUHibOB5q3IX7zJ9pVWQNymN32bv4Ww0mbDDmsB9wFA+RCK3RA6 mqM+gIN92PPe6YheFvFHrTxCk7vwekcDlIUx0UZKGFpdvbbTgz6NXJOAndBiWhS8l6PT O5ix17wD8NYsMenbaXYVZC4zL10OZDnSEARJkt+dBjXcroHWiclyEwdjC5W9BIOEio1a lkdo5WMcAMw9MDgANJf64ulSHOm62B9kqiBjJwJ6LVcDysUc/U5oikXG5nH0/2v5CBDy Al9w== X-Gm-Message-State: AOJu0Yw68tgi+9A/Z+6PhmPHNA73CHv0xYawSc6kBnWKFr793pOVlehP l/nAO88pzCrwx0Htsq1YG5EaWxmjkto= X-Received: by 2002:a17:902:eccd:b0:1cf:6a75:e989 with SMTP id a13-20020a170902eccd00b001cf6a75e989mr3141227plh.6.1700557198184; Tue, 21 Nov 2023 00:59:58 -0800 (PST) Received: from [192.168.0.152] ([103.75.161.209]) by smtp.gmail.com with ESMTPSA id y4-20020a17090322c400b001bbb7af4963sm7401133plg.68.2023.11.21.00.59.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Nov 2023 00:59:57 -0800 (PST) Message-ID: <38a45214-7cd0-482a-a330-65c5be488fba@gmail.com> Date: Tue, 21 Nov 2023 14:29:58 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] driver: gpu: Fixing warning directly dereferencing a rcu pointer Content-Language: en-US To: Danilo Krummrich , kherbst@redhat.com, lyude@redhat.com, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org References: <8e9efe54-2799-4539-a8b0-aa199f8052f6@redhat.com> <20231113191303.3277733-1-singhabhinav9051571833@gmail.com> <0754e669-8b00-461c-b6fe-79c659bf59a3@redhat.com> From: Abhinav Singh In-Reply-To: <0754e669-8b00-461c-b6fe-79c659bf59a3@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 01:00:20 -0800 (PST) On 11/21/23 06:50, Danilo Krummrich wrote: > On 11/13/23 20:13, Abhinav Singh wrote: >> This patch fixes a sparse warning with this message >> "warning:dereference of noderef expression". In this context it means we >> are dereferencing a __rcu tagged pointer directly. >> >> We should not be directly dereferencing a rcu pointer. To get a normal >> (non __rcu tagged pointer) from a __rcu tagged pointer we are using the >> function unrcu_pointer(...). The non __rcu tagged pointer then can be >> dereferenced just like a normal pointer. >> >> I tested with qemu with this command >> qemu-system-x86_64 \ >>     -m 2G \ >>     -smp 2 \ >>     -kernel bzImage \ >>     -append "console=ttyS0 root=/dev/sda earlyprintk=serial >> net.ifnames=0" \ >>     -drive file=bullseye.img,format=raw \ >>     -net user,host=10.0.2.10,hostfwd=tcp:127.0.0.1:10021-:22 \ >>     -net nic,model=e1000 \ >>     -enable-kvm \ >>     -nographic \ >>     -pidfile vm.pid \ >>     2>&1 | tee vm.log >> with lockdep enabled. >> >> Signed-off-by: Abhinav Singh > > Applied, thanks! > > There are a few more such occurrences. [1][2] Plan to fix them as well? > > [1] > https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/nouveau/nv10_fence.c#L35 > [2] > https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/nouveau/nv84_fence.c#L88 > >> --- >> v1 -> v2 : Replaced the rcu_dereference(...) with unrcu_pointer(...) and >>             also removed the rcu locking and unlocking function call. >> v2 -> v3 : Changed the description of the patch to match it with the >> actual >>        implementation. >> >>   drivers/gpu/drm/nouveau/nv04_fence.c | 2 +- >>   1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/nouveau/nv04_fence.c >> b/drivers/gpu/drm/nouveau/nv04_fence.c >> index 5b71a5a5cd85..cdbc75e3d1f6 100644 >> --- a/drivers/gpu/drm/nouveau/nv04_fence.c >> +++ b/drivers/gpu/drm/nouveau/nv04_fence.c >> @@ -39,7 +39,7 @@ struct nv04_fence_priv { >>   static int >>   nv04_fence_emit(struct nouveau_fence *fence) >>   { >> -    struct nvif_push *push = fence->channel->chan.push; >> +    struct nvif_push *push = unrcu_pointer(fence->channel)->chan.push; >>       int ret = PUSH_WAIT(push, 2); >>       if (ret == 0) { >>           PUSH_NVSQ(push, NV_SW, 0x0150, fence->base.seqno); > Thanks a lot for merging this. Yeah sure I will submit the patch for the issues soon. Regards, Abhinav Singh