From patchwork Wed Aug 7 08:30:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Stanner X-Patchwork-Id: 13755957 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 D75A61CCB22 for ; Wed, 7 Aug 2024 08:30:31 +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=1723019433; cv=none; b=P0VBg9RHfHLlS4xWNku4PUNjOs+Qt3wMd5c70MN7GolIGgvpiq6K8gh4xintxY0nXj38LGGzIFG1Zm7XjR37Kun9OWUWEVlCw+9CGugDxI0IVlFJ5Gzdpd0QD90GbJTn9uO6L5S2AzbX14bJPsyXWEyqjYum8BQxqb+MEiD0wHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723019433; c=relaxed/simple; bh=8/IVVXD4FeMZWKFKtoNpDRSh5vex9vQC00VHkqB1wBE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=doDdsAS+FPYIu9T9b3SBBwAKTV8Zpmu98nxtFO1xv8zvobrJU/HvZ9jTk2wJBkgx4d0lHfPax9CbhLOpfJcq4bdFsgxRiiiuJJJnGAVXdTMWuwTizzwboJlJq3TZVn/OWb4jf9aXqaScuWRDoq4hg22L+cssG0pVmyqdfLBWPZQ= 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=YzRJZufl; 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="YzRJZufl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723019430; 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; bh=OfBj6lBAY4VJsMws6sBIFpxuMUursLja0EGRzFyXM78=; b=YzRJZuflcrpWujK5+/dYnmvUTyl6HUDYozzlD7Ux1hUBVngAjHSOQ95CL++WS02fWW4LWU ZyQgcYB1b0+H4x3XO2iwHLCQTwpSDP6Uka8oC4VN7S/Iq21mS6gIuujztPYW/cRi77bUDO rn3tbRcdF9D0+AGHesn8Q82CC+82b4A= 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-205-Hn5SqRRYO02BHMmZ4tWmbg-1; Wed, 07 Aug 2024 04:30:29 -0400 X-MC-Unique: Hn5SqRRYO02BHMmZ4tWmbg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4281e72db54so1306795e9.0 for ; Wed, 07 Aug 2024 01:30:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723019426; x=1723624226; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OfBj6lBAY4VJsMws6sBIFpxuMUursLja0EGRzFyXM78=; b=TM/kMzR4LshGFHnRY5K9gPuZpYpJAV/SpyJWv88a/kms++OmqwlQ724mpv2cd9Z8Xz vsfEhhLBv937RGY9aLgutgotv1bcKhgO0eYce8IY5eEDo4j0lbgooovbTlx+1rbv+mFf 31qCV6KrxMF9bbBlu2rvPjoTMZ8E78z5L3DjmRZd2MoU0eI2OahMqJYluDNCHTkWx4ss esykWZjkKb91BS2wzLfccgB+5AZb0C+P13X9wRP8Hgs2gInOPFbYOlVHFFvQkjk25RYQ xcyxTQBmV0eanM150HI0KSKtlKhm461Viptf80whyK7Nz/d2cwb2yvTtJcQ4H0bLAmHg C3lw== X-Forwarded-Encrypted: i=1; AJvYcCX3cHHmDobWoxxEKLyvaFlPka443xMrWtta92URIjS4KSF9J3B5TUQyBLoKytHIWRZZ/09dc1xXUTw=@vger.kernel.org X-Gm-Message-State: AOJu0YzBEH/farwNKQGguACvP2kXWqn0kzcj3luoWAY4MlB/+lB+GvAB jf57YjObECQk6+p3UW2S0Ky+2BHoNbsyvvejy667VXoJvbW+ATMbdQKVYK4f/lPUibWcpWCo8Gs ftwRudqKTXRygGU9T58O8kiNSBAlWNNoLcQ1HandQPOP7eoKSiUCpOBZ/5g== X-Received: by 2002:a05:600c:4591:b0:426:6f48:415e with SMTP id 5b1f17b1804b1-428e6aea795mr73820965e9.1.1723019425855; Wed, 07 Aug 2024 01:30:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHdhIO0KlL48PS+jaZDCPIETER1vQyM9Ppq36CYnKYH6adnAP4mB8NMbC+bOkQ6YfKhAfEWRA== X-Received: by 2002:a05:600c:4591:b0:426:6f48:415e with SMTP id 5b1f17b1804b1-428e6aea795mr73820815e9.1.1723019425354; Wed, 07 Aug 2024 01:30:25 -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-4290580cb80sm18544835e9.45.2024.08.07.01.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 01:30:25 -0700 (PDT) From: Philipp Stanner To: Dave Airlie , Thomas Zimmermann , Jocelyn Falempe , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , Bjorn Helgaas Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Philipp Stanner Subject: [PATCH 1/2] PCI: Deprecate pcim_iomap_regions() in favor of pcim_iomap_region() Date: Wed, 7 Aug 2024 10:30:18 +0200 Message-ID: <20240807083018.8734-2-pstanner@redhat.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 pcim_iomap_regions() is a complicated function that uses a bit mask to determine the BARs the user wishes to request and ioremap. Almost all users only ever set a single bit in that mask, making that mechanism questionable. pcim_iomap_region() is now available as a more simple replacement. Make pcim_iomap_region() a public function. Mark pcim_iomap_regions() as deprecated. Signed-off-by: Philipp Stanner Acked-by: Bjorn Helgaas Acked-by: Dave Airlie --- drivers/pci/devres.c | 8 ++++++-- include/linux/pci.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 3780a9f9ec00..89ec26ea1501 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -728,7 +728,7 @@ EXPORT_SYMBOL(pcim_iounmap); * Mapping and region will get automatically released on driver detach. If * desired, release manually only with pcim_iounmap_region(). */ -static void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar, +void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar, const char *name) { int ret; @@ -761,6 +761,7 @@ static void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar, return IOMEM_ERR_PTR(ret); } +EXPORT_SYMBOL(pcim_iomap_region); /** * pcim_iounmap_region - Unmap and release a PCI BAR @@ -783,7 +784,7 @@ static void pcim_iounmap_region(struct pci_dev *pdev, int bar) } /** - * pcim_iomap_regions - Request and iomap PCI BARs + * pcim_iomap_regions - Request and iomap PCI BARs (DEPRECATED) * @pdev: PCI device to map IO resources for * @mask: Mask of BARs to request and iomap * @name: Name associated with the requests @@ -791,6 +792,9 @@ static void pcim_iounmap_region(struct pci_dev *pdev, int bar) * Returns: 0 on success, negative error code on failure. * * Request and iomap regions specified by @mask. + * + * This function is DEPRECATED. Do not use it in new code. + * Use pcim_iomap_region() instead. */ int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 4cf89a4b4cbc..fc30176d28ca 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -2292,6 +2292,8 @@ static inline void pci_fixup_device(enum pci_fixup_pass pass, void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); void __iomem * const *pcim_iomap_table(struct pci_dev *pdev); +void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar, + const char *name); 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 Wed Aug 7 08:30: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: 13755958 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 346D01C9DED for ; Wed, 7 Aug 2024 08:30:53 +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=1723019455; cv=none; b=Zi68yU4Pdj8TVm/qkBQs4FpcD72d589tac/fAPpEmbWbwasFXfdWvsKpvw4vnQDAtmnJnaASsKJwOyyKWw5wFHfn2YCW6r3/VR3TEpPDE/jL2D3rLyjTn5vbnigBtUrnddCQPZ9raYJft/TkkxUB4rZRAtYSXkISbFpCS0f4nu8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723019455; c=relaxed/simple; bh=PwYwdcFZJjXI/1ZBi07VVhiw7uh58Ga2zr6zHKgzONw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J1l0tx2noCFuEGh5qjdiZzVssbwMIyFyTDjLgzcque9b6Za3qKuGHfqJ2vs3KHCXsJMHWWpNuZEWMcrkuoRcPDuFtQ5l+g7mueM7Qeqn64nNBSxVXZNVXNcA9ahsO9D9IOjUZ0AXqJSCsM/N3peY22fmpmI1BYPZSFYWXBrhdP8= 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=UbwXSc2m; 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="UbwXSc2m" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723019453; 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=yVbzma6Ld8kQQE1ZL49LKh4hv2SyDx3pxf2xj02v3wI=; b=UbwXSc2mVbrkzLcMsltCZHaFo2kA+Pba2aobY4UjZblBLlRxXYY5VXLUJ7C0B4ze5/npAm MVxvx1ONNDRO7PhS/sr9XqQxqk9D6sxcw1BtkAtL/XOTfkTGOzZ9X911kyImDekUTu3NTS W3+mEziHDITtITlsDCKOMIhKRpQCciE= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-7P6pxkM7PKu7efh2H1JSpw-1; Wed, 07 Aug 2024 04:30:51 -0400 X-MC-Unique: 7P6pxkM7PKu7efh2H1JSpw-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ef185db2b4so3536701fa.1 for ; Wed, 07 Aug 2024 01:30:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723019450; x=1723624250; 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=yVbzma6Ld8kQQE1ZL49LKh4hv2SyDx3pxf2xj02v3wI=; b=YStFq2Y42XVRj/rdPk1h0Ktn5L0QVT2md0Y3NgDoWJTiqAoC/GRqG0pJrslsjAOV63 gaM/8H+WKY5Ul4eMtNYntww5R3Xj/uNYD/h9iJ3E8cUUBwpwMRbojKBIYOegd0dP6eoN X5optWiQ4y5hV7s2jSzid91QAPx8CvkqQMJ8elgW48oRVXOCPjwXdypE/0Wse5SotyaR jfPdX0+g+up+GSSvnO6R7RGMWBclB2PtOlUAbXlmNvjKA22BHfKKLuJCTOkxpyuXPlVu Ig2lc3gqq+0Oar75Foy82oedNprpLW7hUyeYQYdbQcrc8GvB9tfzc5gvDDQIkyPbB/um GdUQ== X-Forwarded-Encrypted: i=1; AJvYcCVxUuzV8n3/o0+oIYhGPWY9R/tsLZ3SNkGxqcW3hXvKNNTZ2zHEB1/rayMhEmSclMfg2CtTdVnicgQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzdHA8XWhnD38eiIsyZLDMiJdAGSbDeb/KqV4mCKLp9jER7+8fJ haoQgEudMbYQH5kVhU4Y25hNndWrjTNxBPLnWNjhI7ggQ4d9MqgMViC+gLktKkAZ581uj/2uZSj +MjEtBxgYNyK8PXjUj2hJm2Kf4UmAfFa7lnNBQKPC+CtrMefEvjUWNpHZpQ== X-Received: by 2002:a2e:9bcb:0:b0:2ef:24a9:6aa4 with SMTP id 38308e7fff4ca-2f15a9f617emr66033651fa.0.1723019450105; Wed, 07 Aug 2024 01:30:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFM3mk64vP4ZIUUqLKFHzIo7xNqsM+xJ9/DLlPYGzmqWK63piOdQggG6zFHh9ocfAw3S9zfvA== X-Received: by 2002:a2e:9bcb:0:b0:2ef:24a9:6aa4 with SMTP id 38308e7fff4ca-2f15a9f617emr66033551fa.0.1723019449584; Wed, 07 Aug 2024 01:30: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-4290580cb80sm18544835e9.45.2024.08.07.01.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Aug 2024 01:30:49 -0700 (PDT) From: Philipp Stanner To: Dave Airlie , Thomas Zimmermann , Jocelyn Falempe , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , Bjorn Helgaas Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Philipp Stanner Subject: [PATCH 2/2] drm/ast: Request PCI BAR with devres Date: Wed, 7 Aug 2024 10:30:20 +0200 Message-ID: <20240807083018.8734-4-pstanner@redhat.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240807083018.8734-2-pstanner@redhat.com> References: <20240807083018.8734-2-pstanner@redhat.com> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ast currently ioremaps two PCI BARs using pcim_iomap(). It does not perform a request on the regions, however, which would make the driver a bit more robust. PCI now offers pcim_iomap_region(), a managed function which both requests and ioremaps a BAR. Replace pcim_iomap() with pcim_iomap_region(). Suggested-by: Thomas Zimmermann Signed-off-by: Philipp Stanner Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/ast/ast_drv.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_drv.c b/drivers/gpu/drm/ast/ast_drv.c index aae019e79bda..1fadaadfbe39 100644 --- a/drivers/gpu/drm/ast/ast_drv.c +++ b/drivers/gpu/drm/ast/ast_drv.c @@ -287,9 +287,9 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) return ret; - regs = pcim_iomap(pdev, 1, 0); - if (!regs) - return -EIO; + regs = pcim_iomap_region(pdev, 1, "ast"); + if (IS_ERR(regs)) + return PTR_ERR(regs); if (pdev->revision >= 0x40) { /* @@ -311,9 +311,9 @@ static int ast_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (len < AST_IO_MM_LENGTH) return -EIO; - ioregs = pcim_iomap(pdev, 2, 0); - if (!ioregs) - return -EIO; + ioregs = pcim_iomap_region(pdev, 2, "ast"); + if (IS_ERR(ioregs)) + return PTR_ERR(ioregs); } else { /* * Anything else is best effort.