From patchwork Thu Dec 21 09:17:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Shao X-Patchwork-Id: 182119 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp294349dyi; Thu, 21 Dec 2023 01:40:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEs1DodYGVIvN3mM64NKFHq5tJzPnBYvMYvxNDeNXqS0V09UiPMCYVND4HJItNf6Q/qeYh4 X-Received: by 2002:a17:90a:d317:b0:28b:6da5:e87c with SMTP id p23-20020a17090ad31700b0028b6da5e87cmr554899pju.5.1703151658752; Thu, 21 Dec 2023 01:40:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703151658; cv=none; d=google.com; s=arc-20160816; b=ldadDmJ9ScLZipLLI+HVJB22yAoO/AS7olow/pC1346cVUYdy6FS9pBGCGha5j/oC9 f5XfeuYqZzvG2rjCYyxFlzOtr0KftVn8M6k+2LnRgijna6Xuzplw1qHgjJ0/mGVIqnNn Nwywp4nbiWX0OoE6InJB0b2UBkgDBayOxL5NY/xVbAmN0D09O2nptB9BESkNfPVfRnDp ZOrOUtwySuLpulzLg5PPZCltEYJoZwACzaf9hrugx5nkbBnJLG/xxNYBWdnPup4PcJUw 236qS8Fz4cfande9OryuXmmxKny9Y98lSBaE9anXlQCImYLFCDeg0Uv63Hxe/WNVOBLK o/dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1lCEYEMR3ZdMjHY32Gwj2vmlAOglAWDLVN2PPmHFWNo=; fh=DCT4jDjkLHZUGvEUTEyHFjdV2W2QSe4+4u0RPV+2WD0=; b=wurgmIab4FO50vYuKplsNW0QwsbMlMYpaWwZ0QtsflB7HPZGcTyFia/ZkKoTmo7ll4 tNq9nTUZemKhNnQ8s0ULKt2R9qBeEHa6z+U90ZuQHw0zybEW1mYN3eAy+9KtzF2x542p uYzas3A9xq59cAN0Qy7ShOljN7BdSnQB5EXaBAHjwsg7l4DZgcrhbpOCuYkZxhIinOuI ww86fooRn3DOeft0XOHCERTvxeiNTaic+9yaG03+40+5zb7RQ1UJmNp3VVUqloff6yVI WS9ni4hbqISAnknhOCsHU0te7TntieK0GwCZ46PmzMEBjEIfdApreBpZ5E39LEsIZ9pa /8Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=axiHFoLp; spf=pass (google.com: domain of linux-kernel+bounces-8111-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8111-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id nk10-20020a17090b194a00b0028bda9780bcsi1386357pjb.3.2023.12.21.01.40.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:40:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8111-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=axiHFoLp; spf=pass (google.com: domain of linux-kernel+bounces-8111-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8111-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E15A7B27CCA for ; Thu, 21 Dec 2023 09:29:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A35E3F8F5; Thu, 21 Dec 2023 09:23:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="axiHFoLp" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.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 CC3B62CCD5 for ; Thu, 21 Dec 2023 09:23:20 +0000 (UTC) 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 Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5cd84c5442cso1241407a12.1 for ; Thu, 21 Dec 2023 01:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703150600; x=1703755400; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1lCEYEMR3ZdMjHY32Gwj2vmlAOglAWDLVN2PPmHFWNo=; b=axiHFoLpP1uLHeHBt18NeiX+NxeOrqpvOQjypTCJ3vbwl5A4kZh1wEnlSS6jCQfLw3 WEhy8ewogCyZPXuzrrTfcjCNJ2e4MdTqD0cy5b32YIV/6gZpzj3eSfkyQn4xJ61LRa/v uA52QVlADhODyDe9VMH3a2nc27W4HQsh8QDh0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703150600; x=1703755400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1lCEYEMR3ZdMjHY32Gwj2vmlAOglAWDLVN2PPmHFWNo=; b=VI/QISMJdt8/d4lN3E/ADLh+CqNR7KQI9A4oBaBzOHbf9EuIt3bUhOdy0WmVujgb3h IfZT6yXZ51q+Ug9J8KJ1fBA3+EJtT6qNnqQ4zOtLRcA/9hkdaIFZwfBhCqnHUrx052t5 qNJwK0z6mq+7cg/E/NhTfWxFLHdzLfmQaZyjmqOWzKwevS3nEVYKwiYJRjNvKehL+W0e Qv0DAdZT7U3nSKmGE63jsIlAuB2CblqSQAiqdcltRCnqblCwWPbwQm3DzKFXQQWdi/z8 xN0UPaz8E8PD5o9N6poysS25281wl04Xa8iSWKf+KWAO0HfCrH9EMWsOc3sQIsY1Ns+h ylVA== X-Gm-Message-State: AOJu0YzoHm6V6GLXc5tnbVx7yWcYykibCI+xT7eqNHpnoSI/Lup+/jtA elZaWvqkeg9O1d30NE5zxuq5rQ== X-Received: by 2002:a17:90a:fa96:b0:28b:e0cd:64a3 with SMTP id cu22-20020a17090afa9600b0028be0cd64a3mr481792pjb.26.1703150600225; Thu, 21 Dec 2023 01:23:20 -0800 (PST) Received: from fshao-p620.tpe.corp.google.com ([2401:fa00:1:10:5d8a:fab1:933a:9ae9]) by smtp.gmail.com with ESMTPSA id l6-20020a17090add8600b00274b035246esm1001915pjv.1.2023.12.21.01.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:23:19 -0800 (PST) From: Fei Shao To: Hans Verkuil , AngeloGioacchino Del Regno Cc: Fei Shao , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Nicolas Dufresne , Tiffany Lin , Yunfei Dong , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 1/4] media: mediatek: vcodec: Replace dev_name in error string Date: Thu, 21 Dec 2023 17:17:43 +0800 Message-ID: <20231221171727.v2.1.I69223f1e438b93fe02f12ab9ef0a26f8c21f6ae7@changeid> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231221092226.1395427-1-fshao@chromium.org> References: <20231221092226.1395427-1-fshao@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785883953607978224 X-GMAIL-MSGID: 1785883953607978224 mtk_v4l2_err() already uses dev_err(), so don't print the device name again. Print function name instead. Signed-off-by: Fei Shao Reviewed-by: AngeloGioacchino Del Regno --- Changes in v2: - rebased on top of next-20231219 .../media/platform/mediatek/vcodec/common/mtk_vcodec_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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..ea8c35c0e667 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c @@ -67,7 +67,7 @@ int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem) mem->va = dma_alloc_coherent(&plat_dev->dev, size, &mem->dma_addr, GFP_KERNEL); if (!mem->va) { mtk_v4l2_err(plat_dev, "%s dma_alloc size=%ld failed!", - dev_name(&plat_dev->dev), size); + __func__, size); return -ENOMEM; } @@ -99,7 +99,7 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem) if (!mem->va) { mtk_v4l2_err(plat_dev, "%s dma_free size=%ld failed!", - dev_name(&plat_dev->dev), size); + __func__, size); return; } From patchwork Thu Dec 21 09:17:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Shao X-Patchwork-Id: 182101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp289797dyi; Thu, 21 Dec 2023 01:29:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWKh+ddT7TAO2njOyJ467JURHgzEtVg95G5wH+qcXmtT1mJwNB+DtF3rx0XvvTgY1OM1fg X-Received: by 2002:ac8:5a48:0:b0:427:7254:a026 with SMTP id o8-20020ac85a48000000b004277254a026mr5253470qta.85.1703150971401; Thu, 21 Dec 2023 01:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703150971; cv=none; d=google.com; s=arc-20160816; b=kuupaweqFI1iWogRJei9MFtSPgRJg0uK/MkRiPzntuKoIszSTz6eo5R8wMk98YRFrw KZrWdFzVKYdjkTgfpZbPs2lChvjIu0QRuhz3FVPZiXsgoj4n2+9CEc/6dEPSrwKkJtzT TrXzT/cEgACfJmb4RPk4XYmGKk6sGu4+f81MndU2M2K+7RdwPBPeyvHCsSiFIgGxItok RFK2AMuVV1AaTCyQU88TyFo0cE+TuWCC/872fJixX+RvrqtvwKI5euMScOh0B495TYr7 RLMvG20uyfGzjY04WzNxyLfKRDy3xZf2Vo2ZC64vUtv69Tad+Aoy7GNfEY68/6pF4INA 3k5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VZlHGzvCeyHzNr9SWDCy3oc9Vlh9aPeReD6PrS2OHo0=; fh=DCT4jDjkLHZUGvEUTEyHFjdV2W2QSe4+4u0RPV+2WD0=; b=LAvNZmG/xnj3N7mB2OKAK3bLwUKr9C5Wu796j2QYME7PwnA39+TnLsX1MZqBFb2Bgx huyXPh1DGkH5cBclsQeCsG2DzlrnLF5Nh3QYG4k1Z+/jvLK1juePxjJ8JkND3+QOjS4R xb8skESBf1vLPEY9j1YvuY9RY1NiaV34CvTO7otozWB3+uYC81XfnUMCqMq8jmYrFrf+ A2hTM2u6BocqYU7gAaMuu6UoqBS9nXKh1EIlnQAydjPXsnMT+EIRAmRt2Ni35qvrnAFf D3NQcLMmw8c/FxQ3d/W3C5ZNybjklHSCIyaYJSIGsvX+vq6C0uVQIyDtGAv/M538NSYD VpLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iE8aT0QJ; spf=pass (google.com: domain of linux-kernel+bounces-8112-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8112-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f36-20020a05622a1a2400b004257bfe6e26si1854145qtb.197.2023.12.21.01.29.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:29:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8112-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iE8aT0QJ; spf=pass (google.com: domain of linux-kernel+bounces-8112-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8112-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 238D61C249B7 for ; Thu, 21 Dec 2023 09:29:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 022414A99D; Thu, 21 Dec 2023 09:23:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="iE8aT0QJ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (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 230F640C1E for ; Thu, 21 Dec 2023 09:23:23 +0000 (UTC) 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 Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-5cddfe0cb64so237538a12.0 for ; Thu, 21 Dec 2023 01:23:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703150603; x=1703755403; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VZlHGzvCeyHzNr9SWDCy3oc9Vlh9aPeReD6PrS2OHo0=; b=iE8aT0QJf95Xjm5HcQeUS1QubIoa57gaRnyRRJYcIaf6kYioB9EuR0DTMJEnxMrJSJ XR2+EC1iNmKOFglQGdcWfdCBB/i5lOoo4UDBJSPe1bJeDTs/ztvh2M+hCWWLFJtxlfjM RDxoHkiyLwwFqfKuwdkxuvJJg4xfFsPOH4JI4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703150603; x=1703755403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VZlHGzvCeyHzNr9SWDCy3oc9Vlh9aPeReD6PrS2OHo0=; b=XK7iO9I+JwGjOVr9XQGa17SpsaTFmv8ITk2f742YMj8+VYIC+rpRJTi9MTbzBWzZH4 MqOfj4varTfelc6AzNcJngASpQ0zqHKkZPlL+pPaU2hBVu83gdOia+dbXgyDORwbtGuF kG0szue6XHdoH32ZwmobNr/MY+yPRj2zKY6/vzZ3hNhOjPM9tItWKS2ici6e+SafzTcO RMKNxPOsl8vW85PPzqQnP3blEaDXrOBhjvXcr7mDVP7G5qjvx2uwhqt5aWRGItqBi9Of +N9/Wlch/AM/oTGzy8K3npfsGsBMUU5S+wGE4DSkos3+RGF2qkLvIwVZBLuT4vgEaPrO lqIw== X-Gm-Message-State: AOJu0Yyq7yV8OqwaYrMnYp9lndcEytdilro6R5cFiKsX5do0tF5fqTox bSUgPBPEYC/HjQScXXf+TNFkaA== X-Received: by 2002:a05:6a20:8c84:b0:18f:97c:5ba2 with SMTP id k4-20020a056a208c8400b0018f097c5ba2mr518290pzh.112.1703150603432; Thu, 21 Dec 2023 01:23:23 -0800 (PST) Received: from fshao-p620.tpe.corp.google.com ([2401:fa00:1:10:5d8a:fab1:933a:9ae9]) by smtp.gmail.com with ESMTPSA id l6-20020a17090add8600b00274b035246esm1001915pjv.1.2023.12.21.01.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:23:22 -0800 (PST) From: Fei Shao To: Hans Verkuil , AngeloGioacchino Del Regno Cc: Fei Shao , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Nicolas Dufresne , Tiffany Lin , Yunfei Dong , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 2/4] media: mediatek: vcodec: Drop unnecessary variable Date: Thu, 21 Dec 2023 17:17:44 +0800 Message-ID: <20231221092226.1395427-2-fshao@chromium.org> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231221092226.1395427-1-fshao@chromium.org> References: <20231221092226.1395427-1-fshao@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785883232601100753 X-GMAIL-MSGID: 1785883232601100753 In mtk_vcodec_mem_alloc() and mtk_vcodec_mem_free(), the value of mem->size is not expected to change before and when using the DMA APIs and debug print, so there's no point in keeping local copies of it. Drop the local variable "size" in the mentioned functions, and update printk format identifiers accordingly. This makes the code slightly more visually consistent, and retrieve a small amount of memory that is used for no real purpose. Signed-off-by: Fei Shao Reviewed-by: AngeloGioacchino Del Regno --- Changes in v2: - revise commit message for clearer intention and rationale .../mediatek/vcodec/common/mtk_vcodec_util.c | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) 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 ea8c35c0e667..23bea2702c9a 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c @@ -49,7 +49,6 @@ int mtk_vcodec_mem_alloc(void *priv, struct mtk_vcodec_mem *mem) { enum mtk_instance_type inst_type = *((unsigned int *)priv); struct platform_device *plat_dev; - unsigned long size = mem->size; int id; if (inst_type == MTK_INST_ENCODER) { @@ -64,15 +63,15 @@ 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_coherent(&plat_dev->dev, mem->size, &mem->dma_addr, GFP_KERNEL); if (!mem->va) { - mtk_v4l2_err(plat_dev, "%s dma_alloc size=%ld failed!", - __func__, size); + mtk_v4l2_err(plat_dev, "%s dma_alloc size=0x%zx failed!", + __func__, mem->size); return -ENOMEM; } - mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%lx", id, mem->va, - (unsigned long)mem->dma_addr, size); + mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%zx", id, mem->va, + (unsigned long)mem->dma_addr, mem->size); return 0; } @@ -82,7 +81,6 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem) { enum mtk_instance_type inst_type = *((unsigned int *)priv); struct platform_device *plat_dev; - unsigned long size = mem->size; int id; if (inst_type == MTK_INST_ENCODER) { @@ -98,15 +96,15 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem) } if (!mem->va) { - mtk_v4l2_err(plat_dev, "%s dma_free size=%ld failed!", - __func__, size); + mtk_v4l2_err(plat_dev, "%s dma_free size=0x%zx failed!", + __func__, mem->size); return; } - mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%lx", id, mem->va, - (unsigned long)mem->dma_addr, size); + mtk_v4l2_debug(plat_dev, 3, "[%d] - va = %p dma = 0x%lx size = 0x%zx", id, mem->va, + (unsigned long)mem->dma_addr, mem->size); - dma_free_coherent(&plat_dev->dev, size, mem->va, mem->dma_addr); + dma_free_coherent(&plat_dev->dev, mem->size, mem->va, mem->dma_addr); mem->va = NULL; mem->dma_addr = 0; mem->size = 0; From patchwork Thu Dec 21 09:17:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Shao X-Patchwork-Id: 182102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp289890dyi; Thu, 21 Dec 2023 01:29:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IE3CpYl+pFFPF9Xs3Ju89xm1Mn06AjQzVoIHLOM1hg/TIJHXv+BTtfx1Tg9Tm9DYJZ0EnVW X-Received: by 2002:ac8:58d3:0:b0:427:87d3:6136 with SMTP id u19-20020ac858d3000000b0042787d36136mr2918681qta.1.1703150987943; Thu, 21 Dec 2023 01:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703150987; cv=none; d=google.com; s=arc-20160816; b=qOMJ59QQ3Y24W2V59mcFqeg7V/vAiua7UlD0HkMBZY/GjySIA+avUziJHl/blfZT0k uMjYi5uKeMcVraz/jlmqnmouxx8FEeCQqN7uwLBqDnOSYZ2+IyqhGanWZqYjPsuow2c1 /Y8xabOls51bb/Onf8zlFGffYP+TYTcn8/Xl7RxQaPi6uA07pTwGbFLysmlCWSqdnm3k /Amg/zMzQC3mWGugIbU4+q8cFzDCnDWjjsTDKOdhrLA7yVgzimH3u5J8gedn32IiLgsh d4cG0VRMaeinwSNmvjanojrN+ob4fZexafy81BVfCBGHUS30eJ8jSKgCcHsNZFEoFCo5 OjAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YpgYqGOhJKgjrH+Y+gow5aHhwckMqDVFEItsLP1DgtE=; fh=DCT4jDjkLHZUGvEUTEyHFjdV2W2QSe4+4u0RPV+2WD0=; b=grwPCC9CtHTNCghENdAtMD3h5FqKYxHzIcunqiuHVBjyL+WKsWzXvEkCDQVry+gnh7 96afilpSCGoHUeGss3L5+NMoMaRXbbHVhn32Z3NVGLnQBcJV9c5r5nXNgdP7QxKWEEmE GnzqryS4KdZySppIgQq1UzQfOF+n7QvTV8ID3YXNOUWPLTW1cYgbmvnCY5q9nejs96Q9 PzOYHEmJGKNzCjWj2Qm0Iqsnku4BARQAGUrgfyBmHb3LJlRmuH03rPyjWpx6YzC6PJrq KzHWyBceGrY0GEW+a4tzuYQifEBe6vHIS/9zn5TY/3Vz9wBhv4PLgWH9lF3lT1tymKzo wSTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AtNvv4dn; spf=pass (google.com: domain of linux-kernel+bounces-8113-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8113-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c9-20020a05622a058900b00423a8bd0b44si1646716qtb.797.2023.12.21.01.29.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:29:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8113-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AtNvv4dn; spf=pass (google.com: domain of linux-kernel+bounces-8113-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8113-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D5161C237C9 for ; Thu, 21 Dec 2023 09:29:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A0D004E60F; Thu, 21 Dec 2023 09:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="AtNvv4dn" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 B187B3C693 for ; Thu, 21 Dec 2023 09:23:26 +0000 (UTC) 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 Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6d532e4f6d6so309129b3a.2 for ; Thu, 21 Dec 2023 01:23:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703150606; x=1703755406; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YpgYqGOhJKgjrH+Y+gow5aHhwckMqDVFEItsLP1DgtE=; b=AtNvv4dnqqqoQIcnxmMRYfV3RJ3eJvizPDs1/uAi0JFwzaDNsM8EFQzMYINH9G3dG6 hpjm4sz4XML+0gm0W6nchdSW2vBCGJNHF43yiP4U8Ku/pXWin7A24q2vSu1ArtgQEzL+ SUci/2oiqF6PqFKK4K3SMkaX5wDCX9+TcfeYg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703150606; x=1703755406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YpgYqGOhJKgjrH+Y+gow5aHhwckMqDVFEItsLP1DgtE=; b=IyM9G/IMTn69iEicDCk9aZl1zqkTAZ8iLv9TRkG8YPZQfYMgbIujSh4HDoTrQO6/kF /9PHb0WFExThoBZIqJ0wss52pWn19Ru97rvJpoia1W7bnEJFU2imVrrCHEaJS9OgUIRo OfU1bYZCAvrkz8WajQgM2T/S+sLdB11MnqdMMERUddRFXe4+z8+2zUziLzpdgN5fzpUy +ZnQEvmPbhw/qnaGKn6GG7P+GWoBABXnzhQCa0wBkDsTZnPKfFtaTGBTVRbi8VFyPP12 dR/FLHLh2EIOOJbWisc1tJ9jYXVqk46djRdGibR58weCHz7iHyM3WYkSNYvl2Fkc/R8l iJnw== X-Gm-Message-State: AOJu0YzXBbUz3pXeItpQSS/Ejsb9rEpuLZsO8vAUOkPpK42FbBa1sQ/a d5zp+OYl/MIbIro7FKc96NohRg== X-Received: by 2002:a05:6a20:2e25:b0:188:1df7:9afe with SMTP id be37-20020a056a202e2500b001881df79afemr560527pzb.30.1703150606111; Thu, 21 Dec 2023 01:23:26 -0800 (PST) Received: from fshao-p620.tpe.corp.google.com ([2401:fa00:1:10:5d8a:fab1:933a:9ae9]) by smtp.gmail.com with ESMTPSA id l6-20020a17090add8600b00274b035246esm1001915pjv.1.2023.12.21.01.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:23:25 -0800 (PST) From: Fei Shao To: Hans Verkuil , AngeloGioacchino Del Regno Cc: Fei Shao , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Nicolas Dufresne , Tiffany Lin , Yunfei Dong , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 3/4] media: mediatek: vcodec: Update mtk_vcodec_mem_free() error messages Date: Thu, 21 Dec 2023 17:17:45 +0800 Message-ID: <20231221092226.1395427-3-fshao@chromium.org> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231221092226.1395427-1-fshao@chromium.org> References: <20231221092226.1395427-1-fshao@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785883250655677035 X-GMAIL-MSGID: 1785883250655677035 In mtk_vcodec_mem_free(), there are two cases where a NULL VA is passed: - mem->size == 0: we are called to free no memory. This may happen when we call mtk_vcodec_mem_free() twice or the memory has never been allocated. - mem->size > 0: we are called to free memory but without VA. This means that we failed to free the memory for real. Both cases are not expected to happen, and we want to have clearer error messages to describe which one we just encountered. Update the error messages to include more information for that purpose. Signed-off-by: Fei Shao Reviewed-by: AngeloGioacchino Del Regno --- Changes in v2: - update the error messages based on the suggestion .../media/platform/mediatek/vcodec/common/mtk_vcodec_util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 23bea2702c9a..c60e4c193b25 100644 --- a/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c +++ b/drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_util.c @@ -96,8 +96,9 @@ void mtk_vcodec_mem_free(void *priv, struct mtk_vcodec_mem *mem) } if (!mem->va) { - mtk_v4l2_err(plat_dev, "%s dma_free size=0x%zx failed!", - __func__, mem->size); + mtk_v4l2_err(plat_dev, "%s: Tried to free a NULL VA", __func__); + if (mem->size) + mtk_v4l2_err(plat_dev, "Failed to free %zu bytes", mem->size); return; } From patchwork Thu Dec 21 09:17:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fei Shao X-Patchwork-Id: 182103 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp289997dyi; Thu, 21 Dec 2023 01:30:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKSrOvPtv9hhOefTiMds0bMBE2tgsiCj2lzbp382Y9fs9SSEmJHqjhEjhwkTKzNc3QAu18 X-Received: by 2002:a05:622a:104e:b0:425:4043:1dae with SMTP id f14-20020a05622a104e00b0042540431daemr29044510qte.129.1703151002660; Thu, 21 Dec 2023 01:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703151002; cv=none; d=google.com; s=arc-20160816; b=Clm8WRJuvmfDL4yLy0X4+1n2c9NJv3apHvUxL1KUSGY7i6HZ2MkMyeYVlrMF61k63K SPnq4bRP1DIwd61G/Lih5+MoBVE+7hXh5waPnH+N1zt5j0w39T3q9jAQhcRzm8/QEIY/ gzKSOuqmyUfer7zjcmLgHmTR1u5YhDfv+T82rCH3Y33xKNtORYsOnOTXei3a/TwpD6R9 KAgfY8uQL8BWW+DDoU6gvmQnx6K/oBwrRvbySUqd00UvJglWG0t9dVj0hki4pT8Si5Ls EmtJxiFldf9cGOeT/kZ8Dfiw6/+CUGwuvtyt/dLF/FLafvlZy0q1rlfFVxdNS5XXlmdY Cgqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VRGqB+rpK2JtTATUiTfsiyokzdHpJCMrcXkOJidY/3Y=; fh=mzUoOnSp9tsqcdq9OaIBPV2yMCSCKqZtZEuSH6TMros=; b=kLtq8NLGcpt9cyWVXJdSNSO+RQ2fCvo2Np8i2pwpAwh7GxCthZTXv0Wt9m4U/RYaxH UqKXR+GarUDo48iGfbCmGyE79bWvtwQxEJmH4o/RYcOXjIMCDMDdR9ILvVQo2OexUjRS W/42nLnXX3MWAlV9HrRgHoOjneGGzaZL7MhKf2gEodzN9SKcp5nfIzQYD2uUVolEA8ck tgyKqnDuVeAo1q81U5hMLMXYwqfz1PVATKBHoB2YrndirZPqPc9mejZCow/2a36BJkaV aWtG0NKjHAY1RuXqgPnUIUX2PMCVlCCh2piqoYbX8brEzdjjAKJbBDW/iL6lUv50aBZD rfig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jMo0qkLf; spf=pass (google.com: domain of linux-kernel+bounces-8114-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8114-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l16-20020a05622a175000b0042540787649si1779136qtk.303.2023.12.21.01.30.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:30:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8114-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jMo0qkLf; spf=pass (google.com: domain of linux-kernel+bounces-8114-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8114-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 624DF1C215E5 for ; Thu, 21 Dec 2023 09:30:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7D68D4E637; Thu, 21 Dec 2023 09:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="jMo0qkLf" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 A80374CE11 for ; Thu, 21 Dec 2023 09:23:29 +0000 (UTC) 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 Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6d6d48354ccso290522b3a.1 for ; Thu, 21 Dec 2023 01:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1703150609; x=1703755409; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VRGqB+rpK2JtTATUiTfsiyokzdHpJCMrcXkOJidY/3Y=; b=jMo0qkLfG7olI5hdqNNW0qUeXBF6d+1PylmgolOoACRMxLiDnURJUzR307WQLREZG5 Ie+uP5FCeL4q2hPE7L/fpYs7PqRX52UmQKSIsAmANKNJdYh/skpIT/40lufs22LJTZeg Uu2r5HvnZ6nks35A+DXGrRJBIX9PmKA2ZDv6g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703150609; x=1703755409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VRGqB+rpK2JtTATUiTfsiyokzdHpJCMrcXkOJidY/3Y=; b=KBSrGo1SMWSlmgO4Qzhu/0rzYxkVc1HYNHYx/7TD06vovRd6cRUQrbQFCo/fE9uoUf Iyb2Z7TmX9JYmXTYHkd5wt8VSJWcWwvh1GigPT5E7EtzdUM/8z9Tej3fUZtvNQ7ZopBn aD69MCS/rxgF1CLGWVSJbMDVMUbTABT7Nf8Of4GGMI+qd5kklZ8m26+b/msCw42zhBGT HuiXN/3GdxtNv1gqmD7rxNreU+9onm8WTEHGEv4GTPolscmJM7bIti7nIQiN9H6E1Ayv 7dI4JJS2pKiaxqwQPB5YZdpi55/1RX2FkryOhcHaPNGm8W+ev0vioTgACwMls9JFuWdy XbwA== X-Gm-Message-State: AOJu0Yxe+Y+Fq6wOunATvxHUe8dTshGGPLF1DKQm2YN4a/65LKCFIdLP 56wHLDQuFCBw2iZuw3MSjh5yAQ== X-Received: by 2002:a05:6a20:8f1c:b0:190:7b07:b7c9 with SMTP id b28-20020a056a208f1c00b001907b07b7c9mr659230pzk.66.1703150608903; Thu, 21 Dec 2023 01:23:28 -0800 (PST) Received: from fshao-p620.tpe.corp.google.com ([2401:fa00:1:10:5d8a:fab1:933a:9ae9]) by smtp.gmail.com with ESMTPSA id l6-20020a17090add8600b00274b035246esm1001915pjv.1.2023.12.21.01.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:23:28 -0800 (PST) From: Fei Shao To: Hans Verkuil , AngeloGioacchino Del Regno Cc: Fei Shao , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Nicolas Dufresne , Tiffany Lin , Xiaoyong Lu , Yunfei Dong , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 4/4] media: mediatek: vcodec: Only free buffer VA that is not NULL Date: Thu, 21 Dec 2023 17:17:46 +0800 Message-ID: <20231221092226.1395427-4-fshao@chromium.org> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog In-Reply-To: <20231221092226.1395427-1-fshao@chromium.org> References: <20231221092226.1395427-1-fshao@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785883265791896325 X-GMAIL-MSGID: 1785883265791896325 In the MediaTek vcodec driver, while mtk_vcodec_mem_free() is mostly called only when the buffer to free exists, there are some instances that didn't do the check and triggered warnings in practice. We believe those checks were forgotten unintentionally. Add the checks back to fix the warnings. Signed-off-by: Fei Shao Reviewed-by: AngeloGioacchino Del Regno --- I had discussion with Yunfei, and he also thinks that the developers just forgot to wrap mtk_vcodec_mem_free() with the checks back then. We believe it's safe to add those checks. .../vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 22 +++++++++++++------ .../vcodec/encoder/venc/venc_h264_if.c | 5 +++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c index 2b6a5adbc419..b0e2e59f61b5 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c @@ -1023,18 +1023,26 @@ static void vdec_av1_slice_free_working_buffer(struct vdec_av1_slice_instance *i int i; for (i = 0; i < ARRAY_SIZE(instance->mv); i++) - mtk_vcodec_mem_free(ctx, &instance->mv[i]); + if (instance->mv[i].va) + mtk_vcodec_mem_free(ctx, &instance->mv[i]); for (i = 0; i < ARRAY_SIZE(instance->seg); i++) - mtk_vcodec_mem_free(ctx, &instance->seg[i]); + if (instance->seg[i].va) + mtk_vcodec_mem_free(ctx, &instance->seg[i]); for (i = 0; i < ARRAY_SIZE(instance->cdf); i++) - mtk_vcodec_mem_free(ctx, &instance->cdf[i]); + if (instance->cdf[i].va) + mtk_vcodec_mem_free(ctx, &instance->cdf[i]); + - mtk_vcodec_mem_free(ctx, &instance->tile); - mtk_vcodec_mem_free(ctx, &instance->cdf_temp); - mtk_vcodec_mem_free(ctx, &instance->cdf_table); - mtk_vcodec_mem_free(ctx, &instance->iq_table); + if (instance->tile.va) + mtk_vcodec_mem_free(ctx, &instance->tile); + if (instance->cdf_temp.va) + mtk_vcodec_mem_free(ctx, &instance->cdf_temp); + if (instance->cdf_table.va) + mtk_vcodec_mem_free(ctx, &instance->cdf_table); + if (instance->iq_table.va) + mtk_vcodec_mem_free(ctx, &instance->iq_table); instance->level = AV1_RES_NONE; } diff --git a/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c b/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c index a68dac72c4e4..f8145998fcaf 100644 --- a/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c +++ b/drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c @@ -301,11 +301,12 @@ static void h264_enc_free_work_buf(struct venc_h264_inst *inst) * other buffers need to be freed by AP. */ for (i = 0; i < VENC_H264_VPU_WORK_BUF_MAX; i++) { - if (i != VENC_H264_VPU_WORK_BUF_SKIP_FRAME) + if (i != VENC_H264_VPU_WORK_BUF_SKIP_FRAME && inst->work_bufs[i].va) mtk_vcodec_mem_free(inst->ctx, &inst->work_bufs[i]); } - mtk_vcodec_mem_free(inst->ctx, &inst->pps_buf); + if (inst->pps_buf.va) + mtk_vcodec_mem_free(inst->ctx, &inst->pps_buf); } static int h264_enc_alloc_work_buf(struct venc_h264_inst *inst, bool is_34bit)