lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20091103003736.GM7768@obsidianresearch.com>
Date:	Mon, 2 Nov 2009 17:37:36 -0700
From:	Jason Gunthorpe <jgunthorpe@...idianresearch.com>
To:	tpmdd-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org,
	srajiv@...ux.vnet.ibm.com
Subject: [RESEND PATCH] TPM: Make tpm_tis always create a platform driver

Any chance of getting some interest in this? :)

Thanks,
Jason

On Tue, Sep 15, 2009 at 11:18:16AM -0600, Jason Gunthorpe wrote:
> This lets systems that don't use PNP to create a platform device and have the
> tpm_tis driver bind to it. For embedded users.
> 
> Rework the force option to just create a platform device with the proper
> resource information and use the usual binding mechanism to set it up.
> 
> Slightly rework the way interrupt auto detection happens to provide a -1 'do
> not ever autodetect' input and use it to force off autodetection if PNP or
> platform devices have no IRQ line.
> 
> Signed-off-by: Jason Gunthorpe <jgunthorpe@...idianresearch.com>
>  drivers/char/tpm/tpm_tis.c |   73 +++++++++++++++++++++++++++++---------------
>  1 files changed, 48 insertions(+), 25 deletions(-)
> 
> Unfortunately I can only test the platform device path here, I don't
> have a PC system that uses this driver to test the force option.
> 
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> index 626dd4c..80db599 100644
> +++ b/drivers/char/tpm/tpm_tis.c
> @@ -435,7 +435,7 @@ module_param(interrupts, bool, 0444);
>  MODULE_PARM_DESC(interrupts, "Enable interrupts");
>  
>  static int tpm_tis_init(struct device *dev, u32 start,
> -			u32 len, unsigned int irq)
> +			u32 len, int irq)
>  {
>  	u32 vendor, intfcaps, intmask;
>  	int rc, i;
> @@ -507,9 +507,11 @@ static int tpm_tis_init(struct device *dev, u32 start,
>  	iowrite32(intmask,
>  		  chip->vendor.iobase +
>  		  TPM_INT_ENABLE(chip->vendor.locality));
> -	if (interrupts)
> +	if (!interrupts)
> +		irq = -1;
> +	if (irq != -1)
>  		chip->vendor.irq = irq;
> -	if (interrupts && !chip->vendor.irq) {
> +	if (irq == 0) {
>  		chip->vendor.irq =
>  		    ioread8(chip->vendor.iobase +
>  			    TPM_INT_VECTOR(chip->vendor.locality));
> @@ -594,15 +596,13 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
>  				      const struct pnp_device_id *pnp_id)
>  {
>  	u32 start, len;
> -	unsigned int irq = 0;
> +	int irq = -1;
>  
>  	start = pnp_mem_start(pnp_dev, 0);
>  	len = pnp_mem_len(pnp_dev, 0);
>  
>  	if (pnp_irq_valid(pnp_dev, 0))
>  		irq = pnp_irq(pnp_dev, 0);
> -	else
> -		interrupts = 0;
>  
>  	return tpm_tis_init(&pnp_dev->dev, start, len, irq);
>  }
> @@ -654,6 +654,30 @@ module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id,
>  		    sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444);
>  MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe");
>  
> +static int force;
> +module_param(force, bool, 0444);
> +MODULE_PARM_DESC(force, "Force device probe rather than using ACPI entry");
> +static struct platform_device *forced_pdev;
> +static int __devinit tpm_tis_probe(struct platform_device *pdev)
> +{
> +	struct resource *mem;
> +	struct resource *irqr;
> +	int irq = -1;
> +
> +	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!mem)
> +		return -EINVAL;
> +
> +	irqr = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +	if (irqr)
> +		irq = irqr->start;
> +	else if (pdev == forced_pdev)
> +		irq = 0;    /* Auto-detect interrupts. */
> +
> +	return tpm_tis_init(&pdev->dev, mem->start, (mem->end - mem->start+1),
> +			    irq);
> +}
> +
>  static int tpm_tis_suspend(struct platform_device *dev, pm_message_t msg)
>  {
>  	return tpm_pm_suspend(&dev->dev, msg);
> @@ -668,30 +692,29 @@ static struct platform_driver tis_drv = {
>  		.name = "tpm_tis",
>  		.owner		= THIS_MODULE,
>  	},
> +	.probe = tpm_tis_probe,
>  	.suspend = tpm_tis_suspend,
>  	.resume = tpm_tis_resume,
>  };
>  
> -static struct platform_device *pdev;
> -
> -static int force;
> -module_param(force, bool, 0444);
> -MODULE_PARM_DESC(force, "Force device probe rather than using ACPI entry");
>  static int __init init_tis(void)
>  {
>  	int rc;
>  
> -	if (force) {
> -		rc = platform_driver_register(&tis_drv);
> -		if (rc < 0)
> -			return rc;
> -		if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0)))
> -			return PTR_ERR(pdev);
> -		if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) {
> -			platform_device_unregister(pdev);
> -			platform_driver_unregister(&tis_drv);
> -		}
> +	rc = platform_driver_register(&tis_drv);
> +	if (rc < 0)
>  		return rc;
> +
> +	if (force) {
> +		struct resource res[1] = {
> +			{.start = TIS_MEM_BASE,
> +			 .end = TIS_MEM_BASE + TIS_MEM_LEN - 1,
> +			 .flags = IORESOURCE_MEM} };
> +		forced_pdev = platform_device_register_simple("tpm_tis", -1,
> +							      res, 1);
> +		if (IS_ERR(forced_pdev))
> +			return PTR_ERR(forced_pdev);
> +		return 0;
>  	}
>  
>  	return pnp_register_driver(&tis_pnp_driver);
> @@ -719,10 +742,10 @@ static void __exit cleanup_tis(void)
>  	}
>  	spin_unlock(&tis_lock);
>  
> -	if (force) {
> -		platform_device_unregister(pdev);
> -		platform_driver_unregister(&tis_drv);
> -	} else
> +	if (forced_pdev)
> +		platform_device_unregister(forced_pdev);
> +	platform_driver_unregister(&tis_drv);
> +	if (!force)
>  		pnp_unregister_driver(&tis_pnp_driver);
>  }
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ