From patchwork Mon Aug 5 13:48:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 170564 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4322238ile; Mon, 5 Aug 2019 06:50:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQNpV6HTW+1WMOP8F6zcoetZh4iHFLwSnvedl3l0+aVpt4huIFmVoGu0ko861oNfOqaPEb X-Received: by 2002:a63:e44b:: with SMTP id i11mr87706406pgk.297.1565013058346; Mon, 05 Aug 2019 06:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565013058; cv=none; d=google.com; s=arc-20160816; b=odChpGLa5eKxci6Td6FfuZcOMnH3xL/bjjhSQQ3RIiSuilJ0uYvDKPjrRpmPqUz66p FUsVJ4td+e7RHLRmHySMceTnN7UWSTi8s8I+qGTZtKTajz81XiwFxZaeqwJyQd6GGS8H +nLW+oXo8D/88S1A4ntDuIH2aOpicIsaUfNerBqPXnoz9mHOjxTtMAGnN4fmYdq053qC u6pz0zWH0fBcHUpcUHbpDprSlp6EIzLKXNkvJo940zTvqVY589yOORoXbiGI/PK2fwgK CS5kDxMaK4W+/aV45dDCeSucZtUIhO1ePf+Q+1grMa7DPXM3p0nta/emo+ZuMfGUQxME 8xfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=24rgm9wkBJ1hTkpySSYQ8RP+bcQ2HAxtlkZmN9O48sA=; b=deKFauroV0TaXl6FPv+rt5ZuJO4/fJRoG5wTXg8nR8BfRXv4mCNhiUYxKJxEOldyBR XaFJ5+zywWgiG6m0zrhmbEVRapygMjZ5kcG/sqS13pPefZjMFlxhH27P+rE1xBHhq6bI U3Rh4Qze0nEMd2UW5e/kc/EjztZW3PtKlztVFGffc7pS2/dwjdk9tQ1WXjIU2uNW3tWS LA1yQI+V7ywdzh4ErMQ+T1OBR6AUO0sYvkg1RDtT3X1QCI0Ev6eC3gMf/ckEus5d1cYb P4F4wwS8dYqFMb4Mg5r+ArhnYITxoE6uPl+2RO591Z17Pprbioiq3ButkFtJABLz1car 2YoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si44357502pfl.288.2019.08.05.06.50.57 for ; Mon, 05 Aug 2019 06:50:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-scsi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-scsi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbfHENuk (ORCPT ); Mon, 5 Aug 2019 09:50:40 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44550 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729845AbfHENu2 (ORCPT ); Mon, 5 Aug 2019 09:50:28 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 20F3588411166E615543; Mon, 5 Aug 2019 21:50:24 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 21:50:13 +0800 From: John Garry To: , CC: , , , Xiang Chen , "John Garry" Subject: [PATCH 08/15] scsi: hisi_sas: Make slot buf minimum allocation of PAGE_SIZE Date: Mon, 5 Aug 2019 21:48:05 +0800 Message-ID: <1565012892-75940-9-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1565012892-75940-1-git-send-email-john.garry@huawei.com> References: <1565012892-75940-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Xiang Chen For a system with PAGE_SIZE of 16K or 64K, the size every time we want to alloc may be small like 4K, but for function dmam_alloc_coherent(), the least size it allocates is PAGE_SIZE, so it will waste much memory for the situation. To solve the issue, limit the minimum allocation size of slot buf to PAGE_SIZE. Signed-off-by: Xiang Chen Signed-off-by: John Garry --- drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c index 7efa8dfa0cc1..39ae69e42d26 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_main.c +++ b/drivers/scsi/hisi_sas/hisi_sas_main.c @@ -2389,7 +2389,7 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba) else sz_slot_buf_ru = sizeof(struct hisi_sas_slot_buf_table); sz_slot_buf_ru = roundup(sz_slot_buf_ru, 64); - s = lcm(max_command_entries_ru, sz_slot_buf_ru); + s = max(lcm(max_command_entries_ru, sz_slot_buf_ru), PAGE_SIZE); blk_cnt = (max_command_entries_ru * sz_slot_buf_ru) / s; slots_per_blk = s / sz_slot_buf_ru;