From patchwork Tue Apr 10 22:25:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 133128 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp91010ljb; Tue, 10 Apr 2018 16:44:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/IcFcb5dHGLFgvF1DIONBDQn9UMbon5orjuYi17KwoL/zFfAMMzUBx632IdxSTbAnyFEIk X-Received: by 10.99.121.134 with SMTP id u128mr1695042pgc.360.1523403842345; Tue, 10 Apr 2018 16:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403842; cv=none; d=google.com; s=arc-20160816; b=HGfuUPwkYuK69es5wBsAeJY1T3PT3UK89lhfyEcJlrG6H5PVFu+1oGE1+xN95rIzZg 6iQo9X+WkczxclhgG/b0gMyGKSShq3OOFOmaKm2a7OBzHXAQ5/jwGjkAYZd0S//JQILU OrXj2xYR0C1WfzUVGzMUoLCP0aV2kAhM+LeeDgyd0XYz/nBW1hyHd9XT9+zNO4uVVIB7 DjOBNM7cl1o7VsV43W5PHhIT6IkvPY/iVZt8K8qmwL6zbWMptEf16DhYFriWatbkNEDX C8PxfVV4poxi7nKEHx2SqDry7fYHG/YasO3En6sa5p+Uc2V63Munm9ceoWv+BgD6GR6f zrZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=/dRevxXRCKJJFWcSXie2zM4fuEtTKys67SAPUMlYQJk=; b=x8bCtZTxd94oqi7GcrXB3r0B3lBliGQz5/6sDgcMITNQxGEPGler1Zls+SizpgkVwP 6W3P/QJ89DXoGhRiuT3t70neto7M4ZK9x6kU29bZa+kAl+XduREhxfQeCEhSJE6zTpDH qD1JiB8LXn/2XGBpq9aLzG5rVltNuR9Bm51ypKXwiFRurR1XE3X2X9263ODTX+L1F/SN pnTif+AMVUi5N+CgapDlXw1aUhH0U9vG37BObmYbvaEcbK+EMpOiUU7D3d+U/l7sOSIN MjY6dNjhbHVUEEwYn0PJ6EpDsiyEoupw5GTkujhtrJYgyvdeBGo5nqKGmR/zb9ohOpVg +jsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kJA4eUCi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x61-v6si3592088plb.213.2018.04.10.16.44.02; Tue, 10 Apr 2018 16:44:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kJA4eUCi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754204AbeDJXn5 (ORCPT + 29 others); Tue, 10 Apr 2018 19:43:57 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:39958 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752985AbeDJW0H (ORCPT ); Tue, 10 Apr 2018 18:26:07 -0400 Received: by mail-it0-f68.google.com with SMTP id u62-v6so236359ita.5 for ; Tue, 10 Apr 2018 15:26:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/dRevxXRCKJJFWcSXie2zM4fuEtTKys67SAPUMlYQJk=; b=kJA4eUCimunvgzwioqimabt2TH3yxai2BgtZjJaJNAIwct0LRNNXvOAiFB572YiUgv jAqQG+clkmN1d6OkLpgb0rGn7uYxpK2FM34VblnMTwetnM15s8emI/S2E9q+2oq+FcKv JXpuOhY85019WqmzgqOwOcuiGPJRBT1W80kdI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/dRevxXRCKJJFWcSXie2zM4fuEtTKys67SAPUMlYQJk=; b=Cx012k2AbYZ7nVUT/oMBFTI4T0BeNpkR7uZDHsNc1cXxRYY0/LqK4QuC0zY90sY1bu 83TgXOQZNKxm4INUHQQpj2rj2kEU8QlKQvDJ9dpKBr9xJ3VkJVvAx2hobTRWOYXoHPFD olTVoAAoE2SG/taGfH7VJ2kV2YL0Kti1EmiZ0DAURpYpKgURRxDuz8HvHwmBGxVC+cHV Za5qNQkpCX0y+tp9yRoT8HVGxHgGLlnj675KVdqvrDqOG0f5w62Ct002saczZUzhErOQ 2mrTD333bZ687/VceAKs39WPqE5ISrIk5JuERfd6qub6BJEbGJGBqdt48vzKiJ2yC3UT X54Q== X-Gm-Message-State: ALQs6tB+IBsqtgvAktQXI84JwjvTqgWdiHpUO0EYQmT3wbsX1jySpxVn A73GoXutd08xA5yHFO1LEzAZlQ== X-Received: by 2002:a24:4a03:: with SMTP id k3-v6mr1467098itb.124.1523399167009; Tue, 10 Apr 2018 15:26:07 -0700 (PDT) Received: from localhost.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id l16-v6sm1373640iti.18.2018.04.10.15.26.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 15:26:06 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] soc: qcom: smem: fix first cache entry calculation Date: Tue, 10 Apr 2018 17:25:37 -0500 Message-Id: <20180410222542.29474-2-elder@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180410222542.29474-1-elder@linaro.org> References: <20180410222542.29474-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/soc/qcom/smem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 0b94d62fad2b..7f38c5e11440 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -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)