Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2666241lqp; Mon, 25 Mar 2024 06:09:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7j1/T4xen4nNb5+zfQenuh5ffavfa5bCnxnInq9j2T40SqXXAMcz+FTpBU4ugYEX43jkHWJloh8cEPKcZwJ2FwJtOYJgTwFqrpbikKA== X-Google-Smtp-Source: AGHT+IGfOYQEM3Jvrh7gaDaNnC+zevfxUgNIG++e4WloHQCPnruEZboM3eDlyMGvlvJwZqgUvWLb X-Received: by 2002:a17:902:e54d:b0:1dd:6f4c:c67 with SMTP id n13-20020a170902e54d00b001dd6f4c0c67mr8098960plf.24.1711372188171; Mon, 25 Mar 2024 06:09:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711372188; cv=pass; d=google.com; s=arc-20160816; b=Q3gW12lrqd6wfVbiL/Z4b/E82UT0BKeltZC7wLVA/SyllzxQmmYzXwxRopY2OEFKHj arEAK4XYi2fUU0cDyHt0oXhNuJFZw4Rq/ZAuZoRRlyS6csA31B114bHGkzWf9a8z2wrK Wr4dmepfIwu3iWXbEyY0/p2zmLfTAkwCWsaxqp4kMeBoaNaVNVVJ1ijdqbqTrwLfzHdX vSvUojuLPOyoXTMYOQiHFQHlXBkfToFNBkeeLQZKHPlfQIUMqJFMCkBBAfe/igC27Z2Z ghlTqGrEv7bwS/9sdlJjtxdne7++JLWOtT7F1+Q37WN9H9MWOF8TgjCVNQv5Jvw6WxQ7 FN8w== ARC-Message-Signature: i=2; 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=USH6Nfz0NCBGWMX/IQB4cQ8iG0IHQkGBXucHa0AClMU=; fh=0UllO0AwdIr3uXN7YwG6wedUx2qIuum245ixtcSszlk=; b=DxWzpLrC3Xd7RuZtaJa6NurEQT7hS4HXUs2CXeee08qREwheARZf4bSNWsLhBtT0bq olbA2LNXWf1fcOAb5ldGWNG0xEd8Y7ll63+eY5ilL4AHIr9mp6w4mutEy/ne7eBwMsof rrVZ14uRSG8fTh1ZDFaZmF269Dk+jIuwioUnBCIr4/yc6ybOtanK/L8VrqsIeCE3ZONk cMwjOfGDwb2u42Enq63LYG9aVqRJD/ba6a/4g6rOi82E58M4ana6RSzBuPGEudBMFOu1 nvasrPppubXoqUAfLOS2dysEyN9d7414fnUxxN21l62eLvV23NpXRJEGZClt/rYo3iK/ ZkFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UkF35Z8g; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-116597-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id o16-20020a170902d4d000b001dd63e18e5bsi5395509plg.136.2024.03.25.06.09.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:09:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116597-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UkF35Z8g; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-116597-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116597-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7652C2A6A43 for ; Mon, 25 Mar 2024 13:08:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 998ED157A41; Mon, 25 Mar 2024 08:53:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UkF35Z8g" Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 BECA415F3F3; Mon, 25 Mar 2024 06:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711348889; cv=none; b=Vo5qMXrOAGg08cfxhDEaM7tImZ1ZRj1P5e7hz5fcWapZanQjoi3a8MPXTzOh8uYMNAb0nDauDe6urw/yRySRAxKseYBkO7AE2OyguslBNcNx6q55z8u61suf3MbvYAkIS4Sm35Wf1cEUBKyjCDWtur8KQJmRkX3Bdip326kop2E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711348889; c=relaxed/simple; bh=WCUsd9wRlKcgYIo1YAVt/aabTPpoE7JMRDqoJPTiBMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=arlaQA9Y8JEp46gL7G+56x/yYusd6mOHec/BiDNRD29hdr7/ANvcxTt/tcwXPiJDvkcC+WhJmvS9hxhEs+yTg+kU7fre5F2x8Y14AyAJLIgSTOkpS06F2b/tN8GIM68bSl8281nAcY/wVm9Xx2TkTob7z6p/I8ygAYFclCiV1MU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UkF35Z8g; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-515a86daf09so1282863e87.3; Sun, 24 Mar 2024 23:41:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711348886; x=1711953686; 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=USH6Nfz0NCBGWMX/IQB4cQ8iG0IHQkGBXucHa0AClMU=; b=UkF35Z8gDFuDpTRGIVaeNX/S2WTkhPMBKP8+pQBselwSGQJg9hgOWoEqk8R7V9Sgk/ 8xmZ0iZn1I+J902tv96qGIWOtv9PDBUFie4OBrYz+86DxaPx2559rpKhX95jbLbziiFl jrhH0qC/HzAVYOgeCqHLL1dnWBEOseQfRxkiif39EkFlM+HkWpkfKb3CUN1mizqVFaR2 jXDiVFrE+n95WqOE/4IvogqnoDwWNfqfZ0xPnH3XxPORNE/GLimYu7NdWuCPVPnVhMnN Dw03wiaWwubqTV3q4FaHUdrMdElFA8sOS5iTs5UfyDda/VD1C6T+C6sncRRmj5w6zAIq byCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711348886; x=1711953686; 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=USH6Nfz0NCBGWMX/IQB4cQ8iG0IHQkGBXucHa0AClMU=; b=s4rZeNehlXztKJRL4t3DPPcHHeiXDBlec2bpqRlSk8I92pv+jg5+3zNeidzGHvNf6e B/ehCCIwzr95r5h+vzXNgS9g4drIXaW1hal9+CE5AyIX7SJbmaFf5IuOremJaU0Jf9Sr zh7h8/cOQmv9ondPNQ210n2I/71Viu+rXDmBwc/enQrt8R5bn2/ikemWO87tUeKtQUV4 cCEH22VTWH8zsKI9XxgzCGqliHHqeXM4PDfUk7q9Bztf7DEUn/Op2VmSb11zi25ulB2a HarKdQ8p/xCFUDLCNdwW4wUj0wev68pVvCAKutCt4famQ83dv4zmvqsktdHbrTWEML9G ULOQ== X-Forwarded-Encrypted: i=1; AJvYcCUcuhIkqH3ZZHUQCeSBNX7KJqzhOLPUDLE6XvyE8sfvtnrZj5faVdjsnQzH5MzqWuTUNpXja7Vi5e6GTceazwlCUQ8iyfbonkgizLU3j5OF3khvO1uaF9Y8Tn+FKtdFVjNJo/tofARcv5Y= X-Gm-Message-State: AOJu0YzA+W9rAeGn2jk002aNr+Zq3wT76I/tIVCz6p0sW8z4mwlBvIZ+ 3kg2FYOJ0s5h6eqhoEJfWmbSdi98Iuwdspx9STyT4X591+2Bx+VQ X-Received: by 2002:a05:6512:1c7:b0:513:5c10:309c with SMTP id f7-20020a05651201c700b005135c10309cmr4522562lfp.3.1711348885777; Sun, 24 Mar 2024 23:41:25 -0700 (PDT) Received: from localhost.localdomain ([178.70.43.28]) by smtp.gmail.com with ESMTPSA id h12-20020a0565123c8c00b00515a411fd20sm828229lfv.105.2024.03.24.23.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 23:41:25 -0700 (PDT) From: Ivan Bornyakov To: Nas Chung , Jackson Lee , Mauro Carvalho Chehab , Philipp Zabel Cc: Ivan Bornyakov , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] media: chips-media: wave5: drop "sram-size" DT prop Date: Mon, 25 Mar 2024 09:40:59 +0300 Message-ID: <20240325064102.9278-5-brnkv.i1@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240325064102.9278-1-brnkv.i1@gmail.com> References: <20240325064102.9278-1-brnkv.i1@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use all available SRAM memory up to WAVE5_MAX_SRAM_SIZE. Remove excessive "sram-size" device-tree property as genalloc is already able to determine available memory. Signed-off-by: Ivan Bornyakov --- .../platform/chips-media/wave5/wave5-vdi.c | 21 ++++++++++--------- .../platform/chips-media/wave5/wave5-vpu.c | 7 ------- .../platform/chips-media/wave5/wave5-vpuapi.h | 1 - .../chips-media/wave5/wave5-vpuconfig.h | 2 ++ 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/chips-media/wave5/wave5-vdi.c b/drivers/media/platform/chips-media/wave5/wave5-vdi.c index 3809f70bc0b4..a63fffed55e9 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vdi.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vdi.c @@ -174,16 +174,19 @@ int wave5_vdi_allocate_array(struct vpu_device *vpu_dev, struct vpu_buf *array, void wave5_vdi_allocate_sram(struct vpu_device *vpu_dev) { struct vpu_buf *vb = &vpu_dev->sram_buf; + dma_addr_t daddr; + void *vaddr; + size_t size; - if (!vpu_dev->sram_pool || !vpu_dev->sram_size) + if (!vpu_dev->sram_pool || vb->vaddr) return; - if (!vb->vaddr) { - vb->size = vpu_dev->sram_size; - vb->vaddr = gen_pool_dma_alloc(vpu_dev->sram_pool, vb->size, - &vb->daddr); - if (!vb->vaddr) - vb->size = 0; + size = min_t(size_t, WAVE5_MAX_SRAM_SIZE, gen_pool_avail(vpu_dev->sram_pool)); + vaddr = gen_pool_dma_alloc(vpu_dev->sram_pool, size, &daddr); + if (vaddr) { + vb->vaddr = vaddr; + vb->daddr = daddr; + vb->size = size; } dev_dbg(vpu_dev->dev, "%s: sram daddr: %pad, size: %zu, vaddr: 0x%p\n", @@ -197,9 +200,7 @@ void wave5_vdi_free_sram(struct vpu_device *vpu_dev) if (!vb->size || !vb->vaddr) return; - if (vb->vaddr) - gen_pool_free(vpu_dev->sram_pool, (unsigned long)vb->vaddr, - vb->size); + gen_pool_free(vpu_dev->sram_pool, (unsigned long)vb->vaddr, vb->size); memset(vb, 0, sizeof(*vb)); } diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c b/drivers/media/platform/chips-media/wave5/wave5-vpu.c index 1e631da58e15..2a972cddf4a6 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c @@ -177,13 +177,6 @@ static int wave5_vpu_probe(struct platform_device *pdev) goto err_reset_assert; } - ret = of_property_read_u32(pdev->dev.of_node, "sram-size", - &dev->sram_size); - if (ret) { - dev_warn(&pdev->dev, "sram-size not found\n"); - dev->sram_size = 0; - } - dev->sram_pool = of_gen_pool_get(pdev->dev.of_node, "sram", 0); if (!dev->sram_pool) dev_warn(&pdev->dev, "sram node not found\n"); diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h index da530fd98964..975d96b22191 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h @@ -750,7 +750,6 @@ struct vpu_device { struct vpu_attr attr; struct vpu_buf common_mem; u32 last_performance_cycles; - u32 sram_size; struct gen_pool *sram_pool; struct vpu_buf sram_buf; void __iomem *vdb_register; diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h b/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h index d9751eedb0f9..9d99afb78c89 100644 --- a/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h @@ -28,6 +28,8 @@ #define WAVE521ENC_WORKBUF_SIZE (128 * 1024) //HEVC 128K, AVC 40K #define WAVE521DEC_WORKBUF_SIZE (1784 * 1024) +#define WAVE5_MAX_SRAM_SIZE (64 * 1024) + #define MAX_NUM_INSTANCE 32 #define W5_MIN_ENC_PIC_WIDTH 256 -- 2.44.0