Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp2501198qtg; Thu, 23 Mar 2023 05:01:17 -0700 (PDT) X-Google-Smtp-Source: AK7set+tfzYZPyjxhPq42Q6dldZQC8fvnPaodIhY7vukGrPQbz+CwD5sLSd+uUfEt1g0xwrzPKnc X-Received: by 2002:aa7:d913:0:b0:4fc:3777:f633 with SMTP id a19-20020aa7d913000000b004fc3777f633mr10226534edr.0.1679572876933; Thu, 23 Mar 2023 05:01:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1679572876; cv=pass; d=google.com; s=arc-20160816; b=MwvZbm117Zaj5IY8ji02toVzH5JKcPtmI3gFYOlijcKRVXoTjK7N8H8l7lTIIv58n1 dYPEeSL3ZkHT4tTttYdAMUUih1oGj45Uq4+GE9VngTKWdSy12Pa1vDQ8u7m3cT/f+Qgy xPBzJlNeaq30nQs95gtib08q7fuNAEojVYR5gwzDnG2l0uH/yLo6kV8Gn0e+1dzO97RG soUiNP+wfQ7hUKs3Eus103v+xXbL7tMNrENMWQiryAUl9SI2jyhPXCPhz6b26pBhoekY Y4szrT4+Yy0aEQG84eO62V7bZEmvMdOzf5QO1EhjxKs9cBXpSpIrpvRTT4qtrr9mMdck XSbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=BnsvHZ/6p1raD5QqSfNbk9GXxc1nvqfb7eK5CrIacTk=; b=MhLLhOpCak0MvBD/hdfheq5YqEtxIkz5x008ew3VeJq385IKpAycu5KYaKBKC2CjyL uob4L923ch5LxPJ+KfjQMUp9+Fr5UxF8TB+RKuIHDjt+bPQAphKPFS9cmOTEsiPqwv4b sV91agqWp93dXJSndQ9h59C0du+5krCdZJC1wsh7XNlbbPKGdYNFljiC31aTLzOKfYl0 SXl2P/JNKnNTYeTDjhEjm8tjMRif3WKIFstecSTjXvRAk9/OsUBEpkkp4xBVlzKJ0gzU 9uio66VGeywnVg4EOlLD4y65SnyUQKknJnfST0wb3JkXYzfj008JlGP60lOGD2lipjUT XhkA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=tcMzMkME; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y1-20020a50eb01000000b004ab49a10653si18979903edp.584.2023.03.23.05.00.43; Thu, 23 Mar 2023 05:01:16 -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=@Nvidia.com header.s=selector2 header.b=tcMzMkME; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.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=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231433AbjCWL7n (ORCPT + 99 others); Thu, 23 Mar 2023 07:59:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230517AbjCWL7W (ORCPT ); Thu, 23 Mar 2023 07:59:22 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20615.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::615]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B93919B9 for ; Thu, 23 Mar 2023 04:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AYYeq5BgSuseRbmzVQ55z9GLHEz8oxWLYikO4XQiHkMnmfzJzsGY3Hsd5EkeGOmFaojTwmQenbXnBHP4vq0065PU/pjeNxatE56MmA+VUaVh7nISWdmQs0UYDTueq+nD5hJrRau6obgrKzHZjhS4oO201mv+K1rm09E/YSVeIcCqjcnjuYVFJr+9i4K5j1MCK877oCgTQYysyIZhhuzh/yP2sYaCBQ3e4k0rA0FZG5RCNuyWY8b/WuAdLXO+whgWX2gwTa44hkFcsmpu5DIX7Vicsz0YCiNZfIU9ACv/St9Fi8BC7wGh67zAmkOXO5AHH8eqkbzBXCJEltaK5I9viQ== 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=BnsvHZ/6p1raD5QqSfNbk9GXxc1nvqfb7eK5CrIacTk=; b=bpAKocGh0ahUJ/7zU2EmvWjN5ESUrbyrMF/6mleRzLmsJYf7v5n/lDPbTSrOHGehz+wSqwS/Qg/UmGeNGYQ5deZ5LY1gkbQQnhcI3QaZbQuLKlGPPijmmEVoVVlDiERSesc/ue+397quTjunZJyra4lCO4QvB50qKIMlhYuAvZPcDhJ41IYTlLdeKwlr7KbyhWY57ZJzJWG2vbSFLl3uBQvyP+7Y4e6aMZAs/E2ckfUrI+ryw1Je9M660vPVw+1oePZxoL3EWplqXdrwZ+f/WRz+2eFSBaUQm6IrUT3HJHIdqYTSHw10F5NXu5M652fFDZwJ8PrIFFnXbdmGWrNd6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BnsvHZ/6p1raD5QqSfNbk9GXxc1nvqfb7eK5CrIacTk=; b=tcMzMkME847B4L/xgfQ+jm1ilXev/pISL6TZgDDhl3J5xL58rxZkQ4V5rX0CY6J8SL7bxzsIZhuiNg6GsnVRyMSwGkQDy6zQ+xe9rrXclWs+f4Ckc8glIc2nDPehio7W1EgQGETMc4TB6ogu2VAnXk+XASO6Q2iASxwSaazkZ0CwtJ/Y4BlUQ4Mdawk639JHgScPViI9ZaHJdX+GFBaW46tYLeWXIM2lhYz7RWit21E5RH/yXS+Hs6oKWyFfhmDBPtpU3SYzFjqFAVirEjj2bNGGVa7MvzmXHJcpRbT/SGa8wwgnTHeGfUTalnNKP6wlRJH+QBDT+LcqOQuA/cCijw== Received: from DM4PR12MB5769.namprd12.prod.outlook.com (2603:10b6:8:60::6) by CH3PR12MB8583.namprd12.prod.outlook.com (2603:10b6:610:15f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Thu, 23 Mar 2023 11:57:55 +0000 Received: from DM4PR12MB5769.namprd12.prod.outlook.com ([fe80::bca7:6774:36b1:78a0]) by DM4PR12MB5769.namprd12.prod.outlook.com ([fe80::bca7:6774:36b1:78a0%9]) with mapi id 15.20.6178.038; Thu, 23 Mar 2023 11:57:55 +0000 From: Krishna Yarlagadda To: Hillf Danton CC: "robh+dt@kernel.org" , "broonie@kernel.org" , "peterhuewe@gmx.de" , "jgg@ziepe.ca" , "jarkko@kernel.org" , "krzysztof.kozlowski+dt@linaro.org" , "linux-kernel@vger.kernel.org" Subject: RE: [Patch V8 2/3] tpm_tis-spi: Add hardware wait polling Thread-Topic: [Patch V8 2/3] tpm_tis-spi: Add hardware wait polling Thread-Index: AQHZTL4LmmU2weVzlkGZavw5z7vfj68CRGuAgAYeA0A= Date: Thu, 23 Mar 2023 11:57:55 +0000 Message-ID: References: <20230302041804.24718-1-kyarlagadda@nvidia.com> <20230319142737.2191-1-hdanton@sina.com> In-Reply-To: <20230319142737.2191-1-hdanton@sina.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM4PR12MB5769:EE_|CH3PR12MB8583:EE_ x-ms-office365-filtering-correlation-id: 754163a7-f6c2-462c-edc5-08db2b95d674 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: +8kug7pMSKhaFf/qgG/jl2iyRFITMlaOw+wNrPs7ZBTax8LN2h1wghd3Zr52gA7Zc18wW7mzyJIR+63q1zR4V4lihUV5XoQGFwu8zfcOMTazWPa2KJQZZ8FnI08UZKxmtf5Vb3KdY8de6G4HeJHBy3Ks2PnJVvKInfjx7lss7M1zekY0cIKouMANnyM0+1cQsLGpGgEPsPPrl8hcpkc0ZEC8UPSyzcSuRrRKOdrvANtmntFT7fSg/9dQfDpZ/fCK7s6A9SfnTkKMrzSZMnGlskxIQ8kYLNMc2erF0Gnn2A3bYdik2g4lWrJL3hyHuXw+LD1XBdOIfpOYvH7lIS8iKB6PT4LqwgMbVsB9mRJ1pji/2fVUs2qkGrh4Ai9jLQxqJ6fD5yXJhvywYnYlA1iZPGr2ZgNKAJmkGojw9VCKuNDihA5tbxBpedDTLyIOy6GKOm0twviIFPkp0+M4cNogDaVkYr2aYwaBc3RQnmJaq5baJKFJZeuvASxF8DX8VloKSEcUuZplIwsN+wU3HZkXtyvK1BSYROcy0p/dfGAgyqs2UcVZ/WaX3BSw3EBMF6gu71eTamz7Z0PJtD/62cSJqz3jySf0STVUrh7ENWVT1WATf5Cx55Ch8BtlRYq3bLWxC8sEBRghXF1mFqFzvmRsLGcCQ6cBMUSWsUA4PdewOnr4HpKWpjkCY1DwrERXjhigxHZG2y9DDFWskTXNQgubmA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5769.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(396003)(366004)(39860400002)(346002)(376002)(136003)(451199018)(186003)(53546011)(26005)(6506007)(83380400001)(55016003)(86362001)(38070700005)(33656002)(38100700002)(122000001)(9686003)(5660300002)(52536014)(8936002)(6916009)(8676002)(64756008)(66476007)(4326008)(71200400001)(66556008)(66446008)(66946007)(76116006)(54906003)(41300700001)(478600001)(316002)(2906002)(7696005);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?K9MRTGtrFT74MHZphDJJuZg2TWPL5gzqTc9Sz/9u45yZXZm0gqyaZEuDiIwK?= =?us-ascii?Q?HPYEExFyrImjVYSdWJDcWFKbjp1E+AGxor9bhqvvPB4bWgNVt7dMMOB59nKq?= =?us-ascii?Q?79GX2hjWIdGbtOoe7DwPnfKlQ+R65P/dr/TaWwnZgzw0kuCVGe3YJwW/RCSG?= =?us-ascii?Q?hBJ7OTq6EIw5xUSdEThU4EDOmRRTS2YLMut/yajzNzRpXhvMuqSIGPv5Ln+C?= =?us-ascii?Q?YfVNjqRblj2GmjmBeKnqgkQ29/A4jdOH9YFfYMmlGO/weU8M31yb5ZgPriNt?= =?us-ascii?Q?C4TXMYlFHO0pttHNgK4anPkXLSTLJNTFke+iP7jJ3Wun52YtXD36aUW2RHlM?= =?us-ascii?Q?pkSBzcjiSRUuYOaNuDGEb0aZ55Z9OLjXrrcv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HHbVHnk0K3hMbqCbnX8esaf60YRddVzVpVALZyZN/bntJ?= =?us-ascii?Q?35ymu7LRC248WR5bl6RtbN/GhjBQrnkgBcBn0u2YY+rhauodUV4Ry5M1Y3gl?= =?us-ascii?Q?9HY2tpi02lOMH8SgL3Uo6R/CZRJ22dSB1NGxcNEfylUZcXEadoms/qlb4oV9?= =?us-ascii?Q?lsgmiHy8ZWJOB5Xrg/bzfScr9dN3NfeWlaVMBUVrtd6G7QiGiUhQpfcH8GIa?= =?us-ascii?Q?cJj/VqxxcYadHwWWhix7JnSvYq6+XSh4FYkuXenjdP+eTXLo7WyrmMkux7cQ?= =?us-ascii?Q?UHNBGOYw6BHrsn39F2mfHblx+/v6/lWA3wt+TZt6?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5769.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 754163a7-f6c2-462c-edc5-08db2b95d674 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2023 11:57:55.0697 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ADZ3S88u1VNIuYxBSOzShGNISnj0CEYze6jPOzFMnt2vTWdG0phtbJCu3zAxJHKckLral2dDGoVE01/TOgOEbg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8583 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,SPF_HELO_PASS, SPF_NONE autolearn=unavailable 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 > -----Original Message----- > From: Hillf Danton > Sent: 19 March 2023 19:58 > To: Krishna Yarlagadda > Cc: robh+dt@kernel.org; broonie@kernel.org; peterhuewe@gmx.de; > jgg@ziepe.ca; jarkko@kernel.org; krzysztof.kozlowski+dt@linaro.org; linux= - > kernel@vger.kernel.org > Subject: Re: [Patch V8 2/3] tpm_tis-spi: Add hardware wait polling >=20 > External email: Use caution opening links or attachments >=20 >=20 > On 2 Mar 2023 09:48:03 +0530 Krishna Yarlagadda > > +static int tpm_tis_spi_hw_flow_transfer(struct tpm_tis_data *data, > > + u32 addr, u16 len, u8 *in, > > + const u8 *out) > > +{ > > + struct tpm_tis_spi_phy *phy =3D to_tpm_tis_spi_phy(data); > > + struct spi_transfer spi_xfer[3]; > > + struct spi_message m; > > + u8 transfer_len; > > + int ret; > > + > > + while (len) { > > + transfer_len =3D min_t(u16, len, MAX_SPI_FRAMESIZE); > > + > > + spi_message_init(&m); > > + phy->iobuf[0] =3D (in ? 0x80 : 0) | (transfer_len - 1); > > + phy->iobuf[1] =3D 0xd4; > > + phy->iobuf[2] =3D addr >> 8; > > + phy->iobuf[3] =3D addr; > > + > > + memset(&spi_xfer, 0, sizeof(spi_xfer)); > > + > > + spi_xfer[0].tx_buf =3D phy->iobuf; > > + spi_xfer[0].len =3D 1; > > + spi_message_add_tail(&spi_xfer[0], &m); > > + > > + spi_xfer[1].tx_buf =3D phy->iobuf + 1; > > + spi_xfer[1].len =3D 3; > > + spi_message_add_tail(&spi_xfer[1], &m); > > + > > + if (out) { > > + spi_xfer[2].tx_buf =3D &phy->iobuf[4]; > > + spi_xfer[2].rx_buf =3D NULL; > > + memcpy(&phy->iobuf[4], out, transfer_len); > > + out +=3D transfer_len; > > + } > > + > > + if (in) { > > + spi_xfer[2].tx_buf =3D NULL; > > + spi_xfer[2].rx_buf =3D &phy->iobuf[4]; > > + } > > + > > + spi_xfer[2].len =3D transfer_len; > > + spi_message_add_tail(&spi_xfer[2], &m); > > + > > + reinit_completion(&phy->ready); >=20 > What breaks without reinit? Or what sense made by init-ing it again? When length is over frame size, this loop will run for more than one iterations. Reinit to start transfer again. KY > > + > > + ret =3D spi_sync_locked(phy->spi_device, &m); > > + if (ret < 0) > > + return ret; > > + > > + if (in) { > > + memcpy(in, &phy->iobuf[4], transfer_len); > > + in +=3D transfer_len; > > + } > > + > > + len -=3D transfer_len; > > + } > > + > > + return ret; > > +}