Commit aa77ea0e authored by Tomas Winkler's avatar Tomas Winkler Committed by Jarkko Sakkinen

tpm/tpm_crb: cache cmd_size register value.

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: default avatarTomas Winkler <tomas.winkler@intel.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent 71801310
...@@ -80,6 +80,7 @@ struct crb_priv { ...@@ -80,6 +80,7 @@ struct crb_priv {
struct crb_control_area __iomem *cca; struct crb_control_area __iomem *cca;
u8 __iomem *cmd; u8 __iomem *cmd;
u8 __iomem *rsp; u8 __iomem *rsp;
u32 cmd_size;
}; };
static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume); static SIMPLE_DEV_PM_OPS(crb_pm, tpm_pm_suspend, tpm_pm_resume);
...@@ -146,11 +147,9 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -146,11 +147,9 @@ static int crb_send(struct tpm_chip *chip, u8 *buf, size_t len)
*/ */
iowrite32(0, &priv->cca->cancel); iowrite32(0, &priv->cca->cancel);
if (len > ioread32(&priv->cca->cmd_size)) { if (len > priv->cmd_size) {
dev_err(&chip->dev, dev_err(&chip->dev, "invalid command count value %zd %d\n",
"invalid command count value %x %zx\n", len, priv->cmd_size);
(unsigned int) len,
(size_t) ioread32(&priv->cca->cmd_size));
return -E2BIG; return -E2BIG;
} }
...@@ -301,6 +300,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, ...@@ -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"); dev_err(dev, FW_BUG "overlapping command and response buffer sizes are not identical");
return -EINVAL; return -EINVAL;
} }
priv->cmd_size = cmd_size;
priv->rsp = priv->cmd; priv->rsp = priv->cmd;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment