Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6086841ybe; Tue, 10 Sep 2019 13:18:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXwVXItSDWfNwHB2LW+gcFjNRAwY+3BCjuxYWepoT82vSnRl5ZXMyatVXcEvvPKvXNVuEk X-Received: by 2002:a17:906:5e09:: with SMTP id n9mr17529225eju.143.1568146726809; Tue, 10 Sep 2019 13:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568146726; cv=none; d=google.com; s=arc-20160816; b=yBjqwEssTJ+lTtYqllcDF7qMbT76w4UawLeeT0NPppoe6lEzxYnNqyU93J7meitZvM tj11WUaj7rnuheC28tJipH2WXICPVNBgtjFIqAWB5WZ2XRopyNjGINkMYoj5lYHCP7v7 bEijiFtVCUGoKpH+n26IYe/lquwXKVyGlpVrjieIf7HuHT2TpcnDg2IWyIU24m7I4EHK Vln/MaAaMyXneEMo1O+48TssFtfWj6GOfg/UJfkSShcz2TA8Sha8k8xzKKKTrF0JEQPm /1vc5xU2YKc++bF167uelze4Es1c0SPsgTyhwp62MLobZEqCHIlgN4BF/laX/pVIWCid h74w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=zabvIlTxGGA/6OPINsxyZrakSKsu3Xza1GrcjBHdrZw=; b=y74IHKhwUfVWUiyBWcSlSKYi42Rkf2ncIG+sSSiiVgrRavJx8H3GVb5WTfedvGMolK UKq6ugnJnqKJni8htsSnMQor7Gb2sQLekCRH6Ercm2pZiWar3Y85NcUTRe0d7lHlkQNN QDkVxX1CMwJo+7i8dONpxjFflLlBtSYcXW9qBqIK8kTleCTcR/OfsUhCo8m5Lch3c425 Z05b4xP+F1syvWBckrD705wmiY3jhzAKUE9631a9/J+v+TRC9PBuOe46BFQOX9hJwrzp paFQ7yHuptPvX2QJyPcRBbGSbQvPsjac5Wdx0kNyfxotBGdO77Top/lga9y5tgeRDzff 0P8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h15si12243615eda.284.2019.09.10.13.18.21; Tue, 10 Sep 2019 13:18:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732561AbfIJPGh (ORCPT + 99 others); Tue, 10 Sep 2019 11:06:37 -0400 Received: from mga04.intel.com ([192.55.52.120]:21182 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbfIJPGh (ORCPT ); Tue, 10 Sep 2019 11:06:37 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2019 08:06:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,489,1559545200"; d="scan'208";a="214334308" Received: from aseticx-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.38.199]) by fmsmga002.fm.intel.com with ESMTP; 10 Sep 2019 08:06:32 -0700 Date: Tue, 10 Sep 2019 16:06:29 +0100 From: Jarkko Sakkinen To: Seunghun Han Cc: Peter Huewe , Matthew Garrett , "open list:TPM DEVICE DRIVER" , linux-kernel@vger.kernel.org, Vanya Lazeev Subject: Re: [PATCH v2 2/2] tpm: tpm_crb: enhance resource mapping mechanism for supporting AMD's fTPM Message-ID: <20190910150342.GA1920@linux.intel.com> References: <20190909090906.28700-1-kkamagui@gmail.com> <20190909090906.28700-3-kkamagui@gmail.com> <20190910144215.GA30780@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190910144215.GA30780@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 10, 2019 at 03:42:15PM +0100, Jarkko Sakkinen wrote: > On Mon, Sep 09, 2019 at 06:09:06PM +0900, Seunghun Han wrote: > > I got an AMD system which had a Ryzen Threadripper 1950X and MSI > > mainboard, and I had a problem with AMD's fTPM. My machine showed an error > > message below, and the fTPM didn't work because of it. > > > > [??5.732084] tpm_crb MSFT0101:00: can't request region for resource > > [mem 0x79b4f000-0x79b4ffff] > > [??5.732089] tpm_crb: probe of MSFT0101:00 failed with error -16 > > > > When I saw the iomem, I found two fTPM regions were in the ACPI NVS area.? > > The regions are below. > > > > 79a39000-79b6afff : ACPI Non-volatile Storage > > 79b4b000-79b4bfff : MSFT0101:00 > > 79b4f000-79b4ffff : MSFT0101:00 > > > > After analyzing this issue, I found that crb_map_io() function called > > devm_ioremap_resource() and it failed. The ACPI NVS didn't allow the TPM > > CRB driver to assign a resource in it because a busy bit was set to > > the ACPI NVS area. > > > > To support AMD's fTPM, I added a function to check intersects between > > the TPM region and ACPI NVS before it mapped the region. If some > > intersects are detected, the function just calls devm_ioremap() for > > a workaround. If there is no intersect, it calls devm_ioremap_resource(). > > > > Signed-off-by: Seunghun Han > > This problem is still valid and not addressed by Vanya's patch (and > should not be as it is a disjoint issue). However, calling > devm_ioremap() is somewhat racy as the NVS driver is not aware of that. > > My take is that this should be fixed in the code that assigns regions to > the NVS driver e.g. it could look up the regions assigned to the > MSFT0101 and ignore those regions. In the end linux-acpi maintainers > have the say on this but this would be the angle that I'd take to > implement such patch probably. Matthew pointed out that having a hook in NVS driver is better solution because it is nil functionality if the TPM driver is loaded. We need functions to: 1. Request a region from the NVS driver (when tpm_crb loads) 2. Release a region back to the NVS Driver (when tpm_crb unloads). My proposal would unnecessarily duplicate code and also leave a side-effect when TPM is not used in the first place. I see this as the overally best solution. If you can come up with a patch for the NVS side and changes to CRB drivers to utilize the new hooks, then combined with Vanya's changes we have a sustainable solution for AMD fTPM. /Jarkko