One comment inline:

On 11 November 2016 at 22:50, Christophe Milard <
christophe.mil...@linaro.org> wrote:

> _odp_ishmphy_memmap_print() prints the virtual to physical address
> mapping of some memory region (defined by virtuall address + length).
>
> Signed-off-by: Christophe Milard <christophe.mil...@linaro.org>
> ---
>  platform/linux-generic/_ishmphy.c                  | 58
> ++++++++++++++++++++++
>  platform/linux-generic/include/_ishmphy_internal.h |  5 ++
>  2 files changed, 63 insertions(+)
>
> diff --git a/platform/linux-generic/_ishmphy.c b/platform/linux-generic/_
> ishmphy.c
> index 8c0f46e..21f6bd1 100644
> --- a/platform/linux-generic/_ishmphy.c
> +++ b/platform/linux-generic/_ishmphy.c
> @@ -265,3 +265,61 @@ int _odp_ishmphy_can_virt_to_phys(void)
>
>         return 1;
>  }
> +
> +/*
> + * dump the physical mapping from virtual address addr, length len.
> + */
> +void _odp_ishmphy_memmap_print(void *curr_addr, uint64_t len)
> +{
> +       int page_sz;
> +       phys_addr_t curr_phy;
> +       phys_addr_t start_phy;
> +       void *start_address = 0;
> +       uint32_t curr_len = 0;
> +       uint32_t pfn_count = 0;
> +
> +       /* get normal page sizes: */
> +       page_sz = odp_sys_page_size();
> +
> +       curr_phy = _odp_ishmphy_virt_to_phys(curr_addr);
> +       if (curr_phy == PHYS_ADDR_INVALID) {
> +               ODP_DBG("Phy Dump failed (permission?).\n");
> +               return;
> +       }
> +
> +       ODP_DBG("Phy Dump:\n");
> +       start_address = curr_addr;
> +       start_phy = curr_phy;
> +
> +       curr_len += page_sz;
> +       curr_addr = (void *)((char *)curr_addr + page_sz);
> +       pfn_count++;
> +       while (curr_len < len) {
> +               if (_odp_ishmphy_virt_to_phys(curr_addr) ==
> +                   curr_phy + page_sz) {
> +                       curr_len += page_sz;
> +                       curr_addr = (void *)((char *)curr_addr + page_sz);
> +                       curr_phy += page_sz;
> +                       pfn_count++;
> +                       continue;
> +               }
> +
> +               ODP_DBG("Virtual: %08" PRIx64 " <-->  Phy: %08" PRIx64
> +                       "   %" PRIu32 " PFNs, %" PRIu32 " bytes\n",
> +                       (uint64_t)start_address, start_phy,
> +                       pfn_count, pfn_count * page_sz);
> +               curr_phy =  _odp_ishmphy_virt_to_phys(curr_addr);
>

Should here check the success or failure of the call? And break in case
failed.


> +               start_address = curr_addr;
> +               start_phy = curr_phy;
> +               pfn_count = 0;
> +               curr_len += page_sz;
> +               curr_addr = (void *)((char *)curr_addr + page_sz);
> +               pfn_count++;
> +       }
> +
> +       if (pfn_count)
> +               ODP_DBG("Virtual: %08" PRIx64 " <-->  Phy: %08" PRIx64
> +                       "   %" PRIu32 " PFNs, %" PRIu32 " bytes\n",
> +                       (uint64_t)start_address, start_phy,
> +                       pfn_count, pfn_count * page_sz);
> +}
> diff --git a/platform/linux-generic/include/_ishmphy_internal.h
> b/platform/linux-generic/include/_ishmphy_internal.h
> index 2022590..c8752c0 100644
> --- a/platform/linux-generic/include/_ishmphy_internal.h
> +++ b/platform/linux-generic/include/_ishmphy_internal.h
> @@ -32,6 +32,11 @@ int _odp_ishmphy_can_virt_to_phys(void);
>   */
>  phys_addr_t _odp_ishmphy_virt_to_phys(const void *addr);
>
> +/*
> + * dump the physical mapping from virtual address addr, length len.
> + */
> +void _odp_ishmphy_memmap_print(void *addr, uint64_t len);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> --
> 2.7.4
>
>

Reply via email to