mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: hisi_sas: Limit max hw sectors for v3 HW
@ 2022-06-23 12:41 John Garry
  2022-06-28  3:24 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: John Garry @ 2022-06-23 12:41 UTC (permalink / raw)
  To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, linuxarm, hch, John Garry

If the controller is behind an IOMMU then the IOMMU IOVA caching range can
affect performance, as discussed in [0].

Limit the max HW sectors to not exceed this limit. We need to hardcode
the value until a proper DMA mapping API is available.

[0] https://lore.kernel.org/linux-iommu/20210129092120.1482-1-thunder.leizhen@huawei.com/

Signed-off-by: John Garry <john.garry@huawei.com>
---
This patch is intended as something which I can backport to stable.
Series [1] is a proper fix but stuck, but I would not plan to backport
it anyway.
[1] https://lore.kernel.org/linux-scsi/1654507822-168026-1-git-send-email-john.garry@huawei.com/T/#m069f33edd547533301e2af156ebd6badee199dea

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
index 7d819fc0395e..eb86afb21aab 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
@@ -2782,6 +2782,7 @@ static int slave_configure_v3_hw(struct scsi_device *sdev)
 	struct hisi_hba *hisi_hba = shost_priv(shost);
 	struct device *dev = hisi_hba->dev;
 	int ret = sas_slave_configure(sdev);
+	unsigned int max_sectors;
 
 	if (ret)
 		return ret;
@@ -2799,6 +2800,12 @@ static int slave_configure_v3_hw(struct scsi_device *sdev)
 		}
 	}
 
+	/* Set according to IOMMU IOVA caching limit */
+	max_sectors = min_t(size_t, queue_max_hw_sectors(sdev->request_queue),
+			    (PAGE_SIZE * 32) >> SECTOR_SHIFT);
+
+	blk_queue_max_hw_sectors(sdev->request_queue, max_sectors);
+
 	return 0;
 }
 
-- 
2.35.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: hisi_sas: Limit max hw sectors for v3 HW
  2022-06-23 12:41 [PATCH] scsi: hisi_sas: Limit max hw sectors for v3 HW John Garry
@ 2022-06-28  3:24 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2022-06-28  3:24 UTC (permalink / raw)
  To: jejb, John Garry
  Cc: Martin K . Petersen, hch, linux-scsi, linuxarm, linux-kernel

On Thu, 23 Jun 2022 20:41:59 +0800, John Garry wrote:

> If the controller is behind an IOMMU then the IOMMU IOVA caching range can
> affect performance, as discussed in [0].
> 
> Limit the max HW sectors to not exceed this limit. We need to hardcode
> the value until a proper DMA mapping API is available.
> 
> [0] https://lore.kernel.org/linux-iommu/20210129092120.1482-1-thunder.leizhen@huawei.com/
> 
> [...]

Applied to 5.19/scsi-fixes, thanks!

[1/1] scsi: hisi_sas: Limit max hw sectors for v3 HW
      https://git.kernel.org/mkp/scsi/c/fce54ed02757

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-28  3:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-23 12:41 [PATCH] scsi: hisi_sas: Limit max hw sectors for v3 HW John Garry
2022-06-28  3:24 ` Martin K. Petersen

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®