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: 13638785 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0010B1514E2 for ; Mon, 22 Apr 2024 17:05:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713805516; cv=none; b=RVhHgYO28zPq2Nc99k3jAdArfwUjbheopq7F0YZ4wJOr44fGHkhuTjOLoJ4xmIwz5XkOxjnImM99E3uuL8mWXrTUNgXnwuwa0ngIfpMlsZRDFhc/BWvorrreDzvefyK9WgzZMkHZCQTuuS+PdWD7qHztjo1dvL7lHg2cc9KaQpQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713805516; c=relaxed/simple; bh=AHu9d6uPryR7QNpvwYORlSRuVIiALc6iKXvSYf0HmQM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pilQEK84CxX+yPrNq/Y686/ukPgBzDTHfSBNiKMJp3sC22nWr3oWQ8NPv2PYQTqQwyMeuiJmMXhoJpULEWLR6OgyBzYFV99bM4dzteXkzpLk8de3ZFrBb7lOqp/u5yKyCR3aL+/wG0NhMFOCVB3MLmXIkGsOA1JXHe4TXtFkVgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=PevJ4Nul; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PevJ4Nul" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6f30f69a958so644904b3a.1 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=vger.kernel.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=PevJ4NulAiOYVbA8mciWxEHev11PduHd/oYest7x9tK2CVHr6/B7olAHtulLtr8epI 04OFtpL3lbl3Fh7ZoIN4grRWoFEAVj05sXGWIapK5oFVTAZjhx4V4QJG44ThmLGpg5sm 4mCQbmQ6Ra1wVfu4OaUA4puUk0w13NswduPik= 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=TW8vJyI0erFOCqUWwOJTqh4OFS79xCQQBe2hZ/z+NxCOQVVTwW++iB/0YUKX39Vr7v m0sWUeDdI54gArVehZQt9W3M+j3gjS08mSOY8dKfgzxeZCZdg57Q6OD9vKQKrWWQNXDp CSvT9s9Rf9SCuXtxfiYCzeZhbDbT3vl2r/xWyaOIGhoyxUaAGlJA7vXzcxi/sm1TWllf pjgH2vAWrmEKc232e90dMHOjut6cln0+hMyxMTgfKy7BfxrwOMaxCiFrPrWjLluGFGOx qC56Ma6kxNS7xt9YuzIW6A2B7DM1QTno+KBGlabs2ug40WUL8aMt27nsA/UwOEzaCzzy BPrQ== X-Forwarded-Encrypted: i=1; AJvYcCWSAE+1jKXK/t6OQw6d8vFWHgM/4jQ6f/rxCfm1wRNFUV/a8fFXiUCDZYa9lmeZmZbvZkdt1jXulWuyHdrE1MuuHc9KdykznEWN9XE= X-Gm-Message-State: AOJu0Yym4SzfJ9Z4HBiSLzVpjtukz4hWlKztCG1jdiL2actfNaS5oJKH aAl3YXd/pLA5dmaSQuqmlLtZiQuUburQjTcnOcOAkE3KwIMlApSb6Is9jTXdmQ== 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 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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);