From: Vasily Gorbik <gor@linux.ibm.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Heiko Carstens <hca@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Niklas Schnelle <schnelle@linux.ibm.com>,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [PATCH] s390/pci: remove custom and misleading bitmap_vzalloc
Date: Mon, 23 Oct 2023 18:11:54 +0200 [thread overview]
Message-ID: <your-ad-here.call-01698077514-ext-9164@work.hours> (raw)
In-Reply-To: <your-ad-here.call-01698077344-ext-9104@work.hours>
This commit effectively reverts commit c1ae1c59c8c6 ("s390/pci: fix
iommu bitmap allocation") and applies a simpler fix instead. Commit
c1ae1c59c8c6 introduced a custom bitmap_vzalloc() function that included
unnecessary and misleading overflow handling.
This fix is only relevant for the current v6.6 and stable backports. It
will be superseded by the upcoming conversion to use the common
code DMA API on s390 (pending in linux-next [2]), which eliminates
arch/s390/pci/pci_dma.c entirely and, therefore, addresses the original
problem in another way.
Instead of relying on a custom bitmap_vzalloc() function, this change goes
back to straightforward allocation using vzalloc() with the appropriate
size calculated using the BITS_TO_LONGS() macro.
Link: https://lore.kernel.org/all/CAHk-=wgTUz1bdY6zvsN4ED0arCLE8Sb==1GH8d0sjm5bu7zesQ@mail.gmail.com/
Link: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20231020&id=c76c067e488c
Cc: stable@vger.kernel.org
Fixes: c1ae1c59c8c6 ("s390/pci: fix iommu bitmap allocation")
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
---
arch/s390/pci/pci_dma.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 99209085c75b..1b4b123d79aa 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -565,17 +565,6 @@ static void s390_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
}
}
-static unsigned long *bitmap_vzalloc(size_t bits, gfp_t flags)
-{
- size_t n = BITS_TO_LONGS(bits);
- size_t bytes;
-
- if (unlikely(check_mul_overflow(n, sizeof(unsigned long), &bytes)))
- return NULL;
-
- return vzalloc(bytes);
-}
-
int zpci_dma_init_device(struct zpci_dev *zdev)
{
u8 status;
@@ -615,13 +604,15 @@ int zpci_dma_init_device(struct zpci_dev *zdev)
zdev->end_dma - zdev->start_dma + 1);
zdev->end_dma = zdev->start_dma + zdev->iommu_size - 1;
zdev->iommu_pages = zdev->iommu_size >> PAGE_SHIFT;
- zdev->iommu_bitmap = bitmap_vzalloc(zdev->iommu_pages, GFP_KERNEL);
+ zdev->iommu_bitmap = vzalloc(BITS_TO_LONGS(zdev->iommu_pages) *
+ sizeof(unsigned long));
if (!zdev->iommu_bitmap) {
rc = -ENOMEM;
goto free_dma_table;
}
if (!s390_iommu_strict) {
- zdev->lazy_bitmap = bitmap_vzalloc(zdev->iommu_pages, GFP_KERNEL);
+ zdev->lazy_bitmap = vzalloc(BITS_TO_LONGS(zdev->iommu_pages) *
+ sizeof(unsigned long));
if (!zdev->lazy_bitmap) {
rc = -ENOMEM;
goto free_bitmap;
--
2.39.2
next prev parent reply other threads:[~2023-10-23 16:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 9:44 [GIT PULL] s390 fixes for 6.6-rc7 Vasily Gorbik
2023-10-21 17:56 ` Linus Torvalds
2023-10-21 18:08 ` Linus Torvalds
2023-10-22 13:17 ` Vasily Gorbik
2023-10-22 14:54 ` Linus Torvalds
2023-10-23 16:09 ` Vasily Gorbik
2023-10-23 16:11 ` Vasily Gorbik [this message]
2023-10-23 16:31 ` [PATCH] s390/pci: remove custom and misleading bitmap_vzalloc Niklas Schnelle
2023-10-21 17:57 ` [GIT PULL] s390 fixes for 6.6-rc7 pr-tracker-bot
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=your-ad-here.call-01698077514-ext-9164@work.hours \
--to=gor@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=schnelle@linux.ibm.com \
--cc=torvalds@linux-foundation.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