Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp197682pxa; Fri, 21 Aug 2020 05:08:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+eXcgu43lK2EMi9+svWCEJvfxzMedhjKgcX9oLSaUfmK0wXpLsRUqLHUrKW1kxbbpl9zt X-Received: by 2002:a05:6402:a59:: with SMTP id bt25mr2491478edb.71.1598011681437; Fri, 21 Aug 2020 05:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598011681; cv=none; d=google.com; s=arc-20160816; b=mmW2A0TOM+yKNVAMJPHAmSyB6wJcqFgWMmIxyjvHUbwcvOxGcvr4SCqbC1HNYSa4Uu iu3Xlaq+4lDBHoKJC+9OJt1p11VJq2xH0CwMddOnUHV+46TyeQ7OmG1lmAbQ8FBcyK1l xpwA/YLGqkOH+HFBBONTrJXSh/8qVtYt/hE6x05gTXsyy5GAEXmpyBHnfgcRbW6fKzjN 1b13E1Ri1LQwDVNkvi+vEem0Kn1UUz02osggoi+oNKpwNoJwvRYzIqQkbFmg34C+HwbM fY0WYaJA+OtKTyg1VPjUlGJZvdUBNOGaaHL5ycfD2vARuHOCnqXd9xrmp9zPgmXHBFz6 df7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:ironport-sdr:dkim-signature; bh=OSgIihW1CoT9YlVOJb8hQIF9griRr0YJwCQRzNymGtA=; b=bAleJYB57tvy1tP7PfJ8T0g17tKAZ7A9Ce4LmUBJobBOdjpjuA4Anquo+zeJQe6BBl Vvqy6yxVqFvmZCoyriOR5W8sLVZ1lcz8HZeN0eLWseBcyd/RGSX4g/EPlITRIn5wzbLy YAcQQvBXStv+GKGAF79upT2/znfePGisS/nVpGCvIcZtqgmCokOyzZVHjPTvdMKIoCtv xBy5N3cdMyzT5Or4Yu6LxG73lldDZ7vrYk4X9VBgmOPtu8qqDdIKjWlQ+3+dbYvCYaXc L1n4tRJ4IsD/LGlU2uQkM5UD097MJ8jwP2ung2sxFRocA1DalpAiIR/k9+J3pCFW4tZC jWkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@skidata.com header.s=selector1 header.b=cNF6ZGPW; 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=fail (p=NONE sp=NONE dis=NONE) header.from=skidata.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si245485edx.135.2020.08.21.05.07.37; Fri, 21 Aug 2020 05:08:01 -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=fail header.i=@skidata.com header.s=selector1 header.b=cNF6ZGPW; 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=fail (p=NONE sp=NONE dis=NONE) header.from=skidata.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728462AbgHUMGF (ORCPT + 99 others); Fri, 21 Aug 2020 08:06:05 -0400 Received: from mail2.skidata.com ([91.230.2.91]:13667 "EHLO mail2.skidata.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728380AbgHUMF7 (ORCPT ); Fri, 21 Aug 2020 08:05:59 -0400 X-Greylist: delayed 431 seconds by postgrey-1.27 at vger.kernel.org; Fri, 21 Aug 2020 08:05:58 EDT DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=skidata.com; i=@skidata.com; q=dns/txt; s=selector1; t=1598011558; x=1629547558; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=CtNUV+9wjaZRe+QdvUN4CbCxHU/f+RRPuYnHIY6MUFw=; b=cNF6ZGPWkvwHOwIsdY07gg2koGRCVvgdEiZk/MMsQoko0+9WVHItkSPc O3oZGjVd+hIb25729BIpp9HpLRkziEpxKWTLoSdZk00lKpJnhQdo9O+K1 kr6dmRBd9+EdMUXJ2OhKQLozZdouMpzt1pfiMZnGvFJCiuI4UJEicbTj9 xH6fSCpf47Klzehm9T51t6J8kXOk1xwQ0o+qJT1okrpNJhgn7S29cG3zL YoLLVean4nPos5toDw3u8EGUaaCo9FjEIn2XQMTPEHrN5Na/nj11lYAzz iY3XNiEPvqWd90bj7QtYxp2Om/7bpK6QdE4Msr1xIv/zgB4C3yuSX1Ujr A==; IronPort-SDR: RTzd4QQ6lzhjElaXYZWeeSW9IEiOKMxizCT/a/C3X6v8STbNckRUANGR5KBJpCMLKIKmxp7zs4 1hxc5jL8gBZA0BptT1KuFPnN9veFvBNi/Uvraff4BoIdA4rTCsDvhoStFgjFBZqu4S2cxeCmiG dqIG/z0+pAyJjAAQeYhT17/Yres3n/24sPrp7JVGU1TZnwFNnKSchU7ne9YXxg7S31Kj7PFIqk /nFQargADrxNUmWIOcpLO38HXKSQ9BVTm/scvatWZyThovRJgJuHkjMY00A1itsKg9ze20jy3H Z+s= X-IronPort-AV: E=Sophos;i="5.76,335,1592863200"; d="scan'208";a="2647786" From: Benjamin Bara - SKIDATA To: "p.zabel@pengutronix.de" , "mchehab@kernel.org" CC: "linux-media@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Richard Leitner - SKIDATA" Subject: [PATCH] media: coda: avoid starvation on well-compressed data Thread-Topic: [PATCH] media: coda: avoid starvation on well-compressed data Thread-Index: AdZ3sFkqxzglukE+Rf6iMENtrYblXQ== Date: Fri, 21 Aug 2020 11:58:45 +0000 Message-ID: <3b140eaf883b4666985c0be0db8d53e8@skidata.com> Accept-Language: en-US, de-AT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.111.252] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The prefetcher requires two 256 byte periods beyond the current one. However, currently it is only checked if there are at least 512 bytes beyond the current meta available. This only works under the assumption that every buffer has a size of at least 256 bytes. To ensure that the requirement is fulfilled with buffers < 256 bytes, the queue head and the queue tail must not be below this threshold. Otherwise, additional buffers are enqueued to ensure a full window. Signed-off-by: Benjamin Bara --- drivers/media/platform/coda/coda-bit.c | 8 ++++++-- drivers/media/platform/coda/coda.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platfor= m/coda/coda-bit.c index b021604eceaa..8158f3b34b36 100644 --- a/drivers/media/platform/coda/coda-bit.c +++ b/drivers/media/platform/coda/coda-bit.c @@ -323,7 +323,7 @@ static bool coda_bitstream_try_queue(struct coda_ctx *c= tx, void coda_fill_bitstream(struct coda_ctx *ctx, struct list_head *buffer_li= st) { struct vb2_v4l2_buffer *src_buf; - struct coda_buffer_meta *meta; + struct coda_buffer_meta *meta, *last_meta; u32 start; =20 if (ctx->bit_stream_param & CODA_BIT_STREAM_END_FLAG) @@ -343,6 +343,8 @@ void coda_fill_bitstream(struct coda_ctx *ctx, struct l= ist_head *buffer_list) ctx->num_metas >=3D ctx->num_internal_frames) { meta =3D list_first_entry(&ctx->buffer_meta_list, struct coda_buffer_meta, list); + last_meta =3D list_last_entry(&ctx->buffer_meta_list, + struct coda_buffer_meta, list); =20 /* * If we managed to fill in at least a full reorder @@ -352,7 +354,8 @@ void coda_fill_bitstream(struct coda_ctx *ctx, struct l= ist_head *buffer_list) * the first buffer to fetch, we can safely stop queuing * in order to limit the decoder drain latency. */ - if (coda_bitstream_can_fetch_past(ctx, meta->end)) + if (!meta->below_threshold && !last_meta->below_threshold && + coda_bitstream_can_fetch_past(ctx, meta->end)) break; } =20 @@ -403,6 +406,7 @@ void coda_fill_bitstream(struct coda_ctx *ctx, struct l= ist_head *buffer_list) meta->start =3D start; meta->end =3D ctx->bitstream_fifo.kfifo.in; meta->last =3D src_buf->flags & V4L2_BUF_FLAG_LAST; + meta->below_threshold =3D (meta->end - meta->start) < 256; if (meta->last) coda_dbg(1, ctx, "marking last meta"); spin_lock(&ctx->buffer_meta_lock); diff --git a/drivers/media/platform/coda/coda.h b/drivers/media/platform/co= da/coda.h index b81f3aca9209..6f77553e81b8 100644 --- a/drivers/media/platform/coda/coda.h +++ b/drivers/media/platform/coda/coda.h @@ -160,6 +160,7 @@ struct coda_buffer_meta { unsigned int start; unsigned int end; bool last; + bool below_threshold; }; =20 /* Per-queue, driver-specific private data */ --=20 2.25.1