From patchwork Thu Aug 29 14:16:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 823657 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F5321B1410 for ; Thu, 29 Aug 2024 14:18:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941135; cv=none; b=A0HSPeQC4ZfJyWa6OpEmi59/YtYUMjod0Ta1QTBRMnK7y78CV82N8qUag86fcU3tA62jKjUKyqnPNXAnC8WR/hl4RAx2x+KrOT5rn7beQ8hL70/nSwa2hAmztsjwWagiXjLQ7an+c7dwbbk+F+mI8K27Ni1cxrXn9zBORGDQqWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941135; c=relaxed/simple; bh=zJ+yRIWc0laMt+VA+WcNeC6inAbzeJDFegXsPKCx36w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o6zW4nntEZE/U/v7JWbSf0HUVqgBs7alk2r6C9Jda1+9QMjegxwWK3wNBs/B/b3vHuCYUqLQcXDTL5q4djfHvfZtSt2SPb8h95dKKSKUfTbMTA8KFQfDv6gpwPyZGam1JKCc7SkEqM8JmVBlmGj2VgP4R4f+oz8T8TfU303gnPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZZCzSrVb; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZZCzSrVb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724941132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GT8+L1vpUCD1XCsuz0jWN9YX0IbdjrEGcfF0kmNNelY=; b=ZZCzSrVby/u0diWZI6WwNaFOpiCXlEEuMFV83N+6fDHyTLrsr7SLJiDFf6/Od/WXaIZKrt 8gyZRZe2sDr/9YstyyEKPCgz3Oh49Zvo1IJ1aSjkcRMrVImcRuEXDvaxuEgkOvAxBfyg5p 3S5xVckTDlkkrXqVYWmxx2WG2zyKBCI= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-509-NdboIV_3OsiRI_KJ4Eo5pw-1; Thu, 29 Aug 2024 10:18:51 -0400 X-MC-Unique: NdboIV_3OsiRI_KJ4Eo5pw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4280f233115so7099395e9.2 for ; Thu, 29 Aug 2024 07:18:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724941130; x=1725545930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GT8+L1vpUCD1XCsuz0jWN9YX0IbdjrEGcfF0kmNNelY=; b=J1LtX7pA3hzhV6D2BSq0rFOxMwNrS/lVXtyMOJu2opvmNBbHceU8oh20mKxWC6NmTJ ZMD1P6eWBMiLacvHYTglxVq1dnFWdLWly0zgFtfvu0q1Wrdo5KDr4lcqxen2Xjh84JiF bKzScc4BUYwaD3MuRuwkk41Kh0ehJXOSxEWK7X+RGAKWPfnLIJBXLoIQbPwSJyZkez1t etjTmLGedBa0d2VCscA5FIs5ZazUHk7BPspiEv0RTZ/vsX0KbL42IXEcBfIBantUrTYe PC3hLxplkJ1+yRkwush1IAUMU4LpXkrPeXI7UiKebicfLotddMjGh69kFezGIlGYHBN5 pnww== X-Forwarded-Encrypted: i=1; AJvYcCUKiml8LIdEABdN4+3yOXXelw/gmPR8rSICfRSXVb9aLNpFJ/GwdCQSc4y10PVEXExlOPBvIZFfTMla@vger.kernel.org X-Gm-Message-State: AOJu0Yx00NeLSn6XVCVT7x/VaAsJerGuSxBE3Qsq+QPfWktJbmM+0/AG GEjtj1WIfeXSpQg7hZJRBHzlja9I5FuGYY4rXOnhH0V+7F2p/cnUEVXjuKhYw/RgUdzk2aAG9zn mWbUAbtP4ENz7R9W8orr8dZMPmkFszQbQm158UdPwTfxtNmSnKJ/x3JKcoto= X-Received: by 2002:a05:600c:4444:b0:428:ea8e:b4a0 with SMTP id 5b1f17b1804b1-42bb02ee51amr21076505e9.14.1724941130178; Thu, 29 Aug 2024 07:18:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIkTKSH/QTeIyV54cadvSe1hYdPiDL+tkcm56iHXiGVeo2pmvJLb7aXhRIrmTDGPReCWareA== X-Received: by 2002:a05:600c:4444:b0:428:ea8e:b4a0 with SMTP id 5b1f17b1804b1-42bb02ee51amr21076255e9.14.1724941129588; Thu, 29 Aug 2024 07:18:49 -0700 (PDT) Received: from eisenberg.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63abebdsm52670425e9.27.2024.08.29.07.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 07:18:48 -0700 (PDT) From: Philipp Stanner To: Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Damien Le Moal , Hannes Reinecke , John Garry , Philipp Stanner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH v5 1/7] PCI: Deprecate pcim_iounmap_regions() Date: Thu, 29 Aug 2024 16:16:20 +0200 Message-ID: <20240829141844.39064-2-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829141844.39064-1-pstanner@redhat.com> References: <20240829141844.39064-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The function pcim_iounmap_regions() is problematic because it uses a bitmask mechanism to release / iounmap multiple BARs at once. It, thus, prevents getting rid of the problematic iomap table mechanism which was deprecated in commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()"). Make pcim_iounmap_region() public as the successor of pcim_iounmap_regions(). Mark pcim_iomap_regions() as deprecated. Signed-off-by: Philipp Stanner --- drivers/pci/devres.c | 8 ++++++-- include/linux/pci.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index b97589e99fad..5f6f889249b0 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -771,7 +771,7 @@ EXPORT_SYMBOL(pcim_iomap_region); * Unmap a BAR and release its region manually. Only pass BARs that were * previously mapped by pcim_iomap_region(). */ -static void pcim_iounmap_region(struct pci_dev *pdev, int bar) +void pcim_iounmap_region(struct pci_dev *pdev, int bar) { struct pcim_addr_devres res_searched; @@ -782,6 +782,7 @@ static void pcim_iounmap_region(struct pci_dev *pdev, int bar) devres_release(&pdev->dev, pcim_addr_resource_release, pcim_addr_resources_match, &res_searched); } +EXPORT_SYMBOL(pcim_iounmap_region); /** * pcim_iomap_regions - Request and iomap PCI BARs (DEPRECATED) @@ -1013,11 +1014,14 @@ int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask, EXPORT_SYMBOL(pcim_iomap_regions_request_all); /** - * pcim_iounmap_regions - Unmap and release PCI BARs + * pcim_iounmap_regions - Unmap and release PCI BARs (DEPRECATED) * @pdev: PCI device to map IO resources for * @mask: Mask of BARs to unmap and release * * Unmap and release regions specified by @mask. + * + * This function is DEPRECATED. Do not use it in new code. + * Use pcim_iounmap_region() instead. */ void pcim_iounmap_regions(struct pci_dev *pdev, int mask) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 01b9f1a351be..9625d8a7b655 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2297,6 +2297,7 @@ void __iomem * const *pcim_iomap_table(struct pci_dev *pdev); int pcim_request_region(struct pci_dev *pdev, int bar, const char *name); void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar, const char *name); +void pcim_iounmap_region(struct pci_dev *pdev, int bar); int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name); int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask, const char *name); From patchwork Thu Aug 29 14:16:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 824449 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 741731B1434 for ; Thu, 29 Aug 2024 14:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941137; cv=none; b=MlI/4FjPpQ0yNdSBgFhCY+c7sVuiyZ2ZGoTjplzBl+9PvVgigfipwFYXe14wZ0zS2HxlrJPIViBrxS5pneS9ytcc+gRnNuF7uJBOwUBbKMAf+AjLtkU8NwoZpPztQTDOGBiTZ8qsYp81cXoRvnBAcwnTlUT0iHB9/er0YYZ9u+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941137; c=relaxed/simple; bh=V4KRcC8BfWc5Sti/Fdc73KUa8QY4uocvnp5UyVnLmQQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XhOxOzgRVUkfwS/aXQo8patUTtQVTsTTt/UnCWIbtsQwfTlSIo82w/6lWv86ppghBUzwdOsshZ0xpY3i37P6NH/dJlcLhm48PDR0eC+YethakDPZOdZbi4p1+qkrb9zvtg0bjJoHQLe2MToNGgF3uMm2NtYdZb9n/ez/oxESb4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EL38qi4c; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EL38qi4c" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724941134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j5hLs33+KllKyvrdGIaXp9UPbFVf3GpM3GrIwQsqtHc=; b=EL38qi4cB3+4SU5JW/ydGVgTvO/anUFhfijY29tDBkoHifNcruZlRGcmW4iYtUS2ZqOF8z z/uVqCl9UrFhsp+I+O541cH7chFy9Al8X07LfLTkZksZW7WiGTTT3uUES8HMv57yOkaz7l opRmYXjMFetGoRkV72vka1gvVm5xc+8= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-360--xXHuEo8PeaMmzA6LzFurQ-1; Thu, 29 Aug 2024 10:18:53 -0400 X-MC-Unique: -xXHuEo8PeaMmzA6LzFurQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3718d9d9267so579971f8f.0 for ; Thu, 29 Aug 2024 07:18:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724941132; x=1725545932; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j5hLs33+KllKyvrdGIaXp9UPbFVf3GpM3GrIwQsqtHc=; b=M2t/iJPdgf/o7XE/xKlgNOaRuMonsQ8nkkitMUs6SH5Rvt2+qxcgddnCF7ioP9Qf+g TIPeqSmCrF4CMYVQhHzfq9pXeYVngYivqmLXSTbRNOwvqXT/1GAEvWlUlyFHrNNW4ijY 2SAvWI5lF398nG/TE8eRVYXDd1OO2DVz85X+Nt2zwXwHGbBMZlzaSRHlac+YjTLT2qaY 7EPQewVf14OgHFB1K6d5uUwLOTEb7tI5/xVLxFqqutTMwiSjTBzc0WunaTGL2nDIGIPu ZzvShrwZZ5MLG8WA04nmLaE1II/IVPqiQ5mnWeVzqwzHhGfwrh+M8e5wn12CBcr3eK/I qAmg== X-Forwarded-Encrypted: i=1; AJvYcCUnziu4iKB6NTxkyCP9htPkzTp8603d3nlYKlzLMgQ0a8HyXIFfxTeymgg3N7X+ocymx606RWRQ0MfC@vger.kernel.org X-Gm-Message-State: AOJu0YzSoYxNfvza04c/o/h5p+4xNakLt3/b5lMOmlqYSKHHrC2aOWKz zydFNBt8+ZPivnIVa+MlwZzDoJWj5LcmcsE995dHNT0J3ZaNTe/2Y4cggMmch66T2F6YHIo5+qd BRXGZVAhjYthvNJZXNun+oV71mDHhRhZB3jCXggZete2Zl3teXG12/wJwiqg= X-Received: by 2002:a05:6000:4d0:b0:371:890c:9b5c with SMTP id ffacd0b85a97d-3749b58e35fmr2067687f8f.62.1724941132038; Thu, 29 Aug 2024 07:18:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExu3DQrPfL2Xn0gAB2fCj8JJI6EtuIM+NkPB8RfQMu0+YrU4TAxvDtIU5CsDAlbEI3/d8Pow== X-Received: by 2002:a05:6000:4d0:b0:371:890c:9b5c with SMTP id ffacd0b85a97d-3749b58e35fmr2067629f8f.62.1724941131450; Thu, 29 Aug 2024 07:18:51 -0700 (PDT) Received: from eisenberg.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63abebdsm52670425e9.27.2024.08.29.07.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 07:18:50 -0700 (PDT) From: Philipp Stanner To: Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Damien Le Moal , Hannes Reinecke , John Garry , Philipp Stanner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH v5 2/7] fpga/dfl-pci.c: Replace deprecated PCI functions Date: Thu, 29 Aug 2024 16:16:21 +0200 Message-ID: <20240829141844.39064-3-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829141844.39064-1-pstanner@redhat.com> References: <20240829141844.39064-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pcim_iomap_regions() and pcim_iomap_table() have been deprecated by the PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()"). Port dfl-pci.c to the successor, pcim_iomap_region(). Consistently, replace pcim_iounmap_regions() with pcim_iounmap_region(). Signed-off-by: Philipp Stanner Reviewed-by: Andy Shevchenko Acked-by: Xu Yilun --- drivers/fpga/dfl-pci.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c index 80cac3a5f976..602807d6afcc 100644 --- a/drivers/fpga/dfl-pci.c +++ b/drivers/fpga/dfl-pci.c @@ -39,14 +39,6 @@ struct cci_drvdata { struct dfl_fpga_cdev *cdev; /* container device */ }; -static void __iomem *cci_pci_ioremap_bar0(struct pci_dev *pcidev) -{ - if (pcim_iomap_regions(pcidev, BIT(0), DRV_NAME)) - return NULL; - - return pcim_iomap_table(pcidev)[0]; -} - static int cci_pci_alloc_irq(struct pci_dev *pcidev) { int ret, nvec = pci_msix_vec_count(pcidev); @@ -235,9 +227,9 @@ static int find_dfls_by_default(struct pci_dev *pcidev, u64 v; /* start to find Device Feature List from Bar 0 */ - base = cci_pci_ioremap_bar0(pcidev); - if (!base) - return -ENOMEM; + base = pcim_iomap_region(pcidev, 0, DRV_NAME); + if (IS_ERR(base)) + return PTR_ERR(base); /* * PF device has FME and Ports/AFUs, and VF device only has one @@ -296,7 +288,7 @@ static int find_dfls_by_default(struct pci_dev *pcidev, } /* release I/O mappings for next step enumeration */ - pcim_iounmap_regions(pcidev, BIT(0)); + pcim_iounmap_region(pcidev, 0); return ret; } From patchwork Thu Aug 29 14:16:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 823656 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5BE61B1505 for ; Thu, 29 Aug 2024 14:18:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941139; cv=none; b=LtJSRZIx1c36V1kP5R7+RZuKWI6tgl7vv2hi5lWT4Qha0KopFwfhdiOhmft9nVNnKF1icwN3aDIiTlyOlXZ8vqzCP6odx/2x2FZVlajPgrGdQ5vDTApKfx/P76iCcnKKODXicWG/SFCY+bjAYroJm3J7sGMAkVspx4RWRo+p/Ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941139; c=relaxed/simple; bh=s4GctkYHbXn3tfM8TOsiQdy7M4dRLmQpFi1urTUZZ7M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PkL+ylOP2llNtv/noL3G81lx6m2B156REy81p+HpywtSz5Br+rW1EqjFOL3gXknlj4EC33Rm4uyEdCx4UACkfCBEQg8YSy8FoDtWifD7U4stHd4Uao2IrKkRfOOc19oUKoWGiQZqR3alFfvAisZM81UHhKMDu6NNDZgFLETiJLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EO7nAydQ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EO7nAydQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724941135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YtYR/gGTmDbAPYmIYRccbXqwblJKOZwAhQg2Y6pwqmg=; b=EO7nAydQGuS8+PH1FdrZVaVS746AZzLW4GgZHIz/ra8IgksF7ismJaK/JSY4y2Z76HnaCn hookJW9Kkun1/J10pcsOVJSYtYjPVO3ij8CLqVoa+cmQPbG+9h2ehXaBe8yp4BMnZMKRo1 TMz4pzH2tYjO9/nPwlK8J4nN7yLjx8I= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-539-QVN2FGJEMnaeQFscQ9FzNQ-1; Thu, 29 Aug 2024 10:18:54 -0400 X-MC-Unique: QVN2FGJEMnaeQFscQ9FzNQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-42b929d654bso7133295e9.1 for ; Thu, 29 Aug 2024 07:18:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724941133; x=1725545933; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YtYR/gGTmDbAPYmIYRccbXqwblJKOZwAhQg2Y6pwqmg=; b=TJ9TTvSIomxp8UNvJTtpC6XqVgsJkXWSJ6aF1DDWpQzSdx7VgrGqEi7J/nrZ0LhKjD 20GgkmeLACwyzh+HoSDih8gMilI+LqY9iehGhok9KgDtGu+LYwAGQ2n1qa42qSnO//vZ fSj9AisNzJM8adTqDaDd7uMAp0+AarIb0c9mZLzzN4pWEpzAlwqU0JrcX/cnrBN4p9yF NHOOIjNa8mu5lhwGw0bvJZ9ygP4aeQu3MJQYJGe4DWg/InKbF2CRqSfyJJBHd66lMOtL buoKB/3WGkx6ke9irMbidQgSOmd4FXynaS8sew3V7T+On6i0zJ4UDpT2+RM4/jRbnv0l LaLg== X-Forwarded-Encrypted: i=1; AJvYcCWy0q5LewiX/FyRRIZNTHnzQ4S8tEe2zkH07eAr4DIrchNZbhO/XP45tLV4YNcrvOu1Yhht2BZYxoDJ@vger.kernel.org X-Gm-Message-State: AOJu0Yx4FBZ8nQQe4qKJcxikunN2b3KoPi2oUdQ5fc6xDg2nEsThSltd HDyZzGWsMyfHbs/xxJ0y/fUVMLp7XnwrSLEpxxr9Lzf1hLnuz3gpyMSZaYUSHqcnWJA9N3M3BDW vMgdF0rnyWaWq55LpQtnXUh8Xhe2eiqjIaUDk6nABxFEkrAsC0iVYagL1oHw= X-Received: by 2002:a7b:c449:0:b0:42b:aecb:d280 with SMTP id 5b1f17b1804b1-42bb27a1021mr25083855e9.27.1724941133424; Thu, 29 Aug 2024 07:18:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGM4L32QAy6bG5zGi4CSR/e0PXgXREM2OUI07zkgBOIcbPjvtDeXtGrw5+r/WVKmA9y9IZ/KA== X-Received: by 2002:a7b:c449:0:b0:42b:aecb:d280 with SMTP id 5b1f17b1804b1-42bb27a1021mr25083605e9.27.1724941132945; Thu, 29 Aug 2024 07:18:52 -0700 (PDT) Received: from eisenberg.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63abebdsm52670425e9.27.2024.08.29.07.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 07:18:52 -0700 (PDT) From: Philipp Stanner To: Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Damien Le Moal , Hannes Reinecke , John Garry , Philipp Stanner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH v5 3/7] block: mtip32xx: Replace deprecated PCI functions Date: Thu, 29 Aug 2024 16:16:22 +0200 Message-ID: <20240829141844.39064-4-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829141844.39064-1-pstanner@redhat.com> References: <20240829141844.39064-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pcim_iomap_regions() and pcim_iomap_table() have been deprecated by the PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()"). In mtip32xx, these functions can easily be replaced by their respective successors, pcim_request_region() and pcim_iomap(). Moreover, the driver's calls to pcim_iounmap_regions() in probe()'s error path and in remove() are not necessary. Cleanup can be performed by PCI devres automatically. Replace pcim_iomap_regions() and pcim_iomap_table(). Remove the calls to pcim_iounmap_regions(). Signed-off-by: Philipp Stanner Reviewed-by: Andy Shevchenko Reviewed-by: Jens Axboe --- drivers/block/mtip32xx/mtip32xx.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index c6ef0546ffc9..e4331b065a5e 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -2716,7 +2716,9 @@ static int mtip_hw_init(struct driver_data *dd) int rv; unsigned long timeout, timetaken; - dd->mmio = pcim_iomap_table(dd->pdev)[MTIP_ABAR]; + dd->mmio = pcim_iomap(dd->pdev, MTIP_ABAR, 0); + if (!dd->mmio) + return -ENOMEM; mtip_detect_product(dd); if (dd->product_type == MTIP_PRODUCT_UNKNOWN) { @@ -3722,14 +3724,14 @@ static int mtip_pci_probe(struct pci_dev *pdev, rv = pcim_enable_device(pdev); if (rv < 0) { dev_err(&pdev->dev, "Unable to enable device\n"); - goto iomap_err; + goto setmask_err; } - /* Map BAR5 to memory. */ - rv = pcim_iomap_regions(pdev, 1 << MTIP_ABAR, MTIP_DRV_NAME); + /* Request BAR5. */ + rv = pcim_request_region(pdev, MTIP_ABAR, MTIP_DRV_NAME); if (rv < 0) { - dev_err(&pdev->dev, "Unable to map regions\n"); - goto iomap_err; + dev_err(&pdev->dev, "Unable to request regions\n"); + goto setmask_err; } rv = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); @@ -3849,9 +3851,6 @@ static int mtip_pci_probe(struct pci_dev *pdev, drop_cpu(dd->work[2].cpu_binding); } setmask_err: - pcim_iounmap_regions(pdev, 1 << MTIP_ABAR); - -iomap_err: kfree(dd); pci_set_drvdata(pdev, NULL); return rv; @@ -3925,7 +3924,6 @@ static void mtip_pci_remove(struct pci_dev *pdev) pci_disable_msi(pdev); - pcim_iounmap_regions(pdev, 1 << MTIP_ABAR); pci_set_drvdata(pdev, NULL); put_disk(dd->disk); From patchwork Thu Aug 29 14:16:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 824448 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D6E11B29B3 for ; Thu, 29 Aug 2024 14:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941140; cv=none; b=ekvK2HyZdpT48RXhvg7W0uthpm9iGyepf+DhommHSm2RvWbeqDVrDyeBdWDey4GtcejR7otDD0rf8cgBaKoBs5ns5hPNb0K2U1sKVM1HIcmRjpkJUHwnd8fjI76ido8tntnew01SHuRYSJsBK7HakX5nR22G3nr86u2rUX5qCrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941140; c=relaxed/simple; bh=Fc7LqA4dsnee2e9i3xlXjC/frSEy4rrwVedoLFfxfmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qr8ABBO4y/spjxzhGQCvFwgZZEe+mWuZCWMYLxnEp7lNOzd9W3q+BmMtCJqg85dLCqz1DGX949lg6rtW1CBxU8n7lye8KHTVbVt7r8m4Tlh1htVJ19TQIjwC8rAzubDQTl68d0zxnwuCgTPno6dCYiHv7TkrfgTmYPA5jE9TZeo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ErAbAP7T; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ErAbAP7T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724941137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/H9qQSvRoJEHuC9fzeIRZ7nyD5NIc+bT7koxtRIZd8A=; b=ErAbAP7TsDCT7KhAyJmeVt9ChwTVkGjAWh6n7/3GUBgQq+T6svF4dmP+ZKUxDUrqy/+cuh A06/s7ZCg0iUwpn6XM0ThzBwgdMopkCuRY9MGJaUArmdQppQceW8/V9knjDg2Eqtd/kZ72 5yROY3GNnH1UMCXj12WvVcQ6u46D4nA= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-ev7JTc7ROpSJ3rT6L-ZfUg-1; Thu, 29 Aug 2024 10:18:56 -0400 X-MC-Unique: ev7JTc7ROpSJ3rT6L-ZfUg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-42809eb7b99so4692315e9.0 for ; Thu, 29 Aug 2024 07:18:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724941135; x=1725545935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/H9qQSvRoJEHuC9fzeIRZ7nyD5NIc+bT7koxtRIZd8A=; b=jNRc11NwB1Jorbg7oT0jTOReFq0AYhHwmBNGfK+HDj8EX3iEPBg8uzY+FAdyhgXAau ghTkmRRlLS8zVGtdR9EWWgxaeOc7czxN8bQZepmD3mED/IbwSDkkRY330oRlqJdUX3Yt wZskW4YMr6u50c3P6Nzsape1iPPp687HQ+cgPDkUAJIP5lfeOPDomCHs5Mt+Yo3W12AD 19onLyCJJlfAtsj9DA6o+LaTekMe/cghackGaKv5kupsEvpaWFqdUxFgK1fMh3lrvU8A fZ8FLmNMz7hyEkeZtyL2KlxGNDDptwsBde1XdqQnE4Y9N76WynMeDrl9j3jQU3tROFMa L3Zw== X-Forwarded-Encrypted: i=1; AJvYcCW5Y6qQeWZSS180QJE96S0D3CFBTwQnd/3tn26smg07Pw2AYOF5t9Lr/vB+VRv5b+2q5WfPNLCLcOMu@vger.kernel.org X-Gm-Message-State: AOJu0YyjvQ0NfDiV66sxXKAMpPK7D1pi0ETSP8JySD4oxRUpi17FJ0kt kVVQDNgPyTeInr7Qec+LMvA92TkVkF7vzIP6B5iC0ox2fHIagTVG+ROhOrt/vu0o2KKqmdVCEvV 1/90+xer0KtRAIS3W+5xAKGxPa6StxFWQUrP0yiodJ/Ur3FyF75xuQJjxKLs= X-Received: by 2002:a05:600c:3d16:b0:42a:a749:e6 with SMTP id 5b1f17b1804b1-42bb74403eemr18537985e9.10.1724941135155; Thu, 29 Aug 2024 07:18:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5CyqY/wd5nkLrhi1KCiNw1KCCPc5Bn48lyL/rJpYaGF/BSmvD7WGs5d/ldDgSNQeuDENYTQ== X-Received: by 2002:a05:600c:3d16:b0:42a:a749:e6 with SMTP id 5b1f17b1804b1-42bb74403eemr18537655e9.10.1724941134717; Thu, 29 Aug 2024 07:18:54 -0700 (PDT) Received: from eisenberg.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63abebdsm52670425e9.27.2024.08.29.07.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 07:18:54 -0700 (PDT) From: Philipp Stanner To: Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Damien Le Moal , Hannes Reinecke , John Garry , Philipp Stanner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, Bartosz Golaszewski Subject: [PATCH v5 4/7] gpio: Replace deprecated PCI functions Date: Thu, 29 Aug 2024 16:16:23 +0200 Message-ID: <20240829141844.39064-5-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829141844.39064-1-pstanner@redhat.com> References: <20240829141844.39064-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pcim_iomap_regions() and pcim_iomap_table() have been deprecated by the PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()"). Replace those functions with calls to pcim_iomap_region(). Signed-off-by: Philipp Stanner Reviewed-by: Andy Shevchenko Acked-by: Bartosz Golaszewski --- drivers/gpio/gpio-merrifield.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpio-merrifield.c b/drivers/gpio/gpio-merrifield.c index 421d7e3a6c66..274afcba31e6 100644 --- a/drivers/gpio/gpio-merrifield.c +++ b/drivers/gpio/gpio-merrifield.c @@ -78,24 +78,24 @@ static int mrfld_gpio_probe(struct pci_dev *pdev, const struct pci_device_id *id if (retval) return retval; - retval = pcim_iomap_regions(pdev, BIT(1) | BIT(0), pci_name(pdev)); - if (retval) - return dev_err_probe(dev, retval, "I/O memory mapping error\n"); - - base = pcim_iomap_table(pdev)[1]; + base = pcim_iomap_region(pdev, 1, pci_name(pdev)); + if (IS_ERR(base)) + return dev_err_probe(dev, PTR_ERR(base), "I/O memory mapping error\n"); irq_base = readl(base + 0 * sizeof(u32)); gpio_base = readl(base + 1 * sizeof(u32)); /* Release the IO mapping, since we already get the info from BAR1 */ - pcim_iounmap_regions(pdev, BIT(1)); + pcim_iounmap_region(pdev, 1); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->dev = dev; - priv->reg_base = pcim_iomap_table(pdev)[0]; + priv->reg_base = pcim_iomap_region(pdev, 0, pci_name(pdev)); + if (IS_ERR(priv->reg_base)) + return dev_err_probe(dev, PTR_ERR(base), "I/O memory mapping error\n"); priv->pin_info.pin_ranges = mrfld_gpio_ranges; priv->pin_info.nranges = ARRAY_SIZE(mrfld_gpio_ranges); From patchwork Thu Aug 29 14:16:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 823655 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 614111B1505 for ; Thu, 29 Aug 2024 14:19:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941142; cv=none; b=fXNHNVXkUDZwPC8dQe+VXpecchr5AsuLcGVwyc3ghhXvCc4RkLpWJH54NfIM6LpfQrQVMQKibt+WTmpIS3tIRhbKHqBUN6ITfFMOg9Buptb3+ZkuNm2W29YhoxKvGqAHrO71FQVsOdxrVyg1vTjFTGL0QJZ+XEYPcigAH6UVbtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941142; c=relaxed/simple; bh=nzy04PgDjxRp4clOpzx7ZwAQtwC8BOnrH0UdBVVoGHw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hktd+WLvcX50bHoznCvbFLLTVyU10giSEdHmKUTZbfA8QJTLJQPiVT4RV8U4adyJlbdUqq29JRXGp4B5xpg3PBXA/8MVn2UmdcNNFOqHHtIRHiND7pK8PX1DQqykCBaY8jex3LJ54BRzT9EXvvlZ6z+gAM78gGWFcOB9FRWXy58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ELZn2oHk; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ELZn2oHk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724941139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=osuRWDMAcWp5GKuvb2jQp7XxiFBFhqIKDkkqm4u4oTc=; b=ELZn2oHkwFpBO06izRWY/dmYlxh11Gnowgq4+iJ1tP7NpNoy19z13508x1uICYiwK+5Fcu Cd7j7tYtS08FdEVXBrXVo5lZ5IVlaYvVPfuUb8WeLVjPr79MnbuT/qu14oNLxELUtCoyLd uMATzfdhuwG4fMrKtOzBG/Ir7KLXU6M= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-454-frXpuXd5OoCpnHutGLcQKA-1; Thu, 29 Aug 2024 10:18:58 -0400 X-MC-Unique: frXpuXd5OoCpnHutGLcQKA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4280a434147so7322025e9.3 for ; Thu, 29 Aug 2024 07:18:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724941137; x=1725545937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=osuRWDMAcWp5GKuvb2jQp7XxiFBFhqIKDkkqm4u4oTc=; b=bp+h17Iuet+gDIEH3Y8q764scQGEVbEWSM30oFaPoj2zb5kxmP7hAloqHN8Z8muzXB X075K5CSBurMfGSzmtYysKmGKu5gfm3w4cebA/HuSfzeWi0znF4MD9MGGu7cZi5c/ULc X5yMM/9hzkXWbKnLeO6HHSfcJKr9kDzuTMT97ZJY5EYKVXX+fc5+56X+9Y2UyMt1v2uK pfsRlC5TrDPlRkQobpLdfIHG9Eu3CByVHkIg6hXCnoCWL3hWl2Ten1NucfqB6u9+sztR TyPJ6NWDte8l5uVGprYtJa3nO7Y8EJxnFotQvGOoiB1FCsr92E7JkWDtw0MLoUolgRA2 ZVvw== X-Forwarded-Encrypted: i=1; AJvYcCX5Wal5QsTQuj/KwbMj4U623lFO91cZaglaHBrvN6uGyxt8rqlapEOpOO5pYwlnUFBSSDvUGsMSvOWh@vger.kernel.org X-Gm-Message-State: AOJu0YxBSQ8fXUL2uXdDexVrspDVCpsOcEMX2a+VQ3DvJAkOpca3x3Um PVNTFiILpiBQiK9Ko/X8+wUzeS4OcG4UqtNmsdYS39eT0TIUKyvvaEvNsiRxnG7ngQbe7noTQ++ 77K+zSVkTHWj9J21HzeR77Ig9Da/kQlVBfbiocq73VuMB9Bucqr47WvCf7mg= X-Received: by 2002:adf:f24c:0:b0:371:8e8b:39d4 with SMTP id ffacd0b85a97d-3749b5503f3mr2024887f8f.28.1724941136561; Thu, 29 Aug 2024 07:18:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYRK3DCkIWLqUxz0XY2NMNmO7BWhVLf+DW2Gbx1uLqQ4PTQOElvgJY4ok5jVfTKZaAWaobsQ== X-Received: by 2002:adf:f24c:0:b0:371:8e8b:39d4 with SMTP id ffacd0b85a97d-3749b5503f3mr2024838f8f.28.1724941136092; Thu, 29 Aug 2024 07:18:56 -0700 (PDT) Received: from eisenberg.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63abebdsm52670425e9.27.2024.08.29.07.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 07:18:55 -0700 (PDT) From: Philipp Stanner To: Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Damien Le Moal , Hannes Reinecke , John Garry , Philipp Stanner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH v5 5/7] ethernet: cavium: Replace deprecated PCI functions Date: Thu, 29 Aug 2024 16:16:24 +0200 Message-ID: <20240829141844.39064-6-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829141844.39064-1-pstanner@redhat.com> References: <20240829141844.39064-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pcim_iomap_regions() and pcim_iomap_table() have been deprecated by the PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()"). Furthermore, the driver contains an unneeded call to pcim_iounmap_regions() in its probe() function's error unwind path. Replace the deprecated PCI functions with pcim_iomap_region(). Remove the unnecessary call to pcim_iounmap_regions(). Signed-off-by: Philipp Stanner --- drivers/net/ethernet/cavium/common/cavium_ptp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cavium/common/cavium_ptp.c b/drivers/net/ethernet/cavium/common/cavium_ptp.c index 9fd717b9cf69..984f0dd7b62e 100644 --- a/drivers/net/ethernet/cavium/common/cavium_ptp.c +++ b/drivers/net/ethernet/cavium/common/cavium_ptp.c @@ -239,12 +239,11 @@ static int cavium_ptp_probe(struct pci_dev *pdev, if (err) goto error_free; - err = pcim_iomap_regions(pdev, 1 << PCI_PTP_BAR_NO, pci_name(pdev)); + clock->reg_base = pcim_iomap_region(pdev, PCI_PTP_BAR_NO, pci_name(pdev)); + err = PTR_ERR_OR_ZERO(clock->reg_base); if (err) goto error_free; - clock->reg_base = pcim_iomap_table(pdev)[PCI_PTP_BAR_NO]; - spin_lock_init(&clock->spin_lock); cc = &clock->cycle_counter; @@ -292,7 +291,7 @@ static int cavium_ptp_probe(struct pci_dev *pdev, clock_cfg = readq(clock->reg_base + PTP_CLOCK_CFG); clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN; writeq(clock_cfg, clock->reg_base + PTP_CLOCK_CFG); - pcim_iounmap_regions(pdev, 1 << PCI_PTP_BAR_NO); + pcim_iounmap_region(pdev, PCI_PTP_BAR_NO); error_free: devm_kfree(dev, clock); From patchwork Thu Aug 29 14:16:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 824447 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 500751B3F00 for ; Thu, 29 Aug 2024 14:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941144; cv=none; b=ep5d2qZzXq72JDEiBZgAvZq833lSmG3rhaNR6F0lii2y3slF0hLePEP9XIe807xIBiu7SyHRRbbkc4+68VIER8YSA7C7XF0edaSwLm3DMmSg6BFUQfzngqS797VTyxWpG6m8aN/bmWH1rOPmrsYqm5KLguvtuf4VtNqiVgVi2G8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941144; c=relaxed/simple; bh=JMbg4eMibkjbCBRT/iJAl8N9RNBguY/qcuyAy9Bi6uc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FVfa5jKAp5gac3yEaLYSN8Am2UCZbi4sxjn4jk6M+liYEBI1rDi/J3MhRSHm3UE5/LFEs+J8V9JhGDRrGT+xUoRYsvvR95suk4Mn6/naPQg1pPg+cLgaX+d227XOM897vm4EWv87gTQ1Hj5XHCrW7Yhrw0BGCHM8wHlX7AEV9JM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=das9/IeG; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="das9/IeG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724941140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=326BlglD5Q8k45ugPSVf+4k9+mzBOEJ61jidx8Y66gA=; b=das9/IeGMNnFFBjOeUlfOW2/Z2+KZF9NZx7lKylCVnc9Rqoda70c0djkWZpdWoO/vUY9Zs 31G6z6SLWjtgV6Xw72tw85qq87pf2sjBIqCjrOeIqHQsiOf/l0txl7PZBzlMKzK6WZ91Ae vsiG+v81Du/3CRFwmeCqiuZn6liLwJM= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-3TypUekKPYW5cVggPZhgaA-1; Thu, 29 Aug 2024 10:18:59 -0400 X-MC-Unique: 3TypUekKPYW5cVggPZhgaA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-371b28fc739so488874f8f.1 for ; Thu, 29 Aug 2024 07:18:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724941138; x=1725545938; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=326BlglD5Q8k45ugPSVf+4k9+mzBOEJ61jidx8Y66gA=; b=mc8CIW/NWDjcToVOuOju7cO0t9sgfnLAUOqdjvxQ6r4ze5j65C/zfbBaIcmouoWhmy KNbflMexlD3CzLgY6mKi4+mXlufsE1WKV6n9rrmd8lCbIRyF6O5rypx4RhgV3hidXJRB UISYuvVoJDDMQ4gEnkT7gHlxbUQnJFsMYp9IResO7U2A+pwKi+kaAecjC8BXrj3j7HLg My2n7UUCM7A0PBni46Ke6pwRBUuW3AN7e7bxgAmNfpJM8KI9pbTmaOh3vvVXeB0BRxU5 /H/VgCJN0fLLzLQR5YH6LkgixFl43YM5V1D/6jNjDNIdaVBnWG4LdmROwOg2bgzpX+W0 QNsw== X-Forwarded-Encrypted: i=1; AJvYcCUnVRb2WXMrWmprBdrTM6nn/NHg5ueh55MSlp078aqrCdWi+Z/jONfjXxoBqTF3IHTsTocHp6lWjbNt@vger.kernel.org X-Gm-Message-State: AOJu0YxUdjEwplYrzWajGeEB3NxEQlSGrt+fF5FnPzp7dt5Msase+jaE jDfRIfDUAnN6xCzp8Ngnj1wYnczr3bINDgxvRnYP/uvezYuiUuEY/951A46KuODJw122zoICO/J tdD3ifdAYIHVVPwhLG5P+TFTnafay/U+O9VDKsq5Dnb9utzzz3H1sz445voY= X-Received: by 2002:a5d:6588:0:b0:367:8418:fde4 with SMTP id ffacd0b85a97d-3749fe45f69mr1407084f8f.7.1724941138019; Thu, 29 Aug 2024 07:18:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGf/Cvj3uFdDafG6t/JWOmnytGzmW7NR6oQDE7fLIyJIivUhu4hLbo/UyEzITWoKFSXYk+WIQ== X-Received: by 2002:a5d:6588:0:b0:367:8418:fde4 with SMTP id ffacd0b85a97d-3749fe45f69mr1407017f8f.7.1724941137555; Thu, 29 Aug 2024 07:18:57 -0700 (PDT) Received: from eisenberg.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63abebdsm52670425e9.27.2024.08.29.07.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 07:18:57 -0700 (PDT) From: Philipp Stanner To: Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Damien Le Moal , Hannes Reinecke , John Garry , Philipp Stanner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev, stable@vger.kernel.org, Christophe JAILLET Subject: [PATCH v5 6/7] vdpa: solidrun: Fix UB bug with devres Date: Thu, 29 Aug 2024 16:16:25 +0200 Message-ID: <20240829141844.39064-7-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829141844.39064-1-pstanner@redhat.com> References: <20240829141844.39064-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In psnet_open_pf_bar() and snet_open_vf_bar() a string later passed to pcim_iomap_regions() is placed on the stack. Neither pcim_iomap_regions() nor the functions it calls copy that string. Should the string later ever be used, this, consequently, causes undefined behavior since the stack frame will by then have disappeared. Fix the bug by allocating the strings on the heap through devm_kasprintf(). Cc: stable@vger.kernel.org # v6.3 Fixes: 51a8f9d7f587 ("virtio: vdpa: new SolidNET DPU driver.") Reported-by: Christophe JAILLET Closes: https://lore.kernel.org/all/74e9109a-ac59-49e2-9b1d-d825c9c9f891@wanadoo.fr/ Suggested-by: Andy Shevchenko Signed-off-by: Philipp Stanner --- drivers/vdpa/solidrun/snet_main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/vdpa/solidrun/snet_main.c b/drivers/vdpa/solidrun/snet_main.c index 99428a04068d..c8b74980dbd1 100644 --- a/drivers/vdpa/solidrun/snet_main.c +++ b/drivers/vdpa/solidrun/snet_main.c @@ -555,7 +555,7 @@ static const struct vdpa_config_ops snet_config_ops = { static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) { - char name[50]; + char *name; int ret, i, mask = 0; /* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. @@ -573,7 +573,10 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) return -ENODEV; } - snprintf(name, sizeof(name), "psnet[%s]-bars", pci_name(pdev)); + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev)); + if (!name) + return -ENOMEM; + ret = pcim_iomap_regions(pdev, mask, name); if (ret) { SNET_ERR(pdev, "Failed to request and map PCI BARs\n"); @@ -590,10 +593,13 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) static int snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet) { - char name[50]; + char *name; int ret; - snprintf(name, sizeof(name), "snet[%s]-bar", pci_name(pdev)); + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "snet[%s]-bars", pci_name(pdev)); + if (!name) + return -ENOMEM; + /* Request and map BAR */ ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name); if (ret) { From patchwork Thu Aug 29 14:16:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 823654 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 654201B29D4 for ; Thu, 29 Aug 2024 14:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941145; cv=none; b=Se0HcqDlneADqf+06XyRECOhzfVPKKNvbDgfKqG94cLp5uleBkffobsIkIP8/RTUHvZoCwAZ0G0Q7SUiJ2FC7cRY1voJOhH7N6+9xL/VF2s02uk/ymflJ8zn9SI7hnINTLs3QTGmdfRQ9pytTUZwHRZfEKJL2fG/WhVrznN5yDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724941145; c=relaxed/simple; bh=DthlLOD0XWT9pUXf24uzdmG5D5JXhN126raQjVqCgeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FBIi/qL2+26T11ylkRkVWZL3sWzGOmT/yaeco4Bq70+fmXPW9iLJ2Qd/rg9ZGBD/1OmzQYI0jQ/jZiVaZNz/EHiBIDRC7F+5925X1YWqfncGzCSD09WXRwTQc/bK1S46b4KZYZpUrPAgCwDAXpxLt6V5C+8DP6Q9PC+OUt9FJLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GZ7ZlKMg; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GZ7ZlKMg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724941142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wt2kRlQoJgJxTzxQjhrYYWN0zj4xz5nEsQIR91A/520=; b=GZ7ZlKMgT48O0gwGI7prQRa8WDJvAsnXIOGSxVSJmcNjHsDRcEn0JBNyRBRp3xKzFeq8cV 15/VuJkaMGwzTdFyHuGtY/9QeQLip3yjSsyYo5Vgsi6OC4fV8fR/YE/0P40cLmGj4vC1VK 0jqITKNzKQJ1LnbSKrYFso+jr6ZDOnE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-rLO7YbV5Nwejc7N90dHdkQ-1; Thu, 29 Aug 2024 10:19:01 -0400 X-MC-Unique: rLO7YbV5Nwejc7N90dHdkQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3718eb22836so448159f8f.3 for ; Thu, 29 Aug 2024 07:19:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724941140; x=1725545940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wt2kRlQoJgJxTzxQjhrYYWN0zj4xz5nEsQIR91A/520=; b=V4SQpOE0Ske/OemKhJDCWfJEZbI6pZwZ5YFEeY2aXwIIX8h4lyTZ27RFQ5pgByx9g/ MHIYtsGvRVAYh/32WaVce/WtIrB3ZfF+jnWsBue3wIhkcd9y2JFlUeK6MooCAhWjgMJY Aj88dJYFeLZY/LHDtRE+6xxphAeeDkUxXZ3X0JUdoABUdv329Be5OdbY1IVyg9g5qQ9x UK3OWoFyTPr6BPq2vZRFkHSj2+uF7z0ht5kdknbEfEKgzvYiedN90TsfygL65fkaB2IG KC6HxNg+7Nf4fxb3ux060RNf19emdLJXiOt5XDdWUUL9R2n8zVmd0IEHL+0mMqr2r8NQ +2SQ== X-Forwarded-Encrypted: i=1; AJvYcCU9MN0LdugNIJaYXDi0DtUQwE5A/qC4XyVhU3SjcU6qnxf8s8D7mSCya1sh7oxc3D1MHmxzYR1FjWBz@vger.kernel.org X-Gm-Message-State: AOJu0YxtqDx1wyx79fWCgufx0JPWXTncCKFqDA8rKSMr7mf84Vu2tZn2 ZJVizJLM4g00D6mqOJ4gSapYiBaAhLBW7Dgomo/RH04/VSb+3w068KEBGLAS05CywyGmNvXk7OA GJ8kmqbLPrDdReZ9uxZwBFtw4KiERPZHkCQ3LB3deM+8lKVz+rdjOnQRkPFo= X-Received: by 2002:a5d:588c:0:b0:371:a8a3:f9a1 with SMTP id ffacd0b85a97d-3749b52ec54mr2845192f8f.11.1724941139757; Thu, 29 Aug 2024 07:18:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVKE4GA6MoFtMHaGld6Pjw11VpfoD8Zbo28+LZWJJjSK41LEicR+xodyvjjYoPw88n/IlaOg== X-Received: by 2002:a5d:588c:0:b0:371:a8a3:f9a1 with SMTP id ffacd0b85a97d-3749b52ec54mr2845129f8f.11.1724941139264; Thu, 29 Aug 2024 07:18:59 -0700 (PDT) Received: from eisenberg.muc.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ba63abebdsm52670425e9.27.2024.08.29.07.18.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 07:18:58 -0700 (PDT) From: Philipp Stanner To: Jens Axboe , Wu Hao , Tom Rix , Moritz Fischer , Xu Yilun , Andy Shevchenko , Linus Walleij , Bartosz Golaszewski , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Damien Le Moal , Hannes Reinecke , John Garry , Philipp Stanner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH v5 7/7] vdap: solidrun: Replace deprecated PCI functions Date: Thu, 29 Aug 2024 16:16:26 +0200 Message-ID: <20240829141844.39064-8-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240829141844.39064-1-pstanner@redhat.com> References: <20240829141844.39064-1-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 solidrun utilizes pcim_iomap_regions(), which has been deprecated by the PCI subsystem in commit e354bb84a4c1 ("PCI: Deprecate pcim_iomap_table(), pcim_iomap_regions_request_all()"), among other things because it forces usage of quite a complicated bitmask mechanism. The bitmask handling code can entirely be removed by replacing pcim_iomap_regions() and pcim_iomap_table(). Replace pcim_iomap_regions() and pcim_iomap_table() with pcim_iomap_region(). Signed-off-by: Philipp Stanner --- drivers/vdpa/solidrun/snet_main.c | 53 +++++++++++-------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/drivers/vdpa/solidrun/snet_main.c b/drivers/vdpa/solidrun/snet_main.c index c8b74980dbd1..2b7ff071aab9 100644 --- a/drivers/vdpa/solidrun/snet_main.c +++ b/drivers/vdpa/solidrun/snet_main.c @@ -556,36 +556,25 @@ static const struct vdpa_config_ops snet_config_ops = { static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) { char *name; - int ret, i, mask = 0; + unsigned short i; + + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev)); + if (!name) + return -ENOMEM; + /* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. * * Later, we will discover the BAR and unmap all other BARs. */ for (i = 0; i < PCI_STD_NUM_BARS; i++) { - if (pci_resource_len(pdev, i)) - mask |= (1 << i); - } - - /* No BAR can be used.. */ - if (!mask) { - SNET_ERR(pdev, "Failed to find a PCI BAR\n"); - return -ENODEV; - } - - name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev)); - if (!name) - return -ENOMEM; - - ret = pcim_iomap_regions(pdev, mask, name); - if (ret) { - SNET_ERR(pdev, "Failed to request and map PCI BARs\n"); - return ret; - } - - for (i = 0; i < PCI_STD_NUM_BARS; i++) { - if (mask & (1 << i)) - psnet->bars[i] = pcim_iomap_table(pdev)[i]; + if (!pci_resource_len(pdev, i)) + continue; + psnet->bars[i] = pcim_iomap_region(pdev, i, name); + if (IS_ERR(psnet->bars[i])) { + SNET_ERR(pdev, "Failed to request and map PCI BARs\n"); + return PTR_ERR(psnet->bars[i]); + } } return 0; @@ -594,21 +583,18 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) static int snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet) { char *name; - int ret; name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "snet[%s]-bars", pci_name(pdev)); if (!name) return -ENOMEM; /* Request and map BAR */ - ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name); - if (ret) { + snet->bar = pcim_iomap_region(pdev, snet->psnet->cfg.vf_bar, name); + if (IS_ERR(snet->bar)) { SNET_ERR(pdev, "Failed to request and map PCI BAR for a VF\n"); - return ret; + return PTR_ERR(snet->bar); } - snet->bar = pcim_iomap_table(pdev)[snet->psnet->cfg.vf_bar]; - return 0; } @@ -656,15 +642,12 @@ static int psnet_detect_bar(struct psnet *psnet, u32 off) static void psnet_unmap_unused_bars(struct pci_dev *pdev, struct psnet *psnet) { - int i, mask = 0; + unsigned short i; for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (psnet->bars[i] && i != psnet->barno) - mask |= (1 << i); + pcim_iounmap_region(pdev, i); } - - if (mask) - pcim_iounmap_regions(pdev, mask); } /* Read SNET config from PCI BAR */