From patchwork Tue Apr 10 22:25:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 133120 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp39194ljb; Tue, 10 Apr 2018 15:26:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx4//KEpoX5SHXEbz/5CQCIstczWPgLnQT8kPyF4roL79ln18yvMOGuXkhPUwu+LXnAoGJt45 X-Received: by 10.101.85.200 with SMTP id k8mr1564689pgs.290.1523399180227; Tue, 10 Apr 2018 15:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523399180; cv=none; d=google.com; s=arc-20160816; b=obGFTC87RGzzQrxrcHGCh+v+dRgz2ErnBWz6Lw1dSg99Rm/h9dD9ZYLllOqvg9vGxP Oi8xEx1ecXSxgbC3TvvgNvNrJoZbcs4PbBRv5z3PbHZxq191dxJAaL1L9AW71AakZlul SLb+f+1CgaViaKvcw6tCH5RTSCiaX5C3C0pGO7g8bD5YO3qfqHG9Skqs+WB4xYLDC2J9 TW3psledrYcPdBohAxh17ifzEiBhWfHRX7EzpWn2GcG+RzGbCiJjXDYBL4cvs7s/RY/F oWgj7/uRUG7nBipp/4ETVYg01VmoCz0mJgC56CWlVVtNcjYywerXX2hvNe9NGNk81u3h LjBg== 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=5wlkiebE+lt8D2K+rDYtdKU2imQTARWjqvZM2UydGD8=; b=I29SwW2qzXM0dS4emnuIbtqvo9YjK7mAmL9m17P07PQO3n54eA4hkJAhRfr3hOoe56 2cAyJhBCK/IvQqXO5KQ5AVZ1MxmdWX9U32cn6xEIcjvbo5L2Wp9KT9QEWmShpg5Y98V+ rhajrTad7stY3rc0sxxe3eJhnQrwzNgaJA9cjXVxuQcBKV4AImESP5HEw1Lcj4sdM6MS oYsA8YoIA3b4qcWe1p7ro+P93WhRodzON60+nYVKgQCRiuTNiuOX2mkcW0OM7T7ZOi8P G5WZbtAgkzU+SczbbaK0cpZCFJhTs3kxSCJ3Pw6VXujm/KKBC7ZDUx6xQ6TtST3bSpgV 0D9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OqTCwApj; 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 s13si2394424pgr.802.2018.04.10.15.26.19; Tue, 10 Apr 2018 15:26:20 -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=OqTCwApj; 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 S1753091AbeDJW0R (ORCPT + 29 others); Tue, 10 Apr 2018 18:26:17 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:37308 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbeDJW0M (ORCPT ); Tue, 10 Apr 2018 18:26:12 -0400 Received: by mail-it0-f66.google.com with SMTP id 71-v6so255437ith.2 for ; Tue, 10 Apr 2018 15:26:12 -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=5wlkiebE+lt8D2K+rDYtdKU2imQTARWjqvZM2UydGD8=; b=OqTCwApjGkfP65S9dpNe+mI/xbYC7MIA7uNTmueb76zGBUKYZ6XJTHaUNqIpHkpGR/ Wnm/RnvftTzlE5B6sPU7LSUXK9m006TA5LO/0iUdPHe/yAvhyTcmxbCjB4JKhJ+IWG9V qOLgd9dffr92EL1Jh47jgCxMcf1kvsbrtvT5o= 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=5wlkiebE+lt8D2K+rDYtdKU2imQTARWjqvZM2UydGD8=; b=sm3shjccE1lqXbzq73TIR+lsHZUKyrZwSftK8Opt0S8bWtp7PFuC5yRYhpbc/LBjeo TDa8z09F5AJr+42SSQ/vTybDohlyf2zYxay7MIuU1iA0+5CJr2ag9bfJqwThBkkgfG8t XRh6cagfvXYtTU4qYODlHWrIY4LMtIXDt2BQ8S4OGGb0WHuYCM1CjwiYcjgKQ6GjMW3C ULoNMKYNZLA+ZLhv2FGtGWFP86fuXlgyTn3U8fkSMyZbPJZfsWjR2C1YL8+SDt/A8hb6 vaU/dxfhCEaxGfxfyCfi/Sn4UQ7d1pBQ3FCygyKpT6K4B4dfN/W0CY1cTx2iZh9t5B4Z OcBA== X-Gm-Message-State: ALQs6tCZehEYQQLkDkJDL5unPcFJDJqYYEzgVTMesmPO34PU3wjI/hs6 /O0EqYTw/pWO8PbTvysebvlixA== X-Received: by 2002:a24:5f45:: with SMTP id r66-v6mr1432180itb.126.1523399171632; Tue, 10 Apr 2018 15:26:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 15:26:11 -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 6/6] soc: qcom: smem: check sooner in qcom_smem_set_global_partition() Date: Tue, 10 Apr 2018 17:25:42 -0500 Message-Id: <20180410222542.29474-7-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 There's no sense in scanning the partition table again if we know the global partition has already been discovered. Check for a non-null global_partition pointer in qcom_smem_set_global_partition() immediately. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.14.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 6e42599b70d4..7d9a43da5084 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -364,6 +364,11 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem, end = phdr_to_last_uncached_entry(phdr); cached = phdr_to_last_cached_entry(phdr); + if (smem->global_partition) { + dev_err(smem->dev, "Already found the global partition\n"); + return -EINVAL; + } + while (hdr < end) { if (hdr->canary != SMEM_PRIVATE_CANARY) goto bad_canary; @@ -729,11 +734,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (smem->global_partition) { - dev_err(smem->dev, "Already found the global partition\n"); - return -EINVAL; - } - header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); host0 = le16_to_cpu(header->host0); host1 = le16_to_cpu(header->host1);