public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
From: Phil Chang <phil.chang@mediatek.com>
To: <jens.wiklander@linaro.org>
Cc: <sumit.garg@linaro.org>, <matthias.bgg@gmail.com>,
	<op-tee@lists.trustedfirmware.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: Re: [PATCH v4] tee: make tee_shm_register_kernel_buf vmalloc supported
Date: Wed, 6 Apr 2022 22:40:28 +0800	[thread overview]
Message-ID: <20220406144028.4203-1-phil.chang@mediatek.com> (raw)
In-Reply-To: <CAHUa44GDg7hAAFsmeOOkeqi8_1P1Q6jATRdnV9b6S-DhpEEQrA@mail.gmail.com>

> On Fri, Feb 25, 2022 at 4:20 PM Phil Chang <phil.chang@mediatek.com>
> wrote:
>>
>> In some low-memory devices, it's hard to aquire large-orders pages,
>> this patch allowed user using scatter pages to register shm.
>>
>> Signed-off-by: Phil Chang <phil.chang@mediatek.com>
>> Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
>> ---
>>  drivers/tee/optee/call.c |  2 +-
>>  drivers/tee/tee_shm.c    | 35 +++++++++++++++++++++++++----------
>>  2 files changed, 26 insertions(+), 11 deletions(-)
>
> Looks good to me. Unfortunately this is too late for the coming merge
> window, so it's going to be the one after that. Meanwhile it will be
> in linux-next.
>
> Thanks,
> Jens

 Hi Jens
   thanks for your review, did I push again wile merge window open ?
   Or just wait ?

 Thanks

>>
>> diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c
>> index bd49ec934060..2082e632adff 100644
>> --- a/drivers/tee/optee/call.c
>> +++ b/drivers/tee/optee/call.c
>> @@ -362,7 +362,7 @@ int optee_check_mem_type(unsigned long start,
>> size_t num_pages)
>>          * Allow kernel address to register with OP-TEE as kernel
>>          * pages are configured as normal memory only.
>>          */
>> -       if (virt_addr_valid(start))
>> +       if (virt_addr_valid(start) || is_vmalloc_addr((void *)start))
>>                 return 0;
>>
>>         mmap_read_lock(mm);
>> diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
>> index f31e29e8f1ca..836872467dc6 100644
>> --- a/drivers/tee/tee_shm.c
>> +++ b/drivers/tee/tee_shm.c
>> @@ -23,21 +23,36 @@ static void shm_put_kernel_pages(struct page
>> **pages, size_t page_count)
>>  static int shm_get_kernel_pages(unsigned long start, size_t
>>  page_count,
>>                                 struct page **pages)
>>  {
>> -       struct kvec *kiov;
>>         size_t n;
>>         int rc;
>>
>> -       kiov = kcalloc(page_count, sizeof(*kiov), GFP_KERNEL);
>> -       if (!kiov)
>> -               return -ENOMEM;
>> +       if (is_vmalloc_addr((void *)start)) {
>> +               struct page *page;
>>
>> -       for (n = 0; n < page_count; n++) {
>> -               kiov[n].iov_base = (void *)(start + n * PAGE_SIZE);
>> -               kiov[n].iov_len = PAGE_SIZE;
>> -       }
>> +               for (n = 0; n < page_count; n++) {
>> +                       page = vmalloc_to_page((void *)(start +
>> PAGE_SIZE * n));
>> +                       if (!page)
>> +                               return -ENOMEM;
>> +
>> +                       get_page(page);
>> +                       pages[n] = page;
>> +               }
>> +               rc = page_count;
>> +       } else {
>> +               struct kvec *kiov;
>> +
>> +               kiov = kcalloc(page_count, sizeof(*kiov), GFP_KERNEL);
>> +               if (!kiov)
>> +                       return -ENOMEM;
>>
>> -       rc = get_kernel_pages(kiov, page_count, 0, pages);
>> -       kfree(kiov);
>> +               for (n = 0; n < page_count; n++) {
>> +                       kiov[n].iov_base = (void *)(start + n *
>> PAGE_SIZE);
>> +                       kiov[n].iov_len = PAGE_SIZE;
>> +               }
>> +
>> +               rc = get_kernel_pages(kiov, page_count, 0, pages);
>> +               kfree(kiov);
>> +       }
>>
>>         return rc;
>>  }
>> --
>> 2.25.1

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

  reply	other threads:[~2022-04-06 14:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-25 15:20 [PATCH v4] tee: make tee_shm_register_kernel_buf vmalloc supported Phil Chang
2022-03-02 13:18 ` Jens Wiklander
2022-04-06 14:40   ` Phil Chang [this message]
2022-04-07  7:42     ` Jens Wiklander

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=20220406144028.4203-1-phil.chang@mediatek.com \
    --to=phil.chang@mediatek.com \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=op-tee@lists.trustedfirmware.org \
    --cc=sumit.garg@linaro.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