Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp389495rdf; Tue, 21 Nov 2023 05:44:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQJ+5iVzA/4TRwHu0+ApivnHA1HGjG888NjsNfdymVDL2jkwwUyS5HisDzOn6gcnoZPa59 X-Received: by 2002:a05:6808:1915:b0:3b5:75ad:5b73 with SMTP id bf21-20020a056808191500b003b575ad5b73mr15878356oib.13.1700574252724; Tue, 21 Nov 2023 05:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700574252; cv=none; d=google.com; s=arc-20160816; b=e/TuxM2CUFbhAS6Y8x2vIwsxtnV+MHYKRlUoKIXkyfhGfQ3jSLvb2d3u21pdXCkMaV 7nKzmmIB1zu2HFfqofHeZCue5WmV9EkdOnNxDPXZwCgWKVR3FJRlo/alwSO1X7eGqpjf 501E2Se2R3YOKa/CEYaJDstAB+OICE9GW0LHbE3jCPrC6MYxEKq9wMNm8q0FKjmbmwLj rI5xsL2uWPkj0uH3prSBJX0pvkjnDBd377E/rMeDY9YoKvmTST0/8ghoWJoiPbzkqAeM QSseBsbLwFjHllEN4c8fwQMfe/63vrBylWu64rnG/gvGnogCkwVpqoXhjlM8RhHZge+s 6JSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=VEfIXtwuorCvI+Dutmy2bt7VlpOi+lBF8ApSgTDAlwU=; fh=L91xCIc/fK2yJI/vQZo7Nun1oIpqS/HKrdjeVidRxOk=; b=VEy4XVwPFWLIn7ltf+aqE1OrQ5q9mzVURSdBNXsF/FVxBVMKfFS2sK9C1cuoa66MrF EEveP19wHSPzPDiL2GzyzXc+Ik1khZK7cHui/d5vA1Ez/L5dZdIR95PmAyTJjol3nGjo 9k1QujporsDhvYuAWoGMQ0uKXB8qgKYfdkNHgoSZY2ckO06v2opXIuIlEVCJsi21TG5P 3nVn4QA1dbZ6Pw1BIsUshhWeNe3PsXosyYnFWKmop5i11sGOcbg+t+wGuXEJgldBvT8n 1WeN0a3zWLhZbxK4GtrJGersnZSMefdCye4izJxffT6heJP7HC+4Kw/bZvqyHciStcB0 o4VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h8-20020a63c008000000b0059779ae5899si10024114pgg.836.2023.11.21.05.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 05:44:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7BADC8129AED; Tue, 21 Nov 2023 05:44:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234303AbjKUNoB (ORCPT + 99 others); Tue, 21 Nov 2023 08:44:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233844AbjKUNoA (ORCPT ); Tue, 21 Nov 2023 08:44:00 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BFF2D6F; Tue, 21 Nov 2023 05:43:55 -0800 (PST) Received: from dggpemd200003.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SZQTC07mWzMnGF; Tue, 21 Nov 2023 21:39:11 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by dggpemd200003.china.huawei.com (7.185.36.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.28; Tue, 21 Nov 2023 21:43:53 +0800 From: Chenghai Huang To: , CC: , , Subject: [PATCH fot-next] hisilicon/zip: Add ZIP comp high perf configuration Date: Tue, 21 Nov 2023 21:40:24 +0800 Message-ID: <20231121134024.114476-1-huangchenghai2@huawei.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemd200003.china.huawei.com (7.185.36.122) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 05:44:11 -0800 (PST) To meet specific application scenarios, the function of switching between the high performance mode and the high compression mode is added. Use the perf_mode=0/1 configuration to set the compression high-perf mode, 0(default, high compression mode), 1(high performance mode). Signed-off-by: Chenghai Huang --- drivers/crypto/hisilicon/zip/zip_main.c | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index d6672b777efc..4309cfb41374 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -107,6 +107,14 @@ #define HZIP_CLOCK_GATED_EN (HZIP_CORE_GATED_EN | \ HZIP_CORE_GATED_OOO_EN) +/* zip comp high performance */ +#define HZIP_HIGH_PERF_OFFSET 0x301208 + +enum { + HZIP_HIGH_COMP_RATE, + HZIP_HIGH_COMP_PERF, +}; + static const char hisi_zip_name[] = "hisi_zip"; static struct dentry *hzip_debugfs_root; @@ -352,6 +360,36 @@ static int hzip_diff_regs_show(struct seq_file *s, void *unused) return 0; } DEFINE_SHOW_ATTRIBUTE(hzip_diff_regs); + +static int perf_mode_set(const char *val, const struct kernel_param *kp) +{ + int ret; + u32 n; + + if (!val) + return -EINVAL; + + ret = kstrtou32(val, 10, &n); + if (ret != 0 || (n != HZIP_HIGH_COMP_PERF && + n != HZIP_HIGH_COMP_RATE)) + return -EINVAL; + + return param_set_int(val, kp); +} + +static const struct kernel_param_ops zip_com_perf_ops = { + .set = perf_mode_set, + .get = param_get_int, +}; + +/* + * perf_mode = 0 means enable high compression rate mode, + * perf_mode = 1 means enable high compression performance mode. + */ +static u32 perf_mode = HZIP_HIGH_COMP_RATE; +module_param_cb(perf_mode, &zip_com_perf_ops, &perf_mode, 0444); +MODULE_PARM_DESC(perf_mode, "ZIP high perf mode 0(default), 1(enable)"); + static const struct kernel_param_ops zip_uacce_mode_ops = { .set = uacce_mode_set, .get = param_get_int, @@ -417,6 +455,28 @@ bool hisi_zip_alg_support(struct hisi_qm *qm, u32 alg) return false; } +static int hisi_zip_set_high_perf(struct hisi_qm *qm) +{ + u32 val; + int ret; + + val = readl_relaxed(qm->io_base + HZIP_HIGH_PERF_OFFSET); + if (perf_mode == HZIP_HIGH_COMP_PERF) + val |= HZIP_HIGH_COMP_PERF; + else + val &= ~HZIP_HIGH_COMP_PERF; + + /* Set perf mode */ + writel(val, qm->io_base + HZIP_HIGH_PERF_OFFSET); + ret = readl_relaxed_poll_timeout(qm->io_base + HZIP_HIGH_PERF_OFFSET, + val, val == perf_mode, HZIP_DELAY_1_US, + HZIP_POLL_TIMEOUT_US); + if (ret) + pci_err(qm->pdev, "failed to set perf mode\n"); + + return ret; +} + static int hisi_zip_set_qm_algs(struct hisi_qm *qm) { struct device *dev = &qm->pdev->dev; @@ -1115,6 +1175,10 @@ static int hisi_zip_pf_probe_init(struct hisi_zip *hisi_zip) if (ret) return ret; + ret = hisi_zip_set_high_perf(qm); + if (ret) + return ret; + hisi_zip_open_sva_prefetch(qm); hisi_qm_dev_err_init(qm); hisi_zip_debug_regs_clear(qm); -- 2.30.0