Message ID | 1473635035-14443-3-git-send-email-tomas.winkler@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Sep 12, 2016 at 02:03:53AM +0300, Tomas Winkler wrote: > Instead of expensive register access on retrieving cmd_size > on each send, save the value during initialization in the private > context. The value doesn't change. > > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> $ git am -3 ~/Downloads/2-4-v2-tpm-tpm_crb-cache-cmd_size-register-value..patch Applying: tpm/tpm_crb: cache cmd_size register value. fatal: sha1 information is lacking or useless (drivers/char/tpm/tpm_crb.c). error: could not build fake ancestor Patch failed at 0001 tpm/tpm_crb: cache cmd_size register value. The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". VCS_INFO_get_data_git:225: no such file or directory: .git/rebase-apply/msg-clean /Jarkko > > --- > V2: rebased > > drivers/char/tpm/tpm_crb.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > index 6a4b32599869..f066810bfc03 100644 > --- a/drivers/char/tpm/tpm_crb.c > +++ b/drivers/char/tpm/tpm_crb.c > @@ -80,6 +80,7 @@ struct crb_priv { > struct crb_control_area __iomem *cca; > u8 __iomem *cmd; > u8 __iomem *rsp; > + u32 cmd_size; > }; > > static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume); > @@ -141,11 +142,9 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len) > struct crb_priv *priv = dev_get_drvdata(&chip->dev); > int rc = 0; > > - if (len > ioread32(&priv->cca->cmd_size)) { > - dev_err(&chip->dev, > - "invalid command count value %x %zx\n", > - (unsigned int) len, > - (size_t) ioread32(&priv->cca->cmd_size)); > + if (len > priv->cmd_size) { > + dev_err(&chip->dev, "invalid command count value %zd %d\n", > + len, priv->cmd_size); > return -E2BIG; > } > > @@ -301,6 +300,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, > dev_err(dev, FW_BUG "overlapping command and response buffer sizes are not identical"); > return -EINVAL; > } > + priv->cmd_size = cmd_size; > > priv->rsp = priv->cmd; > return 0; > -- > 2.7.4 > ------------------------------------------------------------------------------
On Mon, Sep 12, 2016 at 01:49:16PM +0300, Jarkko Sakkinen wrote: > On Mon, Sep 12, 2016 at 02:03:53AM +0300, Tomas Winkler wrote: > > Instead of expensive register access on retrieving cmd_size > > on each send, save the value during initialization in the private > > context. The value doesn't change. > > > > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> > > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > > Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > > $ git am -3 ~/Downloads/2-4-v2-tpm-tpm_crb-cache-cmd_size-register-value..patch > Applying: tpm/tpm_crb: cache cmd_size register value. > fatal: sha1 information is lacking or useless (drivers/char/tpm/tpm_crb.c). > error: could not build fake ancestor > Patch failed at 0001 tpm/tpm_crb: cache cmd_size register value. > The copy of the patch that failed is found in: .git/rebase-apply/patch > When you have resolved this problem, run "git am --continue". > If you prefer to skip this patch, run "git am --skip" instead. > To restore the original branch and stop patching, run "git am --abort". > VCS_INFO_get_data_git:225: no such file or directory: .git/rebase-apply/msg-clean I did this: patch -p1 < ~/Downloads/2-4-v2-tpm-tpm_crb-cache-cmd_size-register-value..patch git commit -a -s --author="Tomas Winkler <tomas.winkler@intel.com>" It's now pushed. Could you check that it looks OK for you so that I can include this to the next pull request? /Jarkko ------------------------------------------------------------------------------
> > On Mon, Sep 12, 2016 at 01:49:16PM +0300, Jarkko Sakkinen wrote: > > On Mon, Sep 12, 2016 at 02:03:53AM +0300, Tomas Winkler wrote: > > > Instead of expensive register access on retrieving cmd_size on each > > > send, save the value during initialization in the private context. > > > The value doesn't change. > > > > > > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> > > > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > > > Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> > > > > $ git am -3 > > ~/Downloads/2-4-v2-tpm-tpm_crb-cache-cmd_size-register-value..patch > > Applying: tpm/tpm_crb: cache cmd_size register value. > > fatal: sha1 information is lacking or useless (drivers/char/tpm/tpm_crb.c). > > error: could not build fake ancestor > > Patch failed at 0001 tpm/tpm_crb: cache cmd_size register value. > > The copy of the patch that failed is found in: .git/rebase-apply/patch > > When you have resolved this problem, run "git am --continue". > > If you prefer to skip this patch, run "git am --skip" instead. > > To restore the original branch and stop patching, run "git am --abort". > > VCS_INFO_get_data_git:225: no such file or directory: .git/rebase- > apply/msg-clean > > I did this: > > patch -p1 < ~/Downloads/2-4-v2-tpm-tpm_crb-cache-cmd_size-register- > value..patch > git commit -a -s --author="Tomas Winkler <tomas.winkler@intel.com>" > > It's now pushed. Could you check that it looks OK for you so that I can include > this to the next pull request? Looks great. Thanks Tomas ------------------------------------------------------------------------------
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 6a4b32599869..f066810bfc03 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -80,6 +80,7 @@ struct crb_priv { struct crb_control_area __iomem *cca; u8 __iomem *cmd; u8 __iomem *rsp; + u32 cmd_size; }; static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume); @@ -141,11 +142,9 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len) struct crb_priv *priv = dev_get_drvdata(&chip->dev); int rc = 0; - if (len > ioread32(&priv->cca->cmd_size)) { - dev_err(&chip->dev, - "invalid command count value %x %zx\n", - (unsigned int) len, - (size_t) ioread32(&priv->cca->cmd_size)); + if (len > priv->cmd_size) { + dev_err(&chip->dev, "invalid command count value %zd %d\n", + len, priv->cmd_size); return -E2BIG; } @@ -301,6 +300,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, dev_err(dev, FW_BUG "overlapping command and response buffer sizes are not identical"); return -EINVAL; } + priv->cmd_size = cmd_size; priv->rsp = priv->cmd; return 0;