From patchwork Thu Jun 22 21:32:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Azhar Shaikh X-Patchwork-Id: 9805339 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 7E7E5600C5 for ; Thu, 22 Jun 2017 21:32:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6761528555 for ; Thu, 22 Jun 2017 21:32:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C0812858F; Thu, 22 Jun 2017 21:32:29 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A9D7C28555 for ; Thu, 22 Jun 2017 21:32:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dO9iE-00023r-5B; Thu, 22 Jun 2017 21:32:26 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1dO9iD-00023l-0c for tpmdd-devel@lists.sourceforge.net; Thu, 22 Jun 2017 21:32:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=2ES9IQJgQx+xpxNc9FKn8/VdkAhuv3tXaZnktwayTsc=; b=ZM/FwugmpmTEGubbfsVrPLRsrwJOjF19ecdgxOMcJ69pxxJx5romQP9pUm1lOj4uvcArO9kdNeZ5fYiUVuUC00V0nvaAV70frX+1Ew0Sy5LAitGKQcTaFjmLm+5WWWEs8ZPg4FReYqUhUfo2GOoEr2Je8cEl15EirzYpWOJJcBI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=2ES9IQJgQx+xpxNc9FKn8/VdkAhuv3tXaZnktwayTsc=; b=WGPoxritSixZS2FhxWRJT51LeiSP1bZ6E9pT5ZH6eNCAzEy8RiHAWwRm/b3Gk+Wch39PTWMkypauS86aWwvupE9pEmYfbMLlhi0YGZ1ZCiU11US0CHdLe0iXNM8NPOgWnbK6yKrWhV+zmUpExh6KujRrgYQpYA//4AeUsTyIZgs=; Received-SPF: pass (sog-mx-4.v43.ch3.sourceforge.com: domain of intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; envelope-from=azhar.shaikh@intel.com; helo=mga04.intel.com; Received: from mga04.intel.com ([192.55.52.120]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1dO9i8-0001Y0-To for tpmdd-devel@lists.sourceforge.net; Thu, 22 Jun 2017 21:32:24 +0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2017 14:32:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,374,1493708400"; d="scan'208";a="102615135" Received: from otc-chromeosbuild-0.jf.intel.com ([10.54.30.57]) by orsmga002.jf.intel.com with ESMTP; 22 Jun 2017 14:32:01 -0700 From: Azhar Shaikh To: jarkko.sakkinen@linux.intel.com, tpmdd-devel@lists.sourceforge.net Date: Thu, 22 Jun 2017 14:32:01 -0700 Message-Id: <1498167121-77638-1-git-send-email-azhar.shaikh@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498156197-180919-1-git-send-email-azhar.shaikh@intel.com> References: <1498156197-180919-1-git-send-email-azhar.shaikh@intel.com> X-Headers-End: 1dO9i8-0001Y0-To Subject: [tpmdd-devel] [PATCH v2] tpm: Fix the ioremap() call for Braswell systems X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, azhar.shaikh@intel.com MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP ioremap() for Intel Braswell processors was done in tpm_tis_pnp_init(). But before this function gets called, platform driver 'tis_drv' gets registered and its probe function tpm_tis_plat_probe() is invoked, which does a TPM access. Now for Braswell processors tpm_platform_begin_xfer() will do an ioread32() without having a mapped address, which will lead to a bad I/O access warning. Hence move the ioremap() call from tpm_tis_pnp_init() to init_tis() before registering the 'tis_drv' or basically before any TPM access. Accordingly also move the iounmap() call from tpm_tis_pnp_remove() to cleanup_tis() after all TPM access are completed. Signed-off-by: Azhar Shaikh Reviewed-by: Jarkko Sakkinen --- Changes from v1: - Do error handling in init_ts(). - Update the commit message. drivers/char/tpm/tpm_tis.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 506e62ca3576..d97ce22267fb 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -330,12 +330,6 @@ static int tpm_tis_pnp_init(struct pnp_dev *pnp_dev, else tpm_info.irq = -1; -#ifdef CONFIG_X86 - if (is_bsw()) - ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR, - ILB_REMAP_SIZE); -#endif - return tpm_tis_init(&pnp_dev->dev, &tpm_info); } @@ -359,12 +353,6 @@ static void tpm_tis_pnp_remove(struct pnp_dev *dev) tpm_chip_unregister(chip); tpm_tis_remove(chip); - -#ifdef CONFIG_X86 - if (is_bsw()) - iounmap(ilb_base_addr); -#endif - } static struct pnp_driver tis_pnp_driver = { @@ -472,6 +460,11 @@ static int __init init_tis(void) if (rc) goto err_force; +#ifdef CONFIG_X86 + if (is_bsw()) + ilb_base_addr = ioremap(INTEL_LEGACY_BLK_BASE_ADDR, + ILB_REMAP_SIZE); +#endif rc = platform_driver_register(&tis_drv); if (rc) goto err_platform; @@ -490,6 +483,10 @@ static int __init init_tis(void) err_platform: if (force_pdev) platform_device_unregister(force_pdev); +#ifdef CONFIG_X86 + if (is_bsw()) + iounmap(ilb_base_addr); +#endif err_force: return rc; } @@ -499,6 +496,10 @@ static void __exit cleanup_tis(void) pnp_unregister_driver(&tis_pnp_driver); platform_driver_unregister(&tis_drv); +#ifdef CONFIG_X86 + if (is_bsw()) + iounmap(ilb_base_addr); +#endif if (force_pdev) platform_device_unregister(force_pdev); }