Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp254541lqh; Thu, 28 Mar 2024 00:23:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVD6kGhiZ8R6ysoFS2kJdnbzWOi5WKoLwfOjMkqrI/6lz8y06zrqCD/S7lUEDwOQcSUtf1LnVKd9iwU4zW/vTazx+aKPRp3JBOTXPsU1A== X-Google-Smtp-Source: AGHT+IEIwuxaWByRwX3wjcl4SyoHamnUeUcizuf0pmgZ6n5BTxpkA0dusnWnS80sZZOhV3YA4ChS X-Received: by 2002:a17:906:6819:b0:a4e:23b5:3874 with SMTP id k25-20020a170906681900b00a4e23b53874mr419421ejr.12.1711610615497; Thu, 28 Mar 2024 00:23:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711610615; cv=pass; d=google.com; s=arc-20160816; b=gMm+fDTI8ayEFHUCikM+87WOhJDmIGEq5y740gtNoeTU4gPd5uv3wBhGNawcMLwU35 wvQelhGpI+jgCuw74r3Q5Cf/wH8pNdMuzi+w6ba/pH72U0lgmYeIC/GKWg8GJeO+QZVX tr00O0+CxgpEuQj1uApbJSUAeHcu1i0sxU+uYbpS92EEjHoL/FNLlyuZQ8pZogxjEQa/ BUwKL9ODxwIQ46YC/Rwf5I2KpMRP611VxtqRe6i3qNDlTsgYyjAhuBl5ap1vO4u29cuc E6is+3YASDApAnFNLUSVKRmh5585s9hcN9iD9tK/JL8jgUoHlIt9F+DrcqC0uN+AycNt ys9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=QQvUiCT1KXtrxr8z0woJSh8T4qQZu5wfgx4hO1jqrRs=; fh=K2SuRpdk2Nzvf8KlZpCrb4JrjK13auVKUe0lcESC5vo=; b=GXNDv8WEsCmnsQJW89uAMsJjkjMnSzPUoFnggzqHDvWQBJMHSWkoF9FH31Pv5h2fgL l04pqZuMu9Cs5OXD3UXLYZhxBAB0oM9gzFJjbZMAHl/wpco9yCTvcovNdoROEzSHHpYv n0FSbhJuSrszYecwnJCWbrLd+dC8yEHZLIj8yjMeDtcnZ5GH0HSBFrFpELL+RRksNUwS S99OhZcl6El5z72Qwah2FKG7ioRiNZjz4X5eRcDhOLSS7KLJhpG8329l/jeLl9Xlwo7+ DQYy1I1WkkJFPWBcJygHpbRWc3jHG52YWSGK3ZV0wKMzDIOhZKQxPnqVgzanCjMoh18a 6lLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pFqhem1N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122496-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id jg19-20020a170907971300b00a4895e39c87si451749ejc.570.2024.03.28.00.23.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:23:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122496-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pFqhem1N; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122496-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3589C1F24EF5 for ; Thu, 28 Mar 2024 07:23:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0770850A80; Thu, 28 Mar 2024 07:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pFqhem1N" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 311C223765; Thu, 28 Mar 2024 07:23:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711610606; cv=none; b=C/FTcnYIzyiYCMblDUQjd/H5xah2ojUTdyZG3mtWTE/NcdOJSmnzz4e9QtamRHBptUfk1oY4A8E0kpcqJCp1UAVk7pQUde9O/cdWeW95IkuZFFZfCfV+RrTBWLEMIOWqHxmPwCVANj/t6LyF1RsyU8sk7L+Pz6axPBmJ0nc1Vow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711610606; c=relaxed/simple; bh=/DBxafWugaS+NBr6xZbPt8hjTlXm4/2YAaTmuUh1cZo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CIHcCASN1s2R22WjbbCTVytXh5NgenUvfXCinLB0r0zdSvwUJeA7rzcXFt3QOUsZfb9GEqKbZajZFcTjCQ3cPE9nyYQn+Gu+mJiEeRUU5mL0gV8mDTmtypTrDcBulHwoZG0QzgHsNN84pmW0XlrvxXCitnhC3YKXdApVyUALGdQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pFqhem1N; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3783C433F1; Thu, 28 Mar 2024 07:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711610605; bh=/DBxafWugaS+NBr6xZbPt8hjTlXm4/2YAaTmuUh1cZo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=pFqhem1NuQqwdqGi1ZzFQJiSsiRlvCNmU7jGrMuOnW9hR5gpfucNViiQE7H4oyTtm x+YScXd4cWxvazuXIQaniANGZThfNtaPKLbtMCNo118Tov7oPCe8GHU3D7kBCwsfZJ vuKVAQPKh341NX+txC7FmOMTqMU2uImO8v9YYodrnLZW2gqH3JjTar3XBGG9U+X70W ABZk1qWqRBtmbhfJzpVZkyQ6xNzCXWy94XPWA115HyrHYxaoZlWTyDE3xRtd5cz66i 0MDHN2OOk+7AwtACuayYVnUhvBdjbcu/7d2gxbUgwk8upmPdf9ygJznfYUDj4nf7nx QY76hjhcSRvBg== Message-ID: <03ed6449-eb57-4a55-b2bf-ecbb9787feca@kernel.org> Date: Thu, 28 Mar 2024 16:23:22 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] scsi: libsas: Allocation SMP request is aligned to ARCH_DMA_MINALIGN To: Yihang Li , Christoph Hellwig , John Garry 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 References: <20240326124358.2466259-1-liyihang9@huawei.com> <5b5b9392-7fd2-4c87-8e41-5e54adf20003@kernel.org> <0ba9914d-7060-498a-beac-2b19770e1963@oracle.com> <75df3e2d-10c3-5370-3cd8-fe2fb0ff2acc@huawei.com> From: Damien Le Moal Content-Language: en-US Organization: Western Digital Research In-Reply-To: <75df3e2d-10c3-5370-3cd8-fe2fb0ff2acc@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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