From patchwork Tue Apr 10 22:25:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 133127 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp90709ljb; Tue, 10 Apr 2018 16:43:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx49WXW1/y/DKyy4iA9OC852j4W42F0IUYzqJR/yVsvbC+UB+ucCq3be3iyxwBBavh4tpOY6F X-Received: by 10.99.43.80 with SMTP id r77mr1676302pgr.193.1523403811010; Tue, 10 Apr 2018 16:43:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403811; cv=none; d=google.com; s=arc-20160816; b=MnpUmVvyAsMTwk7V8QT+0al7WVy3XXohwpUKYCEsCJRV+HHZehzpS0Bwiyrb42NEw1 zmvWmieMp1P+xDtmti8gY3klJiM+2sTLa6OtrHSvyf8yBb+nfVTTm4i1yqWIMphwqDXl da/su9qfR+unI4ChJC3k7rO7yu5cqeiLPMB2e6URrgUZKJWcwbRMbZ/xHDsfWv4AieoN cPweSXACECT95QUfWRw94AoafUVTobBQpLKWjiKytpFFFHy2WvhHvb+lmMJdMp6yOUvI 4qaXMWnN4TVwukdTA+KkqRIpkZB9M4rV/m9mxCnfRdt3MiTCnSu8UfEtRpXAe3tsjMyp 4q6Q== 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=PQb9LvH+x5+Hy7WvGsZAp22qBtd4/tqEzYY9J24Zf2w=; b=bfb/ATkighFUDmjdXMvTpoVYOVxYmqmJqJJql1Frn6nJ+PmSPOYEICF99XErgOwEgo ZIdWM1Ob+Wup+AjodSWOjbpw+AFtAqJTLiio/ce46OOWQ+b91TSYI3VdKiIL0FqrQTIQ wBnJ77Kr6TGNN01BKklmK7frBttQGgAqgCRo7RWSTV8/nFzkj4+A8CBRv6sTbV7id1+7 MkaAJ4TBRn0dDnF9FHxTmrcZfGlh7tKO8rIwThK0OD5HPKQ7XIMEAO+gkBmxURSOHpLE C/Vy2zngsVdqj65tTZgAS1ATcBJ2f/Hz4nqNEh4EK/3Uv/RAfn5a3FYuovx7nSzYrhr6 NHQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SIkGHI0b; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 o2-v6si3577878pls.161.2018.04.10.16.43.30; Tue, 10 Apr 2018 16:43:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=SIkGHI0b; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754673AbeDJXnX (ORCPT + 11 others); Tue, 10 Apr 2018 19:43:23 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:52155 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752995AbeDJW0I (ORCPT ); Tue, 10 Apr 2018 18:26:08 -0400 Received: by mail-it0-f65.google.com with SMTP id b5-v6so288313itj.1 for ; Tue, 10 Apr 2018 15:26:08 -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=gut0PH2awWfpSIs5ubLPbt5sMj/sysSYnqY40nzMmsY=; b=SIkGHI0bYMQinXHxhoL00czcoSlVEhDX9vnWCISPotmIDDZrEPiMrAcH7r4hJGsdjX ekQm665K1qVN/Ul6O9KdqQJtMBstccdFZFfL26tPCGcvWVR7u3MN68X8+AK5yaqK4ggq ioSIBD8IWsrSNrXMGn+le0+IMhJFCMvfVqbv0= 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=gut0PH2awWfpSIs5ubLPbt5sMj/sysSYnqY40nzMmsY=; b=RIM5izXu4GXRXL/zHpQXhn7nb4UcCTnxloQ3GCI41VtwybnGHrsewulroGTow2nxmL gOmToJgzjw77MssENd2ZGb6kA+7I3gJFEys9uWTiwuk8kZT/VOOjHG6xR43rbuSSc70p fyCTJ3VFApnDFGLkzDS49PwQnvEFFHTbGWbd9iP2r6Dtb87QopUQYFG4DeP+MTGVFl2G nkwqHLnKb8KASdBtfvR+saKxZ2yqFdqJnr4xLb2gSjA9lO1yLUduDBZiQo2ghM6F0aCV 1/esEthcDQEsiawc144JizN7q6roXH/AEILYF7jHOL8at1RSx9KZdzaEln22l+nu3QC/ efng== X-Gm-Message-State: ALQs6tAIeRD8XwqhWEKq9fcOiHz5GO4MvX6UP40ELTEFARSYdZb+T+dR kDOjFlXq50GdbGhA4QYq94ABLA== X-Received: by 2002:a24:b911:: with SMTP id w17-v6mr1507855ite.12.1523399167933; 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.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 15:26:07 -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 2/6] soc: qcom: smem: return proper type for cached entry functions Date: Tue, 10 Apr 2018 17:25:38 -0500 Message-Id: <20180410222542.29474-3-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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org What phdr_to_last_uncached_entry() returns is the address of the start of the free space following all allocated uncached entries. It really doesn't refer to an actual (initialized) private entry structure. Similarly phdr_to_last_cached_entry() returns the address of the end of free space, preceding the last allocated cache entry. Change both functions' return type to be pointer to void to reflect this. Meanwhile, phdr_to_first_cached_entry() really *does* point to a private entry structure, so change its return type to reflect this fact. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Bjorn Andersson diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7f38c5e11440..3102aa94aec2 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -280,7 +280,7 @@ struct qcom_smem { struct smem_region regions[0]; }; -static struct smem_private_entry * +static void * phdr_to_last_uncached_entry(struct smem_partition_header *phdr) { void *p = phdr; @@ -288,7 +288,8 @@ phdr_to_last_uncached_entry(struct smem_partition_header *phdr) return p + le32_to_cpu(phdr->offset_free_uncached); } -static void *phdr_to_first_cached_entry(struct smem_partition_header *phdr, +static struct smem_private_entry * +phdr_to_first_cached_entry(struct smem_partition_header *phdr, size_t cacheline) { void *p = phdr; @@ -297,7 +298,8 @@ static void *phdr_to_first_cached_entry(struct smem_partition_header *phdr, return p + le32_to_cpu(phdr->size) - ALIGN(sizeof(*e), cacheline); } -static void *phdr_to_last_cached_entry(struct smem_partition_header *phdr) +static void * +phdr_to_last_cached_entry(struct smem_partition_header *phdr) { void *p = phdr; From patchwork Tue Apr 10 22:25:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 133123 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp89968ljb; Tue, 10 Apr 2018 16:42:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx49fag1T0AA670S/WmyOK+4km1wzJyY39Hd5/D4axzVAM72LLBLLwgnZdk3fw/JFE/TiImxp X-Received: by 10.99.4.3 with SMTP id 3mr1690012pge.147.1523403735023; Tue, 10 Apr 2018 16:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403735; cv=none; d=google.com; s=arc-20160816; b=fUsEaz4PSWVyvmdUhWPZg5Skpl3y4rCoKx6F3Fcy1sVVM7KABiucGI+DOiWGzwt6Ec 9cb1Eh0zV7ij8sOjghH5JajXG1LWvDte8w1Ibebhr9tfHeDkuyS8lqlQQyyNy9W0v+iZ a88p7s1NnHso2k5+4/Lyycv6nh6cwPoY+vbH/Zi/JeNm3QcSiTIvYS+85bDFHZN40hCu xS5VmKflw8KlX6ieM9bqDN90FBcSBLDMSq4oQ7GlqbTDA2CJrvb6WbXuDKMvDeDxnbc+ ZUjRlBO4MH5wh4vEfLPjpefbWQ0ict/GUcOpZ+D6sb82xJQojhTwCoMPVhUsShdfrLme Huiw== 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=danQRC4RDtwFvadGNiA7XF5hHqgKl+TcAT/z9JJ8r5g=; b=gfmhDwdV0aBm2bwpKJnN2S2gMopVmnkqLdjwaPTTsa07te5DonvsLS/6z3GEsuej9/ ueQrLHBYcdwm3FOOlG+yPZD85A1EHRPjYr3CQ84yP0U3G2JQ42RjkFQTJD02hMQJp0xE c+Naz6FVZ6DUlUaLHmJsUZPkRkY+tVj4sqkSkfwYiNYBRm7HAHeXpybPKpHn+HYaBe9S 7ou92oaOq2BsEB/s8vOrhObIjxCT9Kc/5SM5bzX9IAFKnxE/n3Z/Guou2jnkxYuS5WMh BBdMXyd/CFC/d6qAFbVqv7XDHHT5d6cWrF4RrJQtkC7fNhGlvHX4YY8y/446lEJy8ilC wipQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fyciM/YE; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 z14si2500722pgc.401.2018.04.10.16.42.14; Tue, 10 Apr 2018 16:42:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fyciM/YE; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752982AbeDJXmM (ORCPT + 11 others); Tue, 10 Apr 2018 19:42:12 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:39777 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752977AbeDJW0L (ORCPT ); Tue, 10 Apr 2018 18:26:11 -0400 Received: by mail-io0-f195.google.com with SMTP id v13so225095iob.6 for ; Tue, 10 Apr 2018 15:26:11 -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=H9qmvqAiJ/VbTfERmUNt70MGbbyuK6OGOtSlbgP2vA0=; b=fyciM/YEQNQCiJjfJtuucPJasZ4j6lI65d5vWNNu1Z1xy/BUF0kAjY+7jWMXtsukfW 9WgjfgkfR2GrCMLIcpTrogpmh9OrWFzMvZcWFAYukV9CP3xHCKjDb93uf5CTc5pn5s72 5abcRB6MGT8NVPjldDGtQL9tLFPmPlIB8k8m4= 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=H9qmvqAiJ/VbTfERmUNt70MGbbyuK6OGOtSlbgP2vA0=; b=a6RZMROMKOyJQnMTca+FC75Zh1PIFy7m/EBXsNJOTrK87tM0yL4q5b/tAOYF1qQAPc HI84td3kDlBd3N2U+1nie96CeLjiwDbr5eLv99A4c8VypR9xit2ISqwxBFbidl/m4yL9 QNNxpYQWackfDyNpiQ/2Yk4fuJtMhc80Ls7gaxD2p+BbOeYR2TNpzqNFjAF+n4XEA+RE 3wKSDRHMyvsF4Kj6Ena/wBAKsbuMekRrp8+19Nzbp91zt+iU0ydCqsvTFdoPge7/h78v QQxG/t/PMx1eHl3bEzKfZJpGnDPPFLu1ZAi6rDd3vif11w/lDl5chrdhI6YPlIldm6Wb F1tw== X-Gm-Message-State: ALQs6tBHf7fsaIoXB0zMFIx9NJ6BdWLWVe6slwMUYGjr2qKpQeBoAoLC NvUL8YF8gUThaMM1HKdv4f99xw== X-Received: by 10.107.184.198 with SMTP id i189mr2273764iof.228.1523399170615; Tue, 10 Apr 2018 15:26:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Apr 2018 15:26:10 -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 5/6] soc: qcom: smem: fix qcom_smem_set_global_partition() Date: Tue, 10 Apr 2018 17:25:41 -0500 Message-Id: <20180410222542.29474-6-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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If there is at least one entry in the partition table, but no global entry, the qcom_smem_set_global_partition() should return an error just like it does if there are no partition table entries. It turns out the function still returns an error in this case, but it waits to do so until it has mistakenly treated the last entry in the table as if it were the global entry found. Fix the function to return immediately if no global entry is found in the table. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.14.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Bjorn Andersson diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 0ed263055988..6e42599b70d4 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -698,9 +698,10 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem) static int qcom_smem_set_global_partition(struct qcom_smem *smem) { struct smem_partition_header *header; - struct smem_ptable_entry *entry = NULL; + struct smem_ptable_entry *entry; struct smem_ptable *ptable; u32 host0, host1, size; + bool found = false; int i; ptable = qcom_smem_get_ptable(smem); @@ -712,11 +713,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 == SMEM_GLOBAL_HOST && host0 == host1) + if (host0 == SMEM_GLOBAL_HOST && host0 == host1) { + found = true; break; + } } - if (!entry) { + if (!found) { dev_err(smem->dev, "Missing entry for global partition\n"); return -EINVAL; }