Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp521673pxk; Wed, 2 Sep 2020 07:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhcS/MUCxIlOovld9onVLHwYgMgDBM86ZHUI1USju1o5nrcLOaVP8ucW2XMJ+C2WNl7kn6 X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr466417edb.214.1599058480249; Wed, 02 Sep 2020 07:54:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599058480; cv=none; d=google.com; s=arc-20160816; b=K5/KSp7i0JD4S9g9du+r7WG9U5FU2DgA7SJNadHruadEfnzJNRFoa3XQJ0bqSFqlFI n+PGocOzkSsojJHSGhbCrjOpCH7nURHIi0ubgEFtVtOt+MvkpN6rmZjesCBpZ4EgnJlp U2OAqwtERM6cCGW46P7xMRDi8O2Ju9P4ZHJixlFS5MARHI1EfByGjORVCPz9UfpUBEhM EVunRio6ricH5bljTQUX8AFV2+yRlNXzD2eMfRZAm31uRtNZhIz+j+tbvoc8dpLvTjHk jv+TSYdBJTrDTDVefDcwfUEU3GkFCLPSKIPbQVhi68mUqS8BT1YC1nbWbCQ8oGxMnEc8 u+vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=EsQpeI7D1H5k/d2ldZ6dL5UBletkvcQ405Mqk41kvtA=; b=BTicwoySw7B904LpucpyhGMQS1+XNVROXiNnh3TU8Ysh6RD5SIlaABblr2jAD3EA7Y Z8cG12DkkmpNoMgDgjze247gzVvL/Mv1SA055Z+xOQivF2+RznnsuAGNgho9vR1gao7L bbbR1EGk782jz4hC/G9mNkvrEFGCj2lZzOLgKqyfCdoYXubLdamYbBczGSg/wq/XB8j0 R2pCBcvSGzu8fkFyNom7Una5vrC4JVSQOYeVyW/xkIIkVqXCibKEJH6MIAbSGdQJQJFp +ot7uXCmqk8UssuzsYVxhcxH9zDvKGE8mcTfwzvxaGDnzrUJUwL+PsF6tus2J088IMB2 mMZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OFHTYHEq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r3si2599492eja.548.2020.09.02.07.54.16; Wed, 02 Sep 2020 07:54: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; dkim=pass header.i=@chromium.org header.s=google header.b=OFHTYHEq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbgIBOxk (ORCPT + 99 others); Wed, 2 Sep 2020 10:53:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbgIBOx1 (ORCPT ); Wed, 2 Sep 2020 10:53:27 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71FB3C061244 for ; Wed, 2 Sep 2020 07:53:27 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id p13so5228057ils.3 for ; Wed, 02 Sep 2020 07:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EsQpeI7D1H5k/d2ldZ6dL5UBletkvcQ405Mqk41kvtA=; b=OFHTYHEqJUI+FtLrE6PAi2aZwioFNMDfiqJjDZVXi/KHUzL54VOMwMkSZ/Na4d4Ogw OflZqUSOYEI/YWnGu7gZBbi63l+atE12YXmZ0ywQPPRb7gqc6b+FVmj0taaL11erEQnH 0mPWDuTQEQy4kc7PVUtsjcTMS4PkoSyJxV4Yo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EsQpeI7D1H5k/d2ldZ6dL5UBletkvcQ405Mqk41kvtA=; b=aFnygjT9tmYM6Zjb50rqXuEGwd53Dfn4IjzhxZwQXP+xL5fk0tvqGI8mgZ5TXCddgJ VKBCESyQI1QR4XkAYZt0sa4G5Wrfn15+4wul6a/9F15weIhAMjyNvAVWrhs8OAc8U15o KcDmrBzqpIUF+8jkhWzFpO78B2azhPc7ptCGNn3ModjdPsi7uc38IHVcIWg+XlcSXULb thMz0YMZ00fasMEXrSgikMTx7b8wIPYEkEB9kV0N1VwkMidnpYQKqKmyrwFJgt4x0E+7 M8a/7Y+LmCzIQh2uiB1AIKGNFAVfUgGQYHO3S+0dwawd9iLJ4dAEcqqa7qv11xVTNQ7p 4/gw== X-Gm-Message-State: AOAM530fNOJ3VD24Zyv3Z0oCvOoA17bSaIhXzI5Od0aVHRhjkq2m5PpB bEv+k4GRbwVh+VZsina+X2p9M65JBZYlPuHUs2ecxw6rG0yhEA== X-Received: by 2002:a92:c008:: with SMTP id q8mr4094957ild.106.1599058406623; Wed, 02 Sep 2020 07:53:26 -0700 (PDT) MIME-Version: 1.0 References: <20200821041414.1560707-1-hsinyi@chromium.org> In-Reply-To: From: Hsin-Yi Wang Date: Wed, 2 Sep 2020 22:53:00 +0800 Message-ID: Subject: Re: [PATCH] media: mtk-vcodec: set dma max segment size To: Robin Murphy Cc: "moderated list:ARM/Mediatek SoC support" , Andrew-CT Chen , Tiffany Lin , Alexandre Courbot , Irui Wang , lkml , Anand K Mistry , Matthias Brugger , Mauro Carvalho Chehab , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , linux-media@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 2, 2020 at 10:25 PM Robin Murphy wrote: > > On 2020-08-21 05:14, Hsin-Yi Wang wrote: > > Set dma max segment size for encoder and decoder driver. > > > > Fix following warning with CONFIG_DMA_API_DEBUG_SG=y > > > > [ 75.147825] ------------[ cut here ]------------ > > [ 75.147844] mtk-vcodec-enc 19002000.vcodec: DMA-API: mapping sg segment longer than device claims to support [len=983040] [max=65536] > > [ 75.147876] WARNING: CPU: 2 PID: 4069 at kernel/dma/debug.c:1302 debug_dma_map_sg+0x1a8/0x2c4 > > ... > > [ 75.148139] Call trace: > > [ 75.148149] debug_dma_map_sg+0x1a8/0x2c4 > > [ 75.148165] vb2_dc_get_userptr+0x228/0x364 [videobuf2_dma_contig] > > [ 75.148178] __buf_prepare+0x3ac/0x8c0 [videobuf2_common] > > [ 75.148188] vb2_core_qbuf+0xa4/0x58c [videobuf2_common] > > [ 75.148199] vb2_qbuf+0x88/0xe4 [videobuf2_v4l2] > > [ 75.148211] v4l2_m2m_qbuf+0x80/0xf8 [v4l2_mem2mem] > > [ 75.148221] vidioc_venc_qbuf+0x3c/0x70 [mtk_vcodec_enc] > > [ 75.148234] v4l_qbuf+0x48/0x58 > > [ 75.148242] __video_do_ioctl+0x200/0x37c > > [ 75.148250] video_usercopy+0x360/0x834 > > [ 75.148259] video_ioctl2+0x38/0x48 > > [ 75.148267] v4l2_ioctl+0x6c/0x80 > > [ 75.148276] do_video_ioctl+0xefc/0x4b70 > > [ 75.148284] v4l2_compat_ioctl32+0x5c/0xcc > > [ 75.148294] __arm64_compat_sys_ioctl+0xf4/0x240 > > [ 75.148304] el0_svc_common+0xac/0x198 > > [ 75.148312] el0_svc_compat_handler+0x2c/0x40 > > [ 75.148321] el0_svc_compat+0x8/0x18 > > [ 75.148328] irq event stamp: 0 > > [ 75.148337] hardirqs last enabled at (0): [<0000000000000000>] (null) > > [ 75.148347] hardirqs last disabled at (0): [] copy_process+0x380/0x115c > > [ 75.148356] softirqs last enabled at (0): [] copy_process+0x398/0x115c > > [ 75.148364] softirqs last disabled at (0): [<0000000000000000>] (null) > > [ 75.148372] ---[ end trace 588bf529451e3531 ]--- > > > > Reported-by: Anand K Mistry > > Signed-off-by: Hsin-Yi Wang > > --- > > drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 8 ++++++++ > > drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 8 ++++++++ > > 2 files changed, 16 insertions(+) > > > > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c > > index 97a1b6664c20..3bbd0bac56d6 100644 > > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c > > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c > > @@ -242,6 +242,14 @@ static int mtk_vcodec_probe(struct platform_device *pdev) > > mtk_v4l2_err("[VPU] vpu device in not ready"); > > return -EPROBE_DEFER; > > } > > + if (!pdev->dev.dma_parms) { > > + pdev->dev.dma_parms = devm_kzalloc(&pdev->dev, > > + sizeof(*pdev->dev.dma_parms), > > + GFP_KERNEL); > > + if (!pdev->dev.dma_parms) > > + return -ENOMEM; > > + } > > Since 9495b7e92f71, dma_parms is included in the platform_device itself > and always set, so you can drop these allocation paths. > > > + dma_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); > > The segment size is simply a size, not a bitmask, so UINT_MAX would be > more semantically appropriate. > > Robin. > Thanks. since this patch is already in media tree: https://git.linuxtv.org/media_tree.git/commit/?id=13483fc2f20f0e2db7ba9c39b095ac7ea46f8de8, I'll send a patch to modify this.