All of lore.kernel.org
 help / color / mirror / Atom feed
From: shashidhar hiremath <shashidar1887@gmail.com>
To: Loic Pallardy <loic.pallardy-ext@stericsson.com>
Cc: linux-mmc@vger.kernel.org, Chris Ball <cjb@laptop.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	STEricsson_nomadik_linux <STEricsson_nomadik_linux@list.st.com>,
	Ulf Hansson <ulf.hansson@stericcson.com>,
	Alex Macro <alex.macro@stericsson.com>,
	Loic Pallardy <loic.pallardy@stericsson.com>
Subject: Re: [PATCH v3 5/5] mmc: card: Add RPMB support in IOCTL interface
Date: Tue, 21 Aug 2012 12:47:35 +0530	[thread overview]
Message-ID: <CAPM_RLb9P61E+DVQh6e_gFO5QtcVLbxmEPX4WBVO_XxHA=7Saw@mail.gmail.com> (raw)
In-Reply-To: <1344265951-22437-6-git-send-email-loic.pallardy-ext@stericsson.com>

On Mon, Aug 6, 2012 at 8:42 PM, Loic Pallardy
<loic.pallardy-ext@stericsson.com> wrote:
>
> RPMB partition is accessing though /dev/block/mmcXrpmb device
> User callers can read and write entire data frame(s) as defined
> by JEDEC Standard JESD84-A441, using standard IOCTL interface.
>
> Signed-off-by: Alex Macro <alex.macro@stericsson.com>
> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Reviewed-by: Namjae Jeon <linkinjeon@gmail.com>
> ---
>  drivers/mmc/card/block.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index d8edb8d..a9e1f1f 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -126,6 +126,10 @@ enum mmc_blk_status {
>  module_param(perdev_minors, int, 0444);
>  MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device");
>
> +static inline int mmc_blk_part_switch(struct mmc_card *card,
> +                                     struct mmc_blk_data *md);
> +static int get_card_status(struct mmc_card *card, u32 *status, int retries);
> +
>  static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
>  {
>         struct mmc_blk_data *md;
> @@ -357,6 +361,38 @@ out:
>         return ERR_PTR(err);
>  }
>
> +static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status,
> +                                      u32 retries_max)
> +{
> +       int err;
> +       u32 retry_count = 0;
> +
> +       if (!status || !retries_max)
> +               return -EINVAL;
> +
> +       do {
> +               err = get_card_status(card, status, 5);
> +               if (err)
> +                       break;
> +
> +               if (!R1_STATUS(*status) &&
> +                               (R1_CURRENT_STATE(*status) != R1_STATE_PRG))
> +                       break; /* RPMB programming operation complete */
> +
> +               /*
> +                * Rechedule to give the MMC device a chance to continue
> +                * processing the previous command without being polled too
> +                * frequently.
> +                */
> +               usleep_range(1000, 5000);
> +       } while (++retry_count < retries_max);
> +
> +       if (retry_count == retries_max)
> +               err = -EPERM;
> +
> +       return err;
> +}
> +
>  static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>         struct mmc_ioc_cmd __user *ic_ptr)
>  {
> @@ -368,6 +404,8 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>         struct mmc_request mrq = {NULL};
>         struct scatterlist sg;
>         int err;
> +       int is_rpmb = false;
> +       u32 status = 0;
>
>         /*
>          * The caller must have CAP_SYS_RAWIO, and must be calling this on the
> @@ -387,6 +425,9 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>                 goto cmd_err;
>         }
>
> +       if (md->area_type & MMC_BLK_DATA_AREA_RPMB)
> +               is_rpmb = true;
> +
>         card = md->queue.card;
>         if (IS_ERR(card)) {
>                 err = PTR_ERR(card);
> @@ -437,12 +478,23 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>
>         mmc_claim_host(card->host);
>
> +       err = mmc_blk_part_switch(card, md);
> +       if (err)
> +               goto cmd_rel_host;
> +
>         if (idata->ic.is_acmd) {
>                 err = mmc_app_cmd(card->host, card);
>                 if (err)
>                         goto cmd_rel_host;
>         }
>
> +       if (is_rpmb) {
> +               err = mmc_set_blockcount(card, data.blocks,
> +                       idata->ic.write_flag & (1 << 31));
> +               if (err)
> +                       goto cmd_rel_host;
> +       }
> +
>         mmc_wait_for_req(card->host, &mrq);
>
>         if (cmd.error) {
> @@ -478,6 +530,18 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
>                 }
>         }
>
> +       if (is_rpmb) {
> +               /*
> +                * Ensure RPMB command has completed by polling CMD13
> +                * "Send Status".
> +                */
> +               err = ioctl_rpmb_card_status_poll(card, &status, 5);
> +               if (err)
> +                       dev_err(mmc_dev(card->host),
> +                                       "%s: Card Status=0x%08X, error %d\n",
> +                                       __func__, status, err);
> +       }
> +
>  cmd_rel_host:
>         mmc_release_host(card->host);
>
> --
> 1.7.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Hi,
  Any specific reason why the RPMB support is implemented using the
IOCTL interface. Can this be done by the Kernel itself instead of
being initiated by a user space application ?

--
regards,
Shashidhar Hiremath

  reply	other threads:[~2012-08-21  7:17 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 15:12 [PATCH v3 0/5] mmc: Add access to RPMB partition Loic Pallardy
2012-08-06 15:12 ` [PATCH v3 1/5] mmc: core: Expose " Loic Pallardy
     [not found]   ` <CAJOk3oHfTMr7-esASZKV0kmiFmeGzD1OjgwMZrTtz8Pk61Lswg@mail.gmail.com>
2012-11-16 21:32     ` Fwd: " Krishna Konda
2012-08-06 15:12 ` [PATCH v3 2/5] mmc: card: Do not scan RPMB partitions Loic Pallardy
     [not found]   ` <CAJOk3oE2gXH1AQQBqq-nuLCEb4--vcMZRYnQJNWOdCP8c0JcAA@mail.gmail.com>
2012-11-16 21:31     ` Fwd: " Krishna Konda
2012-08-06 15:12 ` [PATCH v3 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support Loic Pallardy
     [not found]   ` <CAJOk3oHSTygZBkj847a+OKcSAB8=G0YN8vrz07080sUdPB0+_Q@mail.gmail.com>
2012-11-16 21:27     ` Fwd: " Krishna Konda
2012-08-06 15:12 ` [PATCH v3 4/5] mmc: core: Add mmc_set_blockcount feature Loic Pallardy
     [not found]   ` <CAJOk3oEvYUEBAP729nbkxA9XKn=1H6076OPLDSsvq5GP7Z8Qxg@mail.gmail.com>
2012-11-16 21:26     ` Fwd: " Krishna Konda
2012-08-06 15:12 ` [PATCH v3 5/5] mmc: card: Add RPMB support in IOCTL interface Loic Pallardy
2012-08-21  7:17   ` shashidhar hiremath [this message]
2012-08-22  7:43     ` Loic pallardy
     [not found]   ` <CAJOk3oERiGjxm-u6iGZLxK0Mq5noC76d33ojwVtY3gtdRBju3g@mail.gmail.com>
2012-11-16 21:23     ` Fwd: " Krishna Konda
     [not found] ` <CAJOk3oGMtZvrkw9ic306BKNSKCAzPQCYmJrvq5=zDi1pHjjQxg@mail.gmail.com>
2012-11-14 21:14   ` Fwd: [PATCH v3 0/5] mmc: Add access to RPMB partition Krishna Konda
2012-11-15  8:04     ` Linus Walleij
2012-11-16 21:11       ` Krishna Konda
2012-11-17 20:19         ` Linus Walleij
2012-11-17 23:12 ` Chris Ball
2012-11-19 10:09   ` Linus Walleij
2012-11-19 18:12   ` Krishna Konda
2012-11-20  8:25     ` Loic PALLARDY
2012-11-20 18:54       ` Krishna Konda
2012-11-21  9:55         ` Loic PALLARDY
2012-11-21 11:02           ` Sundar J. Dev
2012-11-21 17:32             ` Loic PALLARDY
2012-11-22  4:32               ` Sundar J. Dev

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='CAPM_RLb9P61E+DVQh6e_gFO5QtcVLbxmEPX4WBVO_XxHA=7Saw@mail.gmail.com' \
    --to=shashidar1887@gmail.com \
    --cc=STEricsson_nomadik_linux@list.st.com \
    --cc=alex.macro@stericsson.com \
    --cc=cjb@laptop.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=loic.pallardy-ext@stericsson.com \
    --cc=loic.pallardy@stericsson.com \
    --cc=ulf.hansson@stericcson.com \
    /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.