From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Stefan Berger" Subject: Re: [PATCH v9 2/4] tpm: Proxy driver for supporting multiple emulated TPMs Date: Tue, 12 Apr 2016 11:18:20 -0400 Message-ID: <201604121518.u3CFIUTu007360@d03av02.boulder.ibm.com> References: <1459275554-12915-3-git-send-email-stefanb@linux.vnet.ibm.com> <20160407123539.GA17489@intel.com> <57068198.6050407@linux.vnet.ibm.com> <20160411084358.GB11322@intel.com> <20160411181403.GB371@obsidianresearch.com> <201604111933.u3BJXErj001305@d03av03.boulder.ibm.com> <20160411202811.GA3663@obsidianresearch.com> <201604112030.u3BKUeJQ017181@d01av04.pok.ibm.com> <20160411205718.GC3663@obsidianresearch.com> <201604112213.u3BMD3i5028908@d03av02.boulder.ibm.com> <20160412000500.GC5861@obsidianresearch.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4137908708454029394==" Return-path: In-Reply-To: <20160412000500.GC5861-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: tpmdd-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org To: Jason Gunthorpe Cc: tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Christophe Ricard List-Id: tpmdd-devel@lists.sourceforge.net --===============4137908708454029394== Content-Type: multipart/alternative; boundary="=_alternative 00541B1E85257F93_=" --=_alternative 00541B1E85257F93_= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="US-ASCII" Jason Gunthorpe wrote on 04/11/2016=20 08:05:00 PM: >=20 > On Mon, Apr 11, 2016 at 06:12:57PM -0400, Stefan Berger wrote: > > Jason Gunthorpe wrote on=20 04/11/2016 > > 04:57:18 PM: > > > > > > On Mon, Apr 11, 2016 at 04:30:34PM -0400, Stefan Berger wrote: > > > > > > > > Doesn't matter, just dev=5Fset=5Fdrvdata right after the ch= ip=20 is > > > > > allocated, just like vtpm does already for chip->priv. > > > > We don't have a dev at this point. > > > > > > Eh? If you have a chip you have a dev. >=20 > > Ok. I would nevertheless like to reduce the churn in the series=20 where I > > would post next a v10. > > I am using chip->dev.platform=5Fdata =3D proxy=5Fdev to store the=20 proxy=5Fdev. > > Here's the current v10: > > https://github.com/stefanberger/linux/commits/vtpm-driver.v10 >=20 > The *correct* thing for vtpm=5Fproxy.c is to replace this: >=20 > + dev=5Fset=5Fdrvdata(&chip->dev, chip); > + chip->dev.platform=5Fdata =3D proxy=5Fdev; >=20 > With: >=20 > + dev=5Fset=5Fdrvdata(&chip->dev, proxy=5Fdev); >=20 > [and replace all the dev=5Fget=5Fplatdata with dev=5Fget=5Fdrvdata] >=20 > The use of platdata is an ugly hack. >=20 > The entire point of the patch I sent earlier was to allow the original > TPM=5FCHIP=5FFLAG=5FVIRTUAL patch (later versions which moved the > dev=5Fset=5Fdrvdata out of tpm=5Fsys.c and into vtpm=5Fproxy.c are > nonsensical) to entirely drop the dev=5Fset=5Fdrvdata, clearing the way > for vtpm=5Fproxy.c to use the correct approach above. >=20 > Here is an update of the idea patch I sent earlier, I realized the > ordering was wrong. This probably almost works actually. If you and > Christophe can finish it up the issue can be settled quickly. >=20 > Stick it before the TPM=5FCHIP=5FFLAG=5FVIRTUAL patch and throw away most= of > that patch. Just add two flag checks into tpm=5Fadd/del=5Flegacy=5Fsysfs() Here's the v10 series now. If you want a better text for that patch,=20 please let me know. I had to extend it to tpm-interface.c https://github.com/stefanberger/linux/commits/vtpm-driver.v10 The patches pass my test suite and tpm tis seems to also work fine. https://github.com/stefanberger/linux-vtpm-tests A question below. >=20 > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > index 2642cca05cac..657a010c6c02 100644 > --- a/drivers/char/tpm/tpm-chip.c > +++ b/drivers/char/tpm/tpm-chip.c > @@ -275,14 +275,10 @@ static void tpm=5Fdel=5Fchar=5Fdevice(struct tpm=5F= chip=20 *chip) >=20 > static int tpm1=5Fchip=5Fregister(struct tpm=5Fchip *chip) > { > - int rc; > - > if (chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2) > return 0; >=20 > - rc =3D tpm=5Fsysfs=5Fadd=5Fdevice(chip); > - if (rc) > - return rc; > + tpm=5Fsysfs=5Fadd=5Fdevice(chip); >=20 > chip->bios=5Fdir =3D tpm=5Fbios=5Flog=5Fsetup(dev=5Fname(&chip->dev)); >=20 > @@ -296,8 +292,50 @@ static void tpm1=5Fchip=5Funregister(struct tpm=5Fch= ip=20 *chip) >=20 > if (chip->bios=5Fdir) > tpm=5Fbios=5Flog=5Fteardown(chip->bios=5Fdir); > +} > + > +static void tpm=5Fdel=5Flegacy=5Fsysfs(struct tpm=5Fchip *chip) > +{ > + struct attribute **i; > + > + if (chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2) > + return; > + > + sysfs=5Fremove=5Flink(&chip->dev.parent->kobj, "ppi"); >=20 > - tpm=5Fsysfs=5Fdel=5Fdevice(chip); > + for (i =3D chip->groups[0]->attrs; *i !=3D NULL; ++i) > + sysfs=5Fremove=5Flink(&chip->dev.parent->kobj, (*i)->name); > +} > + > +/* For compatability with legacy sysfs paths we provide symlinks from=20 the > + * parent dev directory to selected names within the tpm chip=20 directory. Old > + * kernel versions created these files directly under the parent. > + */ > +static int tpm=5Fadd=5Flegacy=5Fsysfs(struct tpm=5Fchip *chip) > +{ > + struct attribute **i; > + int rc; > + > + if (chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2) > + return 0; > + > + rc =3D =5F=5Fcompat=5Fonly=5Fsysfs=5Flink=5Fentry=5Fto=5Fkobj( > + &chip->dev.parent->kobj, &chip->dev.kobj, "ppi"); > + if (rc && rc !=3D -ENOENT) > + goto out=5Ferr; I wonder whether it is necessary to goto out=5Ferr or not just return rc=20 here? Also, for tpm0 I now find the following two pcrs entries, as well as all=20 the rest of course: /sys/devices/pnp0/00:05/tpm/tpm0/pcrs /sys/devices/pnp0/00:05/pcrs Is this intentionately? Stefan > + > + /* All the names from tpm-sysfs */ > + for (i =3D chip->groups[0]->attrs; *i !=3D NULL; ++i) { > + rc =3D =5F=5Fcompat=5Fonly=5Fsysfs=5Flink=5Fentry=5Fto=5Fkobj( > + &chip->dev.parent->kobj, &chip->dev.kobj, (*i)->name); > + if (rc) > + goto out=5Ferr; > + } > + > + return 0; > +out=5Ferr: > + tpm=5Fdel=5Flegacy=5Fsysfs(chip); > + return rc; > } >=20 > /* > @@ -322,24 +360,20 @@ int tpm=5Fchip=5Fregister(struct tpm=5Fchip *chip) > tpm=5Fadd=5Fppi(chip); >=20 > rc =3D tpm=5Fadd=5Fchar=5Fdevice(chip); > - if (rc) > - goto out=5Ferr; > + if (rc) { > + tpm1=5Fchip=5Funregister(chip); > + return rc; > + } >=20 > chip->flags |=3D TPM=5FCHIP=5FFLAG=5FREGISTERED; >=20 > - if (!(chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2)) { > - rc =3D =5F=5Fcompat=5Fonly=5Fsysfs=5Flink=5Fentry=5Fto=5Fkobj( > - &chip->dev.parent->kobj, &chip->dev.kobj, "ppi"); > - if (rc && rc !=3D -ENOENT) { > - tpm=5Fchip=5Funregister(chip); > - return rc; > - } > + rc =3D tpm=5Fadd=5Flegacy=5Fsysfs(chip); > + if (rc) { > + tpm=5Fchip=5Funregister(chip); > + return rc; > } >=20 > return 0; > -out=5Ferr: > - tpm1=5Fchip=5Funregister(chip); > - return rc; > } > EXPORT=5FSYMBOL=5FGPL(tpm=5Fchip=5Fregister); >=20 > @@ -361,12 +395,11 @@ void tpm=5Fchip=5Funregister(struct tpm=5Fchip *chi= p) > if (!(chip->flags & TPM=5FCHIP=5FFLAG=5FREGISTERED)) > return; >=20 > + tpm=5Fdel=5Flegacy=5Fsysfs(chip); > + > if (chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2) > tpm2=5Fshutdown(chip, TPM2=5FSU=5FCLEAR); >=20 > - if (!(chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2)) > - sysfs=5Fremove=5Flink(&chip->dev.parent->kobj, "ppi"); > - > tpm1=5Fchip=5Funregister(chip); > tpm=5Fdel=5Fchar=5Fdevice(chip); > } > diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c > index a7c3473c3421..5f8e419a7c73 100644 > --- a/drivers/char/tpm/tpm-sysfs.c > +++ b/drivers/char/tpm/tpm-sysfs.c > @@ -36,7 +36,7 @@ static ssize=5Ft pubek=5Fshow(struct device *dev,=20 > struct device=5Fattribute *attr, > int i, rc; > char *str =3D buf; >=20 > - struct tpm=5Fchip *chip =3D dev=5Fget=5Fdrvdata(dev); > + struct tpm=5Fchip *chip =3D to=5Ftpm=5Fchip(dev); >=20 > tpm=5Fcmd.header.in =3D tpm=5Freadpubek=5Fheader; > err =3D tpm=5Ftransmit=5Fcmd(chip, &tpm=5Fcmd, READ=5FPUBEK=5FRESULT= =5FSIZE, > @@ -92,7 +92,7 @@ static ssize=5Ft pcrs=5Fshow(struct device *dev,=20 > struct device=5Fattribute *attr, > ssize=5Ft rc; > int i, j, num=5Fpcrs; > char *str =3D buf; > - struct tpm=5Fchip *chip =3D dev=5Fget=5Fdrvdata(dev); > + struct tpm=5Fchip *chip =3D to=5Ftpm=5Fchip(dev); >=20 > rc =3D tpm=5Fgetcap(dev, TPM=5FCAP=5FPROP=5FPCR, &cap, > "attempting to determine the number of PCRS"); > @@ -222,7 +222,7 @@ static DEVICE=5FATTR=5FRO(caps); > static ssize=5Ft cancel=5Fstore(struct device *dev, struct=20 > device=5Fattribute *attr, > const char *buf, size=5Ft count) > { > - struct tpm=5Fchip *chip =3D dev=5Fget=5Fdrvdata(dev); > + struct tpm=5Fchip *chip =3D to=5Ftpm=5Fchip(dev); > if (chip =3D=3D NULL) > return 0; >=20 > @@ -234,7 +234,7 @@ static DEVICE=5FATTR=5FWO(cancel); > static ssize=5Ft durations=5Fshow(struct device *dev, struct=20 > device=5Fattribute *attr, > char *buf) > { > - struct tpm=5Fchip *chip =3D dev=5Fget=5Fdrvdata(dev); > + struct tpm=5Fchip *chip =3D to=5Ftpm=5Fchip(dev); >=20 > if (chip->duration[TPM=5FLONG] =3D=3D 0) > return 0; > @@ -251,7 +251,7 @@ static DEVICE=5FATTR=5FRO(durations); > static ssize=5Ft timeouts=5Fshow(struct device *dev, struct=20 > device=5Fattribute *attr, > char *buf) > { > - struct tpm=5Fchip *chip =3D dev=5Fget=5Fdrvdata(dev); > + struct tpm=5Fchip *chip =3D to=5Ftpm=5Fchip(dev); >=20 > return sprintf(buf, "%d %d %d %d [%s]\n", > jiffies=5Fto=5Fusecs(chip->timeout=5Fa), > @@ -281,24 +281,12 @@ static const struct attribute=5Fgroup tpm=5Fdev=5Fg= roup=20 =3D { > .attrs =3D tpm=5Fdev=5Fattrs, > }; >=20 > -int tpm=5Fsysfs=5Fadd=5Fdevice(struct tpm=5Fchip *chip) > +void tpm=5Fsysfs=5Fadd=5Fdevice(struct tpm=5Fchip *chip) > { > - int err; > - err =3D sysfs=5Fcreate=5Fgroup(&chip->dev.parent->kobj, > - &tpm=5Fdev=5Fgroup); > - > - if (err) > - dev=5Ferr(&chip->dev, > - "failed to create sysfs attributes, %d\n", err); > - return err; > -} > - > -void tpm=5Fsysfs=5Fdel=5Fdevice(struct tpm=5Fchip *chip) > -{ > - /* The sysfs routines rely on an implicit tpm=5Ftry=5Fget=5Fops, this > - * function is called before ops is null'd and the sysfs core > - * synchronizes this removal so that no callbacks are running or can > - * run again > + /* The sysfs routines rely on an implicit tpm=5Ftry=5Fget=5Fops,=20 device=5Fdel > + * is called before ops is null'd and the sysfs core synchronizes=20 this > + * removal so that no callbacks are running or can run again > */ > - sysfs=5Fremove=5Fgroup(&chip->dev.parent->kobj, &tpm=5Fdev=5Fgroup); > + WARN=5FON(chip->groups=5Fcnt !=3D 0); > + chip->groups[chip->groups=5Fcnt++] =3D &tpm=5Fdev=5Fgroup; > } > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h > index 8bc6fb85fb38..83a231dfe2ed 100644 > --- a/drivers/char/tpm/tpm.h > +++ b/drivers/char/tpm/tpm.h > @@ -168,9 +168,9 @@ struct tpm=5Fchip { >=20 > struct dentry **bios=5Fdir; >=20 > -#ifdef CONFIG=5FACPI > - const struct attribute=5Fgroup *groups[2]; > + const struct attribute=5Fgroup *groups[3]; > unsigned int groups=5Fcnt; > +#ifdef CONFIG=5FACPI > acpi=5Fhandle acpi=5Fdev=5Fhandle; > char ppi=5Fversion[TPM=5FPPI=5FVERSION=5FLEN + 1]; > #endif /* CONFIG=5FACPI */ > @@ -496,8 +496,7 @@ extern struct tpm=5Fchip *tpmm=5Fchip=5Falloc(struct = > device *pdev, > extern int tpm=5Fchip=5Fregister(struct tpm=5Fchip *chip); > extern void tpm=5Fchip=5Funregister(struct tpm=5Fchip *chip); >=20 > -int tpm=5Fsysfs=5Fadd=5Fdevice(struct tpm=5Fchip *chip); > -void tpm=5Fsysfs=5Fdel=5Fdevice(struct tpm=5Fchip *chip); > +void tpm=5Fsysfs=5Fadd=5Fdevice(struct tpm=5Fchip *chip); >=20 > int tpm=5Fpcr=5Fread=5Fdev(struct tpm=5Fchip *chip, int pcr=5Fidx, u8 *r= es=5Fbuf); >=20 >=20 --=_alternative 00541B1E85257F93_= Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="US-ASCII" Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote on 04/11/2016 08:05:00 PM:
>
> On Mon, Apr 11, 2016 at 0= 6:12:57PM -0400, Stefan Berger wrote:
> >    Jason Gunth= orpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org> wrote on 04/11/2016
> >    04:57:18 PM:
> > &nb= sp;  >
> >    > On Mon, Apr 11, 2016 at 04:30= :34PM -0400, Stefan Berger wrote:
> >    >
> >    >= >    > Doesn't matter, just dev=5Fset=5Fdrvdata right after the chip is
> >    > = >    > allocated, just like vtpm does already for chip->priv.
> >    > > &n= bsp;  We don't have a dev at this point.
> >    >
> >    > Eh? If= you have a chip you have a dev.
>
> >    Ok. I w= ould nevertheless like to reduce the churn in the series where I
> >    would post next a v10.
&= gt; >    I am using chip->dev.platform=5Fdata =3D proxy=5Fd= ev to store the proxy=5Fdev.
> >    Here's the current v10:=
> >    
https://github.com= /stefanberger/linux/commits/vtpm-driver.v10
>
> The *correct* thing for vtpm=5Fproxy.c is to replace= this:
>
> +   dev=5Fset=5Fdrvdata(&chip->dev, chi= p);
> +   chip->dev.platform=5Fdata =3D proxy=5Fdev;
> =
> With:
>
> +   dev=5Fset=5Fdrvdata(&chip->= dev, proxy=5Fdev);
>
> [and replace all the dev=5Fget=5Fplatda= ta with dev=5Fget=5Fdrvdata]
>
> The use of platdata is an ugl= y hack.
>
> The entire point of the patch I sent earlier was t= o allow the original
> TPM=5FCHIP=5FFLAG=5FVIRTUAL patch (later versi= ons which moved the
> dev=5Fset=5Fdrvdata out of tpm=5Fsys.c and into= vtpm=5Fproxy.c are
> nonsensical) to entirely drop the dev=5Fset=5Fd= rvdata, clearing the way
> for vtpm=5Fproxy.c to use the correct appr= oach above.
>
> Here is an update of the idea patch I sent ear= lier, I realized the
> ordering was wrong. This probably almost works= actually. If you and
> Christophe can finish it up the issue can be = settled quickly.
>
> Stick it before the TPM=5FCHIP=5FFLAG=5FV= IRTUAL patch and throw away most of
> that patch. Just add two flag checks into tpm=5Fadd/del=5Flegacy= =5Fsysfs()


Here's the v10 series now.= If you want a better text for that patch, please let me know.
I had= to extend it to tpm-interface.c

https://github.com/stefanberger/linux/commits/vtpm-driver.v10


The patches pass my test suite and= tpm tis seems to also work fine.

https://github.com/ste= fanberger/linux-vtpm-tests


&n= bsp;A question below.

>
> d= iff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
&g= t; index 2642cca05cac..657a010c6c02 100644
> --- a/drivers/char/tpm/t= pm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -275,14 +275= ,10 @@ static void tpm=5Fdel=5Fchar=5Fdevice(struct tpm=5Fchip *chip)
>  
>  static int tpm1=5Fchip=5Fregister(struc= t tpm=5Fchip *chip)
>  {
> -   int rc;
> -
&= gt;     if (chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2)
>= ;        return 0;
>  
> -   rc = =3D tpm=5Fsysfs=5Fadd=5Fdevice(chip);
> -   if (rc)
> - &n= bsp;    return rc;
> +   tpm=5Fsysfs=5Fadd=5Fdevice(ch= ip);
>  
>     chip->bios=5Fdir =3D tpm=5Fbio= s=5Flog=5Fsetup(dev=5Fname(&chip->dev));
>  
> @@ -= 296,8 +292,50 @@ static void tpm1=5Fchip=5Funregister(struct tpm=5Fchip *chip)
>  
>     if (chip->bios=5Fdir)
>= ;        tpm=5Fbios=5Flog=5Fteardown(chip->bios=5Fdi= r);
> +}
> +
> +static void tpm=5Fdel=5Flegacy=5Fsysfs(st= ruct tpm=5Fchip *chip)
> +{
> +   struct attribute **i;> +
> +   if (chip->flags & TPM=5FCHIP=5FFLAG=5FTPM2)=
> +      return;
> +
> +   sysfs=5Fr= emove=5Flink(&chip->dev.parent->kobj, "ppi");
> &= nbsp;
> -   tpm=5Fsysfs=5Fdel=5Fdevice(chip);
> +   f= or (i =3D chip->groups[0]->attrs; *i !=3D NULL; ++i)
> +  =    sysfs=5Fremove=5Flink(&chip->dev.parent->kobj, (*i)->name);
> +}
> +
> +/* For compatability with leg= acy sysfs paths we provide symlinks from the
> + * parent dev directory to selected names within the tpm = chip directory. Old
> + * kernel versions created these files directly under the pare= nt.
> + */
> +static int tpm=5Fadd=5Flegacy=5Fsysfs(struct tpm= =5Fchip *chip)
> +{
> +   struct attribute **i;
> + =   int rc;
> +
> +   if (chip->flags & TPM=5FCH= IP=5FFLAG=5FTPM2)
> +      return 0;
> +
>= +   rc =3D =5F=5Fcompat=5Fonly=5Fsysfs=5Flink=5Fentry=5Fto=5Fkobj(> +      &chip->dev.parent->kobj, &chip-&g= t;dev.kobj, "ppi");
> +   if (rc && rc !=3D -ENOENT)
&g= t; +      goto out=5Ferr;



I wonder whether it is necessary to goto out=5Ferr or not just return rc here?


Also, fo= r tpm0 I now find the following two pcrs entries, as well as all the rest of course:

/s= ys/devices/pnp0/00:05/tpm/tpm0/pcrs
/sys/= devices/pnp0/00:05/pcrs

Is this inten= tionately?



   Stefa= n

> +
> +   /* All the = names from tpm-sysfs */
> +   for (i =3D chip->groups[0]->= attrs; *i !=3D NULL; ++i) {
> +      rc =3D =5F=5Fcomp= at=5Fonly=5Fsysfs=5Flink=5Fentry=5Fto=5Fkobj(
> +      = ;    &chip->dev.parent->kobj, &chip->dev.kobj, (*i)->name);
> +      if (r= c)
> +         goto out=5Ferr;
> +   }=
> +
> +   return 0;
> +out=5Ferr:
> +   = tpm=5Fdel=5Flegacy=5Fsysfs(chip);
> +   return rc;
>  = ;}
>  
>  /*
> @@ -322,24 +360,20 @@ int tpm=5F= chip=5Fregister(struct tpm=5Fchip *chip)
>     tpm=5Fadd=5F= ppi(chip);
>  
>     rc =3D tpm=5Fadd=5Fchar=5Fd= evice(chip);
> -   if (rc)
> -      goto ou= t=5Ferr;
> +   if (rc) {
> +      tpm1=5Fch= ip=5Funregister(chip);
> +      return rc;
> + &= nbsp; }
>  
>     chip->flags |=3D TPM=5FCHIP= =5FFLAG=5FREGISTERED;
>  
> -   if (!(chip->flags = & TPM=5FCHIP=5FFLAG=5FTPM2)) {
> -      rc =3D =5F= =5Fcompat=5Fonly=5Fsysfs=5Flink=5Fentry=5Fto=5Fkobj(
> -    = ;      &chip->dev.parent->kobj, &chip->dev.kobj, "ppi");
> -      if = (rc && rc !=3D -ENOENT) {
> -         tpm= =5Fchip=5Funregister(chip);
> -         return rc= ;
> -      }
> +   rc =3D tpm=5Fadd=5Flegac= y=5Fsysfs(chip);
> +   if (rc) {
> +      t= pm=5Fchip=5Funregister(chip);
> +      return rc;
&= gt;     }
>  
>     return 0;
> = -out=5Ferr:
> -   tpm1=5Fchip=5Funregister(chip);
> - &nbs= p; return rc;
>  }
>  EXPORT=5FSYMBOL=5FGPL(tpm=5Fchi= p=5Fregister);
>  
> @@ -361,12 +395,11 @@ void tpm=5Fchip= =5Funregister(struct tpm=5Fchip *chip)
>     if (!(chip->= ;flags & TPM=5FCHIP=5FFLAG=5FREGISTERED))
>       =  return;
>  
> +   tpm=5Fdel=5Flegacy=5Fsysfs(ch= ip);
> +
>     if (chip->flags & TPM=5FCHIP=5F= FLAG=5FTPM2)
>        tpm2=5Fshutdown(chip, TPM2= =5FSU=5FCLEAR);
>  
> -   if (!(chip->flags & = TPM=5FCHIP=5FFLAG=5FTPM2))
> -      sysfs=5Fremove=5Fl= ink(&chip->dev.parent->kobj, "ppi");
> -
>     tpm1=5Fchip=5Funregister(= chip);
>     tpm=5Fdel=5Fchar=5Fdevice(chip);
>  = ;}
> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm= -sysfs.c
> index a7c3473c3421..5f8e419a7c73 100644
> --- a/driv= ers/char/tpm/tpm-sysfs.c
> +++ b/drivers/char/tpm/tpm-sysfs.c
>= @@ -36,7 +36,7 @@ static ssize=5Ft pubek=5Fshow(struct device *dev,
&g= t; struct device=5Fattribute *attr,
>     int i, rc;
>= ;     char *str =3D buf;
>  
> -   struct t= pm=5Fchip *chip =3D dev=5Fget=5Fdrvdata(dev);
> +   struct tpm= =5Fchip *chip =3D to=5Ftpm=5Fchip(dev);
>  
>    = ; tpm=5Fcmd.header.in =3D tpm=5Freadpubek=5Fheader;
>     e= rr =3D tpm=5Ftransmit=5Fcmd(chip, &tpm=5Fcmd, READ=5FPUBEK=5FRESULT=5FS= IZE,
> @@ -92,7 +92,7 @@ static ssize=5Ft pcrs=5Fshow(struct device *= dev,
> struct device=5Fattribute *attr,
>     ssize= =5Ft rc;
>     int i, j, num=5Fpcrs;
>     = char *str =3D buf;
> -   struct tpm=5Fchip *chip =3D dev=5Fget= =5Fdrvdata(dev);
> +   struct tpm=5Fchip *chip =3D to=5Ftpm=5Fch= ip(dev);
>  
>     rc =3D tpm=5Fgetcap(dev, TPM= =5FCAP=5FPROP=5FPCR, &cap,
>           &= quot;attempting to determine the number of PCRS");
> @@ -222,7 +222,7 @@ static DEVICE=5FATTR=5FR= O(caps);
>  static ssize=5Ft cancel=5Fstore(struct device *dev, = struct
> device=5Fattribute *attr,
>       &nbs= p;       const char *buf, size=5Ft count)
>  {
> -   struct tpm=5Fchip *chip = =3D dev=5Fget=5Fdrvdata(dev);
> +   struct tpm=5Fchip *chip =3D = to=5Ftpm=5Fchip(dev);
>     if (chip =3D=3D NULL)
> &= nbsp;      return 0;
>  
> @@ -234,7 +234,7= @@ static DEVICE=5FATTR=5FWO(cancel);
>  static ssize=5Ft durat= ions=5Fshow(struct device *dev, struct
> device=5Fattribute *attr,>                 char *buf)>  {
> -   struct tpm=5Fchip *chip =3D dev=5Fget=5Fdrv= data(dev);
> +   struct tpm=5Fchip *chip =3D to=5Ftpm=5Fchip(dev= );
>  
>     if (chip->duration[TPM=5FLONG] = =3D=3D 0)
>        return 0;
> @@ -251,7 +2= 51,7 @@ static DEVICE=5FATTR=5FRO(durations);
>  static ssize=5F= t timeouts=5Fshow(struct device *dev, struct
> device=5Fattribute *a= ttr,
>                char *b= uf)
>  {
> -   struct tpm=5Fchip *chip =3D dev=5Fget= =5Fdrvdata(dev);
> +   struct tpm=5Fchip *chip =3D to=5Ftpm=5Fch= ip(dev);
>  
>     return sprintf(buf, "%d = %d %d %d [%s]\n",
>             &n= bsp; jiffies=5Fto=5Fusecs(chip->timeout=5Fa),
> @@ -281,24 +281,12= @@ static const struct attribute=5Fgroup tpm=5Fdev=5Fgroup =3D {
>     .attrs =3D tpm=5Fdev=5Fattrs,
>  };<= br>>  
> -int tpm=5Fsysfs=5Fadd=5Fdevice(struct tpm=5Fchip *c= hip)
> +void tpm=5Fsysfs=5Fadd=5Fdevice(struct tpm=5Fchip *chip)
&= gt;  {
> -   int err;
> -   err =3D sysfs=5Fcrea= te=5Fgroup(&chip->dev.parent->kobj,
> -      = ;       &tpm=5Fdev=5Fgroup);
> -
> -   = if (err)
> -      dev=5Ferr(&chip->dev,
>= -         "failed to create sysfs attributes, %d\n", err);
> -   return err;
> -}
> -
>= -void tpm=5Fsysfs=5Fdel=5Fdevice(struct tpm=5Fchip *chip)
> -{
&g= t; -   /* The sysfs routines rely on an implicit tpm=5Ftry=5Fget=5Fops, this
> -    * function is called before ops is null'd and t= he sysfs core
> -    * synchronizes this removal so that no callback= s are running or can
> -    * run again
> +   /* The s= ysfs routines rely on an implicit tpm=5Ftry=5Fget=5Fops, device=5Fdel
> +    * is called before ops is null'd and th= e sysfs core synchronizes this
> +    * removal so that no callbacks are= running or can run again
>      */
> -   sysfs=5Fremove=5Fgrou= p(&chip->dev.parent->kobj, &tpm=5Fdev=5Fgroup);
> + &nb= sp; WARN=5FON(chip->groups=5Fcnt !=3D 0);
> +   chip->grou= ps[chip->groups=5Fcnt++] =3D &tpm=5Fdev=5Fgroup;
>  }
= > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
> i= ndex 8bc6fb85fb38..83a231dfe2ed 100644
> --- a/drivers/char/tpm/tpm.h=
> +++ b/drivers/char/tpm/tpm.h
> @@ -168,9 +168,9 @@ struct tp= m=5Fchip {
>  
>     struct dentry **bios=5Fdir;=
>  
> -#ifdef CONFIG=5FACPI
> -   const struct= attribute=5Fgroup *groups[2];
> +   const struct attribute=5Fgr= oup *groups[3];
>     unsigned int groups=5Fcnt;
> +#= ifdef CONFIG=5FACPI
>     acpi=5Fhandle acpi=5Fdev=5Fhandle= ;
>     char ppi=5Fversion[TPM=5FPPI=5FVERSION=5FLEN + 1];<= br>>  #endif /* CONFIG=5FACPI */
> @@ -496,8 +496,7 @@ extern= struct tpm=5Fchip *tpmm=5Fchip=5Falloc(struct
> device *pdev,
>  extern int tpm=5Fchip=5Fregister(struc= t tpm=5Fchip *chip);
>  extern void tpm=5Fchip=5Funregister(stru= ct tpm=5Fchip *chip);
>  
> -int tpm=5Fsysfs=5Fadd=5Fdevic= e(struct tpm=5Fchip *chip);
> -void tpm=5Fsysfs=5Fdel=5Fdevice(struct= tpm=5Fchip *chip);
> +void tpm=5Fsysfs=5Fadd=5Fdevice(struct tpm=5Fc= hip *chip);
>  
>  int tpm=5Fpcr=5Fread=5Fdev(struct = tpm=5Fchip *chip, int pcr=5Fidx, u8 *res=5Fbuf);
>  
>

--=_alternative 00541B1E85257F93_=-- --===============4137908708454029394== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z --===============4137908708454029394== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ tpmdd-devel mailing list tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/tpmdd-devel --===============4137908708454029394==--