From patchwork Wed Aug 21 07:18:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 13770949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7522BC52D6F for ; Wed, 21 Aug 2024 07:25:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2jtoMc9tojKKL8iwWeM5ToAOyUwxh+I3f+1WrHk/fN0=; b=m//YdwRpJy0qUQdUg2Zb4LLLrL n2YBAl4wgJDHGnBpy5ZQIAr40Fd9y0pIzG9+7cLv+GIEEm7m0i6ZRmAObz0i7Bt15Yc+2t0HZ8AAj pnkAA2+ma1/aSNgwk3cWAUyQezChNDGwJB2yLbS1iFSKmJXjdP/8nvypSaj9QXa0JBjPP4jI1gwb3 uJ3za2zqa62MfiGcjCQX16ccCKH3pOsSiFtwuygCa+uimyyNQLzt4z09HnbL+wKdqTmGc+H2FBH99 pgP/ITeHm/21KCf8hf7xSMltEPAxh6S2js2VaaXR4lZcazJ1ySClN5sJP1+t6zjv6RoxvDLsRAtuG 7287eMiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgfik-00000007trb-1IvB; Wed, 21 Aug 2024 07:25:30 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgfdA-00000007rpW-2qnS for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 07:19:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724224783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2jtoMc9tojKKL8iwWeM5ToAOyUwxh+I3f+1WrHk/fN0=; b=AxZ2gEWIMUvYcT28q7etkRMjh44G/Cz9cyDiK5kXTZimlrRHFfxyCRq2RZWPRPEApeSE+v aRl0Zv0aASYEUdkxIATqIuLiows1T5e0OCU7vdY2F+D/LvSR8o9aPQAdwdeKKQ1yaQW0c/ CWUb4g0vR2K15SZgrs1S4uEGCtvWNZE= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-biSFik4gMxuU5OZvci_vkA-1; Wed, 21 Aug 2024 03:19:42 -0400 X-MC-Unique: biSFik4gMxuU5OZvci_vkA-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7a66b52c944so134578585a.1 for ; Wed, 21 Aug 2024 00:19:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724224782; x=1724829582; 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=2jtoMc9tojKKL8iwWeM5ToAOyUwxh+I3f+1WrHk/fN0=; b=wd3r3Q90jUKsz2w4tSU6l4lWJwBF9QpbNY/3JaaS2KKku/VXHWCuQsxpc7XmPzNV3R AY/sqNzNnxa6hD1KwWw1sXyZW3irSWphaOoHPj9T83D+YBsjxZkrH140/ujx84udbdoI CpAZENO/LLgxqkU56vFKs+oauGqvGrOa1b8XSFR2Lrlnpx/TEUiFxrcw2ogbNmvAh8nP Q3Pcz+/L8LpmylO0matP/DfDWdZChYujClA8v1QGVURa/vlluaBUJlZnuJbbI2QJdlw3 WN8A1/7DNBem/lzATir6TF/UfeKWdE5vc0FpLc+7TbYmqoNZME5brAp7UL7hVuP2xmHp E9Tw== X-Forwarded-Encrypted: i=1; AJvYcCU5rqzFYmUR8LknBj7tPOaU4Mbnl86Bz0UTFchvwjKwYmb6/ZY35ySFHerhi8cpO4fngXVc6rBJfaVlJ0Kh2njv@lists.infradead.org X-Gm-Message-State: AOJu0YzIOEzbpn637DV/k3XReVbatwQJYky8QSqwpZRlbhsTA3q1HGtx 8ADka+wPiEVMXCLaAgWHFkXbRXvZ5sVSldaeIjUnnYid6TJJUpnrhX99LwuB6NPKoRbXfcmEc8B QqqcXm2so8irqUTSrsCJBSj5C4h2XRVvhvc5Kf6Y4FbPPzTduPux1q/JLko29ENWhtXz7oOZJ X-Received: by 2002:a05:620a:3953:b0:79e:e302:7392 with SMTP id af79cd13be357-7a674047d68mr175953485a.32.1724224781995; Wed, 21 Aug 2024 00:19:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEujbivdy0X82ZZM2IZtk3pa0uY+R6FAaLiHcgNfg5GEA0wo0Jm6V+lDWsOUg8+jqkxdP5bpA== X-Received: by 2002:a05:620a:3953:b0:79e:e302:7392 with SMTP id af79cd13be357-7a674047d68mr175949285a.32.1724224781630; Wed, 21 Aug 2024 00:19:41 -0700 (PDT) Received: from eisenberg.redhat.com (nat-pool-muc-t.redhat.com. [149.14.88.26]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff013ef2sm596207885a.11.2024.08.21.00.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2024 00:19:41 -0700 (PDT) From: Philipp Stanner To: Jonathan Corbet , 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 , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Bjorn Helgaas , Alvaro Karsz , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Richard Cochran , Mark Brown , David Lechner , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Philipp Stanner , Damien Le Moal , Hannes Reinecke , Keith Busch Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fpga@vger.kernel.org, linux-gpio@vger.kernel.org, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, virtualization@lists.linux.dev Subject: [PATCH v2 8/9] vdap: solidrun: Replace deprecated PCI functions Date: Wed, 21 Aug 2024 09:18:41 +0200 Message-ID: <20240821071842.8591-10-pstanner@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240821071842.8591-2-pstanner@redhat.com> References: <20240821071842.8591-2-pstanner@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_001944_820266_7EE4B13B X-CRM114-Status: GOOD ( 19.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 pci_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 4d42a05d70fc..ce336f261649 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; - /* 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; - } + unsigned short i; 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; - } - + /* 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 (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,18 +583,15 @@ 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]; - int ret; snprintf(name, sizeof(name), "snet[%s]-bar", pci_name(pdev)); /* 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; } @@ -653,15 +639,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; + int 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 */