From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Rob Herring <robh+dt@kernel.org>
Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-tegra@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 2/4] staging: media: tegra-vde: Manually pack UAPI structures
Date: Sun, 23 Jun 2019 20:07:28 +0300 [thread overview]
Message-ID: <20190623170730.5095-6-digetx@gmail.com> (raw)
In-Reply-To: <20190623170730.5095-1-digetx@gmail.com>
The __packed macro isn't available in userspace with the kernel headers.
Checkpatch asks to use the macro, which is unwanted in a case of a UAPI
header. There is no much benefit in a tight packing of the structures,
hence let's pack them manually to cleanup things a tad. Note that there
is no old-stable userspace that will suffer from this change, hence it's
fine to change the ABI. In a result also more space is reserved for a
possible future expansion of the UAPI as it was already shown that more
fields will be needed for a later SoC generations.
Suggested-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/staging/media/tegra-vde/tegra-vde.c | 13 +++++-
drivers/staging/media/tegra-vde/uapi.h | 44 +++++++++++----------
2 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/drivers/staging/media/tegra-vde/tegra-vde.c b/drivers/staging/media/tegra-vde/tegra-vde.c
index a5020dbf6eef..cc4244da2705 100644
--- a/drivers/staging/media/tegra-vde/tegra-vde.c
+++ b/drivers/staging/media/tegra-vde/tegra-vde.c
@@ -795,7 +795,7 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
{
struct device *dev = vde->miscdev.parent;
struct tegra_vde_h264_decoder_ctx ctx;
- struct tegra_vde_h264_frame frames[17];
+ struct tegra_vde_h264_frame *frames;
struct tegra_vde_h264_frame __user *frames_user;
struct video_frame *dpb_frames;
struct dma_buf_attachment *bitstream_data_dmabuf_attachment;
@@ -830,11 +830,17 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
if (ret)
return ret;
+ frames = kmalloc_array(ctx.dpb_frames_nb, sizeof(*frames), GFP_KERNEL);
+ if (!frames) {
+ ret = -ENOMEM;
+ goto release_bitstream_dmabuf;
+ }
+
dpb_frames = kcalloc(ctx.dpb_frames_nb, sizeof(*dpb_frames),
GFP_KERNEL);
if (!dpb_frames) {
ret = -ENOMEM;
- goto release_bitstream_dmabuf;
+ goto free_frames;
}
macroblocks_nb = ctx.pic_width_in_mbs * ctx.pic_height_in_mbs;
@@ -955,6 +961,9 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde,
free_dpb_frames:
kfree(dpb_frames);
+free_frames:
+ kfree(frames);
+
release_bitstream_dmabuf:
tegra_vde_detach_and_put_dmabuf(bitstream_data_dmabuf_attachment,
bitstream_sgt, DMA_TO_DEVICE);
diff --git a/drivers/staging/media/tegra-vde/uapi.h b/drivers/staging/media/tegra-vde/uapi.h
index dd3e4a8c9f7e..ffb4983e5bb6 100644
--- a/drivers/staging/media/tegra-vde/uapi.h
+++ b/drivers/staging/media/tegra-vde/uapi.h
@@ -21,40 +21,42 @@ struct tegra_vde_h264_frame {
__u32 frame_num;
__u32 flags;
- __u32 reserved;
-} __attribute__((packed));
+ // Must be zero'ed
+ __u32 reserved[6];
+};
struct tegra_vde_h264_decoder_ctx {
__s32 bitstream_data_fd;
__u32 bitstream_data_offset;
__u64 dpb_frames_ptr;
- __u8 dpb_frames_nb;
- __u8 dpb_ref_frames_with_earlier_poc_nb;
+ __u32 dpb_frames_nb;
+ __u32 dpb_ref_frames_with_earlier_poc_nb;
// SPS
- __u8 baseline_profile;
- __u8 level_idc;
- __u8 log2_max_pic_order_cnt_lsb;
- __u8 log2_max_frame_num;
- __u8 pic_order_cnt_type;
- __u8 direct_8x8_inference_flag;
- __u8 pic_width_in_mbs;
- __u8 pic_height_in_mbs;
+ __u32 baseline_profile;
+ __u32 level_idc;
+ __u32 log2_max_pic_order_cnt_lsb;
+ __u32 log2_max_frame_num;
+ __u32 pic_order_cnt_type;
+ __u32 direct_8x8_inference_flag;
+ __u32 pic_width_in_mbs;
+ __u32 pic_height_in_mbs;
// PPS
- __u8 pic_init_qp;
- __u8 deblocking_filter_control_present_flag;
- __u8 constrained_intra_pred_flag;
- __u8 chroma_qp_index_offset;
- __u8 pic_order_present_flag;
+ __u32 pic_init_qp;
+ __u32 deblocking_filter_control_present_flag;
+ __u32 constrained_intra_pred_flag;
+ __u32 chroma_qp_index_offset;
+ __u32 pic_order_present_flag;
// Slice header
- __u8 num_ref_idx_l0_active_minus1;
- __u8 num_ref_idx_l1_active_minus1;
+ __u32 num_ref_idx_l0_active_minus1;
+ __u32 num_ref_idx_l1_active_minus1;
- __u32 reserved;
-} __attribute__((packed));
+ // Must be zero'ed
+ __u32 reserved[11];
+};
#define VDE_IOCTL_BASE ('v' + 0x20)
--
2.22.0
next prev parent reply other threads:[~2019-06-23 17:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-23 17:07 [PATCH v3 0/4] NVIDIA Tegra Video Decoder driver improvements Dmitry Osipenko
2019-06-23 17:07 ` [PATCH v3] ARM: dts: tegra30: Connect SMMU with Video Decoder Engine Dmitry Osipenko
2019-08-12 16:42 ` Dmitry Osipenko
2019-10-29 13:13 ` Thierry Reding
2019-06-23 17:07 ` [PATCH v3] ARM: tegra: Enable Tegra VDE driver in tegra_defconfig Dmitry Osipenko
2019-10-29 13:11 ` Thierry Reding
2019-06-23 17:07 ` [PATCH v3] media: dt: bindings: tegra-vde: Document new optional IOMMU property Dmitry Osipenko
2019-07-09 23:02 ` Rob Herring
2019-06-23 17:07 ` [PATCH v3 1/4] staging: media: tegra-vde: Remove BIT() macro from UAPI header Dmitry Osipenko
2019-06-23 17:07 ` Dmitry Osipenko [this message]
2019-06-23 17:07 ` [PATCH v3 3/4] staging: media: tegra-vde: Add IOMMU support Dmitry Osipenko
2019-06-23 17:07 ` [PATCH v3 4/4] staging: media: tegra-vde: Defer dmabuf's unmapping Dmitry Osipenko
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=20190623170730.5095-6-digetx@gmail.com \
--to=digetx@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=devicetree@vger.kernel.org \
--cc=hverkuil@xs4all.nl \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=thierry.reding@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).