Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp231681rwb; Tue, 13 Dec 2022 16:44:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf4P8iTGN0Os5v3kda64wz0nXZ5TNkSZzvifN5UqAr2RgWIseNvvWShYnfXSf4Vb5cF4ItcR X-Received: by 2002:a05:6a00:2cb:b0:576:d50b:7e6e with SMTP id b11-20020a056a0002cb00b00576d50b7e6emr20712607pft.27.1670978696085; Tue, 13 Dec 2022 16:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670978696; cv=none; d=google.com; s=arc-20160816; b=XHnPv0rFQtx5oI1j7q5wS7H+dlxQsrgG/SidBFE9yhTFjxqgC33gnYCpv2bTspSD2H Ff/NxmtS5lnqJYQY97Uao98jEvUtaRPuaFFaP0VjTRNyFlNRkb8PKG7Nph+c45MOpWsd b2Zz2qNxCyc+zIDJaoe+/Krp+pAK7gdHULkv/Muz71hHYjAcUiBoNAqzOFpAIDV2Z7qC sDqq49mSJM3M3qKi/mXM3ZiwgHzSS76tVntseiUSVem9AtJ8edhNt3d8zNSs133M18l6 xDRVWgL2V+zCCtitF7zNPJyZ7rC8E1I7xL7jA1daXEvSV8P3bDqeVWhBd/Okl6lhDgZk ZMEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=lM2rqbtH72UpLKUzhSuqMdjImF8lyUH41GBxTj1js2g=; b=oiENFYdDBKBXGVkfxYLlwYD1mI/gwQv3d+Ro+oGi4e9C4oq9roGYwUVh2DHiuLzkcQ T7YIegtzhJbfbEfw/0BeFwJUXJVgWfsLjtSkrZGf41KbNMdKJSsCL+32knRm2dZPRZfR dfDTllZqt6tsdMINOya8ZcFi7JjaqJuotXLdNCP/PZWkGNxCiDnZtHwZTUui2UJjMIWG 53jgzwg8AoTk5TpEBoJJZuUw+jjJrl0VlsJ5fx+JTAnpqJjIiQvWfaBR7AW8yZaOvbwO DudLcJmz2Ypy6pNNTMX5/cAy3AShRNaxM/nAsu2cViBTO+NwrbDW6udsPQ6vg2TeqHmj A82w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hv51f69k; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x13-20020aa79acd000000b00562b0b92756si13355978pfp.297.2022.12.13.16.44.46; Tue, 13 Dec 2022 16:44:56 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=hv51f69k; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237390AbiLNA1E (ORCPT + 72 others); Tue, 13 Dec 2022 19:27:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237117AbiLNA0r (ORCPT ); Tue, 13 Dec 2022 19:26:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53414B1E8; Tue, 13 Dec 2022 16:26:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1F710B81609; Wed, 14 Dec 2022 00:26:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92B43C433EF; Wed, 14 Dec 2022 00:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670977603; bh=NDgzNzla8xVcW0uTm0lMUqLVpqM6P7lvLIQIDHm7YwY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=hv51f69k1nOkqwhvVxLbREu63I/O7Y+KIgmKi81hYB/T91GuYo8bAuLiEJUFSQGSM dg42kpX9k2E9HlVKit9ZurnhoiUDRyaBB//FB1AbkTEUBSd3y2VWW6wzAXU9AKE3XA g9HMVocOgpwn5qzUivFll8Ki+HeILE2cs26K2W3qM6mGWJzp0VMVM6HY80/9Nxh28p 9rKGd9c/YS7lvKDtl1z/ceTz3kM3UEftxKAc4j2jHs/KV/3E+rgiw7tzZmd4U76+8Z /v4kZM7Sytcm5Il+qUxoXcqnQiMlURELN5b4Dwgcj5uJiSxufbTzWwvB71l6OBNUWm VNMmGmDCah4Aw== Date: Tue, 13 Dec 2022 18:26:42 -0600 From: Bjorn Helgaas To: Frank Li Cc: mani@kernel.org, allenbh@gmail.com, bhelgaas@google.com, dave.jiang@intel.com, imx@lists.linux.dev, jdmason@kudzu.us, kw@linux.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, ntb@lists.linux.dev Subject: Re: [PATCH v16 7/7] PCI: endpoint: pci-epf-vntb: fix sparse build warning at ntb->reg Message-ID: <20221214002642.GA216337@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221102141014.1025893-8-Frank.Li@nxp.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Wed, Nov 02, 2022 at 10:10:14AM -0400, Frank Li wrote: > From: Frank Li > > pci-epf-vntb.c:1128:33: sparse: expected void [noderef] __iomem *base > pci-epf-vntb.c:1128:33: sparse: got struct epf_ntb_ctrl *reg > > Add __iomem type convert in vntb_epf_peer_spad_read() and > vntb_epf_peer_spad_write(). I don't understand all the bits and pieces here, but I'm a little dubious about adding all these "(void __iomem *)"casts. There are very few of them in drivers/pci/, and I doubt this driver is so unique that it needs them. > @@ -1121,7 +1121,7 @@ static u32 vntb_epf_spad_read(struct ntb_dev *ndev, int idx) > struct epf_ntb *ntb = ntb_ndev(ndev); > int off = ntb->reg->spad_offset, ct = ntb->reg->spad_count * sizeof(u32); > u32 val; > - void __iomem *base = ntb->reg; > + void __iomem *base = (void __iomem *)ntb->reg; > > val = readl(base + off + ct + idx * sizeof(u32)); > return val; > @@ -1132,7 +1132,7 @@ static int vntb_epf_spad_write(struct ntb_dev *ndev, int idx, u32 val) > struct epf_ntb *ntb = ntb_ndev(ndev); > struct epf_ntb_ctrl *ctrl = ntb->reg; > int off = ctrl->spad_offset, ct = ctrl->spad_count * sizeof(u32); > - void __iomem *base = ntb->reg; > + void __iomem *base = (void __iomem *)ntb->reg; > > writel(val, base + off + ct + idx * sizeof(u32)); These things look gratuitously different to begin with: int off = ntb->reg->spad_offset, ct = ntb->reg->spad_count * sizeof(u32); int off = ctrl->spad_offset, ct = ctrl->spad_count * sizeof(u32); They're doing the same thing, and they should do it the same way. Since db_data[] and db_offset[] are never referenced except to be initialized to zero, I'm guessing the point of vntb_epf_spad_read() and vntb_epf_spad_write() is to read/write things in those arrays? You access other things in ntb->reg directly by dereferencing a pointer, e.g., ntb->reg->link_status |= LINK_STATUS_UP; addr = ntb->reg->addr; ctrl->command_status = COMMAND_STATUS_OK; Why don't you just compute the appropriate *index* and access the array directly instead of using readl() and writel()? Bjorn