linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: Daniel Almeida <daniel.almeida@collabora.com>
Cc: wedsonaf@gmail.com, ojeda@kernel.org, mchehab@kernel.org,
	hverkuil@xs4all.nl, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	kernel@collabora.com
Subject: Re: [RFC PATCH v2 0/2] Rewrite parts of rkvdec driver and the VP9 codec library in Rust
Date: Thu, 7 Mar 2024 12:04:09 -0800	[thread overview]
Message-ID: <Zeodua65NJpJI1z6@mz550> (raw)
In-Reply-To: <20240307190841.10260-1-daniel.almeida@collabora.com>

Hi Daniel,

On Thu, Mar 07, 2024 at 04:08:14PM -0300, Daniel Almeida wrote:
> Hi Mauro, Hans,
> 
> While working on v1 for this patchset, I realized that we can go further by
> converting the error-prone sections of our codec drivers to Rust. This also
> does not need any bindings in order to work.
> 
> As yet another proof-of-concept, I have converted parts of the rkvdec driver.
> Refer to instructions in v1 to test this.

I tested this on rk3399 rkvdec with:
./fluster.py run -d GStreamer-VP9-V4L2SL-Gst1.0 -ts VP9-TEST-VECTORS -j1

And I get the same result as on mainline (6.8-rc3)
Ran 220/305 tests successfully               in 913.877 secs

So I can't say I understand all the Rust here but my testing didn't show
any regressions in the VP9 decoding. :)

Deb

> 
> Notice how:
> 
> 1) many problematic memcpy's go away, these become a simple assignment in Rust.
> 
> 2) it can interop seamlessly with the code in rkvdec-vp9.c that was already
> converted in v1 of this series.
> 
> 3) it can use the Rust version of `seg_feat_enabled` directly in vp9.rs, while
> also using the C APIs from the v4l2-vp9-rs library in rkvdec-vp9.c
> 
> 4) more modern things become available for the programmer, like iterators and
> their methods without a performance penalty.
> 
> I want to propose the following:
> 
> Let's merge a non-RFC version of this series and gate it behind some kconfigs
> so that we can switch between the C and Rust implementations. Users get the C
> version by default, while we continuously test the Rust components on a CI for
> a few months. This will hopefully be enough time until the next Media Summit.
> 
> My aim is to eventually deprecate the C parts once we're confident that the
> Rust code is stable enough. I will keep my own tree, and send PRs to the media
> tree if a rebase or fix is needed.
> 
> I believe this will not be disruptive nor require any extra work from anyone
> but me.
> 
> -- Daniel
> 
> 
> Again, applies on top of:
> 
> commit d9c1fae3e5b225f2e45e0bca519f9a2967cd1062
> Author: Alice Ryhl <aliceryhl@google.com>
> Date:   Fri Feb 9 11:18:22 2024 +0000
> 
>     rust: file: add abstraction for `poll_table`
> 
> For those looking for a branch instead: https://gitlab.collabora.com/dwlsalmeida/for-upstream/-/tree/vp9-rs-rkvdec?ref_type=heads
> 
> Daniel Almeida (2):
>   v4l2-core: rewrite the VP9 library in Rust
>   media: rkvdec: rewrite parts of the driver in Rust
> 
>  drivers/media/platform/verisilicon/Kconfig    |    2 +-
>  .../platform/verisilicon/hantro_g2_vp9_dec.c  |   38 +-
>  .../media/platform/verisilicon/hantro_hw.h    |    8 +-
>  drivers/media/v4l2-core/Kconfig               |    5 +
>  drivers/staging/media/rkvdec/Kconfig          |    3 +-
>  drivers/staging/media/rkvdec/Makefile         |    2 +-
>  drivers/staging/media/rkvdec/cbindgen.toml    |   36 +
>  drivers/staging/media/rkvdec/common.rs        |   19 +
>  drivers/staging/media/rkvdec/regs.rs          |  237 ++
>  drivers/staging/media/rkvdec/rkvdec-vp9.c     |  607 +----
>  drivers/staging/media/rkvdec/rkvdec_rs.h      |  125 +
>  drivers/staging/media/rkvdec/rkvdec_rs.rs     |   14 +
>  drivers/staging/media/rkvdec/vp9.rs           |  636 +++++
>  include/media/v4l2-vp9-rs.h                   |   99 +
>  rust/bindings/bindings_helper.h               |    1 +
>  rust/helpers.c                                |    7 +
>  rust/kernel/lib.rs                            |    2 +
>  rust/kernel/media.rs                          |    5 +
>  rust/kernel/media/v4l2_core.rs                |    6 +
>  rust/kernel/media/v4l2_core/cbindgen.toml     |   26 +
>  rust/kernel/media/v4l2_core/vp9.rs            | 2053 +++++++++++++++++
>  21 files changed, 3415 insertions(+), 516 deletions(-)
>  create mode 100644 drivers/staging/media/rkvdec/cbindgen.toml
>  create mode 100644 drivers/staging/media/rkvdec/common.rs
>  create mode 100644 drivers/staging/media/rkvdec/regs.rs
>  create mode 100644 drivers/staging/media/rkvdec/rkvdec_rs.h
>  create mode 100644 drivers/staging/media/rkvdec/rkvdec_rs.rs
>  create mode 100644 drivers/staging/media/rkvdec/vp9.rs
>  create mode 100644 include/media/v4l2-vp9-rs.h
>  create mode 100644 rust/kernel/media.rs
>  create mode 100644 rust/kernel/media/v4l2_core.rs
>  create mode 100644 rust/kernel/media/v4l2_core/cbindgen.toml
>  create mode 100644 rust/kernel/media/v4l2_core/vp9.rs
> 
> -- 
> 2.43.0
> 
> 

      parent reply	other threads:[~2024-03-07 20:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 21:51 [RFC PATCH 0/1] Rewrite the VP9 codec library in Rust Daniel Almeida
2024-02-27 21:51 ` [RFC PATCH 1/1] v4l2-core: rewrite the VP9 " Daniel Almeida
2024-02-28 14:13   ` Alice Ryhl
2024-02-28 17:59     ` Daniel Almeida
2024-03-07 19:08 ` [RFC PATCH v2 0/2] Rewrite parts of rkvdec driver and the VP9 codec " Daniel Almeida
2024-03-07 19:08   ` [RFC PATCH v2 1/2] v4l2-core: rewrite the VP9 " Daniel Almeida
2024-03-07 19:08   ` [RFC PATCH v2 2/2] media: rkvdec: rewrite parts of the driver " Daniel Almeida
2024-03-07 20:56     ` Nicolas Dufresne
2024-03-07 21:45       ` Daniel Almeida
2024-03-07 20:04   ` Deborah Brouwer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zeodua65NJpJI1z6@mz550 \
    --to=deborah.brouwer@collabora.com \
    --cc=daniel.almeida@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=wedsonaf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).