Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2825438ybt; Mon, 22 Jun 2020 07:59:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN/CT47e9cMSf+YCqymbu3khPQOwAioYiT9wbB8gg0w45g2HeoMOS8WIzyBsv/eG1j3aWE X-Received: by 2002:a17:906:97cd:: with SMTP id ef13mr15149649ejb.165.1592837962731; Mon, 22 Jun 2020 07:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592837962; cv=none; d=google.com; s=arc-20160816; b=t8+bQkyYQ4NBDE6Ml7zzJHZ9Anqdy/dKLVqIKeRRVIwEZSesOnqvM6Klz/1MKUfvxy BNJeRG3dibexbDPpUmLfwGrDfiIrB4Js6gnMuQyoC8OuUicGOG06YMdA+aW2NlQGuiLQ jPwpGmch0E10vnyuscFBdI/kyxnSjjLug7QDNKyOT6D+JNIiyJMwcw8Ym0fLxJPgmgPV 1sDloE6QE1pEwrY6hX8/SSCpWhCmKWKByV6pGSYkSJqCG5Ars+nh9jScdGuoh9mqkm82 AXv36qA234v6R7MEJRVnQbuSyiH/UW7Zk435DwYfPAN9ab6xWK31DBzQ3ma/wFQnlrj+ ZQNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DaQaRL/n2na4izh2TsmRyDKAg7niGqHtN8UJRlkcUNk=; b=MpmJzSNgU5da6VUhgjjTvXGiTNGwoEeNX81kjPMW5scXofv+g1RBtEr090nPD3WoFo dhZ1TaBWe7pjO4B9y/tdeT9uHiLnUtHItorwBvKck56+yDI0lvAgrk0bMZQJ68efOWmU HzdYWIvH3bNB0luzU/8ikRo2msCHGKfFLPYT/xQLVHlK0lYErIlrmUIJMgHC+RMWyV1x QIqc0AU2o6d/OVt8EImp6GbMmLeIp7QGuk2rX4bb4wYHKw822Q7YIeLno7mjLI+vysvm IKwlQCjXkcDtRutuHiqBL6aOQdDLNfsHehbSpb3Ib2BAOrGYIPX371eTwK54g5JlABJf Ulmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yh6uQc0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb14si9365700edb.161.2020.06.22.07.58.59; Mon, 22 Jun 2020 07:59:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Yh6uQc0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729180AbgFVO5I (ORCPT + 99 others); Mon, 22 Jun 2020 10:57:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728824AbgFVO5I (ORCPT ); Mon, 22 Jun 2020 10:57:08 -0400 Received: from mail-vk1-xa44.google.com (mail-vk1-xa44.google.com [IPv6:2607:f8b0:4864:20::a44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45AABC061573 for ; Mon, 22 Jun 2020 07:57:08 -0700 (PDT) Received: by mail-vk1-xa44.google.com with SMTP id h190so1388658vkh.6 for ; Mon, 22 Jun 2020 07:57:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DaQaRL/n2na4izh2TsmRyDKAg7niGqHtN8UJRlkcUNk=; b=Yh6uQc0Tk44UUcYHHPdxzcHe4JMuPLNwLsMpf1hfB3Jh8Tu5KzLiUZOVxNrSzFNeRC 1VX+uZFI62Ls1+BJbg7pP2QF3IogycASPqdpS7cK4qx+8UL3mK0h3koU2KF86qJLyXNp ISsh8AdquX9pm+IhFbc8LzxKYCLQ8dhUJwD7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DaQaRL/n2na4izh2TsmRyDKAg7niGqHtN8UJRlkcUNk=; b=OddyixyEqS1drP9zHfM4nNRcSwEC5oemezzlYfWGgptPqYT3fKVWemWZ+4+6m92kWZ 0Htl7TKqZ8MfiHJrFaSId2ayy1S5F6dTpHu79UN8CJpK6P7FFVLOgfu1LvY58Vxm+Axs B3mWf42pMUpqWBSsu0Nt8dAR0LbBycW2AIVkprx3KmoABFE9AXx8zU7JTqpAnTIpvCR5 xRGBemDUZnQUfXi97f+0PAg0jbQtbrpCEDT1OZygHjUglr7aNBwDFmj4pqo7EtNbTojq mV7LppVk5gTrWtkg6E328RnPmsr2Jo07irHPQeVFETABl7YxxXfKxoXPVzKRBHJgwPoF LOIQ== X-Gm-Message-State: AOAM533Iu+1rwjjUReGyb2xxKhq9nkHhLPhPMd3RdNtogmEwyk1zk96O IJkCS8HNBNj/XQHtM14MLtxpnmtu4QQ= X-Received: by 2002:a1f:9e8a:: with SMTP id h132mr9462823vke.14.1592837827205; Mon, 22 Jun 2020 07:57:07 -0700 (PDT) Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com. [209.85.221.173]) by smtp.gmail.com with ESMTPSA id x16sm2083598vko.54.2020.06.22.07.57.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jun 2020 07:57:06 -0700 (PDT) Received: by mail-vk1-f173.google.com with SMTP id s192so4024493vkh.3 for ; Mon, 22 Jun 2020 07:57:06 -0700 (PDT) X-Received: by 2002:ac5:ce86:: with SMTP id 6mr16311424vke.75.1592837825897; Mon, 22 Jun 2020 07:57:05 -0700 (PDT) MIME-Version: 1.0 References: <20200619141958.1.I58d549fded1fd2299543ede6a103fe2bb94c805d@changeid> In-Reply-To: <20200619141958.1.I58d549fded1fd2299543ede6a103fe2bb94c805d@changeid> From: Doug Anderson Date: Mon, 22 Jun 2020 07:56:54 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] tpm_tis_spi: Prefer async probe To: Peter Huewe , Jarkko Sakkinen Cc: Nicolas Boichat , Andrey Pronin , Stephen Boyd , Arnd Bergmann , Greg Kroah-Hartman , Jason Gunthorpe , linux-integrity@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Jun 19, 2020 at 2:20 PM Douglas Anderson wrote: > > On a Chromebook I'm working on I noticed a big (~1 second) delay > during bootup where nothing was happening. Right around this big > delay there were messages about the TPM: > > [ 2.311352] tpm_tis_spi spi0.0: TPM ready IRQ confirmed on attempt 2 > [ 3.332790] tpm_tis_spi spi0.0: Cr50 firmware version: ... > > I put a few printouts in and saw that tpm_tis_spi_init() (specifically > tpm_chip_register() in that function) was taking the lion's share of > this time, though ~115 ms of the time was in cr50_print_fw_version(). > > Let's make a one-line change to prefer async probe for tpm_tis_spi. > There's no reason we need to block other drivers from probing while we > load. > > NOTES: > * It's possible that other hardware runs through the init sequence > faster than Cr50 and this isn't such a big problem for them. > However, even if they are faster they are still doing _some_ > transfers over a SPI bus so this should benefit everyone even if to > a lesser extent. > * It's possible that there are extra delays in the code that could be > optimized out. I didn't dig since once I enabled async probe they > no longer impacted me. I will note that I did continue to dig into the delays, actually. I haven't fully resolved all of them, but I'm fairly sure that most of them are actually inefficiencies in the SPI driver on my platform, which seems to have a lot of overhead in starting a new transfer. I'll work on fixing that, but in any case we should still do the async probe because it's very safe and gives a perf boost. Why do I say it's safe? 1. It's not like our probe order was defined by anything anyway. When we probe is at the whim of when the SPI controller probes and that can be any time. 2. If someone needs to access the TPM from another driver then they have to handle the fact that it might not have probed yet anyway because perhaps the SPI controller hasn't probed yet. 3. There may be other drivers probing at the same time as us anyway because _they_ used async probe. While I won't say that it's impossible to tickle a bug by turning on async probe, I would assert that in almost all cases the bug was already there and needed to be fixed anyway. ;-) -Doug