Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp286759pxb; Wed, 25 Aug 2021 03:19:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzodgGHLlQDgpn6/TQRFpDxlal7MIio+BmZpZbnnntOs28jmEZC2FDBNOn6erT2Es6UXfM+ X-Received: by 2002:a05:6402:48e:: with SMTP id k14mr48524991edv.212.1629886780644; Wed, 25 Aug 2021 03:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629886780; cv=none; d=google.com; s=arc-20160816; b=EbSmvO1qOQO/UPvGSiUaR9xVVfkcn5QJsFeupV7510BKguiznRq95e02ucfM2mcqzr 2RqaDD5shxxBwpOqaSp1pCnEPqzlCtyKFHfZ2TzBM3jvFzY1kIHfGh84Jt152k2nPZ+m GQe3qYpifx4n5sHTaI0Mc1F9jVS2ePP/3HxYh9GIs8nb9aYDsCHziYtUfGhvuvleqd8n OMrxye1HnLboHg1jNEQ84nvZwLjpgyNC4OpKoCcY1zNvXCpCIFm3D9xyHJebus8SLUxZ h4ZwR0jy236BGZwMR5CKxjyi03u9muBElGSLlKOcezhldV68VmwDYX6fhJQLCG1mHCK0 bxfg== 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=6CVMAiRBRgRTN3YK/yTRAcg+yr3Gp6PH6K204+xNpb0=; b=V7RrtsOpnM1kK/vYep8RwT792ZR/CWDC7HDKsuMVYg0Ykr3MVna3snofmT+jY64YLC xRz1fk5Zk6N2RwmgpjHcMXlIj3t2ONMVUdkJ5hcHlEg1WysuqS7YZUoIJBIDUOzLd3rA 9oZiNAvuyhXLwFV+KCaCz1bc8BUNxGRtyyVua2sPZcPAtjW3gLvsE7tXLblfYROWno0b LJRQsgGoxlDXO8Ib63ezDFlP8lb5RTmoObsnLpeH7rgd6ShggJA/mNpEdH0HH8qO8M7m kiGvzPog6or7Yutd6ccRJ0dwsxsfVvbTiXkQMG+DQ3b8kbtXQtUZtrt6RFdKb77OoH3b c2qg== 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 a19si12317405edt.168.2021.08.25.03.19.17; Wed, 25 Aug 2021 03:19:40 -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 S239654AbhHYKST (ORCPT + 99 others); Wed, 25 Aug 2021 06:18:19 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47912 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239525AbhHYKST (ORCPT ); Wed, 25 Aug 2021 06:18:19 -0400 Received: from guri.fritz.box (unknown [IPv6:2a02:810a:880:f54:c5f4:b90c:545d:197]) (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 DAAC61F436B4; Wed, 25 Aug 2021 11:17:31 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Courbot , dafna.hirschfeld@collabora.com, kernel@collabora.com, Enric Balletbo i Serra , hverkuil@xs4all.nl, 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 v3] media: mtk-vpu: Ensure alignment of 8 for DTCM buffer Date: Wed, 25 Aug 2021 12:17:17 +0200 Message-Id: <20210825101717.18075-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 ensures the 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 v2: 1. do the extra copy only if len is not multiple of 8 changes since v1: 1. change sign-off-by tags 2. change values to memset drivers/media/platform/mtk-vpu/mtk_vpu.c | 11 ++++++++++- 1 file changed, 10 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..658161ee3e4e 100644 --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c @@ -349,7 +349,16 @@ int vpu_ipi_send(struct platform_device *pdev, } } while (vpu_cfg_readl(vpu, HOST_TO_VPU)); - memcpy_toio(send_obj->share_buf, buf, len); + if (len % 8 != 0) { + unsigned char data[SHARE_BUF_SIZE]; + + memset(data + len, 0, sizeof(data) - len); + memcpy(data, buf, len); + memcpy_toio(send_obj->share_buf, data, round_up(len, 8)); + } else { + memcpy_toio(send_obj->share_buf, buf, len); + } + writel(len, &send_obj->len); writel(id, &send_obj->id); -- 2.17.1