linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>, Oliver <oohall@gmail.com>
Cc: linuxppc-dev <linuxppc-dev@lists.ozlabs.org>,
	Paul Mackerras <paulus@samba.org>,
	Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH] powerpc/nvdimm: Add support for multibyte read/write for metadata
Date: Thu, 06 Jun 2019 18:20:31 +0530	[thread overview]
Message-ID: <878sueho88.fsf@linux.ibm.com> (raw)
In-Reply-To: <8736konw3i.fsf@concordia.ellerman.id.au>

Michael Ellerman <mpe@ellerman.id.au> writes:

> "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> writes:
>> Oliver <oohall@gmail.com> writes:
>>> On Sun, Jun 2, 2019 at 2:44 PM Aneesh Kumar K.V
>>> <aneesh.kumar@linux.ibm.com> wrote:
> ...
>>>> diff --git a/arch/powerpc/platforms/pseries/papr_scm.c b/arch/powerpc/platforms/pseries/papr_scm.c
>>>> index 0176ce66673f..e33cebb8ee6c 100644
>>>> --- a/arch/powerpc/platforms/pseries/papr_scm.c
>>>> +++ b/arch/powerpc/platforms/pseries/papr_scm.c
>>>> @@ -97,42 +97,102 @@ static int drc_pmem_unbind(struct papr_scm_priv *p)
>>>>  }
>>>>
>>>>  static int papr_scm_meta_get(struct papr_scm_priv *p,
>>>> -                       struct nd_cmd_get_config_data_hdr *hdr)
>>>> +                            struct nd_cmd_get_config_data_hdr *hdr)
>>>>  {
>>>>         unsigned long data[PLPAR_HCALL_BUFSIZE];
>>>> +       unsigned long offset, data_offset;
>>>> +       int len, read;
>>>>         int64_t ret;
>>>>
>>>> -       if (hdr->in_offset >= p->metadata_size || hdr->in_length != 1)
>>>> +       if ((hdr->in_offset + hdr->in_length) >= p->metadata_size)
>>>>                 return -EINVAL;
>>>>
>>>> -       ret = plpar_hcall(H_SCM_READ_METADATA, data, p->drc_index,
>>>> -                       hdr->in_offset, 1);
>>>> -
>>>> -       if (ret == H_PARAMETER) /* bad DRC index */
>>>> -               return -ENODEV;
>>>> -       if (ret)
>>>> -               return -EINVAL; /* other invalid parameter */
>>>> -
>>>> -       hdr->out_buf[0] = data[0] & 0xff;
>>>> -
>>>> +       for (len = hdr->in_length; len; len -= read) {
>>>> +
>>>> +               data_offset = hdr->in_length - len;
>>>> +               offset = hdr->in_offset + data_offset;
>>>> +
>>>> +               if (len >= 8)
>>>> +                       read = 8;
>>>> +               else if (len >= 4)
>>>> +                       read = 4;
>>>> +               else if ( len >= 2)
>>>> +                       read = 2;
>>>> +               else
>>>> +                       read = 1;
>>>> +
>>>> +               ret = plpar_hcall(H_SCM_READ_METADATA, data, p->drc_index,
>>>> +                                 offset, read);
>>>> +
>>>> +               if (ret == H_PARAMETER) /* bad DRC index */
>>>> +                       return -ENODEV;
>>>> +               if (ret)
>>>> +                       return -EINVAL; /* other invalid parameter */
>>>> +
>>>> +               switch (read) {
>>>> +               case 8:
>>>> +                       *(uint64_t *)(hdr->out_buf + data_offset) = be64_to_cpu(data[0]);
>>>> +                       break;
>>>> +               case 4:
>>>> +                       *(uint32_t *)(hdr->out_buf + data_offset) = be32_to_cpu(data[0] & 0xffffffff);
>>>> +                       break;
> ...
>>>
>>> I assume you got the qemu bits sorted out with Shiva? Looks good otherwise.
>>
>> That is correct. I also tested with different xfer values (1, 2, 4, 8)
>> on both Qemu and PowerVM.
>
> With a big endian kernel?

I completed this testing and found new bugs in other parts of the code.

Thanks for the sugestion.

-aneesh


  reply	other threads:[~2019-06-06 12:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-02  4:43 [PATCH] powerpc/nvdimm: Add support for multibyte read/write for metadata Aneesh Kumar K.V
2019-06-03  0:25 ` Oliver
2019-06-04  9:06   ` Aneesh Kumar K.V
2019-06-05 10:51     ` Michael Ellerman
2019-06-06 12:50       ` Aneesh Kumar K.V [this message]
2019-06-05  8:02 ` Alexey Kardashevskiy
2019-06-06 12:49   ` Aneesh Kumar K.V

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=878sueho88.fsf@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=oohall@gmail.com \
    --cc=paulus@samba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).