From: Petr Tesarik <petrtesarik@huaweicloud.com>
To: Jonathan Corbet <corbet@lwn.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
Christoph Hellwig <hch@lst.de>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Robin Murphy <robin.murphy@arm.com>, Borislav Petkov <bp@suse.de>,
"Paul E. McKenney" <paulmck@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Zhen Lei <thunder.leizhen@huawei.com>,
Randy Dunlap <rdunlap@infradead.org>,
Damien Le Moal <damien.lemoal@opensource.wdc.com>,
Kim Phillips <kim.phillips@amd.com>,
"Steven Rostedt (Google)" <rostedt@goodmis.org>,
Muchun Song <muchun.song@linux.dev>, Ondrej Zary <linux@zary.sk>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
Petr Tesarik <petr.tesarik.ext@huawei.com>,
Hans de Goede <hdegoede@redhat.com>,
Dan Williams <dan.j.williams@intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Kees Cook <keescook@chromium.org>,
Thomas Gleixner <tglx@linutronix.de>,
Won Chung <wonchung@google.com>,
linux-doc@vger.kernel.org (open list:DOCUMENTATION),
linux-kernel@vger.kernel.org (open list),
dri-devel@lists.freedesktop.org (open list:DRM DRIVERS),
iommu@lists.linux.dev (open list:DMA MAPPING HELPERS)
Cc: Roberto Sassu <roberto.sassu@huawei.com>,
Kefeng Wang <wangkefeng.wang@huawei.com>,
petr@tesarici.cz
Subject: [PATCH v2 1/7] swiotlb: Use a helper to initialize swiotlb fields in struct device
Date: Wed, 19 Apr 2023 12:03:53 +0200 [thread overview]
Message-ID: <a8b23fa7304512af33897edfdae97bea8a97c39d.1681898595.git.petr.tesarik.ext@huawei.com> (raw)
In-Reply-To: <cover.1681898595.git.petr.tesarik.ext@huawei.com>
From: Petr Tesarik <petr.tesarik.ext@huawei.com>
Move swiotlb initialization code to swiotlb.h. This change also
allows to provide a stub implementation if swiotlb is not
configured, getting rid of an #ifdef in driver core.
Signed-off-by: Petr Tesarik <petr.tesarik.ext@huawei.com>
---
drivers/base/core.c | 4 +---
include/linux/swiotlb.h | 12 ++++++++++++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 6878dfcbf0d6..a5dc7c673102 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3060,9 +3060,7 @@ void device_initialize(struct device *dev)
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
dev->dma_coherent = dma_default_coherent;
#endif
-#ifdef CONFIG_SWIOTLB
- dev->dma_io_tlb_mem = &io_tlb_default_mem;
-#endif
+ swiotlb_dev_init(dev);
}
EXPORT_SYMBOL_GPL(device_initialize);
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index bcef10e20ea4..b65b7330f7e5 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -119,6 +119,15 @@ static inline bool is_swiotlb_force_bounce(struct device *dev)
return mem && mem->force_bounce;
}
+/**
+ * swiotlb_dev_init() - initialize swiotlb fields in &struct device
+ * @dev: device to be initialized
+ */
+static inline void swiotlb_dev_init(struct device *dev)
+{
+ dev->dma_io_tlb_mem = &io_tlb_default_mem;
+}
+
void swiotlb_init(bool addressing_limited, unsigned int flags);
void __init swiotlb_exit(void);
size_t swiotlb_max_mapping_size(struct device *dev);
@@ -128,6 +137,9 @@ void __init swiotlb_adjust_size(unsigned long size);
static inline void swiotlb_init(bool addressing_limited, unsigned int flags)
{
}
+static inline void swiotlb_dev_init(struct device *dev)
+{
+}
static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
{
return false;
--
2.25.1
next prev parent reply other threads:[~2023-04-19 10:05 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 10:03 [PATCH v2 0/7] Allow dynamic allocation of software IO TLB bounce buffers Petr Tesarik
2023-04-19 10:03 ` Petr Tesarik [this message]
2023-04-19 10:03 ` [PATCH v2 2/7] swiotlb: Move code around in preparation for dynamic " Petr Tesarik
2023-04-19 10:03 ` [PATCH v2 3/7] dma-mapping: introduce the DMA_ATTR_MAY_SLEEP attribute Petr Tesarik
2023-04-19 10:03 ` [PATCH v2 4/7] swiotlb: Dynamically allocated bounce buffers Petr Tesarik
2023-04-19 10:03 ` [PATCH v2 5/7] swiotlb: Add a boot option to enable dynamic " Petr Tesarik
2023-04-19 10:03 ` [PATCH v2 6/7] drm: Use DMA_ATTR_MAY_SLEEP from process context Petr Tesarik
2023-04-19 10:03 ` [PATCH v2 7/7] swiotlb: per-device flag if there are dynamically allocated buffers Petr Tesarik
2023-04-26 12:15 ` [PATCH v2 0/7] Allow dynamic allocation of software IO TLB bounce buffers Petr Tesařík
2023-04-26 12:26 ` Greg Kroah-Hartman
2023-04-26 12:44 ` Petr Tesařík
2023-04-26 12:53 ` Greg Kroah-Hartman
2023-04-26 13:16 ` Petr Tesařík
2023-05-09 7:16 ` Petr Tesařík
2023-05-09 7:32 ` Greg Kroah-Hartman
2023-07-10 22:23 ` Mike Lothian
2023-07-11 9:03 ` Petr Tesařík
2023-07-11 11:29 ` Mike Lothian
2023-07-11 13:21 ` Petr Tesařík
2023-07-11 14:40 ` Mike Lothian
2023-04-28 8:53 ` Mike Lothian
2023-04-28 9:07 ` Petr Tesařík
2023-05-01 10:29 ` Mike Lothian
2023-05-02 12:15 ` Petr Tesarik
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=a8b23fa7304512af33897edfdae97bea8a97c39d.1681898595.git.petr.tesarik.ext@huawei.com \
--to=petrtesarik@huaweicloud.com \
--cc=Jason@zx2c4.com \
--cc=airlied@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bp@suse.de \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=damien.lemoal@opensource.wdc.com \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=hdegoede@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=keescook@chromium.org \
--cc=kim.phillips@amd.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@zary.sk \
--cc=m.szyprowski@samsung.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=muchun.song@linux.dev \
--cc=paulmck@kernel.org \
--cc=petr.tesarik.ext@huawei.com \
--cc=petr@tesarici.cz \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=roberto.sassu@huawei.com \
--cc=robin.murphy@arm.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=thunder.leizhen@huawei.com \
--cc=tzimmermann@suse.de \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
--cc=wonchung@google.com \
/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
all inboxes | Powered by JetHome®