* [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN
@ 2024-03-28 9:06 Yihang Li
2024-03-28 9:32 ` John Garry
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yihang Li @ 2024-03-28 9:06 UTC (permalink / raw)
To: john.g.garry, yanaijie, jejb, martin.petersen, dlemoal, chenxiang66
Cc: linux-scsi, linux-kernel, linuxarm, prime.zeng, yangxingui, liyihang9
This series [1] reducing the kmalloc() minimum alignment on arm64 to 8
(from 128). In libsas, this will cause SMP requests to be 8-byte-aligned
through kmalloc() allocation. However, for the hisi_sas hardware, all
commands address must be 16-byte-aligned. Otherwise, the commands fail to
be executed.
ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA
operations, so use ARCH_DMA_MINALIGN as the alignment for SMP request.
Link: https://lkml.kernel.org/r/20230612153201.554742-1-catalin.marinas@arm.com [1]
Signed-off-by: Yihang Li <liyihang9@huawei.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
---
Changes since v3:
- Still aligned to ARCH_DMA_MINALIGN for safe DMA operations.
Changes since v2:
- Use 16B as alignment for SMP requests instead of ARCH_DMA_MINALIGN.
Changes since v1:
- Directly modify alloc_smp_req() instead of using handler callback.
---
drivers/scsi/libsas/sas_expander.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index a2204674b680..c989d182fc75 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -135,7 +135,7 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
static inline void *alloc_smp_req(int size)
{
- u8 *p = kzalloc(size, GFP_KERNEL);
+ u8 *p = kzalloc(ALIGN(size, ARCH_DMA_MINALIGN), GFP_KERNEL);
if (p)
p[0] = SMP_REQUEST;
return p;
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN
2024-03-28 9:06 [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN Yihang Li
@ 2024-03-28 9:32 ` John Garry
2024-03-28 9:49 ` Jason Yan
2024-04-02 1:48 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: John Garry @ 2024-03-28 9:32 UTC (permalink / raw)
To: Yihang Li, yanaijie, jejb, martin.petersen, dlemoal, chenxiang66
Cc: linux-scsi, linux-kernel, linuxarm, prime.zeng, yangxingui
On 28/03/2024 09:06, Yihang Li wrote:
> This series [1] reducing the kmalloc() minimum alignment on arm64 to 8
> (from 128). In libsas, this will cause SMP requests to be 8-byte-aligned
> through kmalloc() allocation. However, for the hisi_sas hardware, all
> commands address must be 16-byte-aligned. Otherwise, the commands fail to
> be executed.
>
> ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA
> operations, so use ARCH_DMA_MINALIGN as the alignment for SMP request.
I'd say that we must align to at least ARCH_DMA_MINALIGN for memory
which we want to map for DMA. ARCH_DMA_MINALIGN would never be less than
the 16B requirement for hisi_sas, so just align to ARCH_DMA_MINALIGN.
>
> Link: https://urldefense.com/v3/__https://lkml.kernel.org/r/20230612153201.554742-1-catalin.marinas@arm.com__;!!ACWV5N9M2RV99hQ!LbkCJSfklWds8mk0UGjtg0qRNpWuAc-ibudDMl7sI_Qip4Hd6WNqHZmRbuJfObd4fcZXj0sC8nGTs1UbA5PlCA$ [1]
> Signed-off-by: Yihang Li <liyihang9@huawei.com>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
> ---
> Changes since v3:
> - Still aligned to ARCH_DMA_MINALIGN for safe DMA operations.
>
> Changes since v2:
> - Use 16B as alignment for SMP requests instead of ARCH_DMA_MINALIGN.
>
> Changes since v1:
> - Directly modify alloc_smp_req() instead of using handler callback.
> ---
> drivers/scsi/libsas/sas_expander.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
> index a2204674b680..c989d182fc75 100644
> --- a/drivers/scsi/libsas/sas_expander.c
> +++ b/drivers/scsi/libsas/sas_expander.c
> @@ -135,7 +135,7 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
>
> static inline void *alloc_smp_req(int size)
> {
> - u8 *p = kzalloc(size, GFP_KERNEL);
> + u8 *p = kzalloc(ALIGN(size, ARCH_DMA_MINALIGN), GFP_KERNEL);
> if (p)
> p[0] = SMP_REQUEST;
> return p;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN
2024-03-28 9:06 [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN Yihang Li
2024-03-28 9:32 ` John Garry
@ 2024-03-28 9:49 ` Jason Yan
2024-04-02 1:48 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Jason Yan @ 2024-03-28 9:49 UTC (permalink / raw)
To: Yihang Li, john.g.garry, jejb, martin.petersen, dlemoal, chenxiang66
Cc: linux-scsi, linux-kernel, linuxarm, prime.zeng, yangxingui
On 2024/3/28 17:06, Yihang Li wrote:
> This series [1] reducing the kmalloc() minimum alignment on arm64 to 8
> (from 128). In libsas, this will cause SMP requests to be 8-byte-aligned
> through kmalloc() allocation. However, for the hisi_sas hardware, all
> commands address must be 16-byte-aligned. Otherwise, the commands fail to
> be executed.
>
> ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA
> operations, so use ARCH_DMA_MINALIGN as the alignment for SMP request.
>
> Link: https://lkml.kernel.org/r/20230612153201.554742-1-catalin.marinas@arm.com [1]
> Signed-off-by: Yihang Li <liyihang9@huawei.com>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> Changes since v3:
> - Still aligned to ARCH_DMA_MINALIGN for safe DMA operations.
>
> Changes since v2:
> - Use 16B as alignment for SMP requests instead of ARCH_DMA_MINALIGN.
>
> Changes since v1:
> - Directly modify alloc_smp_req() instead of using handler callback.
> ---
> drivers/scsi/libsas/sas_expander.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
> index a2204674b680..c989d182fc75 100644
> --- a/drivers/scsi/libsas/sas_expander.c
> +++ b/drivers/scsi/libsas/sas_expander.c
> @@ -135,7 +135,7 @@ static int smp_execute_task(struct domain_device *dev, void *req, int req_size,
>
> static inline void *alloc_smp_req(int size)
> {
> - u8 *p = kzalloc(size, GFP_KERNEL);
> + u8 *p = kzalloc(ALIGN(size, ARCH_DMA_MINALIGN), GFP_KERNEL);
> if (p)
> p[0] = SMP_REQUEST;
> return p;
>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Thanks,
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN
2024-03-28 9:06 [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN Yihang Li
2024-03-28 9:32 ` John Garry
2024-03-28 9:49 ` Jason Yan
@ 2024-04-02 1:48 ` Martin K. Petersen
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2024-04-02 1:48 UTC (permalink / raw)
To: john.g.garry, yanaijie, jejb, dlemoal, chenxiang66, Yihang Li
Cc: Martin K . Petersen, linux-scsi, linux-kernel, linuxarm,
prime.zeng, yangxingui
On Thu, 28 Mar 2024 17:06:26 +0800, Yihang Li wrote:
> This series [1] reducing the kmalloc() minimum alignment on arm64 to 8
> (from 128). In libsas, this will cause SMP requests to be 8-byte-aligned
> through kmalloc() allocation. However, for the hisi_sas hardware, all
> commands address must be 16-byte-aligned. Otherwise, the commands fail to
> be executed.
>
> ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA
> operations, so use ARCH_DMA_MINALIGN as the alignment for SMP request.
>
> [...]
Applied to 6.9/scsi-fixes, thanks!
[1/1] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN
https://git.kernel.org/mkp/scsi/c/e675a4fd6d1f
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-02 1:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 9:06 [PATCH v4] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN Yihang Li
2024-03-28 9:32 ` John Garry
2024-03-28 9:49 ` Jason Yan
2024-04-02 1:48 ` Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.