All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomas Winkler <tomas.winkler@intel.com>
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Ulf Hansson" <ulf.hansson@linaro.org>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"James Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	"Vinayak Holikatti" <vinholikatti@gmail.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Michael Ryleev" <gmar@google.com>,
	"Joao Pinto" <Joao.Pinto@synopsys.com>,
	"Christoph Hellwig" <hch@lst.de>,
	"Yaniv Gardi" <ygardi@codeaurora.org>
Cc: Avri Altman <avri.altman@gmail.com>,
	linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org,
	linux-scsi@vger.kernel.org,
	Tomas Winkler <tomas.winkler@intel.com>
Subject: [PATCH v6 2/9] rpmb: enable emmc specific read data fixup
Date: Tue, 13 Sep 2016 16:22:57 +0300	[thread overview]
Message-ID: <1473772984-17562-3-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1473772984-17562-1-git-send-email-tomas.winkler@intel.com>

For eMMC the block count of the RPMB read operation is not indicated in
the original RPMB Data Read Request packet.
This might be different then the implementation of other protocol
standards.
This patch implements a fixup for this behavior.


Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
V6: new in the series

 drivers/char/rpmb/core.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/char/rpmb/core.c b/drivers/char/rpmb/core.c
index ff10cbb7b644..8cfbbb721538 100644
--- a/drivers/char/rpmb/core.c
+++ b/drivers/char/rpmb/core.c
@@ -117,6 +117,35 @@ static int rpmb_request_verify(struct rpmb_dev *rdev, struct rpmb_data *rpmbd)
 }
 
 /**
+ * rpmb_cmd_fixup - fixup rpmb command
+ *
+ * @rdev: rpmb device
+ * @cmds: rpmb command list
+ * @ncmds: number of commands
+ *
+ */
+static void rpmb_cmd_fixup(struct rpmb_dev *rdev,
+			   struct rpmb_cmd *cmds, u32 ncmds)
+{
+	int i;
+
+	if (rdev->ops->type != RPMB_TYPE_EMMC)
+		return;
+
+	/* Fixup RPMB_READ_DATA specific to eMMC
+	 * The block count of the RPMB read operation is not indicated
+	 * in the original RPMB Data Read Request packet.
+	 * This is different then implementation for other protocol
+	 * standards.
+	 */
+	for (i = 0; i < ncmds; i++)
+		if (cmds->frames->req_resp == cpu_to_be16(RPMB_READ_DATA)) {
+			dev_dbg(&rdev->dev, "Fixing up READ_DATA frame to block_count=0\n");
+			cmds->frames->block_count = 0;
+		}
+}
+
+/**
  * rpmb_cmd_seq - send RPMB command sequence
  *
  * @rdev: rpmb device
@@ -136,10 +165,11 @@ int rpmb_cmd_seq(struct rpmb_dev *rdev, struct rpmb_cmd *cmds, u32 ncmds)
 		return -EINVAL;
 
 	mutex_lock(&rdev->lock);
-	if (rdev->ops && rdev->ops->cmd_seq)
+	err = -EOPNOTSUPP;
+	if (rdev->ops && rdev->ops->cmd_seq) {
+		rpmb_cmd_fixup(rdev, cmds, ncmds);
 		err = rdev->ops->cmd_seq(rdev->dev.parent, cmds, ncmds);
-	else
-		err = -EOPNOTSUPP;
+	}
 	mutex_unlock(&rdev->lock);
 	return err;
 }
-- 
2.7.4

  parent reply	other threads:[~2016-09-13 13:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13 13:22 [PATCH v6 0/9] Replay Protected Memory Block (RPMB) subsystem Tomas Winkler
2016-09-13 13:22 ` [PATCH v6 1/9] rpmb: add " Tomas Winkler
     [not found]   ` <CAG8K7gRqn_Feu_22WESrS8T_xm-GZ9d0jXGSQi=ssvQepVPtwQ@mail.gmail.com>
2016-09-23  9:38     ` Avri Altman
2016-09-24 20:30       ` Winkler, Tomas
2016-09-13 13:22 ` Tomas Winkler [this message]
2016-09-13 13:22 ` [PATCH v6 3/9] rpmb: add sysfs-class ABI documentation Tomas Winkler
2016-09-13 13:22 ` [PATCH v6 4/9] char: rpmb: add device attributes Tomas Winkler
2016-09-13 13:23 ` [PATCH v6 5/9] char: rpmb: provide a user space interface Tomas Winkler
2016-09-13 13:23 ` [PATCH v6 6/9] char: rpmb: add RPMB simulation device Tomas Winkler
2016-09-13 13:23 ` [PATCH v6 7/9] tools rpmb: add RPBM access tool Tomas Winkler
2016-09-13 13:23 ` [PATCH v6 8/9] mmc: block: register RPMB partition with the RPMB subsystem Tomas Winkler
2016-09-13 13:23 ` [PATCH v6 9/9] scsi: ufs: connect to " Tomas Winkler
2016-09-19 12:17 ` [PATCH v6 0/9] Replay Protected Memory Block (RPMB) subsystem Winkler, Tomas
2016-09-20 11:11   ` Greg Kroah-Hartman
2016-09-20 11:58     ` Winkler, Tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473772984-17562-3-git-send-email-tomas.winkler@intel.com \
    --to=tomas.winkler@intel.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=Joao.Pinto@synopsys.com \
    --cc=adrian.hunter@intel.com \
    --cc=arve@android.com \
    --cc=avri.altman@gmail.com \
    --cc=gmar@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vinholikatti@gmail.com \
    --cc=ygardi@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.