Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753270AbdFVUux convert rfc822-to-8bit (ORCPT ); Thu, 22 Jun 2017 16:50:53 -0400 Received: from mga09.intel.com ([134.134.136.24]:2104 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751202AbdFVUuv (ORCPT ); Thu, 22 Jun 2017 16:50:51 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,374,1493708400"; d="scan'208";a="100597320" From: "Shaikh, Azhar" To: Jason Gunthorpe CC: "jarkko.sakkinen@linux.intel.com" , "tpmdd-devel@lists.sourceforge.net" , "linux-security-module@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell systems Thread-Topic: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell systems Thread-Index: AQHS64WQkROWrf8+Ikae2Vao1eB4gqIxyEGA//+MXAA= Date: Thu, 22 Jun 2017 20:50:49 +0000 Message-ID: <5FFFAD06ADE1CA4381B3F0F7C6AF5828916F50@ORSMSX109.amr.corp.intel.com> References: <1498156197-180919-1-git-send-email-azhar.shaikh@intel.com> <20170622202023.GA3579@obsidianresearch.com> In-Reply-To: <20170622202023.GA3579@obsidianresearch.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzEwMjkwOTQtYWUyYy00NzdkLWFlOTMtZDk5MjQwOTc2NTVlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IlBwVTZFRFdxeDluanVYN1F1d2loNmxKa2Zob0s4cmsrZlNYWHZWdVdjWmM9In0= dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.22.254.140] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2552 Lines: 78 > -----Original Message----- > From: Jason Gunthorpe [mailto:jgunthorpe@obsidianresearch.com] > Sent: Thursday, June 22, 2017 1:20 PM > To: Shaikh, Azhar > Cc: jarkko.sakkinen@linux.intel.com; tpmdd-devel@lists.sourceforge.net; > linux-security-module@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [tpmdd-devel] [PATCH] tpm: Fix the ioremap() call for Braswell > systems > > On Thu, Jun 22, 2017 at 11:29:57AM -0700, Azhar Shaikh wrote: > > 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(). > > > > Signed-off-by: Azhar Shaikh > > drivers/char/tpm/tpm_tis.c | 21 +++++++++------------ > > 1 file changed, 9 insertions(+), 12 deletions(-) > > > > diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c > > index 506e62ca3576..3224db80816a 100644 > > +++ 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 > > The iounmap needs to be in the goto unwind for init_tis as well, surely? > Yes! Should have checked before... > > rc = platform_driver_register(&tis_drv); > > if (rc) > > goto err_platform; > > Jason