From: Dave Jiang <dave.jiang@intel.com>
To: vkoul@kernel.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, hpa@zytor.com, bhelgaas@google.com,
gregkh@linuxfoundation.org, arnd@arndb.de
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
dmaengine@vger.kernel.org, dan.j.williams@intel.com,
ashok.raj@intel.com, fenghua.yu@intel.com,
linux-pci@vger.kernel.org, tony.luck@intel.com,
jing.lin@intel.com, sanjay.k.kumar@intel.com
Subject: [PATCH 4/6] device: add cmdmem support for MMIO address
Date: Mon, 30 Mar 2020 14:27:12 -0700 [thread overview]
Message-ID: <158560363242.6059.17603442699301479734.stgit@djiang5-desk3.ch.intel.com> (raw)
In-Reply-To: <158560290392.6059.16921214463585182874.stgit@djiang5-desk3.ch.intel.com>
With the introduction of ENQCMDS CPU instruction on Intel CPU, a number of
accelerator devices that support accepting data via ENQCMDS will be
arriving. Add devm_cmdmem_remap/unmap() wrappers to remap BAR memory to
specifically denote that these regions are of cmdmem behavior type even
thought they are iomem.
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
include/linux/io.h | 4 ++++
lib/devres.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/include/linux/io.h b/include/linux/io.h
index b1c44bb4b2d7..2b3356244553 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -79,6 +79,10 @@ void devm_memunmap(struct device *dev, void *addr);
void *__devm_memremap_pages(struct device *dev, struct resource *res);
+void __iomem *devm_cmdmem_remap(struct device *dev, resource_size_t offset,
+ resource_size_t size);
+void devm_cmdmem_unmap(struct device *dev, void __iomem *addr);
+
#ifdef CONFIG_PCI
/*
* The PCI specifications (Rev 3.0, 3.2.5 "Transaction Ordering and
diff --git a/lib/devres.c b/lib/devres.c
index 6ef51f159c54..a14a49087b37 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -218,6 +218,42 @@ void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int in
}
EXPORT_SYMBOL(devm_of_iomap);
+/**
+ * devm_cmdmem_remap - Managed wrapper for cmdmem ioremap()
+ * @dev: Generic device to remap IO address for
+ * @offset: Resource address to map
+ * @size: Size of map
+ *
+ * Managed cmdmem ioremap() wrapper. Map is automatically unmapped on
+ * driver detach.
+ */
+void __iomem *devm_cmdmem_remap(struct device *dev, resource_size_t offset,
+ resource_size_t size)
+{
+ if (!device_supports_cmdmem(dev))
+ return NULL;
+
+ return devm_ioremap(dev, offset, size);
+}
+EXPORT_SYMBOL(devm_cmdmem_remap);
+
+/**
+ * devm_cmdmem_unmap - Managed wrapper for cmdmem iounmap()
+ * @dev: Generic device to unmap for
+ * @addr: Address to unmap
+ *
+ * Managed cmdmem iounmap(). @addr must have been mapped using
+ * devm_cmdmem_remap*().
+ */
+void devm_cmdmem_unmap(struct device *dev, void __iomem *addr)
+{
+ if (!device_supports_cmdmem(dev))
+ return;
+
+ devm_iounmap(dev, addr);
+}
+EXPORT_SYMBOL(devm_cmdmem_unmap);
+
#ifdef CONFIG_HAS_IOPORT_MAP
/*
* Generic iomap devres
next prev parent reply other threads:[~2020-03-30 21:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 21:26 [PATCH 0/6] Add shared workqueue support for idxd driver Dave Jiang
2020-03-30 21:26 ` [PATCH 1/6] x86/asm: add iosubmit_cmds512_sync() based on enqcmds Dave Jiang
2020-03-30 21:27 ` [PATCH 2/6] device/pci: add cmdmem cap to pci_dev Dave Jiang
2020-03-31 10:04 ` Greg KH
2020-03-31 17:07 ` Dave Jiang
2020-03-31 17:24 ` Greg KH
2020-03-31 17:38 ` Dave Jiang
2020-03-31 16:03 ` Bjorn Helgaas
2020-03-31 21:44 ` Dave Jiang
2020-03-30 21:27 ` [PATCH 3/6] pci: add PCI quirk cmdmem fixup for Intel DSA device Dave Jiang
2020-03-31 15:59 ` Bjorn Helgaas
2020-03-31 18:02 ` Dave Jiang
2020-04-01 7:18 ` Christoph Hellwig
2020-04-02 2:20 ` Dan Williams
2020-04-02 7:39 ` Christoph Hellwig
2020-03-30 21:27 ` Dave Jiang [this message]
2020-04-01 7:19 ` [PATCH 4/6] device: add cmdmem support for MMIO address Christoph Hellwig
2020-03-30 21:27 ` [PATCH 5/6] dmaengine: idxd: add shared workqueue support Dave Jiang
2020-03-30 21:27 ` [PATCH 6/6] dmaengine: idxd: add ABI documentation for shared wq Dave Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=158560363242.6059.17603442699301479734.stgit@djiang5-desk3.ch.intel.com \
--to=dave.jiang@intel.com \
--cc=arnd@arndb.de \
--cc=ashok.raj@intel.com \
--cc=bhelgaas@google.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=fenghua.yu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jing.lin@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=sanjay.k.kumar@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=vkoul@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).