From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93EF4C43217 for ; Mon, 20 Sep 2021 17:04:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5E85E61AED for ; Mon, 20 Sep 2021 17:04:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5E85E61AED Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=P9DAvMzhTneekkTIkTldX4B+2ew9j32kASJagWLLGoE=; b=DejpaSiAlZ6sEf X3TkByVwq3031XiSxk10aenGha5jLRoq4ZvOh5BkIFyYfcwhCCCa8R1y4gFctms28XKL+EJmWDFIn 1xKpt/fndH9eBGgu81+4AyHQPKw+3LGLtl1GXbLHY/8Z7GE27Pfcbl7+LrJ7viBvfPOsD+gAtEKNd 5qAaVMYlQjp9AEc7gVAEAVVpOvmJ+Pt6RJUhVB1FifPofU1dZ7UJqf2Qi2fTwiZ0nCZskAVunp9F3 sUDLozhhP5EOOws/lSdWZBD0qvjhv0S+mGy1sUW8Kxd3jsrYF9Vky05EKS/I1Df0xwDG22+/FvUv8 tfMZ8Lh5gDK8nr9TnPcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSMiU-002Wx3-1M; Mon, 20 Sep 2021 17:04:30 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSMiQ-002WuL-QN for linux-mediatek@lists.infradead.org; Mon, 20 Sep 2021 17:04:28 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210920_100427_014505_06C93A28 X-CRM114-Status: GOOD ( 12.57 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 472EFC433FE for ; Mon, 20 Sep 2021 18:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EE9E610A8 for ; Mon, 20 Sep 2021 18:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385988AbhITSxC (ORCPT ); Mon, 20 Sep 2021 14:53:02 -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