From patchwork Wed Aug 16 17:18:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 110265 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1066848qge; Wed, 16 Aug 2017 10:20:04 -0700 (PDT) X-Received: by 10.84.217.24 with SMTP id o24mr133593pli.218.1502904004586; Wed, 16 Aug 2017 10:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502904004; cv=none; d=google.com; s=arc-20160816; b=Ka5qRhXALf57xom1wccNfl9/vOEFcAE50Xw18C/S30qWcWuhRjcwBZK9XZHNnTW91L LZZaAcx6vjEGrQqENSeoNxb8L37mJZ1WkHp66/8uuiA27ahCyYTtoOHOjyYb9aUvAPzR 0eseU8ZZ3BjY5Fy2f9O0skPEkO9k1pZyv7c+8uVzduoXckAn9N+Pveik+rh6JhUBoy0d E2vEBm7zq5bMnoOKuXVWZ6ilm1iImjdAcT/XwGU2sDyd08lu/n5ruoiH3M/bLn1iFkHl pahWbzS/NRjnJ1fo0hXP7f5B7qWQIIouw9Bt5Yq1gbGy3MMk045pckgD00/spnX1msP0 VQUQ== 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=ZQbsV1Gnl2dUNNOQ8qF7y0yQUn568Bwf7HQj9cyXgGc=; b=NglQhFgRgWWoiS9/Bgc0mD3Xlu6ms30u5Cj81l22dsGShZK+ScO26uyZuFWLDaZMpJ AbjMAo+dPZ26Ho9QwubA94beMT1lHWB1H0zsG7ON+ODZbVY2XIMRlKEcC3zZqIvtIpzd 10/G59DGYY8quP7TiaEw07LDDjkjQ8FD3y1q7aWZ8a7U8C2fFsUQ0Hipe9Bfu+fq0z7u 5B6qj1364zx+CKtkmlqcvWCn8LZmEAkawLCFsN+UrJO0aF7s3w+o2Xjx62AccK5tX+Cy AmQJnQVv28PySKzDrN6pvkf5ORJ1F1v9HAUYXN9tlcxtowtV1Q5HiDWaQS5xSqDp6yvW /GBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KsY/Ylbv; dkim=pass header.i=@codeaurora.org header.s=default header.b=IfZHq43l; 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 e28si733110pgn.916.2017.08.16.10.20.04; Wed, 16 Aug 2017 10:20:04 -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=KsY/Ylbv; dkim=pass header.i=@codeaurora.org header.s=default header.b=IfZHq43l; 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 S1752732AbdHPRUA (ORCPT + 26 others); Wed, 16 Aug 2017 13:20:00 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:51512 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751969AbdHPRTz (ORCPT ); Wed, 16 Aug 2017 13:19:55 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D9827606DC; Wed, 16 Aug 2017 17:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502903994; bh=o1jj8dkET8+SXLJ2x8jXeKjbKkB1fWvz9RW/5fZ//9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KsY/YlbvvmsWSy0WqH5lutJJZDYmAh0hBmiJFI2Z27NNDwTU82+1Q9RbMsp7xGYCd cowgvXMY0tCvFPlcNvTzqPNUPbUJyDo8CDlbL357GnmCLoWZUJ9+nTY+oY8oX3oboo k4qUb34lsn8RF4F2uJTts4enFloGyNAhNumtO9gY= 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 8CBC660766; Wed, 16 Aug 2017 17:19:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1502903983; bh=o1jj8dkET8+SXLJ2x8jXeKjbKkB1fWvz9RW/5fZ//9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfZHq43lQliyw5WaXkHDdwIt5CBDwCQ9NN97WSOGgIj5pDVZM6/VHabDEE1dHOnxI hLg0g1tbcyMiCaVqwGjBReaBp/y37a/P5WxoA/a2BwUyHbOlExxhDk6vFbIDsW+0Rp aOj4Syc2FfYpCKwh8AJ7vO5ffjBkbQnPDM8aVVZo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8CBC660766 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 05/18] rpmsg: glink: Allow unaligned data access Date: Wed, 16 Aug 2017 22:48:58 +0530 Message-Id: <1502903951-5403-6-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1502903951-5403-1-git-send-email-sricharan@codeaurora.org> References: <1502903951-5403-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 04afbb2..1aa92daf 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -226,9 +226,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; @@ -694,9 +691,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); }