Skip to content

Commit

Permalink
soc: qcom: smem: fix first cache entry calculation
Browse files Browse the repository at this point in the history
Cached items are found at the high end of an smem partition.  A
cached item's shared memory precedes the private entry structure
that describes it.

The address of the structure describing the first cached item should
be returned by phdr_to_first_cached_entry().  However the function
calculates the start address using the wrong structure size.

Fix this by computing the first item's entry structure address by
subtracting the size of a private entry structure rather than a
partition header structure.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
  • Loading branch information
Alex Elder authored and Andy Gross committed May 25, 2018
1 parent 36b0aef commit 7070874
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/soc/qcom/smem.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ static void *phdr_to_first_cached_entry(struct smem_partition_header *phdr,
size_t cacheline)
{
void *p = phdr;
struct smem_private_entry *e;

return p + le32_to_cpu(phdr->size) - ALIGN(sizeof(*phdr), cacheline);
return p + le32_to_cpu(phdr->size) - ALIGN(sizeof(*e), cacheline);
}

static void *phdr_to_last_cached_entry(struct smem_partition_header *phdr)
Expand Down

0 comments on commit 7070874

Please sign in to comment.