msm: secure_buffer: Limit continuous time spent in hypervisor

hyp_assign_table() is a costly operation during which nonsecure interrupts
are disabled. Split this operation into multiple parts for better
real-time behavior.

Splitting is done by the following criteria:
maximum number of physically contiguous memory regions
maximum total memory size.

Here is a chart showing the average performance of hyp_assign_table() with
N physically contiguous chunks each with size X.

 #chunks    chunk_size(pages) total_memory(pages)    time(ms)
       2                   1                   2       3.354
       2                   4                   8      12.979
       2                 512                1024       4.349
       8                   1                   8       4.714
       8                   4                  32      26.781
       8                 512                4096       8.724
      32                   1                  32      17.093
      32                   4                 128      50.700
      32                 512               16384      26.717
     128                   1                 128      71.076
     128                   4                 512     126.305

Based on the above, select a maximum of 32 chunks or 512 total pages
as the limits.

Change-Id: I530cfdce76c8a2c38f60d6118647eaefd269e693
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
1 file changed