From patchwork Mon Jan 30 05:13:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 50136 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2014288wrn; Sun, 29 Jan 2023 21:15:43 -0800 (PST) X-Google-Smtp-Source: AK7set/Aq9TfVNFeUFINjjDmJz1TTALl+IYidedCngv0HtLocqN1r5ZEeIsgKlZWBDrHUio38oUs X-Received: by 2002:a17:90a:1c8:b0:22b:e31b:c8d1 with SMTP id 8-20020a17090a01c800b0022be31bc8d1mr8116731pjd.37.1675055743583; Sun, 29 Jan 2023 21:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675055743; cv=none; d=google.com; s=arc-20160816; b=iG7dKI+11xMiMjuDb84DUcGCiqR8eAhJuJXjybxJ0nlBHEBxeMfMApbLkKT8+wvKrh hGJxgvDj74l3kd21Wi7knnRfm/TTRebiUP6hVnlsOuKpTD1L9l9xVDbOh81f5IE4fOGb O+tDgMkO24sa5xTZGcXhrHy8TkXvrPvcX+IoVe0paNRFiBWxgod22ebtcVZDrQQDsMFJ sTVrA6jqge1xC90n7n3jnw5uOvViu2ecA9MUWTP0D3o3/q+/fhpJlLKwvEnxCXk1yF5p HH+aKgkC4J1/l8itJ4RaSpVcnpAkH+YQlpJ7/wsxnkulNFIp7ErKjwjAyyc3iVN2uOcm GwMQ== 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=FuXEuDLHp/PrvEbaT/RkZwXyybcKMLYsAYkn5GLV6bw=; b=Wi/0mq/Z89iko4eA+JqbVN6/eCDe8kVUDOhcozL01waEWrwdRp2L4Zr6HF/stLkpwj 0Lvr6iK3B9cYvo6iAsMSAO+Y/BHh1rc2pAprvS5Do0xNYYNnlas4A0W4x0Hp4AOpvRth u/AeG3+S13fOS1fOue9KQtLmktt17l/UIhMnWqOleRVYa4rHxM/5BFyd7QjaO5vlCpeQ dM+8yPugebVFQewYypmVdKv4AaKXTZXnvkyvl+QGPBiX/PKhbuADPWk0f+q8/2EJ4I+m 8xGOsD8qAfkxiFvCTi27tX7Ntwnzh/nKzDvgCsmshmDACCHYitmGMqSRymsSwccoJzUT VKEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=R5upqniW; 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 j19-20020a633c13000000b004792f347556si11781520pga.623.2023.01.29.21.15.31; Sun, 29 Jan 2023 21:15:43 -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=R5upqniW; 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 S229769AbjA3FO4 (ORCPT + 99 others); Mon, 30 Jan 2023 00:14:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235305AbjA3FOp (ORCPT ); Mon, 30 Jan 2023 00:14:45 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFEA321943; Sun, 29 Jan 2023 21:14:44 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U3jJP9022926; Mon, 30 Jan 2023 05:14:34 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=FuXEuDLHp/PrvEbaT/RkZwXyybcKMLYsAYkn5GLV6bw=; b=R5upqniWzhAmFYNLIy2JC4pA49EGvpXAdQ/BXis6fkBbxq1Amo2s2/tzcgRAvstUj4I0 wFFvUac4B4ezoOP9WlNxI87q+ro9Zj1LqUom2YRdSahAUTBcSyJhN3hdwHw3gGA6vSyY L71hM+ht8BJPxxbV0EkPhr7fuc7Rc1HLZAT0a8v4B/40fP3thb95kdWdUw/6AvnFNx5e jO98dYtWvS1hM2uKyK4cwceqp2Pp3xe/AVUskSIt4zm0nKcrLVvZ2P6RxKMEdaONp2EE 2owUquGvZVoOOw1rhE5E+wq47FX5ymU4qOeLRrfM/rPA6pcvRsvaB9gT9CgL4gPyC+7J cQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nctnyjvb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 05:14:33 +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 30U5EXiL020699 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 05:14:33 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; Sun, 29 Jan 2023 21:14:29 -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 V3 1/3] soc: qcom: dcc: Add bootconfig support for DCC Date: Mon, 30 Jan 2023 10:43:55 +0530 Message-ID: <82087136234e84eb0e10f0f168e1edb171e6d692.1675054375.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: evnd_Dct-NUphLge4VTUMiQ2Z_LS2Eib X-Proofpoint-ORIG-GUID: evnd_Dct-NUphLge4VTUMiQ2Z_LS2Eib 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-30_03,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 priorityscore=1501 phishscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300049 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?1756423251360689361?= X-GMAIL-MSGID: =?utf-8?q?1756423251360689361?= 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 | 3 +- drivers/soc/qcom/dcc.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index 21c4ce2..d11bda2 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -71,8 +71,9 @@ config QCOM_LLCC Say yes here to enable LLCC slice driver. config QCOM_DCC - tristate "Qualcomm Technologies, Inc. Data Capture and Compare(DCC) engine driver" + bool "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 Mon Jan 30 05:13:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 50137 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2014842wrn; Sun, 29 Jan 2023 21:17:46 -0800 (PST) X-Google-Smtp-Source: AK7set+uGjJeuE6ehB4y/NoefUs2F7LLvKYCFZx2P41iy4TUEC6MnbbBk9vtv7TuF8rA/ANIbI6C X-Received: by 2002:a17:903:32c7:b0:196:a07d:7a9c with SMTP id i7-20020a17090332c700b00196a07d7a9cmr275561plr.28.1675055866305; Sun, 29 Jan 2023 21:17:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675055866; cv=none; d=google.com; s=arc-20160816; b=BLcQe2jT4+ke32GCUoT0ChR0fks6D3nUMCwIPehkwECIY8lDrxqvwYTI2/n0Y2V7Wx phUCMVIdTs0HHYlA9bT2xs3Y2+Gbo4KESi2ywwXP/jKWvT+7SMMH6Dmh79SkeKre3TLy tGzAxkVZUMqucGFFCmAziWLA5DDQ1BY529vjASTu1+23B5TysKiw/i3HTcQoh8L8MTbd uXtB5iM+h9SdlKO0cQ2+NbGbBZQ73lPCWwj0XWMlEOX4lQ2EYKoA1HdPD7j56e9Wks6e j4MJuGp1VLuL2GLkOGH9pz8xtwaw7zRM05Z700Y6FKmXHKszA1ODl+rH8D2xHMhDIEz1 9Z2g== 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=EaxFtiOdqtURYmVGvWkEH8PibufO9+3aoNU4hqdjcrXLyfgT5aYi9ubUT2YD2XZPg9 XQ17j0SmP5UEnaSTRIRcw4JQB8MhUkM84MtfAJdfT9RKgmU0g1QL6thA5hdoKGr783Cg /UOwcUkHaV3Y13GtrJXRtgeueywIhCDGZ7y0cGLxFjlKHE+e2T2CHkxn5TuknX63KFpv o8OzR/mG3cooNZ7fUAfAEpJgNjRS6NnTBadUOW051LM4rKXILhwy5OFoqp+BhthpSAOD HsxROkh6qE+hCEizchsQehjddaLGoeQPqfXQAKSom52jkFFoQIViKL0xY5UFjU4kAU5s o+aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cmwE5Rm8; 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 t3-20020a170902d20300b001961bf6484fsi11614889ply.229.2023.01.29.21.17.33; Sun, 29 Jan 2023 21:17:46 -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=cmwE5Rm8; 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 S235607AbjA3FPH (ORCPT + 99 others); Mon, 30 Jan 2023 00:15:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235550AbjA3FOs (ORCPT ); Mon, 30 Jan 2023 00:14:48 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CCF223C68; Sun, 29 Jan 2023 21:14:47 -0800 (PST) Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 30U5Ec03016191; Mon, 30 Jan 2023 05:14:38 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=cmwE5Rm8zt0IYXk6GtsFVjgaDgY+7fYFUYqk9KrkWOsK9HV8rabSUxjiXqQRr0zxHCUW ndY8dBxwn1DcYijtIzuYUuqTEfqPkxAUnquPlGlPXoLhhBA3pkz9bUtl2LEspzoaw5pA CrcPkEP3zgY7o2ZxbFOXBgJXTZ4LwpWxTRAdgUyWqkfvJKpS/IKpcHqw0dZI/9mtDTZR bIinVDk+4gPWooT4VMqQBCCMY4oaIZM+15PTAeOdkE6Y7MdzY1MkKK86LGTkYfTpxwxB WjjlupYN+gwN4O4ZqogMs9P1gPbtL/pbkNQlSu/cLAeLzbaYSEKzoHR0gdavUKpdTQXb ZA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3nctnyjvbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 05:14:37 +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 30U5EbJi004492 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 05:14:37 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; Sun, 29 Jan 2023 21:14:33 -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 V3 2/3] soc: qcom: dcc: Add CTI-trigger support for DCC Date: Mon, 30 Jan 2023 10:43:56 +0530 Message-ID: <79ca9bbfb988445fda98ec23f4a63c562b07d04b.1675054375.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: H8EoiKRx_WcQh0teTfqygA8g0k0BjFFg X-Proofpoint-ORIG-GUID: H8EoiKRx_WcQh0teTfqygA8g0k0BjFFg 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-30_03,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 priorityscore=1501 phishscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300049 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?1756423379655661780?= X-GMAIL-MSGID: =?utf-8?q?1756423379655661780?= 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 Mon Jan 30 05:13:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souradeep Chowdhury X-Patchwork-Id: 50138 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2015460wrn; Sun, 29 Jan 2023 21:20:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXti3DxnOCEt2dBmAO4+FdO2vDprYR2lwuVckwqeK2kE2UbWsaoyrPB65gz56PrBzjC0am77 X-Received: by 2002:a05:6402:3709:b0:49e:baf:f6e9 with SMTP id ek9-20020a056402370900b0049e0baff6e9mr57505947edb.9.1675056003031; Sun, 29 Jan 2023 21:20:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675056003; cv=none; d=google.com; s=arc-20160816; b=j9MzalZrHmswS8r5mFClAYVaraJxI1lnmyISGhWx4g0XoaIaEuoj8sCYWGpbZs/USV vNFtNZw0sEDIBsDWTNA2zKE50DaOGkoLHui4/FDdsMJSERM0NCFOWuboL0M7iftuG74w FO4DxbGgnMSIDkWNrooMC4tm4Z49Ue/EfYdtbHf1Z0JQics+X6hFDp94yr1jEF9MAjz7 S2FkHSOspWC+BJd/Q/slSFAX6eNqKKZeqV1cW+iIkkntWsX7D6BpsCoLRpZ3MYr6IDL2 NJdiPR9UBA3FjtNAT7KorNGhfoYnx1GwuDlM3sLEGi6tmXno+8IwN6MjenHCwgABZf6Z xrdA== 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=jxRMBZfZVaFWJzqtfZ6rjTHPaMf7xOxQnGoF8YAT8lTWGe0/IuXBmEkNqcbjsM/efX Qs9GP/WfG8WfppLg7nVqMz/lqJlbGS1o/C37MB5G/7bvkBP4vvbNeMY/1aTKfxS+tNLA gAuKXLohYzYojek31YNWAU9n6JPO1gbvgOncCa1lC92HD7up6kldbO2zmBofbDyyABCE q1iUA+paU6y8xT+i/My/E1sfk46j2qKdVrnIc8smCRqO1PQieZqcC0OL4lCUBQxECWAE RjJQzoM1Y4TFGCC+UF1PxDt14vm+wuNXAyi9uVF/HFGWPtZxEVjUeNknYVXOKkGsCXPe r5rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="j/KRmJmq"; 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 ef14-20020a05640228ce00b0049f512ad602si12777949edb.336.2023.01.29.21.19.39; Sun, 29 Jan 2023 21:20:03 -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="j/KRmJmq"; 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 S235621AbjA3FPL (ORCPT + 99 others); Mon, 30 Jan 2023 00:15:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235562AbjA3FOv (ORCPT ); Mon, 30 Jan 2023 00:14:51 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73C9721943; Sun, 29 Jan 2023 21:14:50 -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 30U3dHmx016328; Mon, 30 Jan 2023 05:14:42 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=j/KRmJmqv1gi0WpPQObh0xCsx9pBovsbexGF8y8IyUriFyXsL5tPfmqopLXLbm2CUaoR s34SpKUQk+azZObA4+lMqNqxDRNVu9Kx31aZntizCh+jRW0osBO5XnBDbjNto+lhgfXZ EufzTTmJaFdiyRtE+4FN7vdNhqC4DzUQtQiYn5RdkyYLVYZXmcK/Kxu4mT1UecclhYsv zZVfiMXZZZScrEwtIq9KshbZJjp9knqrnQMygwLEUPL2Bz5lKEVVRPaaYgBWuDnHPYhL uLXFvBjixE2oLa9C9AiaNL0UQzpDhNiVP78AWuXXoDHFMTz7F+cyyHCiA7JwgvU0ZBp5 /w== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ncsdptyr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 05:14:41 +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 30U5Efs7004535 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 30 Jan 2023 05:14:41 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; Sun, 29 Jan 2023 21:14:37 -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 V3 3/3] soc: qcom: dcc: Add QAD support for DCC Date: Mon, 30 Jan 2023 10:43:57 +0530 Message-ID: <8d9de5e2089b7fc0245a56f5457b443d2042977f.1675054375.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: 7BFsqGLBFBxm9X8uM7BZ6-w1mRHYVcXG X-Proofpoint-ORIG-GUID: 7BFsqGLBFBxm9X8uM7BZ6-w1mRHYVcXG 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-30_03,2023-01-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 impostorscore=0 mlxscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301300049 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?1756423523477158290?= X-GMAIL-MSGID: =?utf-8?q?1756423523477158290?= 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)