From: Jim Gill <jgill@vmware.com>
To: <pv-drivers@vmware.com>
Cc: <jgill@vmware.com>, <jejb@ibm.linux.com>,
<martin.petersen@oracle.com>, <linux-scsi@vger.kernel.org>
Subject: [PATCH 2/3 for-next] pvscsi: Limit ring pages for swiotlb
Date: Wed, 12 Aug 2020 13:55:02 -0700 [thread overview]
Message-ID: <20200812205502.GA18382@petr-dev3.eng.vmware.com> (raw)
A large number of outstanding scsi commands can
completely fill up the allowable DMA size. Typically this happens with
SWIOTLB and SEV encryption active. While this is harmless for the scsi middle
layer, it floods the kernel log with error messages and can cause other
device drivers to error. Reduce the number of ring pages to 1 if we detect
DMA size restrictions.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
[jgill@vmware.com: Forwarding patch on behalf of thellstrom]
Acked-by: jgill@vmware.com
---
drivers/scsi/vmw_pvscsi.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 0573e94..fa2748f 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -28,6 +28,7 @@
#include <linux/workqueue.h>
#include <linux/pci.h>
#include <linux/dmapool.h>
+#include <linux/mem_encrypt.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
@@ -45,6 +46,7 @@ MODULE_LICENSE("GPL");
MODULE_VERSION(PVSCSI_DRIVER_VERSION_STRING);
#define PVSCSI_DEFAULT_NUM_PAGES_PER_RING 8
+#define PVSCSI_RESTRICT_NUM_PAGES_PER_RING 1
#define PVSCSI_DEFAULT_NUM_PAGES_MSG_RING 1
#define PVSCSI_DEFAULT_QUEUE_DEPTH 254
#define SGL_SIZE PAGE_SIZE
@@ -1416,14 +1418,26 @@ static int pvscsi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
max_id = pvscsi_get_max_targets(adapter);
printk(KERN_INFO "vmw_pvscsi: max_id: %u\n", max_id);
- if (pvscsi_ring_pages == 0)
- /*
- * Set the right default value. Up to 16 it is 8, above it is
- * max.
- */
- pvscsi_ring_pages = (max_id > 16) ?
- PVSCSI_SETUP_RINGS_MAX_NUM_PAGES :
- PVSCSI_DEFAULT_NUM_PAGES_PER_RING;
+ if (pvscsi_ring_pages == 0) {
+ struct sysinfo si;
+
+ si_meminfo(&si);
+ if (mem_encrypt_active())
+ /*
+ * There are DMA size restrictions. Reduce the queue
+ * depth to try to avoid exhausting DMA size and trigger
+ * dma mapping errors.
+ */
+ pvscsi_ring_pages = PVSCSI_RESTRICT_NUM_PAGES_PER_RING;
+ else
+ /*
+ * Set the right default value. Up to 16 it is 8,
+ * above it is max.
+ */
+ pvscsi_ring_pages = (max_id > 16) ?
+ PVSCSI_SETUP_RINGS_MAX_NUM_PAGES :
+ PVSCSI_DEFAULT_NUM_PAGES_PER_RING;
+ }
printk(KERN_INFO
"vmw_pvscsi: setting ring_pages to %d\n",
pvscsi_ring_pages);
--
2.7.4
next reply other threads:[~2020-08-12 20:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 20:55 Jim Gill [this message]
2020-08-13 7:26 ` [PATCH 2/3 for-next] pvscsi: Limit ring pages for swiotlb Christoph Hellwig
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=20200812205502.GA18382@petr-dev3.eng.vmware.com \
--to=jgill@vmware.com \
--cc=jejb@ibm.linux.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=pv-drivers@vmware.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