Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp5540073rwb; Wed, 9 Aug 2023 05:55:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZsnVLLPvx5nARICuFSZ3UOqFfTyidDQtBmpOVv5Opg56V+JdM/IVVccnHrXYSwiFgU/Tb X-Received: by 2002:a05:6a20:a128:b0:141:a70:6c26 with SMTP id q40-20020a056a20a12800b001410a706c26mr3135462pzk.57.1691585728366; Wed, 09 Aug 2023 05:55:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691585728; cv=pass; d=google.com; s=arc-20160816; b=J8lZ+eFtmsnhAVanYBR22ao5//PZIa0KmI0l/vT6MD/w0vH8OIihKH56j0crnBU0QG j/CDf2VrHiRTJ9rEYyx5Nwu/a1mhVJQWi82Th2tTJ82gz4AVbnoQGsW1g2UAuyKIqno/ cyQs7w+PT/WXKJAEwwwGtbQKpi9x42er1WgEQH6fvo7ZPw6l9Bh5a9BAtgAMt0OEEV4x 92oZKeOizyoHib/P2MFOwOKQT8uZVVrCZDE+s9sAOuXiqj2TuLveyJk9tDc1GTsz983B T9MAaUe7oXVzTkMASFtfriA+RoOkDqPRGflTviGDr/CznYtry7r9Ea2xdsl44KEbfR+O 4jUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from:dkim-signature; bh=yIUXfwA2fA5HMPn2vGxy/i7o/zNouOgYPpxpURT00DE=; fh=JhttxQbsudMBO3dbeRFHbPKk2A79wJIPY7F/seMbShQ=; b=wQ+p5GGphNlF2fqjaj0oetw3R/6kd+xUS6I/Yib7JKU5MOG37fg4x3B85ikH4Jn5xH z0QfzaUGwGjexV3CuJ41KMGuq1UfboMoqq2ZK5195GdeRXmUgtA+1Gz4B3zWqBUrv6W6 1RUL/MiCQHTh1a90aMb/flTun8qS1FgVySEi7JsBZem7367GlRXkFyOVyqeXNLi2+Ylr 8QrcD14CMzf7n1FKhgD0TvRtIxflecZcTGfN88vZ+1Gwou4rZ0i4ehqtCJh/rO0mT0ae sw1E94BOwnwaGUDSoNiaNaJbe6AzM3LTohBUaSNcqFZK4dZsECN+othjcLp1AVdxudIz +/kw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=UeCnHIOY; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a056a0008c200b006665f0400a7si6496027pfu.197.2023.08.09.05.55.15; Wed, 09 Aug 2023 05:55:28 -0700 (PDT) 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=@amd.com header.s=selector1 header.b=UeCnHIOY; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233898AbjHILb3 (ORCPT + 99 others); Wed, 9 Aug 2023 07:31:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbjHILb2 (ORCPT ); Wed, 9 Aug 2023 07:31:28 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2059.outbound.protection.outlook.com [40.107.96.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE0E1FEB; Wed, 9 Aug 2023 04:31:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Djk2CMkVqbvLnj/pVCXkAkYfotHrYB9w9rg8gfFys8l7PKOyBkrmz6yaDZ6WWtIfI0zn15e8sR4wqftIsDecR/5qdaj4+ttgHiH8U4VWOJzuQjZCoRRt5Ww6uuToJ90nqDw8llht0iajSzw4tcRZMOrWfC5Kp4VC0UW4HqkElRexPZM8HVqwjUOfhcuFaeXqJs92P0KcL0+b/LATirffTteriI57v+z/MaLGniSKYzMKR9nNWP/La3NOoSG9vcXmNDtrSFggf7OzypuihCf/8IO17MkjIPHuz3y6nJCR5Mq2bAfa0JYGhQsTjlKOIg+ffZWd7T85/H9Qc6d0ZMsyyQ== 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=yIUXfwA2fA5HMPn2vGxy/i7o/zNouOgYPpxpURT00DE=; b=EeVUy3ePH/aR3589JYxNnu8yBz3GnXVW1q7mB5Q2qeRPYtsAgfzwIJ9eGjQusb0UNG4OKKCO1RshaeblKnhEamJos0wprB8d85rZMjkxibqxTE06NxB/A/dq0bk57GqP7sTLOi/uZ8ma+i5xDxHcOoG7/tBAj5gER566W8t+/H5FJ1hix2bcdeXehhIYrCrLblDDGUAZpuDAypkc0AiQN4eHODpI6qcADrzRvoNG9PvCgTWUsMzyHV6yqsYlUtqQupCo87tjG/hde737KI3dD1vEiuE38OeGq9mwk3B0GITWbRalBxHHWxhQm4hg9sV8Xj0wp/Gl97DVxTkmHfV7YA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yIUXfwA2fA5HMPn2vGxy/i7o/zNouOgYPpxpURT00DE=; b=UeCnHIOYH/wOwCYSSkOivlzouxT793sd/qFO6MIRmr+JLNggpOmc++ywIDrZbH/yx5g8ctpg8XiMfX9KGDWx/tXSWUmbNum8iILtw4TYZk2RBy/KpgLA2TC3c6FEIMF2zHQ0vSPEqehcq8BXMw0J9z/DC22gOnWR/4Ygm5K5wc8= Received: from PH8PR12MB6675.namprd12.prod.outlook.com (2603:10b6:510:1c2::15) by SJ2PR12MB8135.namprd12.prod.outlook.com (2603:10b6:a03:4f3::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Wed, 9 Aug 2023 11:31:25 +0000 Received: from PH8PR12MB6675.namprd12.prod.outlook.com ([fe80::6a4c:b0d9:9f2:d986]) by PH8PR12MB6675.namprd12.prod.outlook.com ([fe80::6a4c:b0d9:9f2:d986%7]) with mapi id 15.20.6652.028; Wed, 9 Aug 2023 11:31:24 +0000 From: "Goud, Srinivas" To: Charles Keepax , "broonie@kernel.org" CC: "linux-spi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "patches@opensource.cirrus.com" Subject: RE: [PATCH v2 1/2] spi: spi-cadence: Interleave write of TX and read of RX FIFO Thread-Topic: [PATCH v2 1/2] spi: spi-cadence: Interleave write of TX and read of RX FIFO Thread-Index: AQHZiWymuzIqz3Ot8UaPrMu6fkQ75K9nn7Iw Date: Wed, 9 Aug 2023 11:31:24 +0000 Message-ID: References: <20230518093927.711358-1-ckeepax@opensource.cirrus.com> In-Reply-To: <20230518093927.711358-1-ckeepax@opensource.cirrus.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH8PR12MB6675:EE_|SJ2PR12MB8135:EE_ x-ms-office365-filtering-correlation-id: 95614252-879b-4670-6e43-08db98cc29d1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dr/Yy/VSFu3aHcL6mkQZmto0EAeMZBq1VIeKzphZ1v6TyXoRkN9lQKN0tx1C3IPLHuIgLNMHeV/c4dJRLxrJv0PMdvDSvwiaLJ/sEa7PVISdVEd0PLmPzFQm5dV5B09kr5mFJQK8ltAsovlaR6bhdDfBl0rcWR/C+nUKLxp6JLIr/NN9sXi0SQkXidU1m1C7iaeihaSZy7EnwCf4ZhAKn5fS/GIoesNTs4OeH8clxleWtfBEr6+mMcZyrEyE1IVEPqMDDhJAQzgYoUl0t8GoHXAq7mZrHxDIj3wE5zo8ErnIxeDdp1phItvzbZnrh0qbWNXlpvDYMD1+pn6dptskJ9ig5tlCum+2WZxyyH5e5wiPXkKUdPl5s1jndzoeLvYzCPE6Q9T8XJDQoDpHGv9ymlK6HQFXFGkz0kZSr6g3qCmlTNIdCmxkJGEqIgslCJM2bbI5GHQrd/Yy65mmRaw6fDsUmKT7dTssU8ztKvyxKJKFWiHOzazqkxTo7bArEuxxuDjVX0pr/MG+VB+92BEMgSscJTP5gFFKeW+xTyo3ABdkCdpYyiIcXtsdWP8d5HGA4y7FnIPxNENdXtX3JSRPzQ5YgQgE4LiMp9DyLc02QUpdJWaqVXD7u2Z0+neBCQ2R x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH8PR12MB6675.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(136003)(396003)(366004)(39860400002)(1800799006)(451199021)(186006)(38100700002)(55016003)(99936003)(6506007)(41300700001)(7696005)(478600001)(122000001)(86362001)(9686003)(33656002)(5660300002)(52536014)(316002)(64756008)(66946007)(4326008)(8936002)(8676002)(66476007)(66556008)(76116006)(38070700005)(2906002)(66446008)(110136005)(54906003)(71200400001)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?eDJXzMdwLZJxZCvzuQsWAHDSJotAwz+32jeg6mgQUcfiNP83EwZf0T7WGLzd?= =?us-ascii?Q?YxQ2V4m+kgN4qZBNIwD4RW3UCXwRTTAyZOgiWuihQ4rTMC+KheMCXELW+ORJ?= =?us-ascii?Q?f2Dk46+Z6+wa8pZcz9Ytzx7B/UA26BcL383fRSo4hjBiTj9tQ0F2h9kxiNho?= =?us-ascii?Q?FsCRJwoVSTg40q7rYlFnD16dwzNVrMbiWbrD2+mbPJF28oH67nn3xhUvSnYD?= =?us-ascii?Q?yeniZwkPa1F6deKMT0Aq1kHZVF+75EeUPwusDXPpyIOYJXGosgZXTUYDJHD9?= =?us-ascii?Q?l9w31Ar5CNDksBAqBp7TA+o9YYgTAunW1R3Vy47QV+yXOEkJmTlOF+4/jqLa?= =?us-ascii?Q?vRCWH/GF5cYtRtZEx3VR7XwPkMuazAGZ0IKfW2t1JeXFND5SGfN8bG4jUkbe?= =?us-ascii?Q?LUvWX8unEK4AkedlBn+BT2cEJ964LPlxJFlOyvs4ht8OtNBOONIL9Czlef1y?= =?us-ascii?Q?0Fzei01A+hg+xh7OH2EHhsbA43/AygCUbe+mz5SLRkm85Ep7dqqlBuzIN4eB?= =?us-ascii?Q?WmWnOnuB+Ic6ceDb9lwYv20bA3vwzcYrW0ZbmVXxQQvwq+0Oqfh1JHIwVAmv?= =?us-ascii?Q?B11qy6gpdkBlOecFIneEo8tsJ7+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?Q?+Mj2xsJOdGkKHoWzRauoto5LGTMW56RTP3MktxV/GMEJAsMmzU3bn1KA5Q?= =?us-ascii?Q?=3D=3D?= Content-Type: multipart/mixed; boundary="_002_PH8PR12MB66758946C395E678B7599FE5E112APH8PR12MB6675namp_" MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH8PR12MB6675.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95614252-879b-4670-6e43-08db98cc29d1 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Aug 2023 11:31:24.4801 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: f+gtvKG4f6oxNpi2qrAG/t0OPR0RdFpisnHIZI3ctTSO/zx63QN3fRhatrojpiZs X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8135 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no 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 --_002_PH8PR12MB66758946C395E678B7599FE5E112APH8PR12MB6675namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Charles, >-----Original Message----- >From: Charles Keepax >Sent: Thursday, May 18, 2023 3:09 PM >To: broonie@kernel.org >Cc: Goud, Srinivas ; linux-spi@vger.kernel.org; >linux-kernel@vger.kernel.org; patches@opensource.cirrus.com >Subject: [PATCH v2 1/2] spi: spi-cadence: Interleave write of TX and read = of RX >FIFO > >When working in slave mode it seems the timing is exceedingly tight. >The TX FIFO can never empty, because the master is driving the clock so ze= ros >would be sent for those bytes where the FIFO is empty. > >Return to interleaving the writing of the TX FIFO and the reading of the R= X FIFO >to try to ensure the data is available when required. > >Fixes: a84c11e16dc2 ("spi: spi-cadence: Avoid read of RX FIFO before its >ready") >Signed-off-by: Charles Keepax >--- > >Updates since v1: > - Update the kernel doc to match the changes > >Thanks, >Charles > > drivers/spi/spi-cadence.c | 64 ++++++++++++++++++--------------------- > 1 file changed, 30 insertions(+), 34 deletions(-) > >diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c index >ff02d81041319..26e6633693196 100644 >--- a/drivers/spi/spi-cadence.c >+++ b/drivers/spi/spi-cadence.c >@@ -12,6 +12,7 @@ > #include > #include > #include >+#include > #include > #include > #include >@@ -301,47 +302,43 @@ static int cdns_spi_setup_transfer(struct spi_device >*spi, } > > /** >- * cdns_spi_fill_tx_fifo - Fills the TX FIFO with as many bytes as possib= le >+ * cdns_spi_process_fifo - Fills the TX FIFO, and drain the RX FIFO > * @xspi: Pointer to the cdns_spi structure >+ * @ntx: Number of bytes to pack into the TX FIFO >+ * @nrx: Number of bytes to drain from the RX FIFO > */ >-static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi, unsigned int ava= il) >+static void cdns_spi_process_fifo(struct cdns_spi *xspi, int ntx, int >+nrx) > { >- unsigned long trans_cnt =3D 0; >+ ntx =3D clamp(ntx, 0, xspi->tx_bytes); >+ nrx =3D clamp(nrx, 0, xspi->rx_bytes); > >- while ((trans_cnt < avail) && (xspi->tx_bytes > 0)) { >+ xspi->tx_bytes -=3D ntx; >+ xspi->rx_bytes -=3D nrx; >+ >+ while (ntx || nrx) { > /* When xspi in busy condition, bytes may send failed, > * then spi control did't work thoroughly, add one byte delay > */ >- if (cdns_spi_read(xspi, CDNS_SPI_ISR) & >- CDNS_SPI_IXR_TXFULL) >+ if (cdns_spi_read(xspi, CDNS_SPI_ISR) & >CDNS_SPI_IXR_TXFULL) > udelay(10); Linux driver configured as Slave, due to this above delay we see data corru= ption issue on Master side. when Master is continuously reading the data, Slave is failed to prepare th= e date on time due to above delay. > >- if (xspi->txbuf) >- cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi->txbuf++); >- else >- cdns_spi_write(xspi, CDNS_SPI_TXD, 0); >+ if (ntx) { >+ if (xspi->txbuf) >+ cdns_spi_write(xspi, CDNS_SPI_TXD, *xspi- >>txbuf++); >+ else >+ cdns_spi_write(xspi, CDNS_SPI_TXD, 0); > >- xspi->tx_bytes--; >- trans_cnt++; >- } >-} >+ ntx--; >+ } > >-/** >- * cdns_spi_read_rx_fifo - Reads the RX FIFO with as many bytes as possib= le >- * @xspi: Pointer to the cdns_spi structure >- * @count: Read byte count >- */ >-static void cdns_spi_read_rx_fifo(struct cdns_spi *xspi, unsigned long co= unt) -{ >- u8 data; >- >- /* Read out the data from the RX FIFO */ >- while (count > 0) { >- data =3D cdns_spi_read(xspi, CDNS_SPI_RXD); >- if (xspi->rxbuf) >- *xspi->rxbuf++ =3D data; >- xspi->rx_bytes--; >- count--; >+ if (nrx) { >+ u8 data =3D cdns_spi_read(xspi, CDNS_SPI_RXD); >+ >+ if (xspi->rxbuf) >+ *xspi->rxbuf++ =3D data; >+ >+ nrx--; >+ } > } > } > >@@ -391,11 +388,10 @@ static irqreturn_t cdns_spi_irq(int irq, void *dev_i= d) > if (xspi->tx_bytes < xspi->tx_fifo_depth >> 1) > cdns_spi_write(xspi, CDNS_SPI_THLD, 1); > >- cdns_spi_read_rx_fifo(xspi, trans_cnt); >- > if (xspi->tx_bytes) { >- cdns_spi_fill_tx_fifo(xspi, trans_cnt); >+ cdns_spi_process_fifo(xspi, trans_cnt, trans_cnt); > } else { >+ cdns_spi_process_fifo(xspi, 0, trans_cnt); When Linux driver configured as Slave, we observed data corruption issue wi= th Slave mode read when data length is 400 bytes. As TX empty doesn't guaranties valid data in RX FIFO, hence we added one by= te delay(10us) before RX FIFO read to overcome above issue. Created patch with above changes, find patch as attachment. Can you please test and let me know your observations. Thanks, Srinivas > cdns_spi_write(xspi, CDNS_SPI_IDR, > CDNS_SPI_IXR_DEFAULT); > spi_finalize_current_transfer(ctlr); >@@ -448,7 +444,7 @@ static int cdns_transfer_one(struct spi_controller *ct= lr, > cdns_spi_write(xspi, CDNS_SPI_THLD, xspi- >>tx_fifo_depth >> 1); > } > >- cdns_spi_fill_tx_fifo(xspi, xspi->tx_fifo_depth); >+ cdns_spi_process_fifo(xspi, xspi->tx_fifo_depth, 0); > spi_transfer_delay_exec(transfer); > > cdns_spi_write(xspi, CDNS_SPI_IER, CDNS_SPI_IXR_DEFAULT); >-- >2.30.2 --_002_PH8PR12MB66758946C395E678B7599FE5E112APH8PR12MB6675namp_ Content-Type: application/octet-stream; name="0001-spi-spi-cadence-Fix-data-corruption-issues-in-slave-.patch" Content-Description: 0001-spi-spi-cadence-Fix-data-corruption-issues-in-slave-.patch Content-Disposition: attachment; filename="0001-spi-spi-cadence-Fix-data-corruption-issues-in-slave-.patch"; size=2497; creation-date="Wed, 09 Aug 2023 11:27:51 GMT"; modification-date="Wed, 09 Aug 2023 11:31:23 GMT" Content-Transfer-Encoding: base64 RnJvbSA0MDE1NDkzMmFjNzQ4NmM5OWUzMzliYmMwYjg1YjNjZmUzODIyODZjIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBTcmluaXZhcyBHb3VkIDxzcmluaXZhcy5nb3VkQGFtZC5jb20+ CkRhdGU6IFR1ZSwgMSBBdWcgMjAyMyAyMToyMTowOSArMDUzMApTdWJqZWN0OiBbUEFUQ0hdIHNw aTogc3BpLWNhZGVuY2U6IEZpeCBkYXRhIGNvcnJ1cHRpb24gaXNzdWVzIGluIHNsYXZlIG1vZGUK ClJlbW92ZSAxMHVzIGRlbGF5IGluIGNkbnNfc3Bp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