* [PATCH v3] scsi: libsas: Allocation SMP request is aligned to 16B
@ 2024-03-28 6:26 Yihang Li
2024-03-28 6:34 ` Damien Le Moal
2024-03-28 6:36 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Yihang Li @ 2024-03-28 6:26 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.
So use 16B 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>
---
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..5ddbd00d5c76 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, 16), GFP_KERNEL);
if (p)
p[0] = SMP_REQUEST;
return p;
--
2.33.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] scsi: libsas: Allocation SMP request is aligned to 16B
2024-03-28 6:26 [PATCH v3] scsi: libsas: Allocation SMP request is aligned to 16B Yihang Li
@ 2024-03-28 6:34 ` Damien Le Moal
2024-03-28 6:36 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2024-03-28 6:34 UTC (permalink / raw)
To: Yihang Li, john.g.garry, yanaijie, jejb, martin.petersen, chenxiang66
Cc: linux-scsi, linux-kernel, linuxarm, prime.zeng, yangxingui
On 3/28/24 15:26, 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.
>
> So use 16B 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>
Looks OK to me.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> 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..5ddbd00d5c76 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, 16), GFP_KERNEL);
> if (p)
> p[0] = SMP_REQUEST;
> return p;
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] scsi: libsas: Allocation SMP request is aligned to 16B
2024-03-28 6:26 [PATCH v3] scsi: libsas: Allocation SMP request is aligned to 16B Yihang Li
2024-03-28 6:34 ` Damien Le Moal
@ 2024-03-28 6:36 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-03-28 6:36 UTC (permalink / raw)
To: Yihang Li
Cc: john.g.garry, yanaijie, jejb, martin.petersen, dlemoal,
chenxiang66, linux-scsi, linux-kernel, linuxarm, prime.zeng,
yangxingui
> + u8 *p = kzalloc(ALIGN(size, 16), GFP_KERNEL);
No, a magic undocumented 16 here max no sense at all. See the
discussion on the previous iteration.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-28 6:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-28 6:26 [PATCH v3] scsi: libsas: Allocation SMP request is aligned to 16B Yihang Li
2024-03-28 6:34 ` Damien Le Moal
2024-03-28 6:36 ` Christoph Hellwig
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®