mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Yihang Li <liyihang9@huawei.com>,
	Christoph Hellwig <hch@infradead.org>,
	John Garry <john.g.garry@oracle.com>
Cc: yanaijie@huawei.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, chenxiang66@hisilicon.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxarm@huawei.com, prime.zeng@huawei.com,
	yangxingui@huawei.com
Subject: Re: [PATCH v2] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN
Date: Thu, 28 Mar 2024 16:23:22 +0900	[thread overview]
Message-ID: <03ed6449-eb57-4a55-b2bf-ecbb9787feca@kernel.org> (raw)
In-Reply-To: <75df3e2d-10c3-5370-3cd8-fe2fb0ff2acc@huawei.com>

On 3/28/24 15:59, Yihang Li wrote:
> 
> 
> On 2024/3/28 14:35, Christoph Hellwig wrote:
>> On Tue, Mar 26, 2024 at 01:32:09PM +0000, John Garry wrote:
>>>>> +	u8 *p;
>>>>> +
>>>>> +	size = ALIGN(size, ARCH_DMA_MINALIGN);
>>>
>>>
>>> If this is a hisi_sas requirement, then why use ARCH_DMA_MINALIGN and not
>>> 16B as minimum alignment?
>>>
>>> Or are we really talking about an arch requirement?
>>
>> One thing is that we should never allocate unaligned memory for
>> anything DMA mapped, or data will be corrupted by non-coherent DMA.
>> So ARCH_DMA_MINALIGN needs to be here.  If specific hardware has
>> further requirements we'll need to communicated it through a field
>> or op vector.
> 
> Got it. Looks like it's still going to be aligned to ARCH_DMA_MINALIGN.

But I thought that the original issue was that some arch have ARCH_DMA_MINALIGN
down to 8B but hisi driver needs at least 16 ?

So in the end, you need something like:

	size = ALIGN(size, max(16, ARCH_DMA_MINALIGN));

no ?

And define a macro for the "16" value to document it.
Something like:

#define SAS_SMP_REQ_ALIGN	16

Not sure about the name... Naming is hard :)

> 
> Thanks,
> Yihang
> 
>>
>>
>> .
>>

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2024-03-28  7:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 12:43 Yihang Li
2024-03-26 13:14 ` Damien Le Moal
2024-03-26 13:32   ` John Garry
2024-03-26 13:40     ` Damien Le Moal
2024-03-28  6:35     ` Christoph Hellwig
2024-03-28  6:59       ` Yihang Li
2024-03-28  7:23         ` Damien Le Moal [this message]
2024-03-28  7:29           ` Christoph Hellwig
2024-03-28  7:36             ` Damien Le Moal
2024-03-28  7:45               ` Christoph Hellwig
2024-03-28  8:00                 ` Yihang Li

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=03ed6449-eb57-4a55-b2bf-ecbb9787feca@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=chenxiang66@hisilicon.com \
    --cc=hch@infradead.org \
    --cc=jejb@linux.ibm.com \
    --cc=john.g.garry@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=liyihang9@huawei.com \
    --cc=martin.petersen@oracle.com \
    --cc=prime.zeng@huawei.com \
    --cc=yanaijie@huawei.com \
    --cc=yangxingui@huawei.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

all inboxes | Powered by JetHome®