From patchwork Fri Jun 15 10:14:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 10466179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 979B3600F4 for ; Fri, 15 Jun 2018 10:33:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9512A28852 for ; Fri, 15 Jun 2018 10:33:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8359F28AED; Fri, 15 Jun 2018 10:33:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D48128852 for ; Fri, 15 Jun 2018 10:33:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ivDwRrb8y9V+Z7Vbm4NM+7oR2+zNPuYYTr22mGQbzjg=; b=OlYV3jC81dWImz FrnNy4hQUIdRrAG4dSX9uWuSrl5rFRRFWztjfyO8PQRGBrIQv278mEO7KpJU8F1t5vIzctBhpqN+C Bvv0rcxSjo03oA4WwgbUPPnPVYmkq/7GLJAkU/SNIfCb5G43rHQp9PmtiotjpgTaAPhRGsgj2ysh1 YmxrvBJ3s3eBzWoVmYKC34Z1P6F0ehZUeQs9LFPFzLKS9JvSJ7AcKedPGw0ekQtIYY2p8emI2DsMT /VLE8g8O6MmEWw0et1VCOxOJvfVPUu5y5ivE6Wu8qnK+4TUnpgkIBsauS4H17XazOhh2PBXteDZWu aJT/JkIY2bOHKrUZRVBg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTm33-0007c3-0f; Fri, 15 Jun 2018 10:33:41 +0000 Received: from mail-he1eur01on0138.outbound.protection.outlook.com ([104.47.0.138] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fTllq-00078p-Es for linux-arm-kernel@lists.infradead.org; Fri, 15 Jun 2018 10:15:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PJHXgRLYqh6uLHo7ucH9UOgpQwpEpc6V7zdNhvOegSE=; b=pW/2WUTzflsJfn7nhExxXS20BaL3YRpg0p3Yof5MMh/vkPBrlGyCXi6LBfNZbzE+K31RAf9zDFH7fZ8WeEp8GX9pZLN8cTy6zzsCts3AIbFrpCXTRRfM80ilASgEAk6HP+Lm/C8pGpWR2OQ2Tv7al2qHOfKgL6rGKgtua/FO1y0= Received: from orc.pedanet (85.226.244.23) by HE1PR0201MB2460.eurprd02.prod.outlook.com (2603:10a6:3:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.16; Fri, 15 Jun 2018 10:15:39 +0000 From: Peter Rosin To: linux-kernel@vger.kernel.org Subject: [PATCH 02/11] tpm/tpm_i2c_infineon: switch to i2c_lock_segment Date: Fri, 15 Jun 2018 12:14:57 +0200 Message-Id: <20180615101506.8012-3-peda@axentia.se> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180615101506.8012-1-peda@axentia.se> References: <20180615101506.8012-1-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: HE1PR05CA0248.eurprd05.prod.outlook.com (2603:10a6:3:fb::24) To HE1PR0201MB2460.eurprd02.prod.outlook.com (2603:10a6:3:82::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f84380e3-ae93-45c4-f7c8-08d5d2a8f268 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(7021125)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:HE1PR0201MB2460; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0201MB2460; 3:Nl/P+PZmQIeGTJV93cQBCBVUw345HhyNFksYaBYJbpATbZgaea4qYpJbBLkTpZPMahLz+d0F73/NjcDWz2H1809clrj4aDlqLZpqT7RRkNWI4rLL7j/z3VH8wmqOgOxT4FLqlPgrsC+CTEXnjY+6YEDdmIqkgfRsBT5Yp69k4O3Y8B34Nko50CuYB1BqNfLj1I/oTlMfgoMl3bLnR4Z3SqV2wN1q/53jFAaaSGLvogEwj9rRp9lppSVZwNZCMijI; 25:A20/dgtyk41UQ8P1Rjdt/CZLvkj2ZDVahhe+hBdRkYS2cuZ9KSLgE1RQdhU4CSYU82TnEKwZzVI0zQV3+bFUYHVqOc2voCcgdCla6TiTyb2VV+kWgcYcPSBngcj89ftMm4bEFUfMXD8ovTTgypYMg/Y8goFHUZsc/0min8S/mlaV5gcRRa4p8GWQUbWMVwEku2MbvCHreL4G9/CbWpjgwHgQnG0BaCWnq2uteyOK4mDn2bRcq5GygFSLlts3xn3u8aC4rPn25/p2wPzAvOPAK5zZnkyggfeljkcwKIC9SQFdHUzYZo9vxiFTuikPbNCMcmRUMuxIKVj5pUZNSDRMWQ==; 31:HupwdTG/TmxmHwMaiPE5dJUSyTCR1d50QmZ2CJhoshH9mECEGjYRjQtmdwKMKf3sF1SNI65SDQicS8PNv7JCU4y3WScFTm8Ol0Om2eqLto1SoDdddTKAEKmaR6RX3kUargblkCEO1tEPN94omXk4kojYbxMY153a1m5kaP64LIT0udtYtf69+3zurm2BQrTV9VvSF1GQ545FJ83JW91oQVG7+tJriaALKuzzD8PRLcY= X-MS-TrafficTypeDiagnostic: HE1PR0201MB2460: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(2016111802025)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(6072148)(6043046)(201708071742011)(7699016); SRVR:HE1PR0201MB2460; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0201MB2460; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0201MB2460; 4:bxgoxSwEdnQkxoaoImqeooHpP0hR5EhpwSXrDRzrvQB3GYdP44sSaOqQ1YT+nxtbZ0m1+9BiaRKEvBsq18qAVsPznVEbyc/JjTzCVCfYNwIACUDIZ98u4aayrU1Ut+weCVo2TURzTqpI9rfQBriGMkPFLKiIIIC6Q0EaRHrtp2UTg9nKTok0yqMtsy2ys+Jq5K74HhH1Jn913vjNdM6UREJjHdlTo4Nh18v3YpmQvriTG7kVTiWmAM1S5cw3ayNuIkkvwIt7C1TIshOrCB7eKA== X-Forefront-PRVS: 0704670F76 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(346002)(376002)(396003)(39830400003)(39380400002)(43544003)(199004)(189003)(186003)(16526019)(97736004)(50466002)(386003)(50226002)(68736007)(81166006)(8676002)(74482002)(26005)(52116002)(6666003)(478600001)(51416003)(2351001)(81156014)(59450400001)(8936002)(6506007)(2906002)(76176011)(15760500003)(6116002)(3846002)(1076002)(6916009)(48376002)(86362001)(7416002)(7406005)(106356001)(66066001)(2361001)(8666007)(305945005)(4326008)(39060400002)(53936002)(36756003)(316002)(5660300001)(446003)(476003)(7736002)(105586002)(6486002)(6512007)(11346002)(54906003)(956004)(47776003)(25786009)(2616005)(486006)(16586007)(70780200001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0201MB2460; H:orc.pedanet; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0201MB2460; 23:aVVE5xSBs4RqFon3TdEPbSa/vtKl9FX+oGwF75Q?= =?us-ascii?Q?uTJF8vibU37IjCshfLbNm8cu8110hVfh1XWGLrqFw2QsPQRS6WbyDV6CPsBY?= =?us-ascii?Q?1xrYJQtWN+DfUVq7GgQ4Yl0n2YBlTBL8haryiMurCcntRtP7xcNqwgPruB3t?= =?us-ascii?Q?auOetpB6WBXperOChDV8akdFwWYpFSMEG1awrBb3dERkV0NJNM3SnpyBCFSG?= =?us-ascii?Q?nycvvR1HfkDISKN1ND3OWK0+3LPaigh2yDlv4Tw8PN7z2pOsO01IEp6drKIS?= =?us-ascii?Q?nDz2RUG1Q1ARTFuv3vji6oYjnT1idM7ilF2WGrOv75D7w6HI74nP//wxVg4Q?= =?us-ascii?Q?dfeSLyzaKtco19DUrRQgICs1Gq5TCQSXKTUCauoTzlrgLEfkNtTRE+oykhRV?= =?us-ascii?Q?Vf4Va35WT4LP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B8De9wSwoBq+aEHN9KcSkapkUK0aYTy7HMRfM936ENOwRjxvFuRvzuk+M6ZhpMJxDKf+Drw3aI=; 24:ktCFs2vuNAGNLCgqzNTabWMGtvfr8pgtQ7I+CwK7npclDDGhjaEDNC7KbGKUozdZqWuVSkEFmx3aQdqfkLykRuZJGRaWrAxng1w1MCssEjU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0201MB2460; 7:mTEtfxGDmbPMkL4LCXw0Y2Gt5aSKn8zHmZGUEmNWzXmrZluHY1BDLwSWYNuF53RH8JXWtGcLiIvp6Q1X0ZVoEAyl7Pnzm0O31wEpwNCPuOeYpjLKdUhFDhkjaTVoWJgBOv2NcvYcEd1Tn6adiwfR6VduFPEZzxghyFTRlbZTd/wb13NsOAWZKRCLKh5EnLE+dP8Rf/VcdOzmqf0W9h31i3fw3NMq6O5H2vLQhFjp+qpc6UFJG7mfZNPowUSJ6dOp X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2018 10:15:39.5941 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f84380e3-ae93-45c4-f7c8-08d5d2a8f268 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0201MB2460 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180615_031554_547774_830EDE4C X-CRM114-Status: GOOD ( 14.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Crt Mori , Wolfram Sang , linux-iio@vger.kernel.org, Sekhar Nori , Jarkko Sakkinen , Thierry Reding , linux-i2c@vger.kernel.org, Peter Meerwald-Stadler , Peter Huewe , Michael Krufky , Lee Jones , Antti Palosaari , linux-samsung-soc@vger.kernel.org, Florian Fainelli , Kevin Hilman , Chunyan Zhang , Krzysztof Kozlowski , Jonathan Hunter , Jason Gunthorpe , Kukjin Kim , bcm-kernel-feedback-list@broadcom.com, linux-input@vger.kernel.org, Orson Zhai , Guenter Roeck , Haavard Skinnemoen , Arnd Bergmann , linux-media@vger.kernel.org, Lars-Peter Clausen , Gregory Fong , linux-tegra@vger.kernel.org, Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Baolin Wang , Greg Kroah-Hartman , Dmitry Torokhov , Laxman Dewangan , Hartmut Knaack , linux-integrity@vger.kernel.org, Brian Norris , Peter Rosin , Jonathan Cameron Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Locking the root adapter for __i2c_transfer will deadlock if the device sits behind a mux-locked I2C mux. Switch to the finer-grained i2c_lock_segment. If the device does not sit behind a mux-locked mux, the two locking variants are equivalent. Signed-off-by: Peter Rosin --- drivers/char/tpm/tpm_i2c_infineon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c index 6116cd05e228..b2889405b4fa 100644 --- a/drivers/char/tpm/tpm_i2c_infineon.c +++ b/drivers/char/tpm/tpm_i2c_infineon.c @@ -117,7 +117,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len) /* Lock the adapter for the duration of the whole sequence. */ if (!tpm_dev.client->adapter->algo->master_xfer) return -EOPNOTSUPP; - i2c_lock_adapter(tpm_dev.client->adapter); + i2c_lock_segment(tpm_dev.client->adapter); if (tpm_dev.chip_type == SLB9645) { /* use a combined read for newer chips @@ -192,7 +192,7 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len) } out: - i2c_unlock_adapter(tpm_dev.client->adapter); + i2c_unlock_segment(tpm_dev.client->adapter); /* take care of 'guard time' */ usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI); @@ -224,7 +224,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len, if (!tpm_dev.client->adapter->algo->master_xfer) return -EOPNOTSUPP; - i2c_lock_adapter(tpm_dev.client->adapter); + i2c_lock_segment(tpm_dev.client->adapter); /* prepend the 'register address' to the buffer */ tpm_dev.buf[0] = addr; @@ -243,7 +243,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len, usleep_range(sleep_low, sleep_hi); } - i2c_unlock_adapter(tpm_dev.client->adapter); + i2c_unlock_segment(tpm_dev.client->adapter); /* take care of 'guard time' */ usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);