Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2797072lqp; Mon, 25 Mar 2024 09:25:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVu7pAh+wsm+/AGHVA14bDoaRH0chkSuJYIHvGHRtns8aeHd5jr5cIcKU6ypAt+EHqzSRnOP0VaGv2hbC4XoBIRXASy73Mj63Xzl/ykJg== X-Google-Smtp-Source: AGHT+IGAoK5P/yEtGFvHar1e74khc4c6oT3KxW8h0czlGu/1x/CidL1wWXoT3yNs4R0o2D6wZr+N X-Received: by 2002:ac2:4649:0:b0:513:cf5e:f2ad with SMTP id s9-20020ac24649000000b00513cf5ef2admr5495252lfo.60.1711383945690; Mon, 25 Mar 2024 09:25:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711383945; cv=pass; d=google.com; s=arc-20160816; b=uDeYpsuv6jatWuXjoEvuySgYOat7yIt+1FkGXqEr6X8kvtz9yN+aK0NBXgo7A29yqq c4jsQ4amg81mfnKtI9Q3a5tVWp1Fw/y15R3kR6JDJNo3ViHMzz/zfxz/fci6RPSAOLGk wJdBapSKFJSc6pS2n3wqHMXQJgXZTeaPa8oVjTsXwRoUc+gYDTIp6NtD6kWBGlE+1gN2 Ke9bQgYnQ0no9jmzDjXFyk/D5/czc2ltf0BZzWDdKSS2ADp7cGNLYxvCW+vh0J8dx1B1 aOfQNuzUazDC+obLQcJQkHgb658WunMGYTJYFICTEu8AeW78kupHq0+vGOGtKg9AaWp+ N6IQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=kNcylzx8gEXfcMRBdXxA/xqMAKaIXKvUZQgvb+lpU40=; fh=fT7lnv2XYYhwCZygSrHs6+RVgAEkCq8KnqAh85dh6HQ=; b=uXP91kCDGx0ZMz9+upntAgaibk2fVrzeWB+lgoqq4MVitwmryvKSySbyLWHbRKtDup J9L5vektpVINkxuPZy8iKz+BMPvXcwxdUHtaJYUhQsopCwgBkQtOgX/wTXv1TBtTysEh cGR10ivoNNRgUJOF7iMe44KJl6ZJsjA5QI7neo7RCsMzUCy8XlEhukIsNU2LiyPzLho9 SGSjWsgZdVyK9xsfw2bG8cSm1mu2xbIG6OUxavcNN6Yx/HQf6FE1fDRLWged4K0OTfMn +4xZNvpg5IpaFvfTZFqqiq7PmgZimcQ/VnHw4alxPhvcvxVsp5TsvTkO+FJey2giF4x8 CDeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-117241-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n14-20020a05640205ce00b0056bd00515ffsi2668440edx.284.2024.03.25.09.25.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 09:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117241-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-117241-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117241-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 B747F1F3A5F2 for ; Mon, 25 Mar 2024 16:23:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C378382C7D; Mon, 25 Mar 2024 14:21:55 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 C192D12FF7B; Mon, 25 Mar 2024 14:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711376515; cv=none; b=QHGb/mb1UYeAVCISSCjqg+XQvIAAzUk0bjm4kFChu8v3tnmov7dbhUv4PpPs8RECVYxAA86bqgrtDsG2ruwa0I4tLz9XoaflSEbdEMS22s7ge5hCQsysYVNLT9DbZ8JIU+vjXvLZw1fF9wJ2hyWJU71ulFPJfp3DMEyhCwLMV3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711376515; c=relaxed/simple; bh=remlzvMPT/QCPT/BdyHqvjUubqtO2O/mnAw+udlqkt0=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=aNQ3z6McWqDhMRTeUT3j4m9K/WRzodiVRHjkPJuBcYgsNNiH6gUpR0Fsy4hXO+CQU70//YWtGdEF5hNaafWvkIqlRo8+ocoNqj1KAmLSd8RHym78L/tfLJy9s1fcSCfNT9aj0aOH0rgI1ooq8Wpz2xRBNH9vnkj7cANcoFrz9/k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4V3FV76DKfz1GD06; Mon, 25 Mar 2024 22:21:19 +0800 (CST) Received: from canpemm500008.china.huawei.com (unknown [7.192.105.151]) by mail.maildlp.com (Postfix) with ESMTPS id B6D541A0172; Mon, 25 Mar 2024 22:21:48 +0800 (CST) Received: from canpemm500004.china.huawei.com (7.192.104.92) by canpemm500008.china.huawei.com (7.192.105.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 25 Mar 2024 22:21:48 +0800 Received: from [10.174.179.14] (10.174.179.14) by canpemm500004.china.huawei.com (7.192.104.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 25 Mar 2024 22:21:47 +0800 Subject: Re: [PATCH] scsi: libsas: Add SMP request allocation handler callback To: Damien Le Moal , Yihang Li , , , , CC: , , , , References: <20240325131751.1840329-1-liyihang9@huawei.com> From: Jason Yan Message-ID: Date: Mon, 25 Mar 2024 22:21:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500004.china.huawei.com (7.192.104.92) On 2024/3/25 22:03, Damien Le Moal wrote: > On 3/25/24 22:17, Yihang Li wrote: >> This series [1] reducing the kmalloc() minimum alignment on arm64 to 8 >> (from 128). > > And ? What is the point you are trying to convey here ? > >> The hisi_sas has special requirements on the memory address alignment >> (must be 16-byte-aligned) of the command request frame, so add a SMP >> request allocation callback and fill it in for the hisi_sas driver. > > 128 is aligned to 16. So what is the problem you are trying to solve here ? > Can you clarify ? I suspect this is all about memory allocation optimization ? After series [1] been merged, kmalloc is 8-byte-aligned, however hisi_sas hardware needs 16-byte-aligned. That's the problem. > >> >> Link: https://lkml.kernel.org/r/20230612153201.554742-1-catalin.marinas@arm.com [1] >> Signed-off-by: Yihang Li >> --- >> drivers/scsi/hisi_sas/hisi_sas_main.c | 14 ++++++++++++ >> drivers/scsi/libsas/sas_expander.c | 31 ++++++++++++++++++--------- >> include/scsi/libsas.h | 3 +++ >> 3 files changed, 38 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c >> index 097dfe4b620d..40329558d435 100644 >> --- a/drivers/scsi/hisi_sas/hisi_sas_main.c >> +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c >> @@ -2031,6 +2031,19 @@ static int hisi_sas_write_gpio(struct sas_ha_struct *sha, u8 reg_type, >> reg_index, reg_count, write_data); >> } >> >> +static void *hisi_sas_alloc_smp_req(int size) >> +{ >> + u8 *p; >> + >> + /* The address must be 16-byte-aligned. */ > > ARCH_DMA_MINALIGN is not always 16, right ? > >> + size = ALIGN(size, ARCH_DMA_MINALIGN); >> + p = kzalloc(size, GFP_KERNEL); >> + if (p) >> + p[0] = SMP_REQUEST; >> + >> + return p; >> +} >> + >> static void hisi_sas_phy_disconnected(struct hisi_sas_phy *phy) >> { >> struct asd_sas_phy *sas_phy = &phy->sas_phy; >> @@ -2130,6 +2143,7 @@ static struct sas_domain_function_template hisi_sas_transport_ops = { >> .lldd_write_gpio = hisi_sas_write_gpio, >> .lldd_tmf_aborted = hisi_sas_tmf_aborted, >> .lldd_abort_timeout = hisi_sas_internal_abort_timeout, >> + .lldd_alloc_smp_req = hisi_sas_alloc_smp_req, > > Why this complexity ? Why not simply modify alloc_smp_req() to have the required > alignment ? This will avoid a costly indirect function call. Yeah, I think it's simpler to modify alloc_smp_req() directly too. Yihang, Can you please cook a new one? Thansk, Jason