From patchwork Mon Apr 22 17:03:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13638786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AAD6EC4345F for ; Mon, 22 Apr 2024 17:05:31 +0000 (UTC) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=YFF5TkCSNEbF/jH3awfTeO5SqzdEm6DnFi+fe1kJBMo=; b=S1IQXPYZWnhQOu e2MwSCvMp7OS/+NYGYv6IaDVPrMus2KActmLXWW+6NkSWQigMvXesrfXlgHW4fueNn2KktJlrOMZn vA7fkJZwtox+uEf/q1XE6oUY7R1NNDmCKNMFla2dC60Q8rQVZuqo0j8aYbtzDFdBFUn9RjJ1pFpq5 3aqG1fXFjIcdMOG1O1OX4wNlFS0k5QLqg0Fsr9TvKvO/mnnoN2NYwnUqQnTBJFB6/K5BNF3gZykGK OgqQmlQ3j4uyXaR8B67TRtWxfBcPQq/9f/1a3WmeeiIMpVp7Qw6uSUrlfWZy/aW+T74C4eTxpijVX bNxQwpuYkZtHvzh7NmfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryx6W-0000000EQVn-2xoA; Mon, 22 Apr 2024 17:05:20 +0000 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ryx6S-0000000EQUa-3sKk for linux-arm-kernel@lists.infradead.org; Mon, 22 Apr 2024 17:05:19 +0000 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6eff2be3b33so4493104b3a.2 for ; Mon, 22 Apr 2024 10:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713805514; x=1714410314; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tSkyOzxUcdbMqzp03KnrhjrfOdlW3TL2PUxe3CYy+uU=; b=DzGdwx4W+4Dhv23mFXs7/raq4mB8ER5n/onImRa+BMxptR03wyQE5kDC8+GoXOamIe t2uGn1DVm0MlpfAqqG1pIW4Ne+vPmTKj87m+XFiq7ZFdK4pqoCtdBXaXf3oujL87mnRE lPITJhZJfevJZqpchHPdvwZkEX0Aq0uCBp/Zg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713805514; x=1714410314; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tSkyOzxUcdbMqzp03KnrhjrfOdlW3TL2PUxe3CYy+uU=; b=WksFHEDXHpe0fQ8jZxSrhd/fFpxjhoT1CRg7/LaQSnGujidO4iOce8sjOuTLQYSPbo wOwVRQrFrYvhDdziZvQ5mpoGrATD6GYbE07jU1t3BrXlTGM4kcxqTvxqgyFSc6JpCQND 6oFNJx5gleHJuIud5MhsxTppQPdYSp6qkt9msV6lyB8tLHvMF8xc0Uh/T8lpLBOirs4u CBoIydPTicNA+9pyTjTXafXaIFz6583dAcXjF3wdzwl2bBjlOp9PVAOFPNU16PdCWnKV 1tkLskjHK3ywu96UEiVhSo0JG5qBtNZRULewm0wg/GGOQBl/3xMLrxVzH5jGwAkS5arz waag== X-Forwarded-Encrypted: i=1; AJvYcCVXp8EzxFB4NKK0SbayLzIapWLUZpWM/LLt9cCwC17vN/4yLpY5LiVoK5KzX+ba3Kb9GyjJQD0Hra2wO1AkzM78B3tkUQ0SMz9ZOrfH9h5L0W5r1OE= X-Gm-Message-State: AOJu0YzLvtqo172uSuZ0DMxnW9pp1Ljyw8sOeOdsIdHU2b4ZiN08G9Gk lDuvQWwFMZJPJED5sBIWN+XunX91QxOuOxXq6JAjVoRZPXzT4bXllDOA+bPt1Q== X-Google-Smtp-Source: AGHT+IFxJFeMPcL8ytCxc2u5zPDcX0TiDfN/BOFVsXaXujFuR9MAhpYnZXK32l63JffeuOssUsOYXw== X-Received: by 2002:a05:6a00:1407:b0:6ed:2f2:a8e with SMTP id l7-20020a056a00140700b006ed02f20a8emr11839710pfu.30.1713805514163; Mon, 22 Apr 2024 10:05:14 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:843d:b423:30f9:2b2]) by smtp.gmail.com with ESMTPSA id fa34-20020a056a002d2200b006e5571be110sm7997617pfb.214.2024.04.22.10.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 10:05:13 -0700 (PDT) From: Douglas Anderson To: Tiffany Lin , Andrew-CT Chen , Yunfei Dong , Mauro Carvalho Chehab , Matthias Brugger , AngeloGioacchino Del Regno Cc: Wei-Shun Chang , Douglas Anderson , Hans Verkuil , Nicolas Dufresne , =?utf-8?b?TsOtY29sYXMg?= =?utf-8?b?Ri4gUi4gQS4gUHJhZG8=?= , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH] media: mediatek: vcodec: Alloc DMA memory with DMA_ATTR_ALLOC_SINGLE_PAGES Date: Mon, 22 Apr 2024 10:03:59 -0700 Message-ID: <20240422100354.1.I58b4456c014a4d678455a4ec09b908b1c71c3017@changeid> X-Mailer: git-send-email 2.44.0.769.g3c40516874-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240422_100517_037804_4D49A75F X-CRM114-Status: GOOD ( 13.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As talked about in commit 14d3ae2efeed ("ARM: 8507/1: dma-mapping: Use DMA_ATTR_ALLOC_SINGLE_PAGES hint to optimize alloc"), it doesn't really make sense to try to allocate contiguous chunks of memory for video encoding/decoding. Let's switch the Mediatek vcodec driver to pass DMA_ATTR_ALLOC_SINGLE_PAGES and take some of the stress off the memory subsystem. Signed-off-by: Douglas Anderson Tested-by: Fei Shao Reviewed-by: Fei Shao Reviewed-by: Nicolas Dufresne --- NOTE: I haven't personally done massive amounts of testing with this change, but I originally added the DMA_ATTR_ALLOC_SINGLE_PAGES flag specifically for the video encoding / decoding cases and I know it helped avoid memory problems in the past on other systems. Colleagues of mine have told me that with this change memory problems are harder to reproduce, so it seems like we should consider doing it. .../media/platform/mediatek/vcodec/common/mtk_vcodec_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c index 9ce34a3b5ee6..3fb1d48c3e15 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c @@ -64,7 +64,8 @@ int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem) id = dec_ctx->id; } - mem->va = dma_alloc_coherent(&plat_dev->dev, size, &mem->dma_addr, GFP_KERNEL); + mem->va = dma_alloc_attrs(&plat_dev->dev, size, &mem->dma_addr, + GFP_KERNEL, DMA_ATTR_ALLOC_SINGLE_PAGES); if (!mem->va) { mtk_v4l2_err(plat_dev, "%s dma_alloc size=%ld failed!", dev_name(&plat_dev->dev), size);