From patchwork Tue Jun 26 00:58:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139906 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4617673lji; Mon, 25 Jun 2018 18:01:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIa6mjdmWeEYo4b33Hqbfmezfy3XLhvaOV3laB0nmQg2k0hv2EwYVNv1/LeB1Miksjy84/t X-Received: by 2002:a17:902:b08a:: with SMTP id p10-v6mr14830600plr.0.1529974906393; Mon, 25 Jun 2018 18:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974906; cv=none; d=google.com; s=arc-20160816; b=mVfVpwLbinL9TD68TKrP36ImYoM6kTECTVYYKbVgjvidO2p/M+95Wss95p5Suo9HGA 1bDz3aS/WqUqBie6Dxepi5+P0X/grHAIezCnTvoGwnn5I4DS+nTqhe8nIUqNE3nxv/D1 YdzA+ez+Gx1b/doOthGGTAQEGfxnu53cQz9QKXPvZ8nRHSp+POWbCttsTGuKxO4XDJ4J mY4PfLXID9G/r3juikbM5nrLcMMn/qrmd75QX1VvjEex5VSb28uSbs1gLHGk9CSxxOA/ nj+3V2orJt4Jn87fc6qXosMBWJjMXdTgnF2jbzd4jS2Sy+zZwECbUiS0pHR6qCcVFQ/m aLBA== 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=n+sOnaiAnzk1RDU6WjGHWVb8XkDgEeSKO+QskCnkucM=; b=lpNweBVHr0Rl9L0HhOBXLvzT6VvB3JEXIw85+aGxugmYap64Gjxr/qydxB6pyqv2tP IYaufIe57/i3b3fjhLymifRAh5W6tGbjy4qtCGVmitE8/eSXv+Criz4BJ0qwcMW1QKoz 4baHpTJQlay/4QXy4TBoOR6ItUsyd/ocBhhzrWYLr2oyHZVPwhcjQmKkZ6w9ZqAZ6p2G iX1T/C7HaoLTFJF8bepd/CTIAWgMjfAjvi2meV6RtQPZT1IEqpPnsxdMI92VEG6zhjkn CPg9QDdWYxIMWY0z2hqc1g3LU5oeWtbBJ8QMbZoARg738PL5nkdSkuv4bkPq9XdkSv+m vJTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ivy95Yi0; 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 y15-v6si358699pff.54.2018.06.25.18.01.46; Mon, 25 Jun 2018 18:01:46 -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=ivy95Yi0; 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 S935289AbeFZBBo (ORCPT + 31 others); Mon, 25 Jun 2018 21:01:44 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:47008 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934022AbeFZA7D (ORCPT ); Mon, 25 Jun 2018 20:59:03 -0400 Received: by mail-io0-f196.google.com with SMTP id u23-v6so10609288ioc.13 for ; Mon, 25 Jun 2018 17:59:02 -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=n+sOnaiAnzk1RDU6WjGHWVb8XkDgEeSKO+QskCnkucM=; b=ivy95Yi0EqPpQYJ8I/RxN1PSs/JcwqSIDlRr1iMc5fhHPhx2Xeuj74vZqM8SlBI08P NXOQNCq1iezmJvoatgaGSGGWQw6B2Z1Glt0zWmz6jC/XBJDvuTifpbMe4vt0QhzGA5HI LID1/KR3h5uQPfgLV1PYSRw3p+clk8v8d7xKg= 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=n+sOnaiAnzk1RDU6WjGHWVb8XkDgEeSKO+QskCnkucM=; b=XXai1jh7F+2Cho9YKbcCX+JFRkUObF56EKBDLUkmSb7Tl9lgPTJA0yYMmNFT25J6AK xotkN53GD2RQrLSY7RDkBjEwSz/2cgPTeMA/tG3y5wctMrmQEuGSDZLS+CEOQOFwbbX5 FwLmIuwYXQXxoBwmv7LaZCwScSo3AUdprEpGLuvUKb8c6DGFxEwI8f+6ni0+hTonSess +Ycy8qMj2oa90yylf3haWepwXO6ai9cnEZnjfezvvlh8Y5kS+7nMXfI7scmcr5bEpvlZ Ah8oVW2tDbkqBvCT4us/TyDFhn4k6hdjqyCUNetrmTYHmnKHMXIydFBCQZaHViQgy62w m5LA== X-Gm-Message-State: APt69E2Ut1qjpQd5ArLlMFhIONuPwH0jehx/6yAMe+mRlkafZGoGGXeL EkpTys3D5LX9qGze6JTTlyc3FQ== X-Received: by 2002:a6b:3942:: with SMTP id g63-v6mr11547178ioa.225.1529974742442; Mon, 25 Jun 2018 17:59:02 -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 f193-v6sm372556itf.9.2018.06.25.17.59.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:02 -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 resend 01/12] soc: qcom: smem: rename variable in qcom_smem_get_global() Date: Mon, 25 Jun 2018 19:58:45 -0500 Message-Id: <20180626005856.14174-2-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rename the variable "area" to be "region" in qcom_smem_get_global(), so its name better matches its type. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 70b2ee80d6bd..c46bb43c0f3d 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -277,7 +277,7 @@ struct qcom_smem { u32 item_count; unsigned num_regions; - struct smem_region regions[0]; + struct smem_region regions[]; }; static void * @@ -494,7 +494,7 @@ static void *qcom_smem_get_global(struct qcom_smem *smem, size_t *size) { struct smem_header *header; - struct smem_region *area; + struct smem_region *region; struct smem_global_entry *entry; u32 aux_base; unsigned i; @@ -507,12 +507,12 @@ static void *qcom_smem_get_global(struct qcom_smem *smem, aux_base = le32_to_cpu(entry->aux_base) & AUX_BASE_MASK; for (i = 0; i < smem->num_regions; i++) { - area = &smem->regions[i]; + region = &smem->regions[i]; - if (area->aux_base == aux_base || !aux_base) { + if (region->aux_base == aux_base || !aux_base) { if (size != NULL) *size = le32_to_cpu(entry->size); - return area->virt_base + le32_to_cpu(entry->offset); + return region->virt_base + le32_to_cpu(entry->offset); } } From patchwork Tue Jun 26 00:58:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139895 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4615764lji; Mon, 25 Jun 2018 17:59:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJZWqx09P6t9Ss1EU3pGA/0zoshHc8G/9rprkYM7NmsmmnIEwvo7SzjTh0o0TUU9ds9wVAk X-Received: by 2002:a62:5582:: with SMTP id j124-v6mr2847254pfb.20.1529974750246; Mon, 25 Jun 2018 17:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974750; cv=none; d=google.com; s=arc-20160816; b=n5MBIUpbCc9Z7MauMMf4RCJ7SXcXoBnSmdGtZ1g/WErmPPCmK315szUhOkxIMDFCnU V9hh9TMiNROOqQbIQuQxvGiLrtpX+c1EA5TfhypckJFhVpP1SRo+jv9lY/de2PwcW0X1 ZjJWbJ0yVTFKiYVjnU6/G8ko6lp5E3qjrFGf41uYtluA1ZKh1WZdyVsaJTU5Dpp5yEva Pos1LpZkd4oJGyeO8qdkeaf2W7ZF2Tvjvv815LPE30pq4+gm64klnF+uDBygyEqr8qQK HsYK49c21CnvBbcJpzn5ZQ3N4L5jlVMU0dOEdXzEaWlMMCu1XoOZNYDSL5pGU9uvtLd0 xf7w== 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=Gb0nb2yDTdFiuOpR0M5eWYBBjXEZNg/qX7xReBdXIr0=; b=CKTYLl7jyAxEVeUlsT4D3VjfAH/CeV/1zZi34lwGdD9NELzph7r7F19yhoNvHzrZMO bZUrEvinMPaZkO3HomOeH4UtQgzX3iNjIBL8JcQz59R9nrLRV0g7LGM/QbpW1DCHE3i6 yvDYa+esKhbvQxN1f3Yfh5b8xE7+CgJClcgxtIgWJbVOt1umT53OffrJ/wec49vRkBbv WXbuIJffxZzBQHpvFHkdL03u7eH1kWSUBIvtkkyUWyGzmRV81ie57amOkVVQILC3qI5g SxquErhmMNQk/7nQKCpKgKNxL3vBSlNDmqR5ywTyEi31zgE3q/wyJHLJIpVOT7PfJ3TH a2lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KbbcVmT2; 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 n10-v6si288453pgs.485.2018.06.25.17.59.09; Mon, 25 Jun 2018 17:59:10 -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=KbbcVmT2; 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 S934744AbeFZA7H (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:07 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:42778 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755764AbeFZA7E (ORCPT ); Mon, 25 Jun 2018 20:59:04 -0400 Received: by mail-io0-f196.google.com with SMTP id r24-v6so14309608ioh.9 for ; Mon, 25 Jun 2018 17:59:03 -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=Gb0nb2yDTdFiuOpR0M5eWYBBjXEZNg/qX7xReBdXIr0=; b=KbbcVmT205ORikHxa+fJHoNTiOBxXiI3YQM2Cczb6SXLZjj8XLpAXiuWBRp7K9UrGa 73oSUZ20muO/UHLR5vOAs/A0I31e/FSsGeTOxtt0H7PffOd4h8qs6DRlFtbWNEOpaoIw cWTcLch+eccaMgc0meNOEyK3Lee9qAFxAIkPE= 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=Gb0nb2yDTdFiuOpR0M5eWYBBjXEZNg/qX7xReBdXIr0=; b=NgzfQa3vaCFxe25xwfrWcXHga12Fu2fgd5+OG4ZYkqgZC76Jln4rWq1jdb8/dN68ue XV6yvaPb+3wc3YxvLcypi2vO6sfvZoKx6RAi49fxPWSRTRx1qQ9IEWJIoWiYf+aU8c6m Xg4r6Z0ti2UZqo+8eKPCDDc5AMPAijSI7wN7YHOLpWdL+CnRkzvcRfu+o8zgNfKryEnZ 6N4JK8hUVcbHbjYlImkP7YlK5CgRY57mRKHMWkef2o23/u8y6OZrIt+9z96V7dLvw4s4 pZMFI6wSF5G8khgSE8O1vnzCMfHEOV2H/N58WhdDZC9tpMoVsJvv9nZa6xjaXR6Bcasq m+yQ== X-Gm-Message-State: APt69E3+ART6UnloP+n7EB9zz8XK/g67Tzrcys96E6rq5K6FFl4quGs+ OUv1ka0sz8VTb25HBPaESuGZzQ== X-Received: by 2002:a6b:17c7:: with SMTP id 190-v6mr11392890iox.17.1529974743381; Mon, 25 Jun 2018 17:59:03 -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 f193-v6sm372556itf.9.2018.06.25.17.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:02 -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 resend 02/12] soc: qcom: smem: initialize region struct only when successful Date: Mon, 25 Jun 2018 19:58:46 -0500 Message-Id: <20180626005856.14174-3-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hold off initializing anything for the array entry representing a memory region in qcom_smem_map_memory() until we know we've successfully mapped it. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index c46bb43c0f3d..d8008bf480a4 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -887,6 +887,7 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, { struct device_node *np; struct resource r; + resource_size_t size; int ret; np = of_parse_phandle(dev->of_node, name, 0); @@ -899,12 +900,13 @@ static int qcom_smem_map_memory(struct qcom_smem *smem, struct device *dev, of_node_put(np); if (ret) return ret; + size = resource_size(&r); - smem->regions[i].aux_base = (u32)r.start; - smem->regions[i].size = resource_size(&r); - smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, resource_size(&r)); + smem->regions[i].virt_base = devm_ioremap_wc(dev, r.start, size); if (!smem->regions[i].virt_base) return -ENOMEM; + smem->regions[i].aux_base = (u32)r.start; + smem->regions[i].size = size; return 0; } From patchwork Tue Jun 26 00:58:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139905 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4617416lji; Mon, 25 Jun 2018 18:01:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJYQbiAp++LQom4ghSXJS9MJ2choZefIva1I69DMfUqNvBte2MhD17d53Y+VhCzrtjzZt70 X-Received: by 2002:a65:510c:: with SMTP id f12-v6mr12170802pgq.288.1529974885258; Mon, 25 Jun 2018 18:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974885; cv=none; d=google.com; s=arc-20160816; b=y1Vd8gNbX20fsA9jp1C3Oi+53nYnXKuLh/xi2A11Mr0mhhzGnKIqgXjs+vdjRqWnci wFNaq/BfpIT1ffrDFEc13J59v/z1lo3LoTsgdZQuehQhLXARAIhAISTnMxhjHr4OzKYs 76oSo4Gotlt+o1DSq2hM0CFNq+M/2CUMyMiB6B2XzBqGHXAGQTPBf5Yz8hHp0AUhslzY KbTfbFELQnQmzl/sah3luGoHo09L6xWCpI87Wf0TPXLp8M9XDjZ9nEWFbHG9n61n6PYz umq0eLF6pLc7Qt5kSQVyy4Qh0iErBTu2ve4T8RKJ2dAQj1YzZk6Uf36oeACAqNfs/UHn 6XDQ== 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=XA/E3QTALeKtLrl2UKl+cued+8oFK5Fk+61ksYnsJDA=; b=BRFs3eZ+MigL1hjWymwErLi7MK/7+NMlHe0ISuhDKG5puJHQ5JRVZpOiMFYgtp4sHd OU+1ExZ0DZIl7I+HlaSscBkkcevBi+ggibebgR6jRIeDaNr5B+lhvvNwaPPFH/7BnUHi frD8irYzh0MAZ/G9kr95Yw2np5ASvGTe2et/b4BEXW1R+1LKfFNJu7jqVprVavdxQIN1 Cqy7k+TOrufmDzHwPZ8eMbuyxL7w7dXGqugJSZFd/BZRwcgMmsPoOm3a9h5hpeqZddRz RiDsgkQqq3WY1g8nbFu+0qIaLYZvbq4omo9n6998HDRRcIegIQlEokhuYZmk+sKFHxBn w/QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O+rMum1z; 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 r17-v6si297537pgd.52.2018.06.25.18.01.24; Mon, 25 Jun 2018 18:01:25 -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=O+rMum1z; 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 S935249AbeFZBBX (ORCPT + 31 others); Mon, 25 Jun 2018 21:01:23 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:32891 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755789AbeFZA7E (ORCPT ); Mon, 25 Jun 2018 20:59:04 -0400 Received: by mail-io0-f195.google.com with SMTP id d185-v6so14331451ioe.0 for ; Mon, 25 Jun 2018 17:59:04 -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=XA/E3QTALeKtLrl2UKl+cued+8oFK5Fk+61ksYnsJDA=; b=O+rMum1zamoWjUYs2wfTqNzfawRpjRbLU17yyjd6Nvl9aMiSNZMcr7W0y1EbC4DU3Q Ho0qI5xbHJFolESzOSB0C3PWF63FufIZwUBo+L9w3Nj4Cp9RytkoH18045hg2tJx2BeK j0fmRCr770eW9l1kLkIXA1BI6cXP1TSDXrp3E= 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=XA/E3QTALeKtLrl2UKl+cued+8oFK5Fk+61ksYnsJDA=; b=csLzOAeyU5Sy6Dhg2RhlIkAs5N7tPtoG8E+VW//d65bigqlsAfNFXw7Lp3UipRu/IB A9seyOVsTq7+Hug4bhi1jPnZQIMCOAJ/D0Dyb6kxAQI6CnjGxYRZtLou0+VSpwjyd1pB z37JkwZegj+lD/GZCpiliXoVf7ndpHGSZdCqZjvxvPrmrVFI7zus75gomXd+pdqrSnqP hb8/HZKu1Ng1PMtMWDimvPvDBeKwHdKc0H0JlE+iawevlv9R47Psf97VvtSqAHcpjrqS 7byb1Dgtu1xG7jonjq83C28uwtlALqQNuporbURmwf1tD2V7wFm5u/BxRzaEM9DxC/W4 3/HA== X-Gm-Message-State: APt69E0HoUFSIm8cCSVqrED1mlEPnLX4SCSMOGfqEmE5u76kHn7/PvKh RryJnQQnwd4OmtpZ5HSqSUal6Q== X-Received: by 2002:a6b:9fcb:: with SMTP id i194-v6mr9879060ioe.286.1529974744327; Mon, 25 Jun 2018 17:59:04 -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 f193-v6sm372556itf.9.2018.06.25.17.59.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:03 -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 resend 03/12] soc: qcom: smem: always ignore partitions with 0 offset or size Date: Mon, 25 Jun 2018 19:58:47 -0500 Message-Id: <20180626005856.14174-4-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In qcom_smem_enumerate_partitions(), any partition table entry having a zero offset or size field is ignored. Move those checks earlier in the loop, because there's no sense in examining the host fields for those entries. Add the same checks in qcom_smem_set_global_partition(), so the scan for the global partition skips over these invalid entries. This allows a later check for zero size or offset once the global entry is found to be eliminated. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index d8008bf480a4..83ba549cfea0 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -742,9 +742,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { entry = &ptable->entry[i]; + if (!le32_to_cpu(entry->offset)) + continue; + if (!le32_to_cpu(entry->size)) + continue; + host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 == SMEM_GLOBAL_HOST && host0 == host1) { found = true; break; @@ -756,11 +760,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (!le32_to_cpu(entry->offset) || !le32_to_cpu(entry->size)) { - dev_err(smem->dev, "Invalid entry for 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); @@ -809,18 +808,16 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, for (i = 0; i < le32_to_cpu(ptable->num_entries); i++) { entry = &ptable->entry[i]; + if (!le32_to_cpu(entry->offset)) + continue; + if (!le32_to_cpu(entry->size)) + continue; + host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 != local_host && host1 != local_host) continue; - if (!le32_to_cpu(entry->offset)) - continue; - - if (!le32_to_cpu(entry->size)) - continue; - if (host0 == local_host) remote_host = host1; else From patchwork Tue Jun 26 00:58:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139904 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4616999lji; Mon, 25 Jun 2018 18:00:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWFD4sFrS4sBnMiVUv/DzEdNGylH+Zm1bC5nYRnxzUs2IaxDbdXQTnDFzCD9tC0cgeVYgE X-Received: by 2002:a63:2c9:: with SMTP id 192-v6mr12741741pgc.354.1529974854588; Mon, 25 Jun 2018 18:00:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974854; cv=none; d=google.com; s=arc-20160816; b=QT+2L3GlH2u2aYgSEXeRBqXIXtzP3xWdaeDagfZkE9mzKOnynfUEVsRrYS6ICObP2D 95oDy6nZg1m6VAfNjLCCr4tyxSamtgrfXQodw3q2M6piFGKfgSIwIWhZuaiYlCYSTLIX JklQmPw3UjJ/J5XI+fWoqbJ1qrBwkfJt+hEeANgFxEXNy8f7GgDHmmrvoCXaILnik178 nqSz5Pd0l+oQMPepNL+m6eAJOCqv8n4hqFfsltpv2RQzHhkVKXJeCAU2bmor0K51cPtT mPwATayR+Mu01zKWGBWXbSpg1HbC7LnXu6shc9xHSB+741x8vqtaxPPF879KC5/klFDv wsiw== 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=xNjMY2VoPRCAGDy/phZ/JtqeH0mk6bVlwd6yiC6mUcw=; b=gbas4d6IgAcTWL7azqrwSCyN2hrz7WvRgPnan0W9+Wj/7jGk7osTXBrMvDs+3KaQHN arIDE8r4PhROCZ/y7pe816rK80K0EA6mQ4dizDFKgrb7T28SqvOnS3U3JopEIPKepGI9 KohIoy07jO7CPeE2DhpGEP5NLoBpb/yeB4HAkNTSUlbm19v9AlFL/3h3exzpfuJAfvCL A882DgSrLrqRhs5r2N1CqOHK1chjG8OxuNB4ZaArLu/sa58YtJJHzmKGHiUiVFh2DBDI vEI2AAo8oZON336EpNMN1RUxI3UxurOmGtCDWlm2YfoWrk2C2ELdMYTwHfFl3aOhRGDL ubkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X2Nc5gN0; 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 g17-v6si310563plo.355.2018.06.25.18.00.54; Mon, 25 Jun 2018 18:00:54 -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=X2Nc5gN0; 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 S935231AbeFZBAw (ORCPT + 31 others); Mon, 25 Jun 2018 21:00:52 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:39458 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755801AbeFZA7G (ORCPT ); Mon, 25 Jun 2018 20:59:06 -0400 Received: by mail-it0-f68.google.com with SMTP id p185-v6so15059873itp.4 for ; Mon, 25 Jun 2018 17:59:05 -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=xNjMY2VoPRCAGDy/phZ/JtqeH0mk6bVlwd6yiC6mUcw=; b=X2Nc5gN0Ie6Lz6LS2EKGw2QKVyjqLyVqFUvlAB4YdQnr+cFTwwMM/U6wN/LX4rjovU 9RseU3tIKf2Y8J1zmA3oXW92xMKq9n0zof9KJuLlDcO3TXETdTc0uSzNaB1T4A8znDRT H6Goj/98dlxq5YH1piwJ9kEZ5smGfYww/1xe4= 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=xNjMY2VoPRCAGDy/phZ/JtqeH0mk6bVlwd6yiC6mUcw=; b=BcIBsf0GjhhfTALxmpo9Okd0jBwlg7fff2H01BVQKMVjPaIEE4NRhy41Ma1xmcT6Co LYX0w+9/LNph7pFJ5qP7bSn4g87UJ81vI8w5PYffhku/CMWdUu1g7vOrE+ZowfnL+e8v 8446Dv4v4lIqgtzyGw6JnnMIkSRQ9kDdqgdz/JLHHK2U6vFMOXEoLd1veLCPCTlxeDmZ oqs7xwTWoxAzHxr8BZ+xQs8h8VGLMf8rEGSt2wH7V0i1aqh3CAakeG4wvrbeqYS+DHCZ tFgNrHK7g3TCkth3e3ubzD/V/EJjAnFilK75i9twBpgOYM55MVRzc29usY7IkFs6ltoh P2zg== X-Gm-Message-State: APt69E1RswXRN0pgpiWs/GxqlQg6l7Ttmi7uY1fRAI5Cdy+7NrPUt8qM gZWIjXE2JonvNdIqNqR2vtBrdg== X-Received: by 2002:a24:c054:: with SMTP id u81-v6mr2664109itf.94.1529974745230; Mon, 25 Jun 2018 17:59:05 -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 f193-v6sm372556itf.9.2018.06.25.17.59.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:04 -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 resend 04/12] soc: qcom: smem: small refactor in qcom_smem_enumerate_partitions() Date: Mon, 25 Jun 2018 19:58:48 -0500 Message-Id: <20180626005856.14174-5-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Combine the code that checks whether a partition table entry is associated with the local host with the assignment of the remote host id value. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 83ba549cfea0..5d3ed510e54b 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -815,13 +815,12 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, host0 = le16_to_cpu(entry->host0); host1 = le16_to_cpu(entry->host1); - if (host0 != local_host && host1 != local_host) - continue; - if (host0 == local_host) remote_host = host1; - else + else if (host1 == local_host) remote_host = host0; + else + continue; if (remote_host >= SMEM_HOST_COUNT) { dev_err(smem->dev, From patchwork Tue Jun 26 00:58:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139903 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4616976lji; Mon, 25 Jun 2018 18:00:53 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLM47rjN7Ibmi8/Ytvz+XU6hbuLWA4L3pdbDyEFIgwa0hI2CCHTVJaCwAm38Dcnyjq1qTN7 X-Received: by 2002:a63:9b19:: with SMTP id r25-v6mr12097968pgd.197.1529974853243; Mon, 25 Jun 2018 18:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974853; cv=none; d=google.com; s=arc-20160816; b=bMAZxYZ+vmMPhngjVeQG+3OjrXHO704mHXsg1oEB4i0L04dpkKx2O7+1eyx0AqGYdw RYIuspnP3I0eadBNp4llzo7z9Bix/g2/trymiQ74/F9YLvf//5ukcDEnFWDDikEyPdmi 3y5HKW8EX2iwSiQf7+Fs6aInbyEFBckEKmuZHyv/yLINmGoCyRttS2pPCFovBQcLAIxR WDwjUmSQAzjsjzffUK9euDepFA1fh1cguzbq5xEjdMGOUvFoKjc5/l1fa8yFmEFZxpy9 /EtgO+svZeKuH0MNpcepvSM+3PamuELOOXVaw9YT1iYmCZ7J4LbzxsVTE33VOQCNERsM XK+A== 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=U42+N/Pr+kSZibonyjndzWovOO9lsASoVNkEMXPj8tA=; b=EVOLK5axVWFFXlQYGw6ypfmtoDNz4ZGKo1aVZWW9Q5kVNzc47rDG+zDcJCNXAyK9fg XMuq3IyhKDNwFGGzKuEhsXFNZsbx8FTcmOtny2OmXRkx3/jyjHwvXIz8hrgisRUV3AQY hBOGWKJqAxcway5MhNpzaKhYCZPnuIXbxAumoKYNCkz0XPKdhvb6VuQ/Z/557RbzMPhW lzG4mN7sLY3jvyu79R8FUB+7iI8ojbLHzoTuqzna3+Eze3P66ERyr80VmXTSd3JsTrxM M1z7Zu+UREtRG4eLpVlyqKsmzRAvR0CMASVh+Srv2Wyis2HY9yq2fCNblgdkQtS6V8W3 Y8FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BC9LJmh2; 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 g17-v6si310563plo.355.2018.06.25.18.00.52; Mon, 25 Jun 2018 18:00:53 -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=BC9LJmh2; 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 S935180AbeFZBAv (ORCPT + 31 others); Mon, 25 Jun 2018 21:00:51 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:53196 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934558AbeFZA7G (ORCPT ); Mon, 25 Jun 2018 20:59:06 -0400 Received: by mail-it0-f66.google.com with SMTP id m194-v6so15207914itg.2 for ; Mon, 25 Jun 2018 17:59:06 -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=U42+N/Pr+kSZibonyjndzWovOO9lsASoVNkEMXPj8tA=; b=BC9LJmh2L5hpLyHG3T84x5UZ5U5DhGzecGtUrmIT+Rly7V1hopxHHblcP6cfOEtzkO ZzmRAHEAJ8JRGys9QRqZUSXmQQ9KIW8gpdlvG50MM95IF+NNAw//Ok5IIhe7otASbciX yqsrdWH68/AA2trGqONsYSOrh6ShggL/c/ox4= 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=U42+N/Pr+kSZibonyjndzWovOO9lsASoVNkEMXPj8tA=; b=LJm2ZcppjrstZmKWrQNEvwnyymw/ZXiHi2d5vyhmbpK8XAhDu+a3U6Ht7i1eBu0eLi wA2N482VCJrZiz/D87gg+c08bdnwn4lcgSDnluz6SnFtcot5FVY3k6yQ6+bhuzr9g/jW AXfIpHdwWU/ztp3AVDZVPbl/CxzEWRrThCnmeFq8zYAUN3/qB6LyMZHdHp4ZiIq2PwYL zm44Gp8RlzOfCy/ujCMb3Kj78i7M7EVdrRYnKiQE4E5ly7xCVpWpKcn4oy+5N4+Lmhhm cwxkxlI4bDjVrx82fZrz3Y6mXb4nf5l6nFO20aMtpm+NOAfKmy+JOldMXQTcUecTK+25 jRDQ== X-Gm-Message-State: APt69E2RGWGNg+LozbNq6ActLIgLQpaxAr4TKqId8efV20+lA7hLET6o pAFwuogM8G27lr3d181lsGC0cA== X-Received: by 2002:a24:9b82:: with SMTP id o124-v6mr2598325itd.56.1529974746126; Mon, 25 Jun 2018 17:59:06 -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 f193-v6sm372556itf.9.2018.06.25.17.59.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:05 -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 resend 05/12] soc: qcom: smem: verify both host ids in partition header Date: Mon, 25 Jun 2018 19:58:49 -0500 Message-Id: <20180626005856.14174-6-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The global partition is indicated by having both host values in its table of contents entry equal SMEM_GLOBAL_HOST=0xfffe. In qcom_smem_set_global_partition(), we check whether the header structure at the beginning of the partition contains that host value, but the check only verifies *one* of them. Change the check so the partition header must have SMEM_GLOBAL_HOST for *both* its host fields. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 5d3ed510e54b..6931602d9a9e 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -769,7 +769,7 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (host0 != SMEM_GLOBAL_HOST && host1 != SMEM_GLOBAL_HOST) { + if (host0 != SMEM_GLOBAL_HOST || host1 != SMEM_GLOBAL_HOST) { dev_err(smem->dev, "Global partition hosts are invalid\n"); return -EINVAL; } From patchwork Tue Jun 26 00:58:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139896 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4615788lji; Mon, 25 Jun 2018 17:59:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL08aSPVHn+tjrC/U6XET4uo+9vIc1bMCyWUSzb+1TIw+qeod8Eo+wMaqFToDtTbPhSOJqC X-Received: by 2002:a62:444c:: with SMTP id r73-v6mr15125166pfa.255.1529974752395; Mon, 25 Jun 2018 17:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974752; cv=none; d=google.com; s=arc-20160816; b=P3BW0M7SMKm7u08GVbvMbx1yLSsu+VXdLjWrrqJ9wYm0gOSTgs9oSykS7VasAC+cOD 9FFLNI1srkeqU7j2+s34fOu8yLj2d2h4ebumCP0I69I6utxaZ7cvrnrn8sY77GJyI+fS 1++xgihARtTX3qUynFNRTYkH7vumQAr6xvZgcZlnVIA0q5QVuRhIn8O7OXnOEeDVcZs1 GE1gje5Kq/x/x7i452G45nl2Jh0dbDLfs5Yp6lbJyx14A8Qqn6q9G12j1P7xqv95KUid W5J99sHscXuKewj38zoary7Ik1EQwUPqXwFPpDZJpz6V/ZRW/JHldVOnOv8H9eTwJTHX duRA== 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=kqgmo0i4y6iTyIYd+DAmlJreZeAqlQhGPtH0NQFjIq0=; b=dqq+NFzMliEzd5GCupo/HDgIc6+82n4/5oFpF+MxqjpiUiPpg4wBn/7V0NiUIAXQ4C Qh0NDfX3UMcBP8bndP4sg7e6DUa/DWn/M3irpswuOIpHQn4b+cObf/Vtg3qUBaORm9zB i/elaENnoxZ9spCpKQYMqOprE73w1hMRlrrxxuxncM1AkDxTQh9vMETNZ4FzH2zG8+PX sbeHHcHiBu21qTzLl4IMNlKlBmKfzwuepnBOFj6dEQZvRh7sByh3w+r1/DkBpdBPNkPK emJdfgKrXXqhjOW1XNAoGn8dJOPFUz2jjRkaytYeGG0ZZ2qnzPC6M64XIzGopNuWUMdt qSOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRnGHuqG; 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 n10-v6si288453pgs.485.2018.06.25.17.59.12; Mon, 25 Jun 2018 17:59:12 -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=SRnGHuqG; 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 S934945AbeFZA7K (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:10 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:55887 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934743AbeFZA7H (ORCPT ); Mon, 25 Jun 2018 20:59:07 -0400 Received: by mail-it0-f66.google.com with SMTP id 16-v6so15191013itl.5 for ; Mon, 25 Jun 2018 17:59: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=kqgmo0i4y6iTyIYd+DAmlJreZeAqlQhGPtH0NQFjIq0=; b=SRnGHuqGRWAP9bcYjbBbeEsbcOvOZkdcGCB1Iq9kv18JrY9oKTjqquT1IIQXlbi575 23ez0uSDFaXLHQqbyoYYmatCE/Y7i/+oHQ3gCJ5c2z4StuosYA7hpb8bXdnr3gNGxps0 c/3SaytnfzVdbNLHcKl/60qDy3ATWQevcA6hQ= 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=kqgmo0i4y6iTyIYd+DAmlJreZeAqlQhGPtH0NQFjIq0=; b=ZiuEfDlA5+fBi1wCnMwIPWRe4BjU6UgE6Sv6dcceDL7eXuTzE30zumkH5iWsGnUOBx IOnCpHWKrDZgD9JP79XLXz4t1FR7H5ccs11+P1mq/Eat5dEgiTcSrtd880T9iBy4qGp4 ajrUTeu/Tp+2BjIBDqsdCKPkDQOeL9ZFn/NQMcxYE8r0uQ7Bx4XDWD5vR5i2CY3JUfXq QJ6U0oxSRp2aS6dFBsVaeu88mYULsL2BvOdS/jAKKL5hkx+IzP8m20Vfd7xhlzFvtiaT NMoIA1rVcVv/t9fXOnR9LuKzzH+OuQdPcePqLYAfsdGNl9qqEvP2A5JSzNGBGKQSCfdy 0nYw== X-Gm-Message-State: APt69E2CWErLhnTw+jOS/+n3awYAA/E1Ps+c4AkxBKhC7xvnZbkK5gQY M2X+rOf06EmOSxbwhgx+HVvcWg== X-Received: by 2002:a24:f549:: with SMTP id k70-v6mr883648ith.123.1529974747021; Mon, 25 Jun 2018 17:59: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 f193-v6sm372556itf.9.2018.06.25.17.59.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59: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 resend 06/12] soc: qcom: smem: require order of host ids to match Date: Mon, 25 Jun 2018 19:58:50 -0500 Message-Id: <20180626005856.14174-7-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In qcom_smem_enumerate_partitions(), we find all partitions that have a given local host id in either its host0 or its host1 field in the partition table entry. We then verify that the header structure at the start of each partition also contains the same two host ids as is found in the table of contents. There is no requirement that the order of the two host ids be the same in the table of contents and in the partition header. This patch changes that, requiring host0 to in the partition table entry to equal host0 in the partition header structure (and similar for the host1 values). Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 6931602d9a9e..49f228e9d2d3 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -847,15 +847,9 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - if (host0 != local_host && host1 != local_host) { + if (host0 != host0 || host1 != host1) { dev_err(smem->dev, - "Partition %d hosts are invalid\n", i); - return -EINVAL; - } - - if (host0 != remote_host && host1 != remote_host) { - dev_err(smem->dev, - "Partition %d hosts are invalid\n", i); + "Partition %d hosts don't match\n", i); return -EINVAL; } From patchwork Tue Jun 26 00:58:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139898 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4615985lji; Mon, 25 Jun 2018 17:59:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlGfmLV4yjWYNjhR8EePxZBSvip+jd/zvD4LwkIJFylzLi6mmRoE0EEqHhFnR4LgMTROWI X-Received: by 2002:a62:3cd7:: with SMTP id b84-v6mr7869953pfk.9.1529974772904; Mon, 25 Jun 2018 17:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974772; cv=none; d=google.com; s=arc-20160816; b=i1CsGeOVRYV9qWtdVf4dZV2JZlA21ePkn9NcE+UqQPL/CP5A3ZlcOZl9bWMuYtokfZ gKjed/M9jgkR8QtFHD3iDdPbzoH/s4fraSEg8P97Tg0B8/hB7lgWxgPCkmMSVL4dFEvp DFL2+IJ1U1n3bJTzjQVx381vSLNNn/3Rogf8EeZu5tK5aABeO78q8uJWTJKT7oh/j2Jk Y+dZAYllatdvyZGFCkB1365DHEjD/4AB4dPHsKYJtBYt9xHYbL47dihuTms4NV5UdF/J LtxzqaTexLi4EoKdX9cHy+c3424DX4sUfxBxKGxepn/pa7GvVJ7k4WBdL1LbJxIFwlnE 1PmQ== 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=WXW2CQ4taCc5cvUraPVxkiewob/irwXrM2tspZPurSM=; b=LwlTZa7ltMifdbiSxNbEGr+9P2HZjUvusjhZiYazdLs+AM0L4lc+ujDDSX2fK7wRYi vGMLN5vpH/rjHk++qWjcDZxHQwZKls7y0xCTVbeW7sEKUdVDxaGejlz1ZgxirjM6Tyl3 XX+xZ49eKeJY3qa43AxNJZn9FSsPyc2jZOhYk0puK2eSfsxDQ8ALBrFCUfjkr7zx97ia Q+P3OovbMij0YWm7rxjRyO2kx9JPE6A7WeSsWzzqjCp1NssEuTk6tAeR55erGJ/f5f/c yfJq5CETqya7ggd3aK7OuPW+1j+h13CP+Bz0rA18UOaL22HaGS/2j7ze27KcU4eitjl8 mFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g+DmuyN5; 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 e9-v6si341895pls.325.2018.06.25.17.59.32; Mon, 25 Jun 2018 17:59:32 -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=g+DmuyN5; 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 S935100AbeFZA7T (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:19 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:50812 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934844AbeFZA7K (ORCPT ); Mon, 25 Jun 2018 20:59:10 -0400 Received: by mail-it0-f68.google.com with SMTP id u4-v6so15219556itg.0 for ; Mon, 25 Jun 2018 17:59:10 -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=WXW2CQ4taCc5cvUraPVxkiewob/irwXrM2tspZPurSM=; b=g+DmuyN5g7Pa85Aui/dA6zzbZ/kDMw/bfmuSfHi9dLRwzwb8qRasQ1xDceVE01x2a8 oKBCDnj4SEYOEhZP82OA3MdxuAV72Y0v9Zb+kF3EkOuScM7Xql3NxG65AJInRnpsRdq9 OTaFVAzbTWMxTg1AuqjhyxSfQhg8UrO1B1OXs= 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=WXW2CQ4taCc5cvUraPVxkiewob/irwXrM2tspZPurSM=; b=t9jldL0Vn5uIqeiwtmMRO/M+lRHHIMI1kJ5YEtXsj9+WqKCRqQUlMVW+GqmXkG0IuM eKFZ2sPxg+E5dYGCEdue0RNhf32s6a8tx47LbKxEw2D5sklE4PECy9yndQ7GwOg/GKtX FMihMy3yUyfFk3J3afas3Pe1lO2y5ZaEKxFTJc7Qn8QeFQVJMAxzNAOGxUxuNcyVrEET Br7n/eTjiVArzf3i7dDGq7ry06ZSq2Oga0SxB/OXXseIswI2b/6SYPLc091JPxlmWS9p X5lvii87DJXhiykbReibVeajbrkjFzRxu2/jKNbmkaOw+6f/BP4IQ8Uwj9qQmP557JT9 oxiw== X-Gm-Message-State: APt69E16gAiPhuMQ+A8KzRJShM42acOEXpeiF0zjTjTXroEjqI+dvd2t wdpwZutYKw+bEAtqdyOxecDy5Q== X-Received: by 2002:a24:fc83:: with SMTP id b125-v6mr366151ith.13.1529974749884; Mon, 25 Jun 2018 17:59:09 -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 f193-v6sm372556itf.9.2018.06.25.17.59.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:09 -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 resend 09/12] soc: qcom: smem: verify partition offset_free_uncached Date: Mon, 25 Jun 2018 19:58:53 -0500 Message-Id: <20180626005856.14174-10-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add verification in qcom_smem_partition_header() that the offset_free_uncached field in a partition's header structure does not exceed the partition's size. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 95d218d3a595..f5d7af1623a9 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -755,6 +755,12 @@ qcom_smem_partition_header(struct qcom_smem *smem, return NULL; } + if (le32_to_cpu(header->offset_free_uncached) > size) { + dev_err(smem->dev, "bad partition free uncached (%u > %u)\n", + le32_to_cpu(header->offset_free_uncached), size); + return NULL; + } + return header; } @@ -763,7 +769,7 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) struct smem_partition_header *header; struct smem_ptable_entry *entry; struct smem_ptable *ptable; - u32 host0, host1, size; + u32 host0, host1; bool found = false; int i; @@ -803,13 +809,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - size = le32_to_cpu(header->offset_free_uncached); - if (size > le32_to_cpu(header->size)) { - dev_err(smem->dev, - "Global partition has invalid free pointer\n"); - return -EINVAL; - } - smem->global_partition = header; smem->global_cacheline = le32_to_cpu(entry->cacheline); @@ -873,12 +872,6 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - if (le32_to_cpu(header->offset_free_uncached) > le32_to_cpu(header->size)) { - dev_err(smem->dev, - "Partition %d has invalid free pointer\n", i); - return -EINVAL; - } - smem->partitions[remote_host] = header; smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline); } From patchwork Tue Jun 26 00:58:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139897 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4615883lji; Mon, 25 Jun 2018 17:59:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJjkRnp+UPj6MduxLqNJ5gKEUIVy7wTmPSkjYv2nR/ZiRkrV5hwewyfQODFzzhST9nFELPY X-Received: by 2002:a62:968f:: with SMTP id s15-v6mr15107092pfk.191.1529974762517; Mon, 25 Jun 2018 17:59:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974762; cv=none; d=google.com; s=arc-20160816; b=TTfHBHF3bbvyzJktSnvjoVZfiNqZMxdsKLhGTmepbrTF4QnT5JUnUReUp1S8unPMdZ ft1+dJA3LdAHdeVKgmcQhafnB86S2ImjBtpnNCNUbMXbg6b248241qE0xvEHoCGSD/MA PQkMfXhbO8adhL9l9fEQjGLaPVBmU424iypIVbKHSHo3665pwSZ08yPSpryWY5S/xqm+ MrQSaPgm+aeitKdqpKQjrlkgW7tTM4e0jNbz0iLJvDHgXhEtveOA6Q8AUNMLWYeQ1M8Z nO1WXQDwa4NLkEbl2udvAXeRNZ4F3nFxpfsY19RtTnJLpYj7bFsMzQ3kdoGyL94YLOlF TwbA== 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=T4CUDx/3MI0mxSRgg3ZDgSPUHt20uXodH0yLTHynxPE=; b=R3fZFbSNE9j1IgLuda0Y0xKhoj9X632y3Ko/F6zlVvoJxQzR8icWHDbq7usq7pG8Oy E1K+VhE155MnN5PLz/I5vqhIlkFIX0L7y8IDQ6wvi2vuo83MkGMaQSyHFlfGuZf11gkp nX7HJC53LT3qLcGjgcWVgEdTGmwCBXMU/3qpKNbc4mc+v1ZWG3QMBvr4zmvnVURcFZRp HCRM9rRRDD9KLsx0BfQSP+r2gmr7cTwp0a4BWG4EPq7aqkUxfChgXPbJa6H/JWFS2lVg 2Ua5qa+joFqXcrGwk8sKEdHQErSEJ8AbwVEejo15D1pTmKAA9TXl38ze+G4X3sUFU30F jNnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YSdoX1rP; 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 i11-v6si288658pgr.200.2018.06.25.17.59.22; Mon, 25 Jun 2018 17:59:22 -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=YSdoX1rP; 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 S935145AbeFZA7U (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:20 -0400 Received: from mail-it0-f66.google.com ([209.85.214.66]:53206 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934965AbeFZA7L (ORCPT ); Mon, 25 Jun 2018 20:59:11 -0400 Received: by mail-it0-f66.google.com with SMTP id m194-v6so15208131itg.2 for ; Mon, 25 Jun 2018 17:59: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=T4CUDx/3MI0mxSRgg3ZDgSPUHt20uXodH0yLTHynxPE=; b=YSdoX1rPHCapO7bHzHg6fURu96OYAzv1qrrFa/3E8tlPxek7+KNsr/nHmwe1aNmFoG BAO/8/GBPVXeiKPk8DRYjlBWkhsyr9D8gtnfkOJnHjDFX8c7eP3UWdRtYjvAA6f/MH/6 wkkFNhj6djxqK7DOmYn10Abo6YStA3DunPZ+o= 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=T4CUDx/3MI0mxSRgg3ZDgSPUHt20uXodH0yLTHynxPE=; b=tAzlaK0HZnMZHJ46YmwH9VI8KOoL5G9cA5LkcgtA2XUh59XRhjMXpE6E+D//rZVp1E aRYXxicn4BIf2ZixcssljUy24fy7jO692p8cjKuONde8S7cET7pPL2ptonKRSrqVfjfA lSCPZMO/9T+c34vrNHj+QvD+kJRUGNonR9wkJ80NqRoD/W3fFAQsnbgduDmBRuSbb9Zt Gdqy4MmU8pGoCGbPAZ+C7775GMkHaSPGvz496zQ46MajhTnZzzKjOX7jhWfDZMW1BE+2 qEutG3qB/3VSlFlzDcgQ3B50cPPUJRoWPHh9g8J6g96TASnoivagu77QpdKSiYcAcabL Lz8A== X-Gm-Message-State: APt69E0ZXCsqY1WfuTVmSC0bolFHC0ymZDrcbxys79PCDaU9a+/b55yl 1MV2PqUEfYUmaSSvkKR5wMrcpg== X-Received: by 2002:a24:eb17:: with SMTP id h23-v6mr2648601itj.17.1529974750868; Mon, 25 Jun 2018 17:59: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 f193-v6sm372556itf.9.2018.06.25.17.59.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59: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 resend 10/12] soc: qcom: smem: small change in global entry loop Date: Mon, 25 Jun 2018 19:58:54 -0500 Message-Id: <20180626005856.14174-11-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Change the logic in the loop that finds that global host entry in the partition table not require the host0 and host1 local variables. The next patch will remove them. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index f5d7af1623a9..8597aa03232c 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -784,9 +784,10 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) if (!le32_to_cpu(entry->size)) continue; - host0 = le16_to_cpu(entry->host0); - host1 = le16_to_cpu(entry->host1); - if (host0 == SMEM_GLOBAL_HOST && host0 == host1) { + if (le16_to_cpu(entry->host0) != SMEM_GLOBAL_HOST) + continue; + + if (le16_to_cpu(entry->host1) == SMEM_GLOBAL_HOST) { found = true; break; } From patchwork Tue Jun 26 00:58:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139899 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4616127lji; Mon, 25 Jun 2018 17:59:46 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJyyzBocnPAiqTdQuHrcGlFKRWxUX8r/wBjXHOO6og4yz9xuURRLYVXbRAPTJIVG6Zaack/ X-Received: by 2002:a17:902:654f:: with SMTP id d15-v6mr7923202pln.8.1529974786423; Mon, 25 Jun 2018 17:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974786; cv=none; d=google.com; s=arc-20160816; b=jIlFvcxNnN+B2nhv3CS83/FrxJVylJFtdv3IbzN8wTMryn7tJB/AZNBmZMugdbSKae qBAQhWWiIe/1uJDI03v6/BcxdDOktjX619QniY6FSCKIl1LtxG28bMXpTNye81AxrY+a aQflDcD71NFahxykzonpZrRicUJlwuRp+kcWkzjru4d5IbwcZIKk2IJ65KqZMqZEUYNM 1cpc9Jz29BQBMqFx/t+huTiAKy1Vx7zHFoWVv6JzPGNWzhEDYED7VKM6i7MbD3t4liKz fTJd3MnISFe16pjXptNCux0DXgaeDhtlwCy2ux2KdKWUQYDlV8mZth9w7eMteMzWMcEB KYCA== 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=yQsG3HksJrmEyKMAvWxROvNnNiE4MTIEcDcHnZhiDeA=; b=KytmqS3DTXeuu1Iu4k1XgHN+1puAQaj1MREwrlt0RzcRfsg3V4V6sYvP35WJnJSndZ vOqM0fZFwVYddFLv+uCeNirLZr+Y1NL5yocsleHBzTGw/rhO3PEpSBMYvwxerDoJdo5D BtM/Ru9CeMqdZEqzJZA+yNtL76zizaEbDsZotXJXOi+cX0eWRR9PlvmtwBmMWsIheUM7 xjcxTdo1pj8VulBdBNubRRbp6XYuRrl1Zqt92ICRuZTQeSnWuMddHbFD35+cpm/8DoPi KIaX2UP6N7oiPdR+PrScOTrlj1smk14R1dLJA2cG0200TUuDqfsD5INzlEOEkb/MZG5N TZoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=goiqlv03; 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 a6-v6si279581pgq.18.2018.06.25.17.59.46; Mon, 25 Jun 2018 17:59:46 -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=goiqlv03; 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 S965030AbeFZA7o (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:44 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:50817 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935001AbeFZA7M (ORCPT ); Mon, 25 Jun 2018 20:59:12 -0400 Received: by mail-it0-f65.google.com with SMTP id u4-v6so15219640itg.0 for ; Mon, 25 Jun 2018 17:59: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=yQsG3HksJrmEyKMAvWxROvNnNiE4MTIEcDcHnZhiDeA=; b=goiqlv03NXEFvtFEjqBahJL6aeavffQFIQj66/uEUOt06Fs6IPdPemOxNa/vtYEiYP jNdqAQujBIH5+tkNVZNwlTplXND+VKlUW0ji/Is1D45UGed8D9MCq1q3xZsqG4QwVxuN jei58ukutx0F+T0CpeG3F/F6sS1TIFV+OVYN8= 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=yQsG3HksJrmEyKMAvWxROvNnNiE4MTIEcDcHnZhiDeA=; b=ClRkS2W+mmgdIGkfyKHZ+WRx0mtWvWhA8ZrDIj/TZVwO0/r+NclDwh8/oAMMOHiAxN 2FOi8KnT2BSbPwyPug/RXEQEGNciu+Zni6eoazZPz11Nz2G238EvE3x/6FXslUenMm/f qv43KolyVDrNpX4AyGuyh3d3WNNP4BDNwGA/RXiXrn8BlK5Pgx6FsMH3fSzjDZ/6C17n DhZUUpl8sq/bI2bCXOoTEQU3wu7j5hCHNFmjLNsc+VtdB1r5o+/dIGha6qF/vfhDGxXp 1p6fnnoMz99atUq96rBl78HgWistlQfwdq8+o31gxxr2l8FlAgdEy1B9YCF9pbfYUljT 4kDQ== X-Gm-Message-State: APt69E0xcBNuuP6MAA43K1NUoiGKExhCI3sJ4pZiMuZRY4udqO5gc/LO fpgOHH8M0cyjCA8pQ+wrEqrrtw== X-Received: by 2002:a02:6065:: with SMTP id d37-v6mr12091820jaf.106.1529974751766; Mon, 25 Jun 2018 17:59: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 f193-v6sm372556itf.9.2018.06.25.17.59.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59: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 resend 11/12] soc: qcom: smem: verify partition host ids match Date: Mon, 25 Jun 2018 19:58:55 -0500 Message-Id: <20180626005856.14174-12-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add verification in qcom_smem_partition_header() that the host ids found in a partition's header structure match those in its partition table entry. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 8597aa03232c..7383a0e1b468 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -734,7 +734,7 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem) */ static struct smem_partition_header * qcom_smem_partition_header(struct qcom_smem *smem, - struct smem_ptable_entry *entry) + struct smem_ptable_entry *entry, u16 host0, u16 host1) { struct smem_partition_header *header; u32 size; @@ -748,6 +748,17 @@ qcom_smem_partition_header(struct qcom_smem *smem, return NULL; } + if (host0 != le16_to_cpu(header->host0)) { + dev_err(smem->dev, "bad host0 (%hu != %hu)\n", + host0, le16_to_cpu(header->host0)); + return NULL; + } + if (host1 != le16_to_cpu(header->host1)) { + dev_err(smem->dev, "bad host1 (%hu != %hu)\n", + host1, le16_to_cpu(header->host1)); + return NULL; + } + size = le32_to_cpu(header->size); if (size != le32_to_cpu(entry->size)) { dev_err(smem->dev, "bad partition size (%u != %u)\n", @@ -769,7 +780,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) struct smem_partition_header *header; struct smem_ptable_entry *entry; struct smem_ptable *ptable; - u32 host0, host1; bool found = false; int i; @@ -798,18 +808,11 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - header = qcom_smem_partition_header(smem, entry); + header = qcom_smem_partition_header(smem, entry, + SMEM_GLOBAL_HOST, SMEM_GLOBAL_HOST); if (!header) return -EINVAL; - host0 = le16_to_cpu(header->host0); - host1 = le16_to_cpu(header->host1); - - if (host0 != SMEM_GLOBAL_HOST || host1 != SMEM_GLOBAL_HOST) { - dev_err(smem->dev, "Global partition hosts are invalid\n"); - return -EINVAL; - } - smem->global_partition = header; smem->global_cacheline = le32_to_cpu(entry->cacheline); @@ -860,19 +863,10 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - header = qcom_smem_partition_header(smem, entry); + header = qcom_smem_partition_header(smem, entry, host0, host1); if (!header) return -EINVAL; - host0 = le16_to_cpu(header->host0); - host1 = le16_to_cpu(header->host1); - - if (host0 != host0 || host1 != host1) { - dev_err(smem->dev, - "Partition %d hosts don't match\n", i); - return -EINVAL; - } - smem->partitions[remote_host] = header; smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline); } From patchwork Tue Jun 26 00:58:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139900 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4616233lji; Mon, 25 Jun 2018 17:59:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLzubfaOkf+A2b3jtjGkF+BZg2bSAoglDTjX1u5w9bjTt4PkA2abrMUs13JC3VjYI1Gqxhm X-Received: by 2002:a17:902:3281:: with SMTP id z1-v6mr14659830plb.226.1529974798505; Mon, 25 Jun 2018 17:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974798; cv=none; d=google.com; s=arc-20160816; b=fGtLYL3AtLC2yRo+q/XcsrZDlFRaq4qJqDu1CLmbColoIPHWOvP1Ogk2wbNhE5stRy zgkGrZ/WzwIdGEuEN40g+SfcN2+OPmE0EY3fR11p8sTIjc4enGwpFBc9+LBxKegnTI4Q 7JF2F5XQTx9Nav1vpAKRjtyGvlfuInwQHdbcrA+WxkZn/Cf2/FW8D8Yq2cbNBmtbgU1f GcgnjfWdu1/evdEOkF4NV5djM/34DbuotD+2qTyJGcIkMEuNyeIE0m1oUwaD8Y3qG8LH UtXAQ6oV1OQAqjndWLKQ+3m92g6tW8xO9G/f36+eUc9w8AHTHnZNwiNUGNMOebe7g7iT aWIw== 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=Q/oytLGFLVRRIBLXYs4209CjepSv9RVJ004ROdrEisY=; b=kROwYU8jUESii9uH3tVbtsDnmS4qoa1k/Uid7rovxelkTwxt1RITH49kmXsmTS6yoL p89Fa33aa1GOKIPFJUZaB6RAr9WHXvUhxXk5786ibVbr4gPjo3QxhfL5CIEo2KtrOMRj sLeur4W2PTKCeregCWRCvg1p2Tf6a5cLQXgwLF6/ewHkBf+IPloZXUrgXf4zgQm3d9FZ sMY7hVsky0UKUouk93DHgp0qi+8VWxCvTYE8kf9HXcgRLy7S+nh3ENi4CiJJ3UeiT0h7 Kkm66/F+rvcfcvrFAPXfaNE2aXxGbCSqovmyr4z9DVt1UQhNlbgAAlyJ/M5M4xuhR77f Tx2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B0Oyxgxv; 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 n9-v6si273291pgp.558.2018.06.25.17.59.58; Mon, 25 Jun 2018 17:59:58 -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=B0Oyxgxv; 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 S964916AbeFZA7n (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:43 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:53811 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935032AbeFZA7N (ORCPT ); Mon, 25 Jun 2018 20:59:13 -0400 Received: by mail-it0-f68.google.com with SMTP id a195-v6so15194709itd.3 for ; Mon, 25 Jun 2018 17:59:13 -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=Q/oytLGFLVRRIBLXYs4209CjepSv9RVJ004ROdrEisY=; b=B0Oyxgxv42nR+j95ZjkMjf/e78vZgYARaa38mgsIf3Y78JDQrFB3MYS7s7NF65Fwqa CfgVnnEf3RS7uUGltwgrAD2KURFoDHspBof/yDHATp9xdx3BiRV7POk8KTjOLN2KzEnc Ll98jXq340RyujuGoS9dqZ9z9dPBoGjjaNBwI= 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=Q/oytLGFLVRRIBLXYs4209CjepSv9RVJ004ROdrEisY=; b=Jy2SfNc72xPbHd5L17IJBuW8HArVL8jd7LIaxwVWc3vc1M4mE+j1CHMlYw3WluvI/w XCJ+Eq1nIgtLw2hp2+PIWb/mPXx825OD0ixnops/G0RR7SZ5UtmNQbsy6TLP4XlU5yzf f5jCsPVJ44IQDRwLElR2nBvvVJFsC+fAi2ZIUSA/AGCznqzaN7/vlPHkCrN4KbhIMtN3 65mKzVkTp/XsuHFDmyLKdB9VViQmrHawGXqI8EaKowENlh5kia1A4hdkz4usRhEDAOfg VfVJR41GLnGKGWPGV+tM2Q+iiWzKAJHBmZqkLs1mLk9zxAPVIommdT64ONkcR1K5JDY9 Ij3A== X-Gm-Message-State: APt69E1fvKiw6HxkWZP2cWjuGUfYQFUVQ96/XFkIGi99IJpofpLnviu3 9Lrcy69+U8F9IqyzhB4o/y66YA== X-Received: by 2002:a02:6f47:: with SMTP id b7-v6mr9563847jae.32.1529974752662; Mon, 25 Jun 2018 17:59:12 -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 f193-v6sm372556itf.9.2018.06.25.17.59.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:12 -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 resend 12/12] soc: qcom: smem: a few last cleanups Date: Mon, 25 Jun 2018 19:58:56 -0500 Message-Id: <20180626005856.14174-13-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch contains several small cleanups: - In qcom_smem_enumerate_partitions(), change the "local_host" argument to have 16 bit unsigned type - Also in qcom_smem_enumerate_partitions(), change the type of the "host0" and "host1" local variables to be u16 - Fix error messages reporting host ids to use the right format specifier - Shorten the error messages as well, to fit on one line - Add a compile-time check to ensure the local host value passed to qcom_smem_enumerate_partitions() is in range Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 7383a0e1b468..0d7f369c3f7a 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -819,14 +819,14 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return 0; } -static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, - unsigned int local_host) +static int +qcom_smem_enumerate_partitions(struct qcom_smem *smem, u16 local_host) { struct smem_partition_header *header; struct smem_ptable_entry *entry; struct smem_ptable *ptable; unsigned int remote_host; - u32 host0, host1; + u16 host0, host1; int i; ptable = qcom_smem_get_ptable(smem); @@ -850,16 +850,12 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, continue; if (remote_host >= SMEM_HOST_COUNT) { - dev_err(smem->dev, - "Invalid remote host %d\n", - remote_host); + dev_err(smem->dev, "bad host %hu\n", remote_host); return -EINVAL; } if (smem->partitions[remote_host]) { - dev_err(smem->dev, - "Already found a partition for host %d\n", - remote_host); + dev_err(smem->dev, "duplicate host %hu\n", remote_host); return -EINVAL; } @@ -956,6 +952,7 @@ static int qcom_smem_probe(struct platform_device *pdev) return -EINVAL; } + BUILD_BUG_ON(SMEM_HOST_APPS >= SMEM_HOST_COUNT); ret = qcom_smem_enumerate_partitions(smem, SMEM_HOST_APPS); if (ret < 0 && ret != -ENOENT) return ret;