Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp276314pxt; Fri, 6 Aug 2021 01:33:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7ijb8wozntwU8YGTz+SayzdyMDIhRDTCZ9+q8vJBDeT6GcLz0e+sCw1Rf8bTvUhxWGPur X-Received: by 2002:a05:6402:518c:: with SMTP id q12mr11399956edd.205.1628238799059; Fri, 06 Aug 2021 01:33:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628238799; cv=none; d=google.com; s=arc-20160816; b=fhlUYSYkY1P3wLPDc54zh28+vyHHYVZq1kfqhiz3Uui/i9DbiR2GYMejA3hPUJ68g0 fwj//gWEbhO0B6gkuIWEq1zwXmLYpO+maBtz8TXMeP6ow/yk4RNhrj28uJUvlv2FGcfM Y3/HL5PaeS3TRBNeEQm9XATAbT1ltehVKPDAcT7ulOuTTlhDsJbySpRQxTKmO4WVn2QR v00jwPpphTHiJXXrWPPdZFyxdQjsMqWAyLoTDm+EA4DMzTWn5aaJ3xdivHI29t453qlw j/e+cvLvezb5GhxGuIecdIylveoCN0O+mU4FaeoNHjAb7SMYoXERxis7CJuKoTPYTe4e Iovg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=BPVnxPPEfts0hZwMo8QxSpbIgswUZ8cROsAhTw0uwB8=; b=GBLkUxJQyKQtaBd5sNjaSx0+emvvspz0l+tKUywulG7BIvWjYBvF67jDVMSyj3N905 dz6lE+UhQWEzDUFsEVq/FqOcM3Sve1nzBWg6FtF2wgpmsaIzBUxxN/x8DvN+WGU5Angr pOBZ9r68L8uLSDZfO9Xwd6Ho5OA+gFLdJ6sJAr0WpgGa5+cgxecddcw844MdyHcAJ9U+ ZRq1uC+l0AEP8rkmE3bQevUkctAsre/UbErIQD/gMmgIKjIU40UNzli+XUTgH+Jxrn7A gSlydA3POZ0v6S8TY8EdUVHCL4Okfslj83HTkwwozOg+v0fykCkllyGA/m2VTuMa1UMl PauA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bv8si8912418ejb.87.2021.08.06.01.32.55; Fri, 06 Aug 2021 01:33:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243407AbhHFI3n (ORCPT + 99 others); Fri, 6 Aug 2021 04:29:43 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43504 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244664AbhHFI3R (ORCPT ); Fri, 6 Aug 2021 04:29:17 -0400 Received: from guri.fritz.box (unknown [IPv6:2a02:810a:880:f54:ec56:4a95:44cf:a8a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 86E691F413B3; Fri, 6 Aug 2021 09:28:59 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Courbot , Enric Balletbo i Serra , Dafna Hirschfeld , hverkuil@xs4all.nl, kernel@collabora.com, dafna3@gmail.com, mchehab@kernel.org, tfiga@chromium.org, minghsiu.tsai@mediatek.com, houlong.wei@mediatek.com, andrew-ct.chen@mediatek.com, tiffany.lin@mediatek.com, matthias.bgg@gmail.com, courbot@chromium.org, hsinyi@chromium.org, eizan@chromium.org Subject: [PATCH v2] media: mtk-vpu: Ensure alignment of 8 for DTCM buffer Date: Fri, 6 Aug 2021 10:28:10 +0200 Message-Id: <20210806082810.9378-1-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Courbot When running memcpy_toio: memcpy_toio(send_obj->share_buf, buf, len); it was found that errors appear if len is not a multiple of 8: [58.350841] mtk-mdp 14001000.rdma: processing failed: -22 This patch ensure copy of a multile of 8 size by calling round_up(len, 8) when copying Fixes: e6599adfad30 ("media: mtk-vpu: avoid unaligned access to DTCM buffer.") Signed-off-by: Alexandre Courbot Signed-off-by: Enric Balletbo i Serra Signed-off-by: Dafna Hirschfeld --- changes since v1: 1. change sign-off-by tags 2. change values to memset drivers/media/platform/mtk-vpu/mtk_vpu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mtk-vpu/mtk_vpu.c b/drivers/media/platform/mtk-vpu/mtk_vpu.c index ec290dde59cf..66276c5a1bc3 100644 --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c @@ -316,6 +316,7 @@ int vpu_ipi_send(struct platform_device *pdev, { struct mtk_vpu *vpu = platform_get_drvdata(pdev); struct share_obj __iomem *send_obj = vpu->send_buf; + unsigned char data[SHARE_BUF_SIZE]; unsigned long timeout; int ret = 0; @@ -349,7 +350,9 @@ int vpu_ipi_send(struct platform_device *pdev, } } while (vpu_cfg_readl(vpu, HOST_TO_VPU)); - memcpy_toio(send_obj->share_buf, buf, len); + memset(data + len, 0, sizeof(data) - len); + memcpy(data, buf, len); + memcpy_toio(send_obj->share_buf, data, round_up(len, 8)); writel(len, &send_obj->len); writel(id, &send_obj->id); -- 2.17.1