From patchwork Tue Jan 24 03:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 47521 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1958591wrn; Mon, 23 Jan 2023 20:17:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXs+zNbQ2w6Dubt9B54KNSQVXLWt0hNtD+DFCEfzypK+CxrFP8pBJZY3uGzBELl34JIKAQfO X-Received: by 2002:a05:6402:43ce:b0:461:2288:6808 with SMTP id p14-20020a05640243ce00b0046122886808mr29588362edc.21.1674533834036; Mon, 23 Jan 2023 20:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674533834; cv=none; d=google.com; s=arc-20160816; b=vjF2lqhX3b3QTwppM5NGIywAdmrHSmEFBpKu2Ga1AqMtM6dqGiK6JTIxaZgsA+Ili6 yNd5w+l05aJBPDi1c9GJ3t2wwYkDjEs+BcDVcJeam1ca/gVKIJfZeZd/RA0ySFZ6ZwMx 23egkEyqqgxuX2AEPsA/hdhy6BFozGs/yGqWrpbCOqNKv4oMBMcJW1DeYc/v99Pr8UlI v1Ny4jyLoFWJlguzK8UGjLil0d48ngzAjAhUkDlmEz9tLDolmHkZ+YaPDpedRGMboAU6 FBhNdhSaPbQW4iv9XrVTLXoQ44rC8LzRj+2HcTYp9MVtcU9mYoK32H86aRdQZ1uJJ61i XfAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=HnI59rvn4/v2sg5HehUasd2frp5NQmidbIES/KBH9e4=; b=RgpU6xFKpd0Bp4YwJxLYY3tbI2cLeVLaNgFRkEtxcBBs3ko5Ujh0NwhIygrNAOOr+k 09sWbXk2ea47tY/D7AgyUOD5cFmI/+66h/kM29puGJ+jTTFX8DQmH9DmH74T4aknqmIR GFWlLgBFWZYNTAF7r2O4I3Rpb/alyvVSG4YBfNi+ZxsU8+e7Ed1dg6nanSB0D8NvMRrk fihzCQvfphMILG9om7TkQ4TqYuWdu4pkI3p0NaumQ6DtY/nT2qnr3PAnjySxcxZ32krh jZtt5NBkWFli+50hMsu0aTU/9Gk/90I+Bxi+rSuEw2uvG5E8q00cXxkKlAATOYMcbXXb ghQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NRoWEEbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a056402515100b004639a46d725si1492480edd.31.2023.01.23.20.16.38; Mon, 23 Jan 2023 20:17:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=NRoWEEbK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232149AbjAXDyF (ORCPT + 99 others); Mon, 23 Jan 2023 22:54:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232358AbjAXDyA (ORCPT ); Mon, 23 Jan 2023 22:54:00 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A180A3A5AF; Mon, 23 Jan 2023 19:53:59 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30O3MxV1029467; Tue, 24 Jan 2023 03:53:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=HnI59rvn4/v2sg5HehUasd2frp5NQmidbIES/KBH9e4=; b=NRoWEEbKaKG+tglraWppF7eCoo7IYKmw4vN7qIeIck3SzbaldpMlRaK3nDU13v41DaX+ 9Z/CcNfeobVSPSBTN4Ijxy+aD9pS+OMmZftzi+gXcfBSEg81/6tMXHlxjCOcRkrBipwK gusbPWquuyxWerm8Zz1wUpEU0EoH2LOsYN3lHL57O38c9zCGWo2wOIe24AXoLesCzIgD gk2ygwLWlu3axd17J9Yi/zG+yAn2RPaxuTpp+7iMK17gm5wi9FZ0COc/NWU/X+iy0TpS gDH8W9MK8ePYa0sw7pPrll2q6eA/mAdfJZ10x8OIMridDEknkxCXH0jP+drofRN66eWo aQ== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n89dnc88e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 03:53:48 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30O3rdNw030505 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 03:53:39 GMT Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 23 Jan 2023 19:53:36 -0800 From: Souradeep Chowdhury To: Andy Gross , Konrad Dybcio , Bjorn Andersson , "Alex Elder" CC: , , , Sai Prakash Ranjan , Sibi Sankar , "Rajendra Nayak" , , Souradeep Chowdhury Subject: [PATCH V2 1/3] soc: qcom: dcc: Add bootconfig support for DCC Date: Tue, 24 Jan 2023 09:22:35 +0530 Message-ID: <62d98c7d56e752afff5216cfcd42451edb82cb4d.1674531462.git.quic_schowdhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: Vv_ZXTOp5Q9hwVmfUA-BskBU680DePef X-Proofpoint-ORIG-GUID: Vv_ZXTOp5Q9hwVmfUA-BskBU680DePef X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 suspectscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240033 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755875989252197310?= X-GMAIL-MSGID: =?utf-8?q?1755875989252197310?= Add bootconfig parser for DCC which is used to configure addresses in DCC during boot time. This is needed to debug crashes that can happen during boot-time. The expected format of a bootconfig file is as follows:- dcc_config { link_list_ { id = items =
, } } Example:- dcc_config { link_list_6 { id = 6 items = R_0x1781005c_1_apb, R_0x1782005c_1_apb } } Signed-off-by: Souradeep Chowdhury --- drivers/soc/qcom/Kconfig | 1 + drivers/soc/qcom/dcc.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 21c4ce2..f913b72 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -73,6 +73,7 @@ config QCOM_LLCC config QCOM_DCC tristate "Qualcomm Technologies, Inc. Data Capture and Compare(DCC) engine driver" depends on ARCH_QCOM || COMPILE_TEST + select BOOT_CONFIG help This option enables driver for Data Capture and Compare engine. DCC driver provides interface to configure DCC block and read back diff --git a/drivers/soc/qcom/dcc.c b/drivers/soc/qcom/dcc.c index 5b50d63..93e8f86 100644 --- a/drivers/soc/qcom/dcc.c +++ b/drivers/soc/qcom/dcc.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -148,6 +149,18 @@ struct dcc_cfg_loop_attr { bool loop_start; }; +static char *replace_char(char *str, char find, char replace) +{ + char *current_pos = strchr(str, find); + + while (current_pos) { + *current_pos = replace; + current_pos = strchr(current_pos, find); + } + + return str; +} + static inline u32 dcc_list_offset(int version) { return version == 1 ? 0x1c : version == 2 ? 0x2c : 0x34; @@ -1185,13 +1198,62 @@ static void dcc_sram_dev_exit(struct dcc_drvdata *drvdata) misc_deregister(&drvdata->sram_dev); } -static int dcc_probe(struct platform_device *pdev) +static int __init dcc_bootconfig_parse(struct dcc_drvdata *drvdata, struct xbc_node *dcc_node) +{ + struct xbc_node *linked_list, *node; + int curr_list, ret; + const char *p; + char *input, *token; + char val[30]; + + xbc_node_for_each_subkey(dcc_node, linked_list) { + p = xbc_node_find_value(linked_list, "id", &node); + if (p) { + ret = kstrtoint(p, 0, &curr_list); + if (ret) + return ret; + } else { + dev_err(drvdata->dev, "List number not specified\n"); + continue; + } + + p = xbc_node_find_value(linked_list, "items", &node); + if (!p) + continue; + xbc_array_for_each_value(node, p) { + strcpy(val, p); + input = replace_char(val, '_', ' '); + token = strsep(&input, " "); + + if (!strcmp("R", token)) { + ret = dcc_config_add_read(drvdata, input, curr_list); + } else if (!strcmp("W", token)) { + ret = dcc_config_add_write(drvdata, input, curr_list); + } else if (!strcmp("RW", token)) { + ret = dcc_config_add_read_write(drvdata, input, curr_list); + } else if (!strcmp("L", token)) { + ret = dcc_config_add_loop(drvdata, input, curr_list); + } else { + dev_err(drvdata->dev, "%s is not a correct input\n", token); + return -EINVAL; + } + if (ret) + return ret; + } + dcc_enable(drvdata, curr_list); + } + + return 0; +} + +static int __init dcc_probe(struct platform_device *pdev) { u32 val; int ret = 0, i; struct device *dev = &pdev->dev; struct dcc_drvdata *drvdata; struct resource *res; + struct xbc_node *dcc_node; drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) @@ -1263,6 +1325,13 @@ static int dcc_probe(struct platform_device *pdev) dcc_create_debug_dir(drvdata); + dcc_node = xbc_find_node("dcc_config"); + if (dcc_node) { + ret = dcc_bootconfig_parse(drvdata, dcc_node); + if (ret) + dev_err(drvdata->dev, "DCC: Bootconfig parse error.\n"); + } + return 0; } @@ -1287,14 +1356,13 @@ static const struct of_device_id dcc_match_table[] = { MODULE_DEVICE_TABLE(of, dcc_match_table); static struct platform_driver dcc_driver = { - .probe = dcc_probe, .remove = dcc_remove, .driver = { .name = "qcom-dcc", .of_match_table = dcc_match_table, }, }; -module_platform_driver(dcc_driver); +module_platform_driver_probe(dcc_driver, dcc_probe); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Qualcomm Technologies Inc. DCC driver"); From patchwork Tue Jan 24 03:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 47520 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1957069wrn; Mon, 23 Jan 2023 20:11:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXsEnFH0wpg3mRW8E2tIhaaG5wPqHvLIpUWjrCENfGacS5BmNqPHdbWOFoSt9WY9j4SVs8X2 X-Received: by 2002:a17:902:a5c6:b0:193:33d4:d509 with SMTP id t6-20020a170902a5c600b0019333d4d509mr49683836plq.30.1674533515263; Mon, 23 Jan 2023 20:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674533515; cv=none; d=google.com; s=arc-20160816; b=OZi1HYQNzbw0KJJLCCi6gGvp7sssd7uJwad3b2vs4rptxOb45KNl/ZnUAoJVcwcZiq wrslumIFWbqA0Bb+xTi5kcNwyjsXurNhGjBjQOW+F6m77bdFUub/5nl1nSRuYM485Y3y k3QsLuytIFpvxLYXep+gLAKH3byOAphuHAp1rJ7UfnhBQlNOsJldecr3KPLm/7gRPZ6W QOiN4F4sDrqcSxkVuBQBaFnJhB4R8p1z3FMWtQjbvkaEIav6TMkEaVqi5SSv8EdY7Ni1 r9Bgc7IHzWj6pZlqZPZ7Hvxm9VcrksHEzP0TeuEO2xXB3yVyIE+JoC8CXBdbFdDWiQ73 NV5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=RB1IZ0eslA08J5XuZcIGmlS0kK2WBJ8M8zae1EMsJZM=; b=IqoQPq8y1uSSGutmiPotRldciWzwk0pQQ/DRhXlsFJzTU9qEnUjS222nhfJGghdybF m+GPlnCM8IVijZ8oLuTXePvaIzpBfiSOmARzqDSfE7QXnZ8SgWxKQIoKUR8YyXwiBgE+ 8zFjI5soBBxvsQhrd+worgMd6/E+SYnyaR6hWFNTlpB53wWQuYEbFSb38Gz3c57LknaF gN2T800RfQe9Pa7R3AU7k1C5rYT2the6y6IgirT0u/aCX3EI8OY7iBlVipg1LAeKZwYg cQWLxe0Wys51f7pCvoGs6VuOj3eztaIElobNOaaQsYNrh5bYIhdlEp7r4Mxyt97eDTj4 IFMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dLqPoo78; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x19-20020a17090300d300b00189bbc95db1si1230077plc.11.2023.01.23.20.11.43; Mon, 23 Jan 2023 20:11:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=dLqPoo78; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232209AbjAXDx6 (ORCPT + 99 others); Mon, 23 Jan 2023 22:53:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbjAXDx5 (ORCPT ); Mon, 23 Jan 2023 22:53:57 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F2EE39CF1; Mon, 23 Jan 2023 19:53:54 -0800 (PST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30O3nn4B009124; Tue, 24 Jan 2023 03:53:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=RB1IZ0eslA08J5XuZcIGmlS0kK2WBJ8M8zae1EMsJZM=; b=dLqPoo78UzRewDAXoqSmfL9OIypnQ28HeKb4FdWG05xiNKyp62aNdyroMySZ6+uE040n 95zYfaz7wK4vYNeYPGu35/phJO0Tvw/U1e3Iv3Lu0k7qBS7FLujpf7gdK1sWtYFWiAfA NCbuWQ8fKGkdJ5ssc65Gg8C2nPDtylOI3sQp1T0mhKrxdEclNTAumpfFwvdHc9WYYbdt HNdPlxgIMp9QayZ2YXQMqVuJ6CbDFby5khp7NvVxQQhya24EraLdphFc/DfKO1ag9oRk /VXlBRIs+mCxFKdj2ejY9GWZPFcwzImqPb8Mvir4KASoWkvsfuDl2Adq2bmcLc0RpWsv Ag== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n89pwcb29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 03:53:44 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30O3rhh2024799 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 03:53:43 GMT Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 23 Jan 2023 19:53:40 -0800 From: Souradeep Chowdhury To: Andy Gross , Konrad Dybcio , Bjorn Andersson , "Alex Elder" CC: , , , Sai Prakash Ranjan , Sibi Sankar , "Rajendra Nayak" , , Souradeep Chowdhury Subject: [PATCH V2 2/3] soc: qcom: dcc: Add CTI-trigger support for DCC Date: Tue, 24 Jan 2023 09:22:36 +0530 Message-ID: <8b25308a5dc78ab2c8929db46a347fceedb54b64.1674531462.git.quic_schowdhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: mtj_CjR6d50YGba_Nb-gGv26L16GKu4X X-Proofpoint-GUID: mtj_CjR6d50YGba_Nb-gGv26L16GKu4X X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 clxscore=1015 impostorscore=0 suspectscore=0 bulkscore=0 adultscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240032 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755875655255147729?= X-GMAIL-MSGID: =?utf-8?q?1755875655255147729?= CTI trigger is used to enable the Cross trigger interface for DCC. On enabling CTI trigger the dcc software trigger can be done by writing to CTI trig-out. Add the debugfs file ctitrigger which gives the user option to enable ctitrigger for a list. Also add hwtrigger debugfs file which needs to be disabled on enabling the CTI-trigger. Hwtrigger needs to be disabled for components to be able to write to cti-trigout. Signed-off-by: Souradeep Chowdhury --- Documentation/ABI/testing/debugfs-driver-dcc | 16 +++ drivers/soc/qcom/dcc.c | 148 ++++++++++++++++++++++++++- 2 files changed, 160 insertions(+), 4 deletions(-) diff --git a/Documentation/ABI/testing/debugfs-driver-dcc b/Documentation/ABI/testing/debugfs-driver-dcc index 27ed591..6f5d965 100644 --- a/Documentation/ABI/testing/debugfs-driver-dcc +++ b/Documentation/ABI/testing/debugfs-driver-dcc @@ -125,3 +125,19 @@ Description: on manual or crash induced triggers. Lists must be configured and enabled sequentially, e.g. list 2 can only be enabled when list 1 have so. + +What: /sys/kernel/debug/dcc/.../[list-number]/ctitrigger +Date: January 2023 +Contact: Souradeep Chowdhury +Description: + This debugfs interface is used for enabling the + ctitrigger. Ctitrigger can be enabled by writing + a '1' to the file. + +What: /sys/kernel/debug/dcc/.../[list-number]/hwtrigger +Date: January 2023 +Contact: Souradeep Chowdhury +Description: + This debugfs interface is used for enabling the + hwtrigger. Hwtrigger can be enabled by writing + a '1' to the file. diff --git a/drivers/soc/qcom/dcc.c b/drivers/soc/qcom/dcc.c index 93e8f86..a75b9af 100644 --- a/drivers/soc/qcom/dcc.c +++ b/drivers/soc/qcom/dcc.c @@ -37,6 +37,7 @@ #define DCC_LL_INT_STATUS 0x1c #define DCC_LL_SW_TRIGGER 0x2c #define DCC_LL_BUS_ACCESS_STATUS 0x30 +#define DCC_CTI_TRIG 0x34 /* Default value used if a bit 6 in the HW_INFO register is set. */ #define DCC_FIX_LOOP_OFFSET 16 @@ -115,6 +116,8 @@ struct dcc_config_entry { * @nr_link_list: Total number of linkedlists supported by the DCC configuration * @loop_shift: Loop offset bits range for the addresses * @enable_bitmap: Bitmap to capture the enabled status of each linked list of addresses + * @cti_bitmap: Bitmap to capture the cti-trigger status of each linked list of addresses + * @hwtrig_bitmap: Bitmap to capture the hwtrig status of each linked list of addresses */ struct dcc_drvdata { void __iomem *base; @@ -132,6 +135,8 @@ struct dcc_drvdata { size_t nr_link_list; u8 loop_shift; unsigned long *enable_bitmap; + unsigned long *cti_bitmap; + unsigned long *hwtrig_bitmap; }; struct dcc_cfg_attr { @@ -213,7 +218,10 @@ static int dcc_sw_trigger(struct dcc_drvdata *drvdata) if (!test_bit(i, drvdata->enable_bitmap)) continue; ll_cfg = dcc_list_readl(drvdata, i, DCC_LL_CFG); - tmp_ll_cfg = ll_cfg & ~DCC_TRIGGER_MASK; + if (drvdata->mem_map_ver != 3) + tmp_ll_cfg = ll_cfg & ~DCC_TRIGGER_MASK; + else + tmp_ll_cfg = ll_cfg & ~BIT(8); dcc_list_writel(drvdata, tmp_ll_cfg, i, DCC_LL_CFG); dcc_list_writel(drvdata, 1, i, DCC_LL_SW_TRIGGER); dcc_list_writel(drvdata, ll_cfg, i, DCC_LL_CFG); @@ -590,6 +598,23 @@ static int dcc_enable(struct dcc_drvdata *drvdata, unsigned int curr_list) /* 5. Configure trigger */ dcc_list_writel(drvdata, DCC_TRIGGER_MASK, curr_list, DCC_LL_CFG); + if (drvdata->mem_map_ver == 3) { + dcc_list_writel(drvdata, test_bit(curr_list, drvdata->cti_bitmap), curr_list, + DCC_CTI_TRIG); + if (test_bit(curr_list, drvdata->hwtrig_bitmap)) + dcc_list_writel(drvdata, BIT(8), curr_list, DCC_LL_CFG); + else + dcc_list_writel(drvdata, (unsigned int)~BIT(8), curr_list, DCC_LL_CFG); + } else { + if (test_bit(curr_list, drvdata->hwtrig_bitmap)) + dcc_list_writel(drvdata, DCC_TRIGGER_MASK | + test_bit(curr_list, drvdata->cti_bitmap) << 8, + curr_list, DCC_LL_CFG); + else + dcc_list_writel(drvdata, ~DCC_TRIGGER_MASK & + test_bit(curr_list, drvdata->cti_bitmap) << 8, + curr_list, DCC_LL_CFG); + } out_unlock: mutex_unlock(&drvdata->mutex); @@ -1116,6 +1141,110 @@ static const struct file_operations config_fops = { .release = single_release, }; +static ssize_t ctitrigger_read(struct file *filp, char __user *userbuf, + size_t count, loff_t *ppos) +{ + char *buf; + int curr_list; + struct dcc_drvdata *drvdata = filp->private_data; + + curr_list = dcc_filp_curr_list(filp); + + mutex_lock(&drvdata->mutex); + + if (test_bit(curr_list, drvdata->cti_bitmap)) + buf = "Y\n"; + else + buf = "N\n"; + + mutex_unlock(&drvdata->mutex); + + return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); +} + +static ssize_t ctitrigger_write(struct file *filp, const char __user *userbuf, + size_t count, loff_t *ppos) +{ + int ret, curr_list; + bool val; + struct dcc_drvdata *drvdata = filp->private_data; + + curr_list = dcc_filp_curr_list(filp); + + if (test_bit(curr_list, drvdata->enable_bitmap)) + return -EBUSY; + + ret = kstrtobool_from_user(userbuf, count, &val); + if (ret < 0) + return ret; + + if (val) + set_bit(curr_list, drvdata->cti_bitmap); + else + clear_bit(curr_list, drvdata->cti_bitmap); + + return count; +} + +static const struct file_operations ctitrigger_fops = { + .read = ctitrigger_read, + .write = ctitrigger_write, + .open = simple_open, + .llseek = generic_file_llseek, +}; + +static ssize_t hwtrigger_read(struct file *filp, char __user *userbuf, + size_t count, loff_t *ppos) +{ + char *buf; + int curr_list; + struct dcc_drvdata *drvdata = filp->private_data; + + curr_list = dcc_filp_curr_list(filp); + + mutex_lock(&drvdata->mutex); + + if (test_bit(curr_list, drvdata->hwtrig_bitmap)) + buf = "Y\n"; + else + buf = "N\n"; + + mutex_unlock(&drvdata->mutex); + + return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); +} + +static ssize_t hwtrigger_write(struct file *filp, const char __user *userbuf, + size_t count, loff_t *ppos) +{ + int ret, curr_list; + bool val; + struct dcc_drvdata *drvdata = filp->private_data; + + curr_list = dcc_filp_curr_list(filp); + + if (test_bit(curr_list, drvdata->enable_bitmap)) + return -EBUSY; + + ret = kstrtobool_from_user(userbuf, count, &val); + if (ret < 0) + return ret; + + if (val) + set_bit(curr_list, drvdata->hwtrig_bitmap); + else + clear_bit(curr_list, drvdata->hwtrig_bitmap); + + return count; +} + +static const struct file_operations hwtrigger_fops = { + .read = hwtrigger_read, + .write = hwtrigger_write, + .open = simple_open, + .llseek = generic_file_llseek, +}; + static void dcc_delete_debug_dir(struct dcc_drvdata *drvdata) { debugfs_remove_recursive(drvdata->dbg_dir); @@ -1145,6 +1274,8 @@ static void dcc_create_debug_dir(struct dcc_drvdata *drvdata) debugfs_create_file("ready", 0400, drvdata->dbg_dir, drvdata, &ready_fops); debugfs_create_file("config_reset", 0200, drvdata->dbg_dir, drvdata, &config_reset_fops); + debugfs_create_file("ctitrigger", 0600, list, drvdata, &ctitrigger_fops); + debugfs_create_file("hwtrigger", 0600, list, drvdata, &hwtrigger_fops); } static ssize_t dcc_sram_read(struct file *file, char __user *data, @@ -1304,18 +1435,27 @@ static int __init dcc_probe(struct platform_device *pdev) mutex_init(&drvdata->mutex); - drvdata->enable_bitmap = devm_kcalloc(dev, BITS_TO_LONGS(drvdata->nr_link_list), - sizeof(*drvdata->enable_bitmap), GFP_KERNEL); + drvdata->enable_bitmap = devm_bitmap_alloc(dev, drvdata->nr_link_list, GFP_KERNEL); if (!drvdata->enable_bitmap) return -ENOMEM; + drvdata->cti_bitmap = devm_bitmap_alloc(dev, drvdata->nr_link_list, GFP_KERNEL); + if (!drvdata->cti_bitmap) + return -ENOMEM; + + drvdata->hwtrig_bitmap = devm_bitmap_alloc(dev, drvdata->nr_link_list, GFP_KERNEL); + if (!drvdata->hwtrig_bitmap) + return -ENOMEM; + drvdata->cfg_head = devm_kcalloc(dev, drvdata->nr_link_list, sizeof(*drvdata->cfg_head), GFP_KERNEL); if (!drvdata->cfg_head) return -ENOMEM; - for (i = 0; i < drvdata->nr_link_list; i++) + for (i = 0; i < drvdata->nr_link_list; i++) { INIT_LIST_HEAD(&drvdata->cfg_head[i]); + set_bit(i, drvdata->hwtrig_bitmap); + } ret = dcc_sram_dev_init(drvdata); if (ret) { From patchwork Tue Jan 24 03:52:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 47522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1966217wrn; Mon, 23 Jan 2023 20:45:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwliVGY5YXMM0nWirGFIFP/bPgewtbpkoP8cQ+1jyFyPeJKM/YS/5h0A0buLsgbwcoojNQ X-Received: by 2002:a17:902:6b85:b0:193:1aa5:573 with SMTP id p5-20020a1709026b8500b001931aa50573mr22769953plk.13.1674535530992; Mon, 23 Jan 2023 20:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674535530; cv=none; d=google.com; s=arc-20160816; b=oQInA4581P+FyrsPKyfUyFknNxfD7mNwOnJprWEcep341RM535cA9g2UbE2Nzk9Eow 4D6XQnqxd87motje77snU2vePye2XEa4d8cQYW6+FYt0aVVXmbYqgGwnGAIxP5X9rDYV CyLdeXOPvRmB2amVf+TBI1t521do473RrUAOYYZCUsSoYrdUI3cnDszDCB7WxtYbx+LB nxzRtwpjzgOnCjrFAP4wE2c2zEaB5p0iA3J++Cm1osEuCJbgZ/FUEFTIK5sDrYdz6I1B P9gAP5SFqSENbhkkVEA4FM+2djZ8xageLjHB+cps7SW9GY2PNsXjSBdPjqQ6OkCx+Pzl +/vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=k65g+eExnJdy0tTXGuv1aap79ovZjuYjX4MIDwcI82Q=; b=f7rnyRMEmhi7uZq/3TFihh3GW2GntHWY/fhDURnbNo+Ar0NV+OLpmi0sEMjEsO/Uel 1n242lFVav9grGr6MfkhGeJQac/8v2xgPoVFg1jfK0tpVNPM7qeu7S68F7K19bK/P6hj N7wTGWmCpOZgiMJiAz9tZcaYbcWfcSPavDcp1i9yTxYpifZEjBysVlQHPh4/SMqkz39p Q84/QfWAAxOU2bWu64AtG4uFsyU/n44QFRh8VU/s7kYkdZrYua+e4LgbueYg4/M95VZ9 y6vONt7whSKUvKn2EkDQe6+K1rSiavZ+cnHRYUv+3+LoxtUXnfbMytHbpxsqxAACICNr qRjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="XTzuwMZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k64-20020a636f43000000b004d0e6a9776asi1009943pgc.594.2023.01.23.20.45.16; Mon, 23 Jan 2023 20:45:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="XTzuwMZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232354AbjAXDyA (ORCPT + 99 others); Mon, 23 Jan 2023 22:54:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232149AbjAXDx6 (ORCPT ); Mon, 23 Jan 2023 22:53:58 -0500 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EBDD39CF9; Mon, 23 Jan 2023 19:53:57 -0800 (PST) Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30O3Reru026831; Tue, 24 Jan 2023 03:53:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=k65g+eExnJdy0tTXGuv1aap79ovZjuYjX4MIDwcI82Q=; b=XTzuwMZ/bBwW20xBtgDrLzPYOsOtLZp/wyPificCgHgzZhMT6XANTaSyXcm2hBRg13gX t8hJpLDC+ddSdgyZCMXgV3FMLS5ALlNB0peHkQSM8nFLdAVVtGN1WeIpAHqiWau+xYh7 F+qPo2pNMRVXPEXSdjstWZwZj2/nokSJI0I/lWRqKFvel4MyODynp6QAQc30pKMzEAnA 0g/s2vMlEB2OJbbSNImWgNFJtEcmOHgn2ceF9RY+sa0OTI40hJgYwmi8bnpeX9sKmSRf eHumQTB/lzENvZHF1/owND18kpp6Ud05I5uSc9IX7hK07KfYSFEu0rCbJGf2QLYrXR1S 9w== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3n89k9c9vw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 03:53:48 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 30O3rlrr012426 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 24 Jan 2023 03:53:47 GMT Received: from blr-ubuntu-525.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 23 Jan 2023 19:53:43 -0800 From: Souradeep Chowdhury To: Andy Gross , Konrad Dybcio , Bjorn Andersson , "Alex Elder" CC: , , , Sai Prakash Ranjan , Sibi Sankar , "Rajendra Nayak" , , Souradeep Chowdhury Subject: [PATCH V2 3/3] soc: qcom: dcc: Add QAD support for DCC Date: Tue, 24 Jan 2023 09:22:37 +0530 Message-ID: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: 5VHETjDFzWxoh9-dqI4XZzLZ6m1yHI5v X-Proofpoint-GUID: 5VHETjDFzWxoh9-dqI4XZzLZ6m1yHI5v X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-01-23_12,2023-01-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=999 spamscore=0 clxscore=1015 adultscore=0 priorityscore=1501 phishscore=0 bulkscore=0 mlxscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301240032 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755877768821751779?= X-GMAIL-MSGID: =?utf-8?q?1755877768821751779?= Add QAD debugfs file for DCC which can be used to enable/disable the QAD for a list. QAD is used to specify the access control for DCC configurations, on enabling it the access control to dcc configuration space is restricted. On setting the QAD value, the list gets locked out for a particular component and cannot be used by the rest. Signed-off-by: Souradeep Chowdhury --- Documentation/ABI/testing/debugfs-driver-dcc | 8 ++++ drivers/soc/qcom/dcc.c | 68 ++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) diff --git a/Documentation/ABI/testing/debugfs-driver-dcc b/Documentation/ABI/testing/debugfs-driver-dcc index 6f5d965..a3c4657 100644 --- a/Documentation/ABI/testing/debugfs-driver-dcc +++ b/Documentation/ABI/testing/debugfs-driver-dcc @@ -141,3 +141,11 @@ Description: This debugfs interface is used for enabling the hwtrigger. Hwtrigger can be enabled by writing a '1' to the file. + +What: /sys/kernel/debug/dcc/.../[list-number]/QAD +Date: January 2023 +Contact: Souradeep Chowdhury +Description: + This debugfs interface is used for enabling the + QAD. QAD can be enabled by writing a '1' to the + file. diff --git a/drivers/soc/qcom/dcc.c b/drivers/soc/qcom/dcc.c index a75b9af..eeeaa8b 100644 --- a/drivers/soc/qcom/dcc.c +++ b/drivers/soc/qcom/dcc.c @@ -38,6 +38,7 @@ #define DCC_LL_SW_TRIGGER 0x2c #define DCC_LL_BUS_ACCESS_STATUS 0x30 #define DCC_CTI_TRIG 0x34 +#define DCC_QAD_OUTPUT 0x38 /* Default value used if a bit 6 in the HW_INFO register is set. */ #define DCC_FIX_LOOP_OFFSET 16 @@ -118,6 +119,7 @@ struct dcc_config_entry { * @enable_bitmap: Bitmap to capture the enabled status of each linked list of addresses * @cti_bitmap: Bitmap to capture the cti-trigger status of each linked list of addresses * @hwtrig_bitmap: Bitmap to capture the hwtrig status of each linked list of addresses + * @qad_bitmap: Bitmap to capture the qad status of each linked list of addresses */ struct dcc_drvdata { void __iomem *base; @@ -137,6 +139,7 @@ struct dcc_drvdata { unsigned long *enable_bitmap; unsigned long *cti_bitmap; unsigned long *hwtrig_bitmap; + unsigned long *qad_bitmap; }; struct dcc_cfg_attr { @@ -599,6 +602,8 @@ static int dcc_enable(struct dcc_drvdata *drvdata, unsigned int curr_list) dcc_list_writel(drvdata, DCC_TRIGGER_MASK, curr_list, DCC_LL_CFG); if (drvdata->mem_map_ver == 3) { + dcc_list_writel(drvdata, test_bit(curr_list, drvdata->qad_bitmap), curr_list, + DCC_QAD_OUTPUT); dcc_list_writel(drvdata, test_bit(curr_list, drvdata->cti_bitmap), curr_list, DCC_CTI_TRIG); if (test_bit(curr_list, drvdata->hwtrig_bitmap)) @@ -1245,6 +1250,64 @@ static const struct file_operations hwtrigger_fops = { .llseek = generic_file_llseek, }; +static ssize_t qad_read(struct file *filp, char __user *userbuf, + size_t count, loff_t *ppos) +{ + char *buf; + int curr_list; + + struct dcc_drvdata *drvdata = filp->private_data; + + curr_list = dcc_filp_curr_list(filp); + + mutex_lock(&drvdata->mutex); + + if (test_bit(curr_list, drvdata->qad_bitmap)) + buf = "Y\n"; + else + buf = "N\n"; + + mutex_unlock(&drvdata->mutex); + + return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); +} + +static ssize_t qad_write(struct file *filp, const char __user *userbuf, + size_t count, loff_t *ppos) +{ + int ret, curr_list; + bool val; + struct dcc_drvdata *drvdata = filp->private_data; + + curr_list = dcc_filp_curr_list(filp); + + if (drvdata->mem_map_ver != 3) { + dev_err(drvdata->dev, "QAD is not supported\n"); + return -EINVAL; + } + + if (test_bit(curr_list, drvdata->enable_bitmap)) + return -EBUSY; + + ret = kstrtobool_from_user(userbuf, count, &val); + if (ret < 0) + return ret; + + if (val) + set_bit(curr_list, drvdata->qad_bitmap); + else + clear_bit(curr_list, drvdata->qad_bitmap); + + return count; +} + +static const struct file_operations qad_fops = { + .read = qad_read, + .write = qad_write, + .open = simple_open, + .llseek = generic_file_llseek, +}; + static void dcc_delete_debug_dir(struct dcc_drvdata *drvdata) { debugfs_remove_recursive(drvdata->dbg_dir); @@ -1276,6 +1339,7 @@ static void dcc_create_debug_dir(struct dcc_drvdata *drvdata) drvdata, &config_reset_fops); debugfs_create_file("ctitrigger", 0600, list, drvdata, &ctitrigger_fops); debugfs_create_file("hwtrigger", 0600, list, drvdata, &hwtrigger_fops); + debugfs_create_file("QAD", 0600, list, drvdata, &qad_fops); } static ssize_t dcc_sram_read(struct file *file, char __user *data, @@ -1447,6 +1511,10 @@ static int __init dcc_probe(struct platform_device *pdev) if (!drvdata->hwtrig_bitmap) return -ENOMEM; + drvdata->qad_bitmap = devm_bitmap_alloc(dev, drvdata->nr_link_list, GFP_KERNEL); + if (!drvdata->qad_bitmap) + return -ENOMEM; + drvdata->cfg_head = devm_kcalloc(dev, drvdata->nr_link_list, sizeof(*drvdata->cfg_head), GFP_KERNEL); if (!drvdata->cfg_head)