From patchwork Wed Jan 24 17:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjian Song X-Patchwork-Id: 13529430 X-Patchwork-Delegate: kuba@kernel.org Received: from AUS01-SY4-obe.outbound.protection.outlook.com (mail-sy4aus01olkn2161.outbound.protection.outlook.com [40.92.62.161]) (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 5C95D7E774 for ; Wed, 24 Jan 2024 17:00:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.62.161 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115648; cv=fail; b=VzD9QzHC9sxwqU0GmrC+JX79YYZY1kIlATiecJNgJKb/U8udzLahSCF8qk8hL9022WZOd+IAIAyQgfqAKj4XTobO2W73VMCDK90bRQTzkwIX9nYWHjDdsNI5o93gn+2eb7tbhR0sYwJebH5hbWdaqxF2WKBPjTcPnn3Twm6n7+8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115648; c=relaxed/simple; bh=HCFE15hhhCzY7AxfUl4epowycEHVa4ZbaA5H6ZzyGXY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=AgzcXR9xa96rADQ3SvyGAw2R/KtlhS0L6+NcK1qDJkWK+awc4GYvlK3lhN6HR1jyhxrNOjdzfCv5VVwpisgioY3jmHdmMqO06vhxIXLT8OqoWpCEgjen+EcTmGk8HG/BiepBT4q4L/y3760rATHf0gcDweCackOQN0A7YO5pLxw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com; spf=pass smtp.mailfrom=hotmail.com; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b=rJaAlgSt; arc=fail smtp.client-ip=40.92.62.161 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hotmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="rJaAlgSt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DyDVpQNKWSYGrKA52zip7lhhfHZoprFr+4U5ODxCjW4wsC+v5MNH1fziH8dGKSVLB8GCgurKObIZJ1fKZ+1VrJ1fJLchbnMZi5W/TeiLiMTLbfcjxn72aOPF3uYnFvFg+2hfETjUY0+0ykIMxz0ihjOrO4Tvoxd2BurIOGya78+gN0Tkh99mtcXjpqmavrK3ozgIu2p13VSh6gUygK/NU1eoMNG7MVRluGk9RUb0vF1DonGu98q8tXCDozLKA8kmZhBIXdKlBq/wi5yc6bqR8mPgHLqyKnLykzlbWeV+b7Vd17vc2siaF0jWBcPrEg1F0tR3KglRt9d16de0P10d4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u1bNUaprUgF+W03xjmZkX0ARuAs7sGxl2P1Y2Q8mYRI=; b=LLmDHNeIFe3T9r9vG+uL9sN/m8jZPRGbSXON+EbKvPOPWnxVk94OYX8at/NKNj0pCh0+4kCbPB0rk29mlR9ND3YhLCxp0e80sSD7n7z3eLm0pCu/vz+vjT03lHn3M5GM1u3HNuzja4OcVXcHgCcwtsq+Am7k3aLNTdGaxmRXrteXl/0RkjpeOZEa8WyTEWXITWU53JXNrfI6+QYvKUQR56GcRqg+xVAUSlTibcuiNZ0rT9QSnYv0MJIuoWc6xG2tKbcqXBWxoUc2BVlEvGq7/ImwVdZGlBIhmn4GXNWCJW1QjwauvBmTOqDBWk1TLDBJUaUDwI0Ze7qtZWT9ZZ0x8A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u1bNUaprUgF+W03xjmZkX0ARuAs7sGxl2P1Y2Q8mYRI=; b=rJaAlgStszpDOr/sGX9jmYhKTFPjEtSXMOnP7nam5iyPBkqeDift5zBICNXWz3j990kp7hH9XUsN0x4t9r7r8RL3xUcg0DMB2sVkjAFJ/lQu5cux8nIATuS8LWPe69SH56K0QbQFUSutM0iSJ7ZtrA2awgGfeTzBXkuxyr6PR/7WEpJyT5htWU0d/UVYG+YmUfSmFvGADeZ1A8fBVHdkJ7OfX/APLf9pQTPX2KDU0Beab7etmtlgX0138OxHCn1gtCEfh9fP7Hf33vZsBxXq8RVLlvtHjHal5NSx58Jk62oP2AYcLjm3KdENhD54p0Iv1suGEx4LiNJn6NjZbL0fgQ== Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) by SY5P282MB4936.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:26f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 17:00:40 +0000 Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f]) by MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f%3]) with mapi id 15.20.7202.031; Wed, 24 Jan 2024 17:00:40 +0000 From: Jinjian Song To: netdev@vger.kernel.org Cc: chandrashekar.devegowda@intel.com, chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com, loic.poulain@linaro.org, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.com, vsankar@lenovo.com, danielwinkler@google.com, nmarupaka@google.com, joey.zhao@fibocom.com, liuqf@fibocom.com, felix.yan@fibocom.com, Jinjian Song Subject: [net-next v6 1/4] wwan: core: Add WWAN fastboot port type Date: Thu, 25 Jan 2024 01:00:07 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240124170010.19445-1-songjinjian@hotmail.com> References: <20240124170010.19445-1-songjinjian@hotmail.com> X-TMN: [QbKri85XlZziw+A6oQzSP/9CseaJQfRy] X-ClientProxiedBy: SI2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:4:195::16) To MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) X-Microsoft-Original-Message-ID: <20240124170010.19445-2-songjinjian@hotmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MEYP282MB2697:EE_|SY5P282MB4936:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cd6cff8-324c-4425-2e0a-08dc1cfdfe48 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 52EYR7rWf4E0I987kWnFohcE9dyA3VdfkkRj6x8B/Xqezf4TAMgbLg0n0v4zoE6oSZtjzGtXYgaxB0KI2oCAtJg1JiMX0YPX39+p0QQ0yrU1owTQR6VYuLW0b2S9+5wDSbKo2SKwP9AgqLGmvDOtF4aIN9+IivL8EdXXGjjowthbKsEUllbz32rZNgcvgfnR9L8AQZmd57WXZ9wLoapvExO1YtKSH/FJ8YDzoY5H1L6oK09iMG7Rn81lIuUQQ3N8pf6sCEE032wjopv4of2FK8FgLR+pHi0Ou1qZw1uRPR/0NCfHc3svqovqHLCed/PRPB56bdt5PPsjq5iehhqHJfnhSZ4Me0jSJqkkY22+AjV8YhfSWQQ39yGT3a+0PT2GlxK1u5XTNINErlLfQLOeUynYEIa1x++wl57jxbHL7fdlCN6p755v2xFjK1TUXO22YlrNnitAjCIckdm3HWYjXtvZrRGblyS1ckpdxnWIatpsvRpDWJddDb6zVF7+gHdsSsJk7IlOHI990gU+Zsg4X2l7krDbWy190bnexKo/rjEafNZhIAQqHJ7TbzAnBpXE X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tL+iaz7O+dVKIC2q5g6LyJ98flsZ6suC+LQ0bgwNsaAwC/wxWU5OIKvpMv4q5FLLwIT8iN8z9x6ivLOVgxEwtUEDyuVL253fylBo0XuSYg316Bxcdc6Zdyuqp+jPV1v2uQrw79PV73rFrdJyflpGOgJtFwILnaZyVLRieRLtr5Hx9b2g63piUfyzWdtm2Y+6F2gMj9iQcpgtWXf2ya56V6Iq2HR/TOAIAx/aG3Sp7V0EgzZWZz8H+ahFPFluvCSgNxZYHIrL019SFgHl6SrFDML9aeaHmSxI6YPDSLQspzK3OS5iK9P6dYpk9XteqP3gF2+UNL8rMAnNpzZg7GIeNfe7LXjAcMf2PSETnU7kbtZCiBxh10vCYqYMV4zbCw4Hm5X4+vx05vu82tDzEpJ06La6QDrbOmM1uaeX5XZX/mDhQLdbgwNJN1v4LyXzUah5VnkrXm1NGn3Yd8Zz9+RVh4PxE3p5ErJZp+caTnI9uDx6SQoE+lOuIKsdjpBY3bjhmWuhgjqMLg8qjwdB2+e7pqppZU4xfEFeH0DXes4tUpt0soJKsmzTFT25ubxXco3+EecWb9KhJCT0kiYmZtLa1Rw6bBEcXSjb0iI4IsGRLAca2S79JwB7Uy+VjNXuB6u/NLeRHnq9BZxdieFV7YMmE5OYC7x/7f8BGs2chpsO7QCdYZ5y+gZG5zoIhTP77GPtuLFIyQ91dWpw4u4FFhWprDchy9EfsnRqg8W3TQaKuEdKq+3SS/hVWjLbz0c8IQLvtJex4IcaDhU4FM7/cYLxHCl0MX4PaTDg+BjLfNpRekKsPj4Grmm4Znwbf5HMAQDrm0HceZECjQ09T01iiFNJrKSvlebNTZUJzfRwIu3uexnK97pH+ULiK/dTEbnTFvJ7sKstxYg8u4NwpXLMmMU54HaSpEvfL6+RZHstut4Rl/n3epMvq3yPmmopvypjNZCRZbOb/Qq9GiNM1gjgiGNAJ7V1FBlM6YUF8+sameemBYXe0jFhMbKzLGIH8XeLP6b8uO67h84ca5Z2kvLB7I6uP6Ut4dguMoHp1wqGOgU3sgR3gEsLu50YQUxhc92hRqgf5bKBGvVFTVTvTbQQ9mqCVsRGTYVcWkiA767h/0p2D5GUWYnZRjPkoiZXQmmucdWoUEYvrDSfp3vPXnfyydvXLqTYJ33Gv/KdhXe0KRvN8eZY/q79aWAExu00HhlXYCjWKq7Qxnvjngqu7yfyGUi0QdfwvYd2D7at/yMYY5n+Y3k= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 1cd6cff8-324c-4425-2e0a-08dc1cfdfe48 X-MS-Exchange-CrossTenant-AuthSource: MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 17:00:40.2597 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY5P282MB4936 X-Patchwork-Delegate: kuba@kernel.org From: Jinjian Song Add a new WWAN port that connects to the device fastboot protocol interface. Signed-off-by: Jinjian Song Reviewed-by: Loic Poulain --- v2-v6: * no change --- drivers/net/wwan/wwan_core.c | 4 ++++ include/linux/wwan.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c index 72e01e550a16..2ed20b20e7fc 100644 --- a/drivers/net/wwan/wwan_core.c +++ b/drivers/net/wwan/wwan_core.c @@ -328,6 +328,10 @@ static const struct { .name = "XMMRPC", .devsuf = "xmmrpc", }, + [WWAN_PORT_FASTBOOT] = { + .name = "FASTBOOT", + .devsuf = "fastboot", + }, }; static ssize_t type_show(struct device *dev, struct device_attribute *attr, diff --git a/include/linux/wwan.h b/include/linux/wwan.h index 01fa15506286..170fdee6339c 100644 --- a/include/linux/wwan.h +++ b/include/linux/wwan.h @@ -16,6 +16,7 @@ * @WWAN_PORT_QCDM: Qcom Modem diagnostic interface * @WWAN_PORT_FIREHOSE: XML based command protocol * @WWAN_PORT_XMMRPC: Control protocol for Intel XMM modems + * @WWAN_PORT_FASTBOOT: Fastboot protocol control * * @WWAN_PORT_MAX: Highest supported port types * @WWAN_PORT_UNKNOWN: Special value to indicate an unknown port type @@ -28,6 +29,7 @@ enum wwan_port_type { WWAN_PORT_QCDM, WWAN_PORT_FIREHOSE, WWAN_PORT_XMMRPC, + WWAN_PORT_FASTBOOT, /* Add new port types above this line */ From patchwork Wed Jan 24 17:00:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjian Song X-Patchwork-Id: 13529431 X-Patchwork-Delegate: kuba@kernel.org Received: from AUS01-SY4-obe.outbound.protection.outlook.com (mail-sy4aus01olkn2175.outbound.protection.outlook.com [40.92.62.175]) (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 4A97F7E580 for ; Wed, 24 Jan 2024 17:00:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.62.175 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115656; cv=fail; b=KzoIUBmi6iR02/NqmlY/DTRmoVhs2i3rDGjvRzHkFezd4E8nduY86Ny2XTSZhKNqFnYa/2zWgT2+IPiAJwVqbZwCLBCWCuTPZzdqwfiQacV6NOKAErW0w5/mt35DrmKNMUQYde+5HcGgH68LKXUmgC400sj9OCikbD3y1To0OGA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115656; c=relaxed/simple; bh=CV4ZmaGba1te4KGpKxDA9t+gCwzaiMIBS99zfhN3iS0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=OHUB3tR+HB0roevD77NkTeeAulYaLxV/kwaQ/A/VBxZeGM5TISJ8jXCb70zoWVAb7sXp7J/lm0iy0DqPQgtjnldaZSGrZ3eYmaVnYCMcn2PTS4ckSss5w+rlZsFTRYRmyPgCfrskO5VFAGxjZAcsjknI4tyYaaGopizhGqiSIfk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com; spf=pass smtp.mailfrom=hotmail.com; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b=u5sXm4DN; arc=fail smtp.client-ip=40.92.62.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hotmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="u5sXm4DN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ewrEFVDdqqAnxeg7LfmNiAOvvCY2L4u6pbz8TATKQtrzaCyhGXPDC7u7qAKY8oEnwagN2mDHG0EcdRVxqRWGT24wGSp3sZF6sMj6eAsn7euRX7hQlwK43f5VqAjHC850Mn+vocxrVV+J6rqNLmj4l9iYjNUQUTXnpygU+ONYZgKmNv1C0yiPmxvC2FFMwkZBm1q6RmnrBHtjlg9XDFfcdwYXwFISfdvxNC9w869vrcaObIpqjn77MFZzysEjE6LPDLp87zErMctJkfdrXybG9KiozGYt4z5mWb/BxUuy9xXe24upQM9a7EV/9qrzoT9vFtaNGSRky7We6ew06eSq5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iiACtjaGoJg24eJ4T8qz1rVfeodmpekMlTLOZ6RW5uA=; b=aYdQbWNsEnATW0l2y1mURcQgZD/UiCLI3WTjLDeDMeCPAvdDo/9YKJeAR3vQnIuc2nL6X4FDpyXvNTwAXE5KpJnm2d5GXUmJQ0C/jVB13fOqruIVgkpY3HrgaVfgV+ND8bneAdvtaiIY8DVrURCdulYfasZlvT3Ia7wPi/Yfs8prUpVs/e14DZjRJ7siyph/LjU5SDXWHD2C+tY0M9Qlx+2gR+0yXl1d7KXicopRdvgCBGcMJDfmTdjfOPH/BuZQLzKUNCwjJ5qwX6FHDKNVSH/tUfdrAWJlTizo4JIw8xmhdT4U57XLmPQzNIuNvwFHhxcgj/RDRJoPpyINnewjZw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iiACtjaGoJg24eJ4T8qz1rVfeodmpekMlTLOZ6RW5uA=; b=u5sXm4DNYYDPRJe+5UXdiryuOy+mEjSyrhlUgXzh97Ivm1pqoVOphcgm6UK9ds4XMs1Dt5IaToN1dzpTjNmUdTEAwPISudeAcGXE+Glg5t8g30okub1UbhEl6M8sLWlMigW25wcXGxJ5BXFrkl3aMY8U7g3GxqhAvvXOQ6g7y2TvsptK798RIXg7jwWWkGTJyT2rzT/aP8caM14EoKfnptLo+je8BaJ9YvezhWTkmDg96qwsEgMNESuNf89XxfJ2kLTqh/H66Gh9h+kIOM4Lqea9FX+V+7gbZ3KN17FIdOulTx8Ml5I42xPub16Lp3OoDw4qmcjheOwOu57FUL/3Dg== Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) by SY8P282MB4480.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:258::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 17:00:46 +0000 Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f]) by MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f%3]) with mapi id 15.20.7202.031; Wed, 24 Jan 2024 17:00:45 +0000 From: Jinjian Song To: netdev@vger.kernel.org Cc: chandrashekar.devegowda@intel.com, chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com, loic.poulain@linaro.org, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.com, vsankar@lenovo.com, danielwinkler@google.com, nmarupaka@google.com, joey.zhao@fibocom.com, liuqf@fibocom.com, felix.yan@fibocom.com, Jinjian Song Subject: [net-next v6 2/4] net: wwan: t7xx: Add sysfs attribute for device state machine Date: Thu, 25 Jan 2024 01:00:08 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240124170010.19445-1-songjinjian@hotmail.com> References: <20240124170010.19445-1-songjinjian@hotmail.com> X-TMN: [hqr2Tp0GR9eRSiROSO2lUfEA2ju8quCO] X-ClientProxiedBy: SI2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:4:195::16) To MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) X-Microsoft-Original-Message-ID: <20240124170010.19445-3-songjinjian@hotmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MEYP282MB2697:EE_|SY8P282MB4480:EE_ X-MS-Office365-Filtering-Correlation-Id: c009ea5b-bda8-4eee-8a09-08dc1cfe01a3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JLP7Wd83Pmub2BmHJ3FfvyHp01ddmTQTolQZ/af07BckZ6F7fFJQPxz4vrricH5ojQ2iP3gJ06pz6JwvFz265a59Nvt7uKB7m0rDuaSf50F+Gq0l2eUs/LCDfCsXsyiDVbRCnxAgtg+CUZ7q15AIxb2OfqcKvioB9nDM+4h4o6c4Z1te1Z7wQFOADqbMKEc3WuVwgoSZvvatWIO8PBfVYvjYGyuwsuEIxBbhmtPTKSadted7Oht/vTpOCk2l5pSaVYLOAHNrvS2o6q/nwLrDw8+vSebjZfT9kAsNtaC0jYJpEE37Z6EQ02KzIpbCyU6HTOjLVOERwQzxk2XxrF+CZyB/S4M2GqydSzztg4lp1+ugG5LvsHEedsTDWhYXzmXP16tEHCMcEf2ijYroniwf+0gx4kDbBlrxRotxVWLzywBlpAwY65+QVBgoIWy4minDqw05Bq9p49ioWA6W9SJs6GmhzpOLUmYzgSWsnq5v7f/Emtfpinlxlf1XCdW3TLbs4gnRblMF+m6hmAVK15zvxQK/o8nBQfQkz7mOTklm+NXn5VqNUQKURrAdAVjNZj4g X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bTvNYr7+vBd++AoBqYmbwzHr3QYu37o24sKk764as4a1HkNLjT5j56HO3EHqyUh5zqXeLWaZEJFwITeqJfuY/Dnwo2JjHf3z+/3HIMlmYU9q52fok6ciq1FoRjQtKhry7rz8tNTom+pRNOLtHfUiNfl5x0TWr8LGKurO+ISmiKz9jJ5ny8Gcx2ajKpK9s2hHmOHAkqu/MPU0nRJ0kwn8t4HJfc9/3/4jv793acjge4u+8XpK9/+jDMEJ9bI8GDYF1deMEdDhZFyUsOg9lbfRxL1uDddebzyCOuMS5Es9W3Lo8uF9Ii5BfaFgQ1UwsNl5rVRCfvNaG6PD9URUZicBRkMBQmX/YtBUSizwZyw3a3tn/ztpHmDuUq1dVlF8bhsDohstZVtQWCEhHM2TLN7vhwN78vr966x2XBfIZhEZpuF8zrwBi0xFfhs7YJza9xOabXeYH0UihGMQcoG7qOv4ryEGMxWPH2q/tK+kdpsXEBMspyplAP9Oo7wdV5mJb4mV/iS0OJe0bpAypZuWN3NubXwxmS/Grn7RPdEzTAoJzWankGS3PW4g8QsZt0eGYsooaR88AghEOQ4heCmhjbSUDR85jaoi3h0i2iX+1fmpMDn6zweqidLjBnPMFOew+/ULZNc7+Kl2mC7rfn9N2rT1I91Itn1DK0MzI7F6QAddyIGTMt1Cwas3WhLlMB5LQSo+A21fJhpQioX+/U8bKfICQIiBrfJrDTYr4MVHYC1I7oCdKFgCONM7o9LGGjrkN0O91gLClhmAW6JrrdiFXkvn/YC261zAdmEN2lRhFfkU8AXPvJSaqR6rQ49ShlGJXk8MQ9qkO6J5/Mb+rQEqI+/V3oLtUkoJwOtBM9FSPG+e/HI5U/Hx/AW5WCaFZ2+f10aIAbMhYf2YtaemVbsaaNIrvjCOSD3rhwdm2ueYIzjw1ZOSwWeyXfbYDQjg9XDYWoX8ehFnr6s3LEsdGwk5JkfHO/SI707SXtJhGOxZ5qW8QbQSnS9PV6jP/ANrjD3T25I3/N8ZtMvQd+9ZY718nOU1L0W5VVgIkPZgECFxuqoy1gm9bqnlveqEzwK8vLoTGwQKER8SDAgaUyBTGc1Kci/I4UJxX87XvtuuqGYDBbkca7IYrZy6vgJnDuQVz9Fwg/ThGuyjkbRijPRLOT9c1VO0xCVACf1hdtCMc0KLDlxGv5cidjwTOCnrHyuGkZKvFWIVznyC6TYqbdVfd+WztDigORIULGCwBBB0WoZGzUpe4Ek= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: c009ea5b-bda8-4eee-8a09-08dc1cfe01a3 X-MS-Exchange-CrossTenant-AuthSource: MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 17:00:45.6800 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY8P282MB4480 X-Patchwork-Delegate: kuba@kernel.org From: Jinjian Song Add support for userspace to get/set the device mode, e.g., reset/ready/fastboot mode. Signed-off-by: Jinjian Song --- v6: * change code style in t7xx_mode_store() v5: * add cold reset support via sysfs t7xx_mode v4: * narrow down the set of accepted values in t7xx_mode_store() * change mode type atomic to u32 with READ_ONCE()/WRITE_ONCE() * delete 'T7XX_MODEM' prefix and using sysfs_emit in t7xx_mode_show() * add description of sysfs t7xx_mode in document t7xx.rst v2: * optimizing using goto label in t7xx_pci_probe --- .../networking/device_drivers/wwan/t7xx.rst | 28 ++++++ drivers/net/wwan/t7xx/t7xx_modem_ops.c | 6 ++ drivers/net/wwan/t7xx/t7xx_modem_ops.h | 1 + drivers/net/wwan/t7xx/t7xx_pci.c | 96 ++++++++++++++++++- drivers/net/wwan/t7xx/t7xx_pci.h | 14 ++- drivers/net/wwan/t7xx/t7xx_state_monitor.c | 1 + 6 files changed, 141 insertions(+), 5 deletions(-) diff --git a/Documentation/networking/device_drivers/wwan/t7xx.rst b/Documentation/networking/device_drivers/wwan/t7xx.rst index dd5b731957ca..d13624a52d8b 100644 --- a/Documentation/networking/device_drivers/wwan/t7xx.rst +++ b/Documentation/networking/device_drivers/wwan/t7xx.rst @@ -39,6 +39,34 @@ command and receive response: - open the AT control channel using a UART tool or a special user tool +Sysfs +===== +The driver provides sysfs interfaces to userspace. + +t7xx_mode +--------- +The sysfs interface provides userspace with access to the device mode, this interface +supports read and write operations. + +Device mode: + +- ``UNKNOW`` represents that device in unknown status +- ``READY`` represents that device in ready status +- ``RESET`` represents that device in reset status +- ``FASTBOOT_DL_SWITCHING`` represents that device in fastboot switching status +- ``FASTBOOT_DL_MODE`` represents that device in fastboot download status +- ``FASTBOOT_DL_DUMP_MODE`` represents that device in fastboot dump status + +Read from userspace to get the current device mode. + +:: + $ cat /sys/bus/pci/devices/${bdf}/t7xx_mode + +Write from userspace to set the device mode. + +:: + $ echo FASTBOOT_DL_SWITCHING > /sys/bus/pci/devices/${bdf}/t7xx_mode + Management application development ================================== The driver and userspace interfaces are described below. The MBIM protocol is diff --git a/drivers/net/wwan/t7xx/t7xx_modem_ops.c b/drivers/net/wwan/t7xx/t7xx_modem_ops.c index 24e7d491468e..ca262d2961ed 100644 --- a/drivers/net/wwan/t7xx/t7xx_modem_ops.c +++ b/drivers/net/wwan/t7xx/t7xx_modem_ops.c @@ -177,6 +177,11 @@ int t7xx_acpi_fldr_func(struct t7xx_pci_dev *t7xx_dev) return t7xx_acpi_reset(t7xx_dev, "_RST"); } +int t7xx_acpi_pldr_func(struct t7xx_pci_dev *t7xx_dev) +{ + return t7xx_acpi_reset(t7xx_dev, "MRST._RST"); +} + static void t7xx_reset_device_via_pmic(struct t7xx_pci_dev *t7xx_dev) { u32 val; @@ -192,6 +197,7 @@ static irqreturn_t t7xx_rgu_isr_thread(int irq, void *data) { struct t7xx_pci_dev *t7xx_dev = data; + t7xx_mode_update(t7xx_dev, T7XX_RESET); msleep(RGU_RESET_DELAY_MS); t7xx_reset_device_via_pmic(t7xx_dev); return IRQ_HANDLED; diff --git a/drivers/net/wwan/t7xx/t7xx_modem_ops.h b/drivers/net/wwan/t7xx/t7xx_modem_ops.h index abe633cf7adc..b39e945a92e0 100644 --- a/drivers/net/wwan/t7xx/t7xx_modem_ops.h +++ b/drivers/net/wwan/t7xx/t7xx_modem_ops.h @@ -85,6 +85,7 @@ int t7xx_md_init(struct t7xx_pci_dev *t7xx_dev); void t7xx_md_exit(struct t7xx_pci_dev *t7xx_dev); void t7xx_clear_rgu_irq(struct t7xx_pci_dev *t7xx_dev); int t7xx_acpi_fldr_func(struct t7xx_pci_dev *t7xx_dev); +int t7xx_acpi_pldr_func(struct t7xx_pci_dev *t7xx_dev); int t7xx_pci_mhccif_isr(struct t7xx_pci_dev *t7xx_dev); #endif /* __T7XX_MODEM_OPS_H__ */ diff --git a/drivers/net/wwan/t7xx/t7xx_pci.c b/drivers/net/wwan/t7xx/t7xx_pci.c index 91256e005b84..3776bd8650a6 100644 --- a/drivers/net/wwan/t7xx/t7xx_pci.c +++ b/drivers/net/wwan/t7xx/t7xx_pci.c @@ -52,6 +52,79 @@ #define PM_RESOURCE_POLL_TIMEOUT_US 10000 #define PM_RESOURCE_POLL_STEP_US 100 +static const char * const mode_names[] = { + [T7XX_UNKNOWN] = "UNKNOWN", + [T7XX_READY] = "READY", + [T7XX_RESET] = "RESET", + [T7XX_FASTBOOT_DL_SWITCHING] = "FASTBOOT_DL_SWITCHING", + [T7XX_FASTBOOT_DL_MODE] = "FASTBOOT_DL_MODE", + [T7XX_FASTBOOT_DUMP_MODE] = "FASTBOOT_DUMP_MODE", +}; + +static_assert(ARRAY_SIZE(mode_names) == T7XX_MODE_LAST); + +static ssize_t t7xx_mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct t7xx_pci_dev *t7xx_dev; + struct pci_dev *pdev; + int index = 0; + + pdev = to_pci_dev(dev); + t7xx_dev = pci_get_drvdata(pdev); + if (!t7xx_dev) + return -ENODEV; + + index = sysfs_match_string(mode_names, buf); + if (index == T7XX_FASTBOOT_DL_SWITCHING) + WRITE_ONCE(t7xx_dev->mode, T7XX_FASTBOOT_DL_SWITCHING); + else if (index == T7XX_RESET) + t7xx_acpi_pldr_func(t7xx_dev); + + return count; +}; + +static ssize_t t7xx_mode_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + enum t7xx_mode mode = T7XX_UNKNOWN; + struct t7xx_pci_dev *t7xx_dev; + struct pci_dev *pdev; + + pdev = to_pci_dev(dev); + t7xx_dev = pci_get_drvdata(pdev); + if (!t7xx_dev) + return -ENODEV; + + mode = READ_ONCE(t7xx_dev->mode); + if (mode < T7XX_MODE_LAST) + return sysfs_emit(buf, "%s\n", mode_names[mode]); + + return sysfs_emit(buf, "%s\n", mode_names[T7XX_UNKNOWN]); +} + +static DEVICE_ATTR_RW(t7xx_mode); + +static struct attribute *t7xx_mode_attr[] = { + &dev_attr_t7xx_mode.attr, + NULL +}; + +static const struct attribute_group t7xx_mode_attribute_group = { + .attrs = t7xx_mode_attr, +}; + +void t7xx_mode_update(struct t7xx_pci_dev *t7xx_dev, enum t7xx_mode mode) +{ + if (!t7xx_dev) + return; + + WRITE_ONCE(t7xx_dev->mode, mode); + sysfs_notify(&t7xx_dev->pdev->dev.kobj, NULL, "t7xx_mode"); +} + enum t7xx_pm_state { MTK_PM_EXCEPTION, MTK_PM_INIT, /* Device initialized, but handshake not completed */ @@ -729,16 +802,28 @@ static int t7xx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) t7xx_pcie_mac_interrupts_dis(t7xx_dev); + ret = sysfs_create_group(&t7xx_dev->pdev->dev.kobj, + &t7xx_mode_attribute_group); + if (ret) + goto err_md_exit; + ret = t7xx_interrupt_init(t7xx_dev); - if (ret) { - t7xx_md_exit(t7xx_dev); - return ret; - } + if (ret) + goto err_remove_group; + t7xx_pcie_mac_set_int(t7xx_dev, MHCCIF_INT); t7xx_pcie_mac_interrupts_en(t7xx_dev); return 0; + +err_remove_group: + sysfs_remove_group(&t7xx_dev->pdev->dev.kobj, + &t7xx_mode_attribute_group); + +err_md_exit: + t7xx_md_exit(t7xx_dev); + return ret; } static void t7xx_pci_remove(struct pci_dev *pdev) @@ -747,6 +832,9 @@ static void t7xx_pci_remove(struct pci_dev *pdev) int i; t7xx_dev = pci_get_drvdata(pdev); + + sysfs_remove_group(&t7xx_dev->pdev->dev.kobj, + &t7xx_mode_attribute_group); t7xx_md_exit(t7xx_dev); for (i = 0; i < EXT_INT_NUM; i++) { diff --git a/drivers/net/wwan/t7xx/t7xx_pci.h b/drivers/net/wwan/t7xx/t7xx_pci.h index f08f1ab74469..0abba7e6f8aa 100644 --- a/drivers/net/wwan/t7xx/t7xx_pci.h +++ b/drivers/net/wwan/t7xx/t7xx_pci.h @@ -43,6 +43,16 @@ struct t7xx_addr_base { typedef irqreturn_t (*t7xx_intr_callback)(int irq, void *param); +enum t7xx_mode { + T7XX_UNKNOWN, + T7XX_READY, + T7XX_RESET, + T7XX_FASTBOOT_DL_SWITCHING, + T7XX_FASTBOOT_DL_MODE, + T7XX_FASTBOOT_DUMP_MODE, + T7XX_MODE_LAST, /* must always be last */ +}; + /* struct t7xx_pci_dev - MTK device context structure * @intr_handler: array of handler function for request_threaded_irq * @intr_thread: array of thread_fn for request_threaded_irq @@ -59,6 +69,7 @@ typedef irqreturn_t (*t7xx_intr_callback)(int irq, void *param); * @md_pm_lock: protects PCIe sleep lock * @sleep_disable_count: PCIe L1.2 lock counter * @sleep_lock_acquire: indicates that sleep has been disabled + * @mode: indicates the device mode */ struct t7xx_pci_dev { t7xx_intr_callback intr_handler[EXT_INT_NUM]; @@ -82,6 +93,7 @@ struct t7xx_pci_dev { #ifdef CONFIG_WWAN_DEBUGFS struct dentry *debugfs_dir; #endif + u32 mode; }; enum t7xx_pm_id { @@ -120,5 +132,5 @@ int t7xx_pci_pm_entity_register(struct t7xx_pci_dev *t7xx_dev, struct md_pm_enti int t7xx_pci_pm_entity_unregister(struct t7xx_pci_dev *t7xx_dev, struct md_pm_entity *pm_entity); void t7xx_pci_pm_init_late(struct t7xx_pci_dev *t7xx_dev); void t7xx_pci_pm_exp_detected(struct t7xx_pci_dev *t7xx_dev); - +void t7xx_mode_update(struct t7xx_pci_dev *t7xx_dev, enum t7xx_mode mode); #endif /* __T7XX_PCI_H__ */ diff --git a/drivers/net/wwan/t7xx/t7xx_state_monitor.c b/drivers/net/wwan/t7xx/t7xx_state_monitor.c index 0bc97430211b..c5d46f45fa62 100644 --- a/drivers/net/wwan/t7xx/t7xx_state_monitor.c +++ b/drivers/net/wwan/t7xx/t7xx_state_monitor.c @@ -272,6 +272,7 @@ static void fsm_routine_ready(struct t7xx_fsm_ctl *ctl) ctl->curr_state = FSM_STATE_READY; t7xx_fsm_broadcast_ready_state(ctl); + t7xx_mode_update(md->t7xx_dev, T7XX_READY); t7xx_md_event_notify(md, FSM_READY); } From patchwork Wed Jan 24 17:00:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjian Song X-Patchwork-Id: 13529432 X-Patchwork-Delegate: kuba@kernel.org Received: from AUS01-SY4-obe.outbound.protection.outlook.com (mail-sy4aus01olkn2172.outbound.protection.outlook.com [40.92.62.172]) (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 7C0EA7E584 for ; Wed, 24 Jan 2024 17:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.62.172 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115662; cv=fail; b=Am/QAw+xiE7Me9SiJWV0zwfkHtbi3JzW+Evmt+ASr+Nckvg8ZrNbaNs+EOxFayQIMIl6TanECid+V/lWbtZV7AI35Sj4/j3Pu0nZWiaOSUUwC80ZSmMEyRqSsUJ639Fxl0Wcy4/4+mpGpZKiaHxzIo6JeN1ZE3Nx1B+Y6emOsi4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115662; c=relaxed/simple; bh=zpLwMmWm+5rPq7hLE9EDJv7rVeSXJd1M64D8PEJjiqA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=i157Er5YJo9DRGMhwevb4IFyRpaabTbAgNNMRb9YhxscUuctX8obnxtSdc5Gp1nLLp3a6u9O57ekVSnen5TxnAPod1YK1n3mXL4gII3itkqCQxrFeSlY7Q02kS1dpzleMcFp/dA/LRI/7gVf7ekfythoA/i1rqAYKD7Mh67BzpY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com; spf=pass smtp.mailfrom=hotmail.com; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b=gWWJ7LRx; arc=fail smtp.client-ip=40.92.62.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hotmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="gWWJ7LRx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MAdnHgE7zcBCUudrDM6b95Zv+ACO3h+0N5PaMP0Fu0KmVMWsiCT230foye290Yr3rw3+9xefnWa41RFMipjWGP2RWiKmMKOhaaxJQMEYmlcMvfuHjtlbrlxwDOYTOytmg82vANcEyImiqqGgySzWN6Fe6KoE4O0HR+Ur2G4KoWWWn/LHfIcq/DN97AYQ9cDj/1bLzxY5yUig2bk3GtCsgTJ1lEilWZbXZBnE4YqhxYUPkbmB4fnMAve1YjitbUhu8bJRW8sR+J5EBfab882wXpq8O2W/rTSm0pOOQtpANmhAqhuE2YAkGDyiqeUnyxvprerax5TH6EZCcziLcQCXkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OWKg8Wg8hhIZUYwIXBet095SZhI1rLngqDn/LbQBaPM=; b=mVED3+0r/H7OetxhLSW96xuCXO2lwtu0o4x/xtYVKuCZPtileUeH8zza8HXuXYwBNgCSO+G9/eGf/rk+xNwR/5LRLqR+dCt+0e4c66Hvlqo1EyXQYgxi2UssCWGsEOKxbkQaypUjU56GBzf97ktLqYkMu8w3v6kczBaq1ieLshW0DoBikN8vzMzbSgHqLZR/xd8BLA4GLgdVe6c+ytNW0/18v87pQQ0wLrzqD7EzPyQfAmah1rBUNGCCAjC8lx0jIylN6YyFXMXw6W9dyiySR0gku97J0mELmT2fEdDikGrhV4wyedlveWevmpJJm9Dn6FeuHu16iIul82HxGTbjdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OWKg8Wg8hhIZUYwIXBet095SZhI1rLngqDn/LbQBaPM=; b=gWWJ7LRxVSoOyxYeHWyrr205wixTLcMDq7KsoOHM/Ks4QRSPC64+P9oXKygK/wp+KLtCAI2ROkGBlZE7JwT91bcpkTURcJ+97xGTln5ysqy+vvpLPx7tIeL71Ib5gCsCmfnZT0IFRvctDKUeJR5YL5dOa6KMU99pMZuqLwQsAKp4hv0B+5Xn0E8oj4002N4UvykOqex26pGStmQYKTF5zqYNgMaKDtXMHuz15kPkgYB/EXd8t4njbl8qT7FoIg0/dnMEAdbohIBnnscvi7O1cm35dvu6wDNGH3Lfvw+hVxqopbg1+RKrkqeoDCBcGCXoyGPf8oqiXPg8mpNaVEIy4g== Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) by SY8P282MB4480.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:258::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 17:00:51 +0000 Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f]) by MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f%3]) with mapi id 15.20.7202.031; Wed, 24 Jan 2024 17:00:51 +0000 From: Jinjian Song To: netdev@vger.kernel.org Cc: chandrashekar.devegowda@intel.com, chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com, loic.poulain@linaro.org, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.com, vsankar@lenovo.com, danielwinkler@google.com, nmarupaka@google.com, joey.zhao@fibocom.com, liuqf@fibocom.com, felix.yan@fibocom.com, Jinjian Song Subject: [net-next v6 3/4] net: wwan: t7xx: Infrastructure for early port configuration Date: Thu, 25 Jan 2024 01:00:09 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240124170010.19445-1-songjinjian@hotmail.com> References: <20240124170010.19445-1-songjinjian@hotmail.com> X-TMN: [BqW7h66rc3iVqDv93GUjAo9jHfbkIat/] X-ClientProxiedBy: SI2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:4:195::16) To MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) X-Microsoft-Original-Message-ID: <20240124170010.19445-4-songjinjian@hotmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MEYP282MB2697:EE_|SY8P282MB4480:EE_ X-MS-Office365-Filtering-Correlation-Id: dad28461-b856-4118-25c3-08dc1cfe04f0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: he318OQFagbyUvHadgewx3tftd5kwh4GIz9g9YgV8S8/C/04F1TBi7Fy3mBurZqBbsJHvVZq5tc3ri7dq1WS1xeqP1OjGcXCRfgidUXL+Ta+xmbRukP5TK2fqi1SHFRQZNVejQ9Te4Oc3Hwju9OdO19SJCzwv4flUPFuXavy/9rzWrAVzUJ6p9y32XJO5eVg1wxH/xv3ZiAHBstU1arq83dUkgkLnmA0IYPPQBqAcZy90etpL5+QPwQKURsm9nt6RqBKXkRPMHc2kY+3r71Vs+edp9Rw6hLPuGeipG9iAmM2+hdrXJMF7Q0oucrJgQNz1bRgkqJT7R000BJZkxsFb12QDiBnC10b6SxJThuBmjo0tv3SIFmVlPJIYA8kuT1pJ3HK+2zA9Mvy3epNymR16KdctBLol3uYaXJXL0bOOS3pPCgp5ZmT0/MNvq+v6y62jwFRztnkBFfYDcoa/Cn+n+Y9FjbKlHfRHTI+BtNc9uDWHeZb4ZylUd6F58OaorwUioVeQ1XE4IQuV+xhgSTujjaXsHux+IBSkuBA1cGcYqkziyi4O5jCZ3QkuTZCwSRZP9/nBfsCRjsC9XWMR6cUqhiD1mn+L41Qec7UQm5t9Qw= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BEjpm/dD+weTuRnEol4hBWBzlCXh5S4wR0lzw3DiTQvMgFaBlptf0+GUn2e66xsFRyaJHSxKagqVXffE0iXqHmXxh0+Gjjrh0zo8pBpRnXpyr+IvVkq2fuRJrDQkCEU+f9NA9Jav2DhYnh0VsNlT91Cs+lXuQuI90yWFVDnL6dik9ZWqxAMkznb5+E2PJ2RMlpShoKoTyyFR2gGi7xxJyF4Vrcjp5CuxRsH4PUMObdN1i0JeUXKWe75lPfCnfMwnIJUdXJfQDWVAREZuhdoA4bNZFUSFQQfU0WUl60tHmpUfAOxj78H398AP/Z84vl/OStrGQEuctZF4XKqGUusul/6BexpntBdgYAodBTMlZaXdm3g9vZXz1W+y+N57uR+aZJlTPEXOjcZSAS5XQlkccjpEtk8GpxPxqiSzq6wYdWUa8LAXTQ1DCKa4+mbWRCF1FRUw6EyP4pbaCsr2BdRchK0+P8t+aQFYzUJmYisOl+hg9+ytMRluK/0CyDUbKS1t/e5M/UIxPgojO1OCOV/IhXtyf8EAJOjSu3uIPlUEh1kXJWC0cwC6JzrAKX/yJAnTW+Kfy4391tY0+jpAp2G+G9Srzf3j2Mqgk3w0gXi+78pIKT3M5Tq7YCfWMP/ydBzaqJLA+1CRjbNMQj8gnfwwJcaTPYbw3wGbPNFI6R0pbllqa7wtcgUvi4sq7JbwmXFl1qJweNHfaV7fNy1mE08s3Z/Lrp/ZyRoxquRyECfy197cq6DM5l4+vBItNSXeor2hySPtEecTPi5lQciTjU9vW/4f5FRO/zEzeOyjWdLx8EdRDEQdzrc250ShQGm8twELA72RoNNBwV4LwOs91IvCbXANf1RAoWiAnKMvo/8jntCq6jLzT4nahep1vonIcuA9xWcEymf76lZdXdFSvq+YHE3XOT7nYhivSioisT1YWkxjiww1nh9DiInPkR+21+aPMtbJCU0H7QhI3Nqh+YL6V3OMuz0GUwDdnj1q8fJaf5l960Uy3AyOayQAJD/VNHF2896hy0vJHzo9fXfGuOVBRRJcg5+c1foDtCIncLdku4C0ELY0TgDwe7VCHvq4Qpg9LTCx1NSkQut6KqPBd04dNIYVnrXy6ei51RqVYpZ6/naXuIpE+VMbjIKZzeH3iM3e9SABc8H+bkEsLkmysyRKHoQjrxinI1gJfn27klpqGqgRvqbyCVyxmiqPZEb0g/W/SczMcM2yRniWI43g9BF6fCizGEtIdtKktqx5UGY8r8U= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: dad28461-b856-4118-25c3-08dc1cfe04f0 X-MS-Exchange-CrossTenant-AuthSource: MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 17:00:51.2338 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY8P282MB4480 X-Patchwork-Delegate: kuba@kernel.org From: Jinjian Song To support cases such as FW update or Core dump, the t7xx device is capable of signaling the host that a special port needs to be created before the handshake phase. Adds the infrastructure required to create the early ports which also requires a different configuration of CLDMA queues. Base on the v5 patch version of follow series: 'net: wwan: t7xx: fw flashing & coredump support' (https://patchwork.kernel.org/project/netdevbpf/patch/3777bb382f4b0395cb594a602c5c79dbab86c9e0.1674307425.git.m.chetan.kumar@linux.intel.com/) Signed-off-by: Jinjian Song --- v5: * using t7xx_mode_update to update sysfs t7xx_mode v4: * change PORT_CH_ID_UNIMPORTANT to PORT_CH_UNIMPORTANT * delete t7xx_wait_pm_config() in t7xx_pci_pm_init() * define T7XX_MAX_POSSIBLE_PORTS_NUM to get max port num * define macro wait_for_expected_dev_stage to be more readable * change prev_status to status in struct t7xx_fsm_ctl --- drivers/net/wwan/t7xx/t7xx_hif_cldma.c | 47 +++++--- drivers/net/wwan/t7xx/t7xx_hif_cldma.h | 18 ++- drivers/net/wwan/t7xx/t7xx_modem_ops.c | 4 +- drivers/net/wwan/t7xx/t7xx_pci.c | 2 +- drivers/net/wwan/t7xx/t7xx_port.h | 4 + drivers/net/wwan/t7xx/t7xx_port_proxy.c | 105 +++++++++++++++--- drivers/net/wwan/t7xx/t7xx_port_proxy.h | 10 ++ drivers/net/wwan/t7xx/t7xx_port_wwan.c | 5 +- drivers/net/wwan/t7xx/t7xx_reg.h | 24 +++- drivers/net/wwan/t7xx/t7xx_state_monitor.c | 123 ++++++++++++++++++--- drivers/net/wwan/t7xx/t7xx_state_monitor.h | 1 + 11 files changed, 287 insertions(+), 56 deletions(-) diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c index cc70360364b7..abc41a7089fa 100644 --- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.c +++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.c @@ -57,8 +57,6 @@ #define CHECK_Q_STOP_TIMEOUT_US 1000000 #define CHECK_Q_STOP_STEP_US 10000 -#define CLDMA_JUMBO_BUFF_SZ (63 * 1024 + sizeof(struct ccci_header)) - static void md_cd_queue_struct_reset(struct cldma_queue *queue, struct cldma_ctrl *md_ctrl, enum mtk_txrx tx_rx, unsigned int index) { @@ -161,7 +159,7 @@ static int t7xx_cldma_gpd_rx_from_q(struct cldma_queue *queue, int budget, bool skb_reset_tail_pointer(skb); skb_put(skb, le16_to_cpu(gpd->data_buff_len)); - ret = md_ctrl->recv_skb(queue, skb); + ret = queue->recv_skb(queue, skb); /* Break processing, will try again later */ if (ret < 0) return ret; @@ -897,13 +895,13 @@ static void t7xx_cldma_hw_start_send(struct cldma_ctrl *md_ctrl, int qno, /** * t7xx_cldma_set_recv_skb() - Set the callback to handle RX packets. - * @md_ctrl: CLDMA context structure. + * @queue: CLDMA queue. * @recv_skb: Receiving skb callback. */ -void t7xx_cldma_set_recv_skb(struct cldma_ctrl *md_ctrl, +void t7xx_cldma_set_recv_skb(struct cldma_queue *queue, int (*recv_skb)(struct cldma_queue *queue, struct sk_buff *skb)) { - md_ctrl->recv_skb = recv_skb; + queue->recv_skb = recv_skb; } /** @@ -993,6 +991,28 @@ int t7xx_cldma_send_skb(struct cldma_ctrl *md_ctrl, int qno, struct sk_buff *skb return ret; } +static void t7xx_cldma_adjust_config(struct cldma_ctrl *md_ctrl, enum cldma_cfg cfg_id) +{ + int qno; + + for (qno = 0; qno < CLDMA_RXQ_NUM; qno++) { + md_ctrl->rx_ring[qno].pkt_size = CLDMA_SHARED_Q_BUFF_SZ; + t7xx_cldma_set_recv_skb(&md_ctrl->rxq[qno], t7xx_port_proxy_recv_skb); + } + + md_ctrl->rx_ring[CLDMA_RXQ_NUM - 1].pkt_size = CLDMA_JUMBO_BUFF_SZ; + + for (qno = 0; qno < CLDMA_TXQ_NUM; qno++) + md_ctrl->tx_ring[qno].pkt_size = CLDMA_SHARED_Q_BUFF_SZ; + + if (cfg_id == CLDMA_DEDICATED_Q_CFG) { + md_ctrl->tx_ring[CLDMA_Q_IDX_DUMP].pkt_size = CLDMA_DEDICATED_Q_BUFF_SZ; + md_ctrl->rx_ring[CLDMA_Q_IDX_DUMP].pkt_size = CLDMA_DEDICATED_Q_BUFF_SZ; + t7xx_cldma_set_recv_skb(&md_ctrl->rxq[CLDMA_Q_IDX_DUMP], + t7xx_port_proxy_recv_skb_from_dedicated_queue); + } +} + static int t7xx_cldma_late_init(struct cldma_ctrl *md_ctrl) { char dma_pool_name[32]; @@ -1018,16 +1038,9 @@ static int t7xx_cldma_late_init(struct cldma_ctrl *md_ctrl) dev_err(md_ctrl->dev, "control TX ring init fail\n"); goto err_free_tx_ring; } - - md_ctrl->tx_ring[i].pkt_size = CLDMA_MTU; } for (j = 0; j < CLDMA_RXQ_NUM; j++) { - md_ctrl->rx_ring[j].pkt_size = CLDMA_MTU; - - if (j == CLDMA_RXQ_NUM - 1) - md_ctrl->rx_ring[j].pkt_size = CLDMA_JUMBO_BUFF_SZ; - ret = t7xx_cldma_rx_ring_init(md_ctrl, &md_ctrl->rx_ring[j]); if (ret) { dev_err(md_ctrl->dev, "Control RX ring init fail\n"); @@ -1094,6 +1107,7 @@ int t7xx_cldma_alloc(enum cldma_id hif_id, struct t7xx_pci_dev *t7xx_dev) { struct device *dev = &t7xx_dev->pdev->dev; struct cldma_ctrl *md_ctrl; + int qno; md_ctrl = devm_kzalloc(dev, sizeof(*md_ctrl), GFP_KERNEL); if (!md_ctrl) @@ -1102,7 +1116,9 @@ int t7xx_cldma_alloc(enum cldma_id hif_id, struct t7xx_pci_dev *t7xx_dev) md_ctrl->t7xx_dev = t7xx_dev; md_ctrl->dev = dev; md_ctrl->hif_id = hif_id; - md_ctrl->recv_skb = t7xx_cldma_default_recv_skb; + for (qno = 0; qno < CLDMA_RXQ_NUM; qno++) + md_ctrl->rxq[qno].recv_skb = t7xx_cldma_default_recv_skb; + t7xx_hw_info_init(md_ctrl); t7xx_dev->md->md_ctrl[hif_id] = md_ctrl; return 0; @@ -1332,9 +1348,10 @@ int t7xx_cldma_init(struct cldma_ctrl *md_ctrl) return -ENOMEM; } -void t7xx_cldma_switch_cfg(struct cldma_ctrl *md_ctrl) +void t7xx_cldma_switch_cfg(struct cldma_ctrl *md_ctrl, enum cldma_cfg cfg_id) { t7xx_cldma_late_release(md_ctrl); + t7xx_cldma_adjust_config(md_ctrl, cfg_id); t7xx_cldma_late_init(md_ctrl); } diff --git a/drivers/net/wwan/t7xx/t7xx_hif_cldma.h b/drivers/net/wwan/t7xx/t7xx_hif_cldma.h index 4410bac6993a..f2d9941be9c8 100644 --- a/drivers/net/wwan/t7xx/t7xx_hif_cldma.h +++ b/drivers/net/wwan/t7xx/t7xx_hif_cldma.h @@ -31,6 +31,10 @@ #include "t7xx_cldma.h" #include "t7xx_pci.h" +#define CLDMA_JUMBO_BUFF_SZ (63 * 1024 + sizeof(struct ccci_header)) +#define CLDMA_SHARED_Q_BUFF_SZ 3584 +#define CLDMA_DEDICATED_Q_BUFF_SZ 2048 + /** * enum cldma_id - Identifiers for CLDMA HW units. * @CLDMA_ID_MD: Modem control channel. @@ -55,6 +59,11 @@ struct cldma_gpd { __le16 not_used2; }; +enum cldma_cfg { + CLDMA_SHARED_Q_CFG, + CLDMA_DEDICATED_Q_CFG, +}; + struct cldma_request { struct cldma_gpd *gpd; /* Virtual address for CPU */ dma_addr_t gpd_addr; /* Physical address for DMA */ @@ -82,6 +91,7 @@ struct cldma_queue { wait_queue_head_t req_wq; /* Only for TX */ struct workqueue_struct *worker; struct work_struct cldma_work; + int (*recv_skb)(struct cldma_queue *queue, struct sk_buff *skb); }; struct cldma_ctrl { @@ -101,24 +111,22 @@ struct cldma_ctrl { struct md_pm_entity *pm_entity; struct t7xx_cldma_hw hw_info; bool is_late_init; - int (*recv_skb)(struct cldma_queue *queue, struct sk_buff *skb); }; +#define CLDMA_Q_IDX_DUMP 1 #define GPD_FLAGS_HWO BIT(0) #define GPD_FLAGS_IOC BIT(7) #define GPD_DMAPOOL_ALIGN 16 -#define CLDMA_MTU 3584 /* 3.5kB */ - int t7xx_cldma_alloc(enum cldma_id hif_id, struct t7xx_pci_dev *t7xx_dev); void t7xx_cldma_hif_hw_init(struct cldma_ctrl *md_ctrl); int t7xx_cldma_init(struct cldma_ctrl *md_ctrl); void t7xx_cldma_exit(struct cldma_ctrl *md_ctrl); -void t7xx_cldma_switch_cfg(struct cldma_ctrl *md_ctrl); +void t7xx_cldma_switch_cfg(struct cldma_ctrl *md_ctrl, enum cldma_cfg cfg_id); void t7xx_cldma_start(struct cldma_ctrl *md_ctrl); int t7xx_cldma_stop(struct cldma_ctrl *md_ctrl); void t7xx_cldma_reset(struct cldma_ctrl *md_ctrl); -void t7xx_cldma_set_recv_skb(struct cldma_ctrl *md_ctrl, +void t7xx_cldma_set_recv_skb(struct cldma_queue *queue, int (*recv_skb)(struct cldma_queue *queue, struct sk_buff *skb)); int t7xx_cldma_send_skb(struct cldma_ctrl *md_ctrl, int qno, struct sk_buff *skb); void t7xx_cldma_stop_all_qs(struct cldma_ctrl *md_ctrl, enum mtk_txrx tx_rx); diff --git a/drivers/net/wwan/t7xx/t7xx_modem_ops.c b/drivers/net/wwan/t7xx/t7xx_modem_ops.c index ca262d2961ed..fd79a2a1cc6f 100644 --- a/drivers/net/wwan/t7xx/t7xx_modem_ops.c +++ b/drivers/net/wwan/t7xx/t7xx_modem_ops.c @@ -535,7 +535,7 @@ static void t7xx_md_hk_wq(struct work_struct *work) /* Clear the HS2 EXIT event appended in core_reset() */ t7xx_fsm_clr_event(ctl, FSM_EVENT_MD_HS2_EXIT); - t7xx_cldma_switch_cfg(md->md_ctrl[CLDMA_ID_MD]); + t7xx_cldma_switch_cfg(md->md_ctrl[CLDMA_ID_MD], CLDMA_SHARED_Q_CFG); t7xx_cldma_start(md->md_ctrl[CLDMA_ID_MD]); t7xx_fsm_broadcast_state(ctl, MD_STATE_WAITING_FOR_HS2); md->core_md.handshake_ongoing = true; @@ -550,7 +550,7 @@ static void t7xx_ap_hk_wq(struct work_struct *work) /* Clear the HS2 EXIT event appended in t7xx_core_reset(). */ t7xx_fsm_clr_event(ctl, FSM_EVENT_AP_HS2_EXIT); t7xx_cldma_stop(md->md_ctrl[CLDMA_ID_AP]); - t7xx_cldma_switch_cfg(md->md_ctrl[CLDMA_ID_AP]); + t7xx_cldma_switch_cfg(md->md_ctrl[CLDMA_ID_AP], CLDMA_SHARED_Q_CFG); t7xx_cldma_start(md->md_ctrl[CLDMA_ID_AP]); md->core_ap.handshake_ongoing = true; t7xx_core_hk_handler(md, &md->core_ap, ctl, FSM_EVENT_AP_HS2, FSM_EVENT_AP_HS2_EXIT); diff --git a/drivers/net/wwan/t7xx/t7xx_pci.c b/drivers/net/wwan/t7xx/t7xx_pci.c index 3776bd8650a6..9384f86d72ca 100644 --- a/drivers/net/wwan/t7xx/t7xx_pci.c +++ b/drivers/net/wwan/t7xx/t7xx_pci.c @@ -181,7 +181,7 @@ static int t7xx_pci_pm_init(struct t7xx_pci_dev *t7xx_dev) pm_runtime_set_autosuspend_delay(&pdev->dev, PM_AUTOSUSPEND_MS); pm_runtime_use_autosuspend(&pdev->dev); - return t7xx_wait_pm_config(t7xx_dev); + return 0; } void t7xx_pci_pm_init_late(struct t7xx_pci_dev *t7xx_dev) diff --git a/drivers/net/wwan/t7xx/t7xx_port.h b/drivers/net/wwan/t7xx/t7xx_port.h index 4ae8a00a8532..f74d3bab810d 100644 --- a/drivers/net/wwan/t7xx/t7xx_port.h +++ b/drivers/net/wwan/t7xx/t7xx_port.h @@ -75,6 +75,8 @@ enum port_ch { PORT_CH_DSS6_TX = 0x20df, PORT_CH_DSS7_RX = 0x20e0, PORT_CH_DSS7_TX = 0x20e1, + + PORT_CH_UNIMPORTANT = 0xffff, }; struct t7xx_port; @@ -135,11 +137,13 @@ struct t7xx_port { }; }; +int t7xx_get_port_mtu(struct t7xx_port *port); struct sk_buff *t7xx_port_alloc_skb(int payload); struct sk_buff *t7xx_ctrl_alloc_skb(int payload); int t7xx_port_enqueue_skb(struct t7xx_port *port, struct sk_buff *skb); int t7xx_port_send_skb(struct t7xx_port *port, struct sk_buff *skb, unsigned int pkt_header, unsigned int ex_msg); +int t7xx_port_send_raw_skb(struct t7xx_port *port, struct sk_buff *skb); int t7xx_port_send_ctl_skb(struct t7xx_port *port, struct sk_buff *skb, unsigned int msg, unsigned int ex_msg); diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.c b/drivers/net/wwan/t7xx/t7xx_port_proxy.c index 274846d39fbf..e53a152faee4 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_proxy.c +++ b/drivers/net/wwan/t7xx/t7xx_port_proxy.c @@ -48,6 +48,9 @@ i < (proxy)->port_count; \ i++, (p) = &(proxy)->ports[i]) +#define T7XX_MAX_POSSIBLE_PORTS_NUM \ + (max(ARRAY_SIZE(t7xx_port_conf), ARRAY_SIZE(t7xx_early_port_conf))) + static const struct t7xx_port_conf t7xx_port_conf[] = { { .tx_ch = PORT_CH_UART2_TX, @@ -100,6 +103,18 @@ static const struct t7xx_port_conf t7xx_port_conf[] = { }, }; +static const struct t7xx_port_conf t7xx_early_port_conf[] = { + { + .tx_ch = PORT_CH_UNIMPORTANT, + .rx_ch = PORT_CH_UNIMPORTANT, + .txq_index = CLDMA_Q_IDX_DUMP, + .rxq_index = CLDMA_Q_IDX_DUMP, + .txq_exp_index = CLDMA_Q_IDX_DUMP, + .rxq_exp_index = CLDMA_Q_IDX_DUMP, + .path_id = CLDMA_ID_AP, + }, +}; + static struct t7xx_port *t7xx_proxy_get_port_by_ch(struct port_proxy *port_prox, enum port_ch ch) { const struct t7xx_port_conf *port_conf; @@ -214,7 +229,17 @@ int t7xx_port_enqueue_skb(struct t7xx_port *port, struct sk_buff *skb) return 0; } -static int t7xx_port_send_raw_skb(struct t7xx_port *port, struct sk_buff *skb) +int t7xx_get_port_mtu(struct t7xx_port *port) +{ + enum cldma_id path_id = port->port_conf->path_id; + int tx_qno = t7xx_port_get_queue_no(port); + struct cldma_ctrl *md_ctrl; + + md_ctrl = port->t7xx_dev->md->md_ctrl[path_id]; + return md_ctrl->tx_ring[tx_qno].pkt_size; +} + +int t7xx_port_send_raw_skb(struct t7xx_port *port, struct sk_buff *skb) { enum cldma_id path_id = port->port_conf->path_id; struct cldma_ctrl *md_ctrl; @@ -329,6 +354,39 @@ static void t7xx_proxy_setup_ch_mapping(struct port_proxy *port_prox) } } +/** + * t7xx_port_proxy_recv_skb_from_dedicated_queue() - Dispatch early port received skb. + * @queue: CLDMA queue. + * @skb: Socket buffer. + * + * Return: + ** 0 - Packet consumed. + ** -ERROR - Failed to process skb. + */ +int t7xx_port_proxy_recv_skb_from_dedicated_queue(struct cldma_queue *queue, struct sk_buff *skb) +{ + struct t7xx_pci_dev *t7xx_dev = queue->md_ctrl->t7xx_dev; + struct port_proxy *port_prox = t7xx_dev->md->port_prox; + const struct t7xx_port_conf *port_conf; + struct t7xx_port *port; + int ret; + + port = &port_prox->ports[0]; + if (WARN_ON_ONCE(port->port_conf->rxq_index != queue->index)) { + dev_kfree_skb_any(skb); + return -EINVAL; + } + + port_conf = port->port_conf; + ret = port_conf->ops->recv_skb(port, skb); + if (ret < 0 && ret != -ENOBUFS) { + dev_err(port->dev, "drop on RX ch %d, %d\n", port_conf->rx_ch, ret); + dev_kfree_skb_any(skb); + } + + return ret; +} + static struct t7xx_port *t7xx_port_proxy_find_port(struct t7xx_pci_dev *t7xx_dev, struct cldma_queue *queue, u16 channel) { @@ -359,7 +417,7 @@ static struct t7xx_port *t7xx_port_proxy_find_port(struct t7xx_pci_dev *t7xx_dev ** 0 - Packet consumed. ** -ERROR - Failed to process skb. */ -static int t7xx_port_proxy_recv_skb(struct cldma_queue *queue, struct sk_buff *skb) +int t7xx_port_proxy_recv_skb(struct cldma_queue *queue, struct sk_buff *skb) { struct ccci_header *ccci_h = (struct ccci_header *)skb->data; struct t7xx_pci_dev *t7xx_dev = queue->md_ctrl->t7xx_dev; @@ -444,33 +502,54 @@ static void t7xx_proxy_init_all_ports(struct t7xx_modem *md) spin_lock_init(&port->port_update_lock); port->chan_enable = false; - if (port_conf->ops->init) + if (port_conf->ops && port_conf->ops->init) port_conf->ops->init(port); } t7xx_proxy_setup_ch_mapping(port_prox); } +void t7xx_port_proxy_set_cfg(struct t7xx_modem *md, enum port_cfg_id cfg_id) +{ + struct port_proxy *port_prox = md->port_prox; + const struct t7xx_port_conf *port_conf; + u32 port_count; + int i; + + t7xx_port_proxy_uninit(port_prox); + + if (cfg_id == PORT_CFG_ID_EARLY) { + port_conf = t7xx_early_port_conf; + port_count = ARRAY_SIZE(t7xx_early_port_conf); + } else { + port_conf = t7xx_port_conf; + port_count = ARRAY_SIZE(t7xx_port_conf); + } + + for (i = 0; i < port_count; i++) + port_prox->ports[i].port_conf = &port_conf[i]; + + port_prox->cfg_id = cfg_id; + port_prox->port_count = port_count; + + t7xx_proxy_init_all_ports(md); +} + static int t7xx_proxy_alloc(struct t7xx_modem *md) { - unsigned int port_count = ARRAY_SIZE(t7xx_port_conf); struct device *dev = &md->t7xx_dev->pdev->dev; struct port_proxy *port_prox; - int i; - port_prox = devm_kzalloc(dev, sizeof(*port_prox) + sizeof(struct t7xx_port) * port_count, + port_prox = devm_kzalloc(dev, sizeof(*port_prox) + + sizeof(struct t7xx_port) * T7XX_MAX_POSSIBLE_PORTS_NUM, GFP_KERNEL); if (!port_prox) return -ENOMEM; md->port_prox = port_prox; port_prox->dev = dev; + t7xx_port_proxy_set_cfg(md, PORT_CFG_ID_EARLY); - for (i = 0; i < port_count; i++) - port_prox->ports[i].port_conf = &t7xx_port_conf[i]; - - port_prox->port_count = port_count; - t7xx_proxy_init_all_ports(md); return 0; } @@ -492,8 +571,6 @@ int t7xx_port_proxy_init(struct t7xx_modem *md) if (ret) return ret; - t7xx_cldma_set_recv_skb(md->md_ctrl[CLDMA_ID_AP], t7xx_port_proxy_recv_skb); - t7xx_cldma_set_recv_skb(md->md_ctrl[CLDMA_ID_MD], t7xx_port_proxy_recv_skb); return 0; } @@ -505,7 +582,7 @@ void t7xx_port_proxy_uninit(struct port_proxy *port_prox) for_each_proxy_port(i, port, port_prox) { const struct t7xx_port_conf *port_conf = port->port_conf; - if (port_conf->ops->uninit) + if (port_conf->ops && port_conf->ops->uninit) port_conf->ops->uninit(port); } } diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.h b/drivers/net/wwan/t7xx/t7xx_port_proxy.h index 81d059fbc0fb..7f5706811445 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_proxy.h +++ b/drivers/net/wwan/t7xx/t7xx_port_proxy.h @@ -31,11 +31,18 @@ #define RX_QUEUE_MAXLEN 32 #define CTRL_QUEUE_MAXLEN 16 +enum port_cfg_id { + PORT_CFG_ID_INVALID, + PORT_CFG_ID_NORMAL, + PORT_CFG_ID_EARLY, +}; + struct port_proxy { int port_count; struct list_head rx_ch_ports[PORT_CH_ID_MASK + 1]; struct list_head queue_ports[CLDMA_NUM][MTK_QUEUES]; struct device *dev; + enum port_cfg_id cfg_id; struct t7xx_port ports[]; }; @@ -98,5 +105,8 @@ void t7xx_port_proxy_md_status_notify(struct port_proxy *port_prox, unsigned int int t7xx_port_enum_msg_handler(struct t7xx_modem *md, void *msg); int t7xx_port_proxy_chl_enable_disable(struct port_proxy *port_prox, unsigned int ch_id, bool en_flag); +void t7xx_port_proxy_set_cfg(struct t7xx_modem *md, enum port_cfg_id cfg_id); +int t7xx_port_proxy_recv_skb(struct cldma_queue *queue, struct sk_buff *skb); +int t7xx_port_proxy_recv_skb_from_dedicated_queue(struct cldma_queue *queue, struct sk_buff *skb); #endif /* __T7XX_PORT_PROXY_H__ */ diff --git a/drivers/net/wwan/t7xx/t7xx_port_wwan.c b/drivers/net/wwan/t7xx/t7xx_port_wwan.c index 17389c8f6600..ddc20ddfa734 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_wwan.c +++ b/drivers/net/wwan/t7xx/t7xx_port_wwan.c @@ -152,14 +152,15 @@ static int t7xx_port_wwan_disable_chl(struct t7xx_port *port) static void t7xx_port_wwan_md_state_notify(struct t7xx_port *port, unsigned int state) { const struct t7xx_port_conf *port_conf = port->port_conf; - unsigned int header_len = sizeof(struct ccci_header); + unsigned int header_len = sizeof(struct ccci_header), mtu; struct wwan_port_caps caps; if (state != MD_STATE_READY) return; if (!port->wwan.wwan_port) { - caps.frag_len = CLDMA_MTU - header_len; + mtu = t7xx_get_port_mtu(port); + caps.frag_len = mtu - header_len; caps.headroom_len = header_len; port->wwan.wwan_port = wwan_create_port(port->dev, port_conf->port_type, &wwan_ops, &caps, port); diff --git a/drivers/net/wwan/t7xx/t7xx_reg.h b/drivers/net/wwan/t7xx/t7xx_reg.h index c41d7d094c08..9c7dc72ac6f6 100644 --- a/drivers/net/wwan/t7xx/t7xx_reg.h +++ b/drivers/net/wwan/t7xx/t7xx_reg.h @@ -101,11 +101,33 @@ enum t7xx_pm_resume_state { PM_RESUME_REG_STATE_L2_EXP, }; +enum host_event_e { + HOST_EVENT_INIT = 0, + FASTBOOT_DL_NOTIFY = 0x3, +}; + #define T7XX_PCIE_MISC_DEV_STATUS 0x0d1c #define MISC_STAGE_MASK GENMASK(2, 0) #define MISC_RESET_TYPE_PLDR BIT(26) #define MISC_RESET_TYPE_FLDR BIT(27) -#define LINUX_STAGE 4 +#define MISC_RESET_TYPE_PLDR BIT(26) +#define MISC_LK_EVENT_MASK GENMASK(11, 8) +#define HOST_EVENT_MASK GENMASK(31, 28) + +enum lk_event_id { + LK_EVENT_NORMAL = 0, + LK_EVENT_CREATE_PD_PORT = 1, + LK_EVENT_CREATE_POST_DL_PORT = 2, + LK_EVENT_RESET = 7, +}; + +enum t7xx_device_stage { + T7XX_DEV_STAGE_INIT = 0, + T7XX_DEV_STAGE_BROM_PRE = 1, + T7XX_DEV_STAGE_BROM_POST = 2, + T7XX_DEV_STAGE_LK = 3, + T7XX_DEV_STAGE_LINUX = 4, +}; #define T7XX_PCIE_RESOURCE_STATUS 0x0d28 #define T7XX_PCIE_RESOURCE_STS_MSK GENMASK(4, 0) diff --git a/drivers/net/wwan/t7xx/t7xx_state_monitor.c b/drivers/net/wwan/t7xx/t7xx_state_monitor.c index c5d46f45fa62..2bcd061617e2 100644 --- a/drivers/net/wwan/t7xx/t7xx_state_monitor.c +++ b/drivers/net/wwan/t7xx/t7xx_state_monitor.c @@ -47,6 +47,13 @@ #define FSM_MD_EX_PASS_TIMEOUT_MS 45000 #define FSM_CMD_TIMEOUT_MS 2000 +#define wait_for_expected_dev_stage(status) \ + read_poll_timeout(ioread32, status, \ + ((status & MISC_STAGE_MASK) == T7XX_DEV_STAGE_LINUX) || \ + ((status & MISC_STAGE_MASK) == T7XX_DEV_STAGE_LK), 100000, \ + 20000000, false, IREG_BASE(md->t7xx_dev) + \ + T7XX_PCIE_MISC_DEV_STATUS) + void t7xx_fsm_notifier_register(struct t7xx_modem *md, struct t7xx_fsm_notifier *notifier) { struct t7xx_fsm_ctl *ctl = md->fsm_ctl; @@ -206,6 +213,51 @@ static void fsm_routine_exception(struct t7xx_fsm_ctl *ctl, struct t7xx_fsm_comm fsm_finish_command(ctl, cmd, 0); } +static void t7xx_host_event_notify(struct t7xx_modem *md, unsigned int event_id) +{ + u32 value; + + value = ioread32(IREG_BASE(md->t7xx_dev) + T7XX_PCIE_MISC_DEV_STATUS); + value &= ~HOST_EVENT_MASK; + value |= FIELD_PREP(HOST_EVENT_MASK, event_id); + iowrite32(value, IREG_BASE(md->t7xx_dev) + T7XX_PCIE_MISC_DEV_STATUS); +} + +static void t7xx_lk_stage_event_handling(struct t7xx_fsm_ctl *ctl, unsigned int status) +{ + struct t7xx_modem *md = ctl->md; + struct cldma_ctrl *md_ctrl; + enum lk_event_id lk_event; + struct device *dev; + + dev = &md->t7xx_dev->pdev->dev; + lk_event = FIELD_GET(MISC_LK_EVENT_MASK, status); + switch (lk_event) { + case LK_EVENT_NORMAL: + case LK_EVENT_RESET: + break; + + case LK_EVENT_CREATE_PD_PORT: + case LK_EVENT_CREATE_POST_DL_PORT: + md_ctrl = md->md_ctrl[CLDMA_ID_AP]; + t7xx_cldma_hif_hw_init(md_ctrl); + t7xx_cldma_stop(md_ctrl); + t7xx_cldma_switch_cfg(md_ctrl, CLDMA_DEDICATED_Q_CFG); + + t7xx_cldma_start(md_ctrl); + + if (lk_event == LK_EVENT_CREATE_POST_DL_PORT) + t7xx_mode_update(md->t7xx_dev, T7XX_FASTBOOT_DL_MODE); + else + t7xx_mode_update(md->t7xx_dev, T7XX_FASTBOOT_DUMP_MODE); + break; + + default: + dev_err(dev, "Invalid LK event %d\n", lk_event); + break; + } +} + static int fsm_stopped_handler(struct t7xx_fsm_ctl *ctl) { ctl->curr_state = FSM_STATE_STOPPED; @@ -230,7 +282,9 @@ static void fsm_routine_stopping(struct t7xx_fsm_ctl *ctl, struct t7xx_fsm_comma struct cldma_ctrl *md_ctrl; int err; - if (ctl->curr_state == FSM_STATE_STOPPED || ctl->curr_state == FSM_STATE_STOPPING) { + if (ctl->curr_state == FSM_STATE_STOPPED || + ctl->curr_state == FSM_STATE_STOPPING || + ctl->md->rgu_irq_asserted) { fsm_finish_command(ctl, cmd, -EINVAL); return; } @@ -242,11 +296,16 @@ static void fsm_routine_stopping(struct t7xx_fsm_ctl *ctl, struct t7xx_fsm_comma t7xx_fsm_broadcast_state(ctl, MD_STATE_WAITING_TO_STOP); t7xx_cldma_stop(md_ctrl); - if (!ctl->md->rgu_irq_asserted) { - t7xx_mhccif_h2d_swint_trigger(t7xx_dev, H2D_CH_DRM_DISABLE_AP); - /* Wait for the DRM disable to take effect */ - msleep(FSM_DRM_DISABLE_DELAY_MS); + if (READ_ONCE(t7xx_dev->mode) == T7XX_FASTBOOT_DL_SWITCHING) + t7xx_host_event_notify(ctl->md, FASTBOOT_DL_NOTIFY); + t7xx_mhccif_h2d_swint_trigger(t7xx_dev, H2D_CH_DRM_DISABLE_AP); + /* Wait for the DRM disable to take effect */ + msleep(FSM_DRM_DISABLE_DELAY_MS); + + if (READ_ONCE(t7xx_dev->mode) == T7XX_FASTBOOT_DL_SWITCHING) { + t7xx_mhccif_h2d_swint_trigger(t7xx_dev, H2D_CH_DEVICE_RESET); + } else { err = t7xx_acpi_fldr_func(t7xx_dev); if (err) t7xx_mhccif_h2d_swint_trigger(t7xx_dev, H2D_CH_DEVICE_RESET); @@ -318,7 +377,8 @@ static int fsm_routine_starting(struct t7xx_fsm_ctl *ctl) static void fsm_routine_start(struct t7xx_fsm_ctl *ctl, struct t7xx_fsm_command *cmd) { struct t7xx_modem *md = ctl->md; - u32 dev_status; + struct device *dev; + u32 status; int ret; if (!md) @@ -330,23 +390,53 @@ static void fsm_routine_start(struct t7xx_fsm_ctl *ctl, struct t7xx_fsm_command return; } + dev = &md->t7xx_dev->pdev->dev; ctl->curr_state = FSM_STATE_PRE_START; t7xx_md_event_notify(md, FSM_PRE_START); - ret = read_poll_timeout(ioread32, dev_status, - (dev_status & MISC_STAGE_MASK) == LINUX_STAGE, 20000, 2000000, - false, IREG_BASE(md->t7xx_dev) + T7XX_PCIE_MISC_DEV_STATUS); + ret = wait_for_expected_dev_stage(status); + if (ret) { - struct device *dev = &md->t7xx_dev->pdev->dev; + dev_err(dev, "read poll timeout %d\n", ret); + goto finish_command; + } - fsm_finish_command(ctl, cmd, -ETIMEDOUT); - dev_err(dev, "Invalid device status 0x%lx\n", dev_status & MISC_STAGE_MASK); - return; + if (status != ctl->status || cmd->flag != 0) { + u32 stage = FIELD_GET(MISC_STAGE_MASK, status); + + switch (stage) { + case T7XX_DEV_STAGE_INIT: + case T7XX_DEV_STAGE_BROM_PRE: + case T7XX_DEV_STAGE_BROM_POST: + dev_dbg(dev, "BROM_STAGE Entered\n"); + ret = t7xx_fsm_append_cmd(ctl, FSM_CMD_START, 0); + break; + + case T7XX_DEV_STAGE_LK: + dev_dbg(dev, "LK_STAGE Entered\n"); + t7xx_lk_stage_event_handling(ctl, status); + break; + + case T7XX_DEV_STAGE_LINUX: + dev_dbg(dev, "LINUX_STAGE Entered\n"); + t7xx_mhccif_mask_clr(md->t7xx_dev, D2H_INT_PORT_ENUM | + D2H_INT_ASYNC_MD_HK | D2H_INT_ASYNC_AP_HK); + if (cmd->flag == 0) + break; + t7xx_cldma_hif_hw_init(md->md_ctrl[CLDMA_ID_AP]); + t7xx_cldma_hif_hw_init(md->md_ctrl[CLDMA_ID_MD]); + t7xx_port_proxy_set_cfg(md, PORT_CFG_ID_NORMAL); + ret = fsm_routine_starting(ctl); + break; + + default: + break; + } + ctl->status = status; } - t7xx_cldma_hif_hw_init(md->md_ctrl[CLDMA_ID_AP]); - t7xx_cldma_hif_hw_init(md->md_ctrl[CLDMA_ID_MD]); - fsm_finish_command(ctl, cmd, fsm_routine_starting(ctl)); +finish_command: + fsm_finish_command(ctl, cmd, ret); } static int fsm_main_thread(void *data) @@ -518,6 +608,7 @@ void t7xx_fsm_reset(struct t7xx_modem *md) fsm_flush_event_cmd_qs(ctl); ctl->curr_state = FSM_STATE_STOPPED; ctl->exp_flg = false; + ctl->status = T7XX_DEV_STAGE_INIT; } int t7xx_fsm_init(struct t7xx_modem *md) diff --git a/drivers/net/wwan/t7xx/t7xx_state_monitor.h b/drivers/net/wwan/t7xx/t7xx_state_monitor.h index b0b3662ae6d7..7b0a9baf488c 100644 --- a/drivers/net/wwan/t7xx/t7xx_state_monitor.h +++ b/drivers/net/wwan/t7xx/t7xx_state_monitor.h @@ -96,6 +96,7 @@ struct t7xx_fsm_ctl { bool exp_flg; spinlock_t notifier_lock; /* Protects notifier list */ struct list_head notifier_list; + u32 status; /* Device boot stage */ }; struct t7xx_fsm_event { From patchwork Wed Jan 24 17:00:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjian Song X-Patchwork-Id: 13529433 X-Patchwork-Delegate: kuba@kernel.org Received: from AUS01-SY4-obe.outbound.protection.outlook.com (mail-sy4aus01olkn2172.outbound.protection.outlook.com [40.92.62.172]) (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 402557E772 for ; Wed, 24 Jan 2024 17:01:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.62.172 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115664; cv=fail; b=dvS0/p79zufa3NjLMuAFmAIzIh5LE4/8/RqNnstRksgIJ49DqtQH9pzoBjTNDf4C4GPY2xv8iSlRLIQbAcqqAGysq7YbPHwq0/M66xzS7GwGa651r8Nns0a3ZmMgDcG2ohL/NrqNg4xiOzcg/oOwN1JEzgh+fBzQQpcu9oatGSM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706115664; c=relaxed/simple; bh=i00nK1Vkn0NJgdHwFHUfKzRSdtkDdicc9Ra4tOhUccE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=fKZZMVxaaJe0kG/eBJDIEbVcqILP/Jy9pekZPBzyiAjcE29ZNfMoHSPXQJBNxOa0JrYB1/9L33FlHXPcWVccdl7nHisnTBvyU8O43gOSI3QDhWUSm986s6VKYYDBcHhQebAS2HIBq0+uUPMcKBTc1fiolxOKjvtg94+dEIg8bhw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com; spf=pass smtp.mailfrom=hotmail.com; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b=Pb75dZBo; arc=fail smtp.client-ip=40.92.62.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hotmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hotmail.com header.i=@hotmail.com header.b="Pb75dZBo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=guYrNVmh95kp8/ytj+gbN9NAGAXcHFu7SudOQO6GRtD26iPCb/2i7BHNk7dcauFxqMcvM0GfiHJIaTXsYydNBqhuWOwvtNCklkTl05w6zlKuOS4uO8tN99LFvebcC6L/qnrSnAkfvwqe6DgqnOWD1aWLZ9YX4AP6jkojiqbhvFqubczsPs/1PZ2N6Y/S7xHtKMuhihBBjP/uRHPoHGRBzhhUc2qd4hHYWIraG9PgIUKHyacEznN7509nmAlROl9J3Qh4gHcTiqW3jwcWaAmPIXSfF1vdaUWJUFqe1zU98AA7tKAK7ZD2mViWLm9/DaXkDMk9jC0Ga33k07JkT0OD6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3cjtH5EutjCZHV0kXQcwBKraNTJZYbnQDZs0djWzck4=; b=cL5F6jZmf9DAmym49M4wOMegYyp1pns8Gfeem90ihxZ2HC5jh7k36xtZWIAV7W5RItM72VGtrInLHC21kXeYP2JId6nCYDrvPjGInn3s8zMlTdULhtWNfZUDhaWR2uhBy0A9s+oC826+eTsM5bvSA6b31wJEYgY1WZGaaUv5PxWgVWiB7/lXnVpRjOyGLxcjo+Dut6kvCCpS4PV/+dhGakWXYKKm+zwROLOt3TFzHyj4Xa+ja0gcC/KQx30JFmkEM4Ijz0/IcyqMqoMcjlSYDJAzzrGVCGn1hZs0jQKRcA/jcAVvmSycfZjpBkXskqYiFTdPijN9aUD8H5jE1QzjmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3cjtH5EutjCZHV0kXQcwBKraNTJZYbnQDZs0djWzck4=; b=Pb75dZBoalfv5Wd97pujcaI7YXQDht/RYhDmXmSEdsmoWY6bUP+nuiwtuCMOhZGrW7v8A7NmEMQBIVzpggJ2c3mVwFDRBAm62XImvQd8RkNBLGPsOmrfvle3jJqkSpSz3NAVBv3r+YYkyfDWUtiiDl4/4gcaEO/85aDwPaeu1VvbNLQNK8uERe4tDaISF3z0tDpqQ2XfVb/xDsw8q4ssj/TX92Hj537E4ubNLgL+hNTYgEapLJgrj0CIs2jbY4pMPZEnMfrg4LN0n5bYRli67MI0iEXz3g8QWbZeNKf8iOUpzC7+O+UNEEGqUR7Lze5VELCORC0xxIvJHGLdV7D2VQ== Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) by SY8P282MB4480.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:258::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Wed, 24 Jan 2024 17:00:56 +0000 Received: from MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f]) by MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM ([fe80::4b5:c5db:e39a:e48f%3]) with mapi id 15.20.7202.031; Wed, 24 Jan 2024 17:00:56 +0000 From: Jinjian Song To: netdev@vger.kernel.org Cc: chandrashekar.devegowda@intel.com, chiranjeevi.rapolu@linux.intel.com, haijun.liu@mediatek.com, m.chetan.kumar@linux.intel.com, ricardo.martinez@linux.intel.com, loic.poulain@linaro.org, ryazanov.s.a@gmail.com, johannes@sipsolutions.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.com, vsankar@lenovo.com, danielwinkler@google.com, nmarupaka@google.com, joey.zhao@fibocom.com, liuqf@fibocom.com, felix.yan@fibocom.com, Jinjian Song Subject: [net-next v6 4/4] net: wwan: t7xx: Add fastboot WWAN port Date: Thu, 25 Jan 2024 01:00:10 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240124170010.19445-1-songjinjian@hotmail.com> References: <20240124170010.19445-1-songjinjian@hotmail.com> X-TMN: [Xe/0KlBXxvMaNmtXbLbVv5kwI4hL/JcV] X-ClientProxiedBy: SI2PR02CA0031.apcprd02.prod.outlook.com (2603:1096:4:195::16) To MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:14c::12) X-Microsoft-Original-Message-ID: <20240124170010.19445-5-songjinjian@hotmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MEYP282MB2697:EE_|SY8P282MB4480:EE_ X-MS-Office365-Filtering-Correlation-Id: 6f9e32e4-6787-42b9-413d-08dc1cfe082b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yo69p0OPLCNRF/uqp4aOIdE+vo7qhlvHPtrMQP6BcArjgr0bYtwvSF3L7cmGc8ii8F8LYwsDOTcSsLPxshqE4I6w9RgMhpl1LZzrVTGi1z4Jxpjlqm9+Aqtyhx/ZhY/HT44lPbPVyuKthaGSVlUZZjgj5tO0c8M2jvgPbroT9jx+UQ4//po3gUzbvKNAxsNTS23c3x1R8iGGwikbxP9lES6Wc5ahRg5SSeataYTyH/dXgVgNbRpq+ytluaKBdQNReBRINbufIwTg6d3bjJv07hU2iRUN6F4UCi+LJ+C4dkikHC3/c+Z2P9TLkuAg55iCT4KnBCCD7dl1m1VWHdMWYpvrq9ZeRU/Xe7m6RKbqLZPvyG31x+FVS3db+931s62k0AhhSQ7e8sSLA+zI4IRlKcv/OPoY42GOa+z+0len0sHODtbhSLfnO2bWg4YEXOsyNiuut8FJhHJEoCYdIZJN57lMLD10ySbgT+capg9uPim6p+xvJWRHzPcLdWjgEkhQ99FAF+rgQOjGj67E2lsXOcl2jOICCYwRDReQiBN6I34989GxVgArjr87x3wPu0/O X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jrf4ieWTf8n1+Xbc4gV8SWkPEsCNrvnlteft56gXhOm/CUqdLh+zpQmlii2cZNd1QkXS6gUbmEpSqIVShwyIyeV/XwLiLY/lqh4J7LtzPOyJKpTeVTlSxLlTWiWMB7wZayBN6uP2/fo2uyjl9YdVBNVBVoYAfcgHE0VRAU9pM8zJncBxgjTgV9p5rU9PzWNZnYP9e497tiGrLOCQQ8GdIdYQfL95iIi8yOLwpW4tSYqPuty6sqk+8UR6id5boIGbAKk23MAKKPDIgMaTeHHPuUf7D567gdYKrpce2tgppuNUr/3D7bOwb6acxWAQ/udADoVSvS59W/OK8f+8Tk7fa1UAf3dDVuJbM3ubwmsQcACYMMGVf1NdlrwxjSyhveeUAw86G8zv4ZbdA7MBEFmpkdJfaBMzAWqba1+oam4FrTNxYqlFyDSko2EutysEOZJZm19Lvcg2EJXTaOVGVoTOAkniSN6C+po0o28Q077sGNl3K14Yj3oTDKG6LcKnU+X6zJgOEUWJmlV2AWUg3gbe9F9cKeNzklmO/suyU+JqrVI5x3+nPagLsnTaAxhJgPT8iWY7cH2ojDsfY4AxC/p7je8HSmx2ZXHdoSdNp0XzruYrS4FzfA+Bj3gVk4krLMEDjf2sHEQEtPNZOr7eHBTrC6HFsp7uY+Mzj/8MFp4a4QF37eVshHIJfxYasVGt6+upgo6JkFYU687AbdeU9W+R+DDmPB/neCZW+mV+0dA1wtJM4wSqGu5AmiF/nALudzeh/+deGg7HckGvqGQ7Jltkov5cQ65uBxhvLOZn6MEEB0lcm/D5Mq2pStbB1c8I4BQcRr1yrLgXExfonU0oD6ZwNBRh3c94hz6SEs2PvfuDT2zopfHqwfRQVc4pqCNyolrAxQG4vmNm3CPZ0lbEysvjKSujvTYh1p7+7yk8QJ/ks+/yOawVuUggkgVRZfMFNcR6o8ZMcLLm2z8mODOdkzY968qLSfWextixtUCDwCsmipPoxehurQBgjcstwlXaRSAdRlOhmUbljNdPXeobTG0l0876bzjLj9tbCFXgumVw5ykToY9SsoYCn5peHsmWGmRjhcqiqy7L4qguB4RCW37zRTMVwORhmpOlTFqhsGk81wwjElB1WBsnQYixWWOBIGXubdM/k7NVb4C48kuHGZnwezPaDmFMOwl0PhyPg7XXiPHd525g6gssQ0nXOp+8gvZftRHL8mU/+EJ3IrOKn7PLwRUWi8ZFh+XXyVR3yTknuGU= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 6f9e32e4-6787-42b9-413d-08dc1cfe082b X-MS-Exchange-CrossTenant-AuthSource: MEYP282MB2697.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2024 17:00:56.6758 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY8P282MB4480 X-Patchwork-Delegate: kuba@kernel.org From: Jinjian Song On early detection of wwan device in fastboot mode, driver sets up CLDMA0 HW tx/rx queues for raw data transfer and then create fastboot port to userspace. Application can use this port to flash firmware and collect core dump by fastboot protocol commands. Signed-off-by: Jinjian Song --- v6: * reorganize code to avoid dumplication v4: * change function prefix to t7xx_port_fastboot * change the name 'FASTBOOT' to fastboot in struct t7xx_early_port_conf --- .../networking/device_drivers/wwan/t7xx.rst | 14 +++ drivers/net/wwan/t7xx/t7xx_port_proxy.c | 3 + drivers/net/wwan/t7xx/t7xx_port_wwan.c | 116 ++++++++++++++---- drivers/net/wwan/t7xx/t7xx_state_monitor.c | 4 + 4 files changed, 111 insertions(+), 26 deletions(-) diff --git a/Documentation/networking/device_drivers/wwan/t7xx.rst b/Documentation/networking/device_drivers/wwan/t7xx.rst index d13624a52d8b..7257ede90152 100644 --- a/Documentation/networking/device_drivers/wwan/t7xx.rst +++ b/Documentation/networking/device_drivers/wwan/t7xx.rst @@ -125,6 +125,20 @@ The driver exposes an AT port by implementing AT WWAN Port. The userspace end of the control port is a /dev/wwan0at0 character device. Application shall use this interface to issue AT commands. +fastboot port userspace ABI +--------------------------- + +/dev/wwan0fastboot0 character device +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The driver exposes a fastboot protocol interface by implementing +fastboot WWAN Port. The userspace end of the fastboot channel pipe is a +/dev/wwan0fastboot0 character device. Application shall use this interface for +fastboot protocol communication. + +Please note that driver needs to be reloaded to export /dev/wwan0fastboot0 +port, because device needs a cold reset after enter ``FASTBOOT_DL_SWITCHING`` +mode. + The MediaTek's T700 modem supports the 3GPP TS 27.007 [4] specification. References diff --git a/drivers/net/wwan/t7xx/t7xx_port_proxy.c b/drivers/net/wwan/t7xx/t7xx_port_proxy.c index e53a152faee4..8f5e01705af2 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_proxy.c +++ b/drivers/net/wwan/t7xx/t7xx_port_proxy.c @@ -112,6 +112,9 @@ static const struct t7xx_port_conf t7xx_early_port_conf[] = { .txq_exp_index = CLDMA_Q_IDX_DUMP, .rxq_exp_index = CLDMA_Q_IDX_DUMP, .path_id = CLDMA_ID_AP, + .ops = &wwan_sub_port_ops, + .name = "fastboot", + .port_type = WWAN_PORT_FASTBOOT, }, }; diff --git a/drivers/net/wwan/t7xx/t7xx_port_wwan.c b/drivers/net/wwan/t7xx/t7xx_port_wwan.c index ddc20ddfa734..1d3372848cb6 100644 --- a/drivers/net/wwan/t7xx/t7xx_port_wwan.c +++ b/drivers/net/wwan/t7xx/t7xx_port_wwan.c @@ -2,6 +2,7 @@ /* * Copyright (c) 2021, MediaTek Inc. * Copyright (c) 2021-2022, Intel Corporation. + * Copyright (c) 2024, Fibocom Wireless Inc. * * Authors: * Amir Hanania @@ -15,6 +16,7 @@ * Chiranjeevi Rapolu * Eliot Lee * Sreehari Kancharla + * Jinjian Song */ #include @@ -33,7 +35,7 @@ #include "t7xx_port_proxy.h" #include "t7xx_state_monitor.h" -static int t7xx_port_ctrl_start(struct wwan_port *port) +static int t7xx_port_wwan_start(struct wwan_port *port) { struct t7xx_port *port_mtk = wwan_port_get_drvdata(port); @@ -44,30 +46,60 @@ static int t7xx_port_ctrl_start(struct wwan_port *port) return 0; } -static void t7xx_port_ctrl_stop(struct wwan_port *port) +static void t7xx_port_wwan_stop(struct wwan_port *port) { struct t7xx_port *port_mtk = wwan_port_get_drvdata(port); atomic_dec(&port_mtk->usage_cnt); } -static int t7xx_port_ctrl_tx(struct wwan_port *port, struct sk_buff *skb) +static int t7xx_port_fastboot_tx(struct t7xx_port *port, struct sk_buff *skb) +{ + struct sk_buff *cur = skb, *tx_skb; + size_t actual, len, offset = 0; + int txq_mtu; + int ret; + + txq_mtu = t7xx_get_port_mtu(port); + if (txq_mtu < 0) + return -EINVAL; + + actual = cur->len; + while (actual) { + len = min_t(size_t, actual, txq_mtu); + tx_skb = __dev_alloc_skb(len, GFP_KERNEL); + if (!tx_skb) + return -ENOMEM; + + skb_put_data(tx_skb, cur->data + offset, len); + + ret = t7xx_port_send_raw_skb(port, tx_skb); + if (ret) { + dev_kfree_skb(tx_skb); + dev_err(port->dev, "Write error on fastboot port, %d\n", ret); + break; + } + offset += len; + actual -= len; + } + + dev_kfree_skb(skb); + return 0; +} + +static int t7xx_port_ctrl_tx(struct t7xx_port *port, struct sk_buff *skb) { - struct t7xx_port *port_private = wwan_port_get_drvdata(port); const struct t7xx_port_conf *port_conf; struct sk_buff *cur = skb, *cloned; struct t7xx_fsm_ctl *ctl; enum md_state md_state; int cnt = 0, ret; - if (!port_private->chan_enable) - return -EINVAL; - - port_conf = port_private->port_conf; - ctl = port_private->t7xx_dev->md->fsm_ctl; + port_conf = port->port_conf; + ctl = port->t7xx_dev->md->fsm_ctl; md_state = t7xx_fsm_get_md_state(ctl); if (md_state == MD_STATE_WAITING_FOR_HS1 || md_state == MD_STATE_WAITING_FOR_HS2) { - dev_warn(port_private->dev, "Cannot write to %s port when md_state=%d\n", + dev_warn(port->dev, "Cannot write to %s port when md_state=%d\n", port_conf->name, md_state); return -ENODEV; } @@ -75,10 +107,10 @@ static int t7xx_port_ctrl_tx(struct wwan_port *port, struct sk_buff *skb) while (cur) { cloned = skb_clone(cur, GFP_KERNEL); cloned->len = skb_headlen(cur); - ret = t7xx_port_send_skb(port_private, cloned, 0, 0); + ret = t7xx_port_send_skb(port, cloned, 0, 0); if (ret) { dev_kfree_skb(cloned); - dev_err(port_private->dev, "Write error on %s port, %d\n", + dev_err(port->dev, "Write error on %s port, %d\n", port_conf->name, ret); return cnt ? cnt + ret : ret; } @@ -93,14 +125,53 @@ static int t7xx_port_ctrl_tx(struct wwan_port *port, struct sk_buff *skb) return 0; } +static int t7xx_port_wwan_tx(struct wwan_port *port, struct sk_buff *skb) +{ + struct t7xx_port *port_private = wwan_port_get_drvdata(port); + const struct t7xx_port_conf *port_conf = port_private->port_conf; + int ret; + + if (!port_private->chan_enable) + return -EINVAL; + + if (port_conf->port_type != WWAN_PORT_FASTBOOT) + ret = t7xx_port_ctrl_tx(port_private, skb); + else + ret = t7xx_port_fastboot_tx(port_private, skb); + + return ret; +} + static const struct wwan_port_ops wwan_ops = { - .start = t7xx_port_ctrl_start, - .stop = t7xx_port_ctrl_stop, - .tx = t7xx_port_ctrl_tx, + .start = t7xx_port_wwan_start, + .stop = t7xx_port_wwan_stop, + .tx = t7xx_port_wwan_tx, }; +static void t7xx_port_wwan_create(struct t7xx_port *port) +{ + const struct t7xx_port_conf *port_conf = port->port_conf; + unsigned int header_len = sizeof(struct ccci_header), mtu; + struct wwan_port_caps caps; + + if (!port->wwan.wwan_port) { + mtu = t7xx_get_port_mtu(port); + caps.frag_len = mtu - header_len; + caps.headroom_len = header_len; + port->wwan.wwan_port = wwan_create_port(port->dev, port_conf->port_type, + &wwan_ops, &caps, port); + if (IS_ERR(port->wwan.wwan_port)) + dev_err(port->dev, "Unable to create WWWAN port %s", port_conf->name); + } +} + static int t7xx_port_wwan_init(struct t7xx_port *port) { + const struct t7xx_port_conf *port_conf = port->port_conf; + + if (port_conf->port_type == WWAN_PORT_FASTBOOT) + t7xx_port_wwan_create(port); + port->rx_length_th = RX_QUEUE_MAXLEN; return 0; } @@ -152,21 +223,14 @@ static int t7xx_port_wwan_disable_chl(struct t7xx_port *port) static void t7xx_port_wwan_md_state_notify(struct t7xx_port *port, unsigned int state) { const struct t7xx_port_conf *port_conf = port->port_conf; - unsigned int header_len = sizeof(struct ccci_header), mtu; - struct wwan_port_caps caps; + + if (port_conf->port_type == WWAN_PORT_FASTBOOT) + return; if (state != MD_STATE_READY) return; - if (!port->wwan.wwan_port) { - mtu = t7xx_get_port_mtu(port); - caps.frag_len = mtu - header_len; - caps.headroom_len = header_len; - port->wwan.wwan_port = wwan_create_port(port->dev, port_conf->port_type, - &wwan_ops, &caps, port); - if (IS_ERR(port->wwan.wwan_port)) - dev_err(port->dev, "Unable to create WWWAN port %s", port_conf->name); - } + t7xx_port_wwan_create(port); } struct port_ops wwan_sub_port_ops = { diff --git a/drivers/net/wwan/t7xx/t7xx_state_monitor.c b/drivers/net/wwan/t7xx/t7xx_state_monitor.c index 2bcd061617e2..60bc8d635ade 100644 --- a/drivers/net/wwan/t7xx/t7xx_state_monitor.c +++ b/drivers/net/wwan/t7xx/t7xx_state_monitor.c @@ -229,6 +229,7 @@ static void t7xx_lk_stage_event_handling(struct t7xx_fsm_ctl *ctl, unsigned int struct cldma_ctrl *md_ctrl; enum lk_event_id lk_event; struct device *dev; + struct t7xx_port *port; dev = &md->t7xx_dev->pdev->dev; lk_event = FIELD_GET(MISC_LK_EVENT_MASK, status); @@ -244,6 +245,9 @@ static void t7xx_lk_stage_event_handling(struct t7xx_fsm_ctl *ctl, unsigned int t7xx_cldma_stop(md_ctrl); t7xx_cldma_switch_cfg(md_ctrl, CLDMA_DEDICATED_Q_CFG); + port = &ctl->md->port_prox->ports[0]; + port->port_conf->ops->enable_chl(port); + t7xx_cldma_start(md_ctrl); if (lk_event == LK_EVENT_CREATE_POST_DL_PORT)