Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2353929pxb; Mon, 20 Sep 2021 19:52:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7e+VisN/qlrYdSj7D2ipmgX4cuP/fCPVfzKXbW9tlU6x1psfTKgK8RxDwB5vxJ5mgyty1 X-Received: by 2002:a05:6638:1030:: with SMTP id n16mr16066011jan.36.1632192771765; Mon, 20 Sep 2021 19:52:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192771; cv=none; d=google.com; s=arc-20160816; b=lsK5BYT8iUaeXKsBrAaxCVwdVgSVC2lel29eh5GKKkex1QMr4KxDK/bERAWwBKDE+2 l0rSPvuEaV7CexAzwQM0qvkL8zKvDc43ODGNuDu4SA7fxP2qOOBCLZRt0EQSaKMA5Sg+ CLupyPnFQ1oH4KGlk68h+eQ/7t8Lnkkj9byBWB0PL4GxZ7eAIKyUFXguSq9wTzAmpXrt +HlTY4G14VOm7YR97y82VLoUVTcDThg1DaISdh35KZ4rR4gf3l5NJcjubaZW1WljmA1y agSiLIle7nO/c3BXqDN8oB5iL+FOLu0kgMdWgXcEDitwCyhjaa9hXeUfXAg6P+iK4F+O Yf8A== 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=aUKxAfuhqfeHJxFcdr/5KWZr+3RvdI1iykedv3w+fws=; b=G4jq0Ok16VZwm7/MV1Lq/Kt2E0bymdHHEhSSa+zPZSPL8kjGtcSzbUllZPxHbN+LAz +LPoWRIebywRErkjL8OJ8xgYy8Ud3FvSvtaEfWcK/ygfDNXHm2f8yzAIX+z4NaPQ7PjP yOUdoGXeWhQQ075ER9/SlOjnCVOZu/HXETNRzREjitWFoFxx734E5ozBo8nIVfadjvRV 2kaoscn7DabH4QH524eTmMMBPFKI9vvGppjPNjPSxJn36JJXKcSqAUpBbEbDSGN/WQun oWJgChki7BTqPQMALw2lignEMrHBzIdakguwyHYFgT1kmLLDNqcp6IpnYWux3BLnnaXA dJVg== 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 67si8861296ioc.91.2021.09.20.19.52.40; Mon, 20 Sep 2021 19:52:51 -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 S1385980AbhITSxA (ORCPT + 99 others); Mon, 20 Sep 2021 14:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385494AbhITSu3 (ORCPT ); Mon, 20 Sep 2021 14:50:29 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3043C0A8888; Mon, 20 Sep 2021 10:04:23 -0700 (PDT) Received: from guri.fritz.box (unknown [IPv6:2a02:810a:880:f54:34ca:272f:b5af:bab9]) (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 914251F42EBB; Mon, 20 Sep 2021 18:04:21 +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 , dafna3@gmail.com, tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com, minghsiu.tsai@mediatek.com, houlong.wei@mediatek.com, mchehab@kernel.org, matthias.bgg@gmail.com, hverkuil@xs4all.nl Subject: [PATCH v4] media: mtk-vpu: Ensure alignment of 8 for DTCM buffer Date: Mon, 20 Sep 2021 19:04:08 +0200 Message-Id: <20210920170408.1561-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 multiple 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 Reviewed-by: Houlong Wei --- changes since v3: 1. multile -> multiple 2. add inline doc 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 | 15 ++++++++++++++- 1 file changed, 14 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..1df031716c8f 100644 --- a/drivers/media/platform/mtk-vpu/mtk_vpu.c +++ b/drivers/media/platform/mtk-vpu/mtk_vpu.c @@ -349,7 +349,20 @@ int vpu_ipi_send(struct platform_device *pdev, } } while (vpu_cfg_readl(vpu, HOST_TO_VPU)); - memcpy_toio(send_obj->share_buf, buf, len); + /* + * when copying data to the vpu hardware, the memcpy_toio operation must copy + * a multiple of 8. Otherwise the processing fails + */ + 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