Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6916555ybp; Wed, 16 Oct 2019 00:35:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwG/b5OLHGq6X9AIWvRo7ccZy6NSSUC5gXPDZOcORXv42s1U5sZEmIr1yC0eXTmp6+HT0gX X-Received: by 2002:aa7:d3ca:: with SMTP id o10mr38023713edr.279.1571211330174; Wed, 16 Oct 2019 00:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571211330; cv=none; d=google.com; s=arc-20160816; b=cTXVoWNvsCQDn3JKdAVC1GHLmp36WnLxmGxX65P+vlbWXnhDDYhqCWlYL3SCefH9gi KijYhf1ggGL1xSYuyS8Ihcyd3Gc3CGXy0GhwRbKK+TSx063kH3wtTtMplZfx6vcvR5Ji c6Wgt5lvwksj4GEJ5DGjEP/IXYxmhqE7o9ZEutzfWUDlumZ+2QCDHY2UT9xLNQewxMKn 4zSNqtNrFRO3EIouxlgiJITMhezEfMafvA5NGY/0Pkl9tNU46XLvb3hja/VqlFkqYz15 CjMcPwZjD5LrpzctCDC42FUwqfgO/hvl+63SHnV71sjO7syGzE/5qH28yPF3k30yfvSx QJrw== 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; bh=Xkl1PEm6PjOKAdBEuYy5l8ljzm4XzkefiTF2G+osw9g=; b=r0nQcVFeEorsOpcipAD1FnbIpZep2ogSz6ygx9yWD6QUqMBBIDceWcMZCQABHyngXU VqobAjxsrEShjt9w6cfFYm1qbnTAvhJQs1fNOE/Hc0kY6JY04PdeJxHFSgHkWJSB3frD sKRX6WSzwyERZ3RM9snCajeS83Q5XGm2O/APodBQ90uVlcSpVF3YIQvpIpqyfzmrpwqd Hl7V62LgAWZ8OK28Sw3zHXSc5GusbCzk00s526AuzGf4d2i0H+bhfABxbxSSzPz7kvqs uEBf8zItqHHBUiMhmwnWcv4ivL37X3BKP/R9/BcdFEb9vrzAvPbGjNR7Afibt9i5/Qz1 GdrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=WfxjInaH; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w54si18099872edd.427.2019.10.16.00.35.06; Wed, 16 Oct 2019 00:35:30 -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=@broadcom.com header.s=google header.b=WfxjInaH; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390019AbfJOWq6 (ORCPT + 99 others); Tue, 15 Oct 2019 18:46:58 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35331 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728835AbfJOWq6 (ORCPT ); Tue, 15 Oct 2019 18:46:58 -0400 Received: by mail-pg1-f196.google.com with SMTP id p30so13033896pgl.2 for ; Tue, 15 Oct 2019 15:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xkl1PEm6PjOKAdBEuYy5l8ljzm4XzkefiTF2G+osw9g=; b=WfxjInaH8u7IeDqrg3R8m7CSa3YmVXEHADW0204Wh2b1NKxFkH0maH6HGfUvTHCTJH SX0t74KIu8UHc3mc4LQhFSJ5LP2p56s/JawwceVz8t5qhGbBxM8Hyr5evin/CH7kpEYI i/dP4QgPlyIFLgPrCsZARwLppOdt1ywuYPJqQ= 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=Xkl1PEm6PjOKAdBEuYy5l8ljzm4XzkefiTF2G+osw9g=; b=fkkQ5goWvfvGroMJNzveah/1f/qRKVrWMO5p1R5xnyWAxU2Ao8qmqry1PFOCokOiVI Z3y/FrfjLnG7u20kHAUw+iACUmh5wvJxJln/jrzA6vg+gCn6vx2bD/nmqrNIF5IXlF+p BnHNTCjlTd0OYAUkwSguHjjWAY+tFw4+I0U0BjUSn6qmPUa/Nd5xQa9KcjgfXRxvL26S XQFa3Kb140R5/DeiwMvm2SJiwtdfylUY9JtqOl1iomfakKUKqGcvMzzIZBJsOrYRO1yX oekUjvtbGp6MeL8+c08tGifOxrTldphBIrZL7TECWci6e82NVTnlK6YWHLV65FlsOYAi ZeZg== X-Gm-Message-State: APjAAAUfyHLaeWlKT5xI/IrQBGC3l1zYvdT5UAPh4BeGXl07oui50xTg BlYAvdVK8gghKj6fNYGPlYYyyg== X-Received: by 2002:a17:90a:32a6:: with SMTP id l35mr976437pjb.55.1571179617670; Tue, 15 Oct 2019 15:46:57 -0700 (PDT) Received: from lbrmn-mmayer.ric.broadcom.com ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id e127sm23019837pfe.37.2019.10.15.15.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 15:46:57 -0700 (PDT) From: Markus Mayer To: Brian Norris , Florian Fainelli , Gregory Fong Cc: Broadcom Kernel List , ARM Kernel List , Linux Kernel Mailing List , Markus Mayer Subject: [PATCH 7/8] memory: brcmstb: dpfe: Compute checksum at __send_command() time Date: Tue, 15 Oct 2019 15:45:12 -0700 Message-Id: <20191015224513.16969-8-mmayer@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191015224513.16969-1-mmayer@broadcom.com> References: <20191015224513.16969-1-mmayer@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Florian Fainelli Instead of pre-computing the checksum, do it at the time we send the command, this reduces the possibility of introducing errors as well as limits the amount of code necessary while adding new commands and/or new API versions. The MSG_CHKSUM enumeration value is no longer necessary and is removed. Signed-off-by: Florian Fainelli Signed-off-by: Markus Mayer --- drivers/memory/brcmstb_dpfe.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c index cf320302d2c0..7c6e85ad25a7 100644 --- a/drivers/memory/brcmstb_dpfe.c +++ b/drivers/memory/brcmstb_dpfe.c @@ -127,7 +127,6 @@ enum dpfe_msg_fields { MSG_COMMAND, MSG_ARG_COUNT, MSG_ARG0, - MSG_CHKSUM, MSG_FIELD_MAX = 16 /* Max number of arguments */ }; @@ -243,21 +242,18 @@ static const struct dpfe_api dpfe_api_v2 = { [MSG_COMMAND] = 1, [MSG_ARG_COUNT] = 1, [MSG_ARG0] = 1, - [MSG_CHKSUM] = 4, }, [DPFE_CMD_GET_REFRESH] = { [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND, [MSG_COMMAND] = 2, [MSG_ARG_COUNT] = 1, [MSG_ARG0] = 1, - [MSG_CHKSUM] = 5, }, [DPFE_CMD_GET_VENDOR] = { [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND, [MSG_COMMAND] = 2, [MSG_ARG_COUNT] = 1, [MSG_ARG0] = 2, - [MSG_CHKSUM] = 6, }, } }; @@ -273,18 +269,11 @@ static const struct dpfe_api dpfe_api_v3 = { [MSG_COMMAND] = 0x0101, [MSG_ARG_COUNT] = 1, [MSG_ARG0] = 1, - [MSG_CHKSUM] = 0x104, }, [DPFE_CMD_GET_REFRESH] = { [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND, [MSG_COMMAND] = 0x0202, [MSG_ARG_COUNT] = 0, - /* - * This is a bit ugly. Without arguments, the checksum - * follows right after the argument count and not at - * offset MSG_CHKSUM. - */ - [MSG_ARG0] = 0x203, }, /* There's no GET_VENDOR command in API v3. */ }, @@ -432,9 +421,17 @@ static int __send_command(struct brcmstb_dpfe_priv *priv, unsigned int cmd, return -ETIMEDOUT; } + /* Compute checksum over the message */ + chksum_idx = msg[MSG_ARG_COUNT] + MSG_ARG_COUNT + 1; + chksum = get_msg_chksum(msg, chksum_idx); + /* Write command and arguments to message area */ - for (i = 0; i < MSG_FIELD_MAX; i++) - writel_relaxed(msg[i], regs + DCPU_MSG_RAM(i)); + for (i = 0; i < MSG_FIELD_MAX; i++) { + if (i == chksum_idx) + writel_relaxed(chksum, regs + DCPU_MSG_RAM(i)); + else + writel_relaxed(msg[i], regs + DCPU_MSG_RAM(i)); + } /* Tell DCPU there is a command waiting */ writel_relaxed(1, regs + REG_TO_DCPU_MBOX); -- 2.17.1