From patchwork Thu Aug 24 07:21:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 110868 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp8065377ybm; Thu, 24 Aug 2017 00:22:23 -0700 (PDT) X-Received: by 10.99.133.65 with SMTP id u62mr5459866pgd.100.1503559343057; Thu, 24 Aug 2017 00:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503559343; cv=none; d=google.com; s=arc-20160816; b=uPzZKKsL9hEF1HZDb7aEGDwzHlxHwTg3VYJ9ybXAr2MF2Axm7TTnJcLq6D2HjQz8bE E2BvJXUDNRqZOhhpgQ8GLx8Gm3TR6XbPwvUEpWKzXQUvbWH9A2UQ2waiI1k3FnQjVRMH jw8Ch/Nlohf4GuYXqBALZUqIpcoJAsiiiLabt5dPFv0GJMjyfECmyulKv9Th7HofcMc2 WrLfpfNtkyY92JGfMQ1ZTd83IMw8pjZ7/DzjFx6gEH9/YJVPbmexqwW8yKjhvY3e30nk yqM92YiI68Rn/IoloESTsjzv9FpfAD3WjXY4RRkqrgozZiHtU+4enl0A4PS5K0CQQ9Ex lVug== 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:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=2XX+0Fv81dAmPk3EWnAQUKq9UodzOt/b24x8qRYLqDQ=; b=ZgeSnlJLnWRytNhdKM8B3jwx0q1HtQFMNn18lR/+Vmxft3bVh4hE6Kc96kBIjxk1ss 7+yBdKAalbdLjT4cRgOxf06rZVRGCEDIV8qJNPdfQr6b5a/HzyS2AML3AnKtbu1atwZ4 rznKIRfMUycI4Eixb8S7b6bp6m23Te11QSEhTaspCdudUNapyAe392yFY+wpFR4VcnB7 SWBqVN5QmIOa0ziltdf5kXffyVx+DSoDtI59aoLoYAKNVVDwlfA7fay7yqftCwZDHc5l XlV79D1aXbtZ7CB3XB2YWqSK+rNTdBpmpUR+rym9D0foXJO/RcB2x/h3P/eqDlMX8XwT JRXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=mKEREwwa; dkim=pass header.i=@codeaurora.org header.s=default header.b=bxPc2jNz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si2305360pgc.533.2017.08.24.00.22.22; Thu, 24 Aug 2017 00:22:23 -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=@codeaurora.org header.s=default header.b=mKEREwwa; dkim=pass header.i=@codeaurora.org header.s=default header.b=bxPc2jNz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751596AbdHXHWT (ORCPT + 26 others); Thu, 24 Aug 2017 03:22:19 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:60560 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751135AbdHXHWP (ORCPT ); Thu, 24 Aug 2017 03:22:15 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DD7A9606DB; Thu, 24 Aug 2017 07:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559334; bh=F5wuKVAc22GDS+S7y7cf4o0UspSuXC6XE0TsBgF+h6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mKEREwwaab2QyLVphjZU5DaMv1a1omyAbnd2tBHtWBD2TZeFJDFO1uaaZlcCu+bXf lgCPr1zuPj+8IT4woRKKJt5emlvhxXd9c87T9SuSn08FrMk6Kuu/W7mdpiSVbD/1Tb H9BaLMZRoJnF5idNsxG39Yl25XjuaMFJmJMfXIFI= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from srichara-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 431996071D; Thu, 24 Aug 2017 07:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1503559330; bh=F5wuKVAc22GDS+S7y7cf4o0UspSuXC6XE0TsBgF+h6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxPc2jNzAiklWZbN8vFiScZfxIqFuH+o4izfD9WdDZgAUSaikfApN0q+aGm1D87ZA Y+wZy5g+SjKUhkj7y26lpC+lt+iN4WTkuvOB9cWghVGHYr/ma2onv7kBX9wmaUKsPZ Da9InJMGJsYTLkKiYjr1VV/vgLogwTG0HqUVDq2Q= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 431996071D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=sricharan@codeaurora.org From: Sricharan R To: ohad@wizery.com, bjorn.andersson@linaro.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sricharan@codeaurora.org Subject: [PATCH v2 05/20] rpmsg: glink: Allow unaligned data access Date: Thu, 24 Aug 2017 12:51:27 +0530 Message-Id: <1503559302-3744-6-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503559302-3744-1-git-send-email-sricharan@codeaurora.org> References: <1503559302-3744-1-git-send-email-sricharan@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Andersson Glink protocol requires that each message is aligned on a 8 byte offset. This is purely a restriction from glink, so in order to support clients which do not adher to this, allow data packets of any size, but align the head index accordingly, effectively removing the alignment restriction. Signed-off-by: Bjorn Andersson Signed-off-by: Sricharan R --- drivers/rpmsg/qcom_glink_native.c | 6 ------ drivers/rpmsg/qcom_glink_rpm.c | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index ffdf88e..a6394cd 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -227,9 +227,6 @@ static int qcom_glink_tx(struct qcom_glink *glink, if (tlen >= glink->tx_pipe->length) return -EINVAL; - if (WARN(tlen % 8, "Unaligned TX request")) - return -EINVAL; - ret = mutex_lock_interruptible(&glink->tx_lock); if (ret) return ret; @@ -695,9 +692,6 @@ static int __qcom_glink_send(struct glink_channel *channel, __le32 left_size; } __packed req; - if (WARN(len % 8, "RPM GLINK expects 8 byte aligned messages\n")) - return -EINVAL; - req.msg.cmd = cpu_to_le16(RPM_CMD_TX_DATA); req.msg.param1 = cpu_to_le16(channel->lcid); req.msg.param2 = cpu_to_le32(channel->rcid); diff --git a/drivers/rpmsg/qcom_glink_rpm.c b/drivers/rpmsg/qcom_glink_rpm.c index 33daa32..cc73af0 100644 --- a/drivers/rpmsg/qcom_glink_rpm.c +++ b/drivers/rpmsg/qcom_glink_rpm.c @@ -156,11 +156,31 @@ static void glink_rpm_tx_write(struct qcom_glink_pipe *glink_pipe, const void *data, size_t dlen) { struct glink_rpm_pipe *pipe = to_rpm_pipe(glink_pipe); + size_t tlen = hlen + dlen; + size_t aligned_dlen; unsigned int head; + char padding[8] = {0}; + size_t pad; + + /* Header length comes from glink native and is always 4 byte aligned */ + if (WARN(hlen % 4, "Glink Header length must be 4 bytes aligned\n")) + return; + + /* + * Move the unaligned tail of the message to the padding chunk, to + * ensure word aligned accesses + */ + aligned_dlen = ALIGN_DOWN(dlen, 4); + if (aligned_dlen != dlen) + memcpy(padding, data + aligned_dlen, dlen - aligned_dlen); head = readl(pipe->head); head = glink_rpm_tx_write_one(pipe, head, hdr, hlen); - head = glink_rpm_tx_write_one(pipe, head, data, dlen); + head = glink_rpm_tx_write_one(pipe, head, data, aligned_dlen); + + pad = ALIGN(tlen, 8) - ALIGN_DOWN(tlen, 4); + if (pad) + head = glink_rpm_tx_write_one(pipe, head, padding, pad); writel(head, pipe->head); }