platform/kernel/linux-rpi.git
4 years agommc: sdhci: Silence MMC warnings
Maxime Ripard [Fri, 6 Dec 2019 12:05:27 +0000 (13:05 +0100)]
mmc: sdhci: Silence MMC warnings

When the MMC isn't plugged in, the driver will spam the console which is
pretty annoying when using NFS.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agodefconfig: Add V4L2 HEVC driver to bcm2711_defconfig
Dave Stevenson [Fri, 13 Mar 2020 16:55:32 +0000 (16:55 +0000)]
defconfig: Add V4L2 HEVC driver to bcm2711_defconfig

This replaces the register mapped driver.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agodtoverlays: Add overlay to enable the HEVC V4L2 driver
Dave Stevenson [Fri, 13 Mar 2020 16:52:55 +0000 (16:52 +0000)]
dtoverlays: Add overlay to enable the HEVC V4L2 driver

This replaces the rpivid_mem register mapping driver.
When the driver is complete, these DT changes should be
merged into the base DT instead of being an overlay.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agostaging: media: Add Raspberry Pi V4L2 H265 decoder
John Cox [Thu, 5 Mar 2020 18:30:41 +0000 (18:30 +0000)]
staging: media: Add Raspberry Pi V4L2 H265 decoder

This driver is for the HEVC/H265 decoder block on the Raspberry
Pi 4, and conforms to the V4L2 stateless decoder API.

Signed-off-by: John Cox <jc@kynesim.co.uk>
4 years agomedia: dt-bindings: media: Add binding for the Raspberry PI HEVC decoder
Dave Stevenson [Tue, 17 Mar 2020 10:53:16 +0000 (10:53 +0000)]
media: dt-bindings: media: Add binding for the Raspberry PI HEVC decoder

Adds a binding for the HEVC decoder found on the BCM2711 / Raspberry Pi 4.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: v4l2-mem2mem: allow request job buffer processing after job finish
John Cox [Thu, 5 Mar 2020 14:46:54 +0000 (14:46 +0000)]
media: v4l2-mem2mem: allow request job buffer processing after job finish

Allow the capture buffer to be detached from a v4l2 request job such
that another job can start before the capture buffer is returned. This
allows h/w codecs that can process multiple requests at the same time
to operate more efficiently.

Signed-off-by: John Cox <jc@kynesim.co.uk>
4 years agomedia: videodev2.h: Add a format for column YUV4:2:0 modes
Dave Stevenson [Fri, 24 Jan 2020 14:28:21 +0000 (14:28 +0000)]
media: videodev2.h: Add a format for column YUV4:2:0 modes

Some of the Broadcom codec blocks use a column based YUV4:2:0 image
format, so add the documentation and defines for both 8 and 10 bit
versions.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: uapi: Add hevc ctrls for WPP decoding
Dave Stevenson [Mon, 23 Mar 2020 19:00:17 +0000 (19:00 +0000)]
media: uapi: Add hevc ctrls for WPP decoding

WPP can allow greater parallelism within the decode, but needs
offset information to be passed in.

Adds num_entry_point_offsets and entry_point_offset_minus1 to
v4l2_ctrl_hevc_slice_params.

This is based on Jernej Skrabec's patches for cedrus which
implement the same feature.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: hevc_ctrls: Add slice param dependent slice segment
Dave Stevenson [Mon, 23 Mar 2020 18:34:01 +0000 (18:34 +0000)]
media: hevc_ctrls: Add slice param dependent slice segment

Adds V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT define.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: uapi: hevc: Add segment address field
Jernej Skrabec [Fri, 13 Dec 2019 16:04:27 +0000 (17:04 +0100)]
media: uapi: hevc: Add segment address field

From https://patchwork.linuxtv.org/patch/60725/
Changes requested, but mainly docs.

If HEVC frame consists of multiple slices, segment address has to be
known in order to properly decode it.

Add segment address field to slice parameters.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
4 years agomedia: uapi: hevc: Add scaling matrix control
Jernej Skrabec [Fri, 13 Dec 2019 16:04:25 +0000 (17:04 +0100)]
media: uapi: hevc: Add scaling matrix control

Taken from https://patchwork.linuxtv.org/patch/60728/
Changes (mainly documentation) have been requested.

HEVC has a scaling matrix concept. Add support for it.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
4 years agomedia: pixfmt: Document the HEVC slice pixel format
Paul Kocialkowski [Tue, 22 Oct 2019 15:26:53 +0000 (12:26 -0300)]
media: pixfmt: Document the HEVC slice pixel format

Commit de06f289283298e2938445019999cec46435375c upstream.

Document the current state of the HEVC slice pixel format.
The format will need to evolve in the future, which is why it is
not part of the public API.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: Fix hold buf flag checks
Jernej Skrabec [Wed, 6 Nov 2019 07:02:53 +0000 (08:02 +0100)]
media: v4l2-mem2mem: Fix hold buf flag checks

Commit 1076df3a77b490d33429560a9e0603b3673223e2 upstream.

Hold buf flag is set on output queue, not capture. Fix that.

Fixes: f07602ac3887 ("media: v4l2-mem2mem: add new_frame detection")
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
4 years agomedia: v4l: Add definitions for HEVC stateless decoding
Paul Kocialkowski [Tue, 22 Oct 2019 15:26:52 +0000 (12:26 -0300)]
media: v4l: Add definitions for HEVC stateless decoding

This introduces the required definitions for HEVC decoding support with
stateless VPUs. The controls associated to the HEVC slice format provide
the required meta-data for decoding slices extracted from the bitstream.

They are not exported to the public V4L2 API since reworking this API
will likely be needed for covering various use-cases and new hardware.

Multi-slice decoding is exposed as a valid decoding mode to match current
H.264 support but it is not yet implemented.

The interface comes with the following limitations:
* No custom quantization matrices (scaling lists);
* Support for a single temporal layer only;
* No slice entry point offsets support;
* No conformance window support;
* No VUI parameters support;
* No support for SPS extensions: range, multilayer, 3d, scc, 4 bits;
* No support for PPS extensions: range, multilayer, 3d, scc, 4 bits.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
[hverkuil-cisco@xs4all.nl: use 1ULL in flags defines in hevc-ctrls.h]
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: Documentation: media: Document V4L2_CTRL_TYPE_AREA
Ricardo Ribalda Delgado [Mon, 7 Oct 2019 15:06:32 +0000 (12:06 -0300)]
media: Documentation: media: Document V4L2_CTRL_TYPE_AREA

Commit 8ae3a0862993c09a8ef0f9abb379553370c517e3 upstream.

A struct v4l2_area containing the width and the height of a rectangular
area.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: add new_frame detection
Hans Verkuil [Fri, 11 Oct 2019 09:32:44 +0000 (06:32 -0300)]
media: v4l2-mem2mem: add new_frame detection

Commit f07602ac388723233e9e3c5a05b54baf34e0a3e9 upstream.

Drivers that support VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF
typically want to know if a new frame is started (i.e. the first
slice is about to be processed). Add a new_frame bool to v4l2_m2m_ctx
and set it accordingly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: add stateless_(try_)decoder_cmd ioctl helpers
Jernej Skrabec [Fri, 11 Oct 2019 09:32:43 +0000 (06:32 -0300)]
media: v4l2-mem2mem: add stateless_(try_)decoder_cmd ioctl helpers

Commit bef41d93aac64b54c3008ca6170bec54f85784f5 upstream.

These helpers are used by stateless codecs when they support multiple
slices per frame and hold capture buffer flag is set. It's expected that
all such codecs will use this code.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Co-developed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: videodev2.h: add V4L2_DEC_CMD_FLUSH
Hans Verkuil [Fri, 11 Oct 2019 09:32:42 +0000 (06:32 -0300)]
media: videodev2.h: add V4L2_DEC_CMD_FLUSH

Add this new V4L2_DEC_CMD_FLUSH decoder command and document it.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-mem2mem: support held capture buffers
Hans Verkuil [Fri, 11 Oct 2019 09:32:41 +0000 (06:32 -0300)]
media: v4l2-mem2mem: support held capture buffers

Commit f8cca8c97a63d77f48334cde81d15014f43530ef upstream.

Check for held buffers that are ready to be returned to vb2 in
__v4l2_m2m_try_queue(). This avoids drivers having to handle this
case.

Add v4l2_m2m_buf_done_and_job_finish() to correctly return source
and destination buffers and mark the job as finished while taking
a held destination buffer into account (i.e. that buffer won't be
returned). This has to be done while job_spinlock is held to avoid
race conditions.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: vb2: add V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF
Hans Verkuil [Fri, 11 Oct 2019 09:32:40 +0000 (06:32 -0300)]
media: vb2: add V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF

This patch adds support for the V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF
flag.

It also adds a new V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF
capability.

Drivers should set vb2_queue->subsystem_flags to
VB2_V4L2_FL_SUPPORTS_M2M_HOLD_CAPTURE_BUF to indicate support
for this flag.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-common: add RGB565 and RGB55 to v4l2_format_info
Benoit Parrot [Mon, 7 Oct 2019 15:10:08 +0000 (12:10 -0300)]
media: v4l2-common: add RGB565 and RGB55 to v4l2_format_info

Commit b373f84d77e1c409aacb4ff5bb5726c45fc8b166 upstream.

Add RGB565 and RGB555 to the v4l2_format_info table.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: v4l2-common: add pixel encoding support
Benoit Parrot [Mon, 7 Oct 2019 15:10:07 +0000 (12:10 -0300)]
media: v4l2-common: add pixel encoding support

Commit d5a897c8428b38053df4b427a4277b1a0722bfa0 upstream.

It is often useful to figure out if a pixel_format is either YUV or RGB
especially for driver who can perform the pixel encoding conversion.

Instead of having each driver implement its own "is_this_yuv/rgb"
function based on a restricted set of pixel value, it is better to do
this in centralized manner.

We therefore add a pixel_enc member to the v4l2_format_info structure to
quickly identify the related pixel encoding.
And add helper functions to check pixel encoding.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: add V4L2_CID_UNIT_CELL_SIZE control
Ricardo Ribalda Delgado [Mon, 7 Oct 2019 15:06:33 +0000 (12:06 -0300)]
media: add V4L2_CID_UNIT_CELL_SIZE control

Commit 61fd036d01111679b01e4b92e6bd0cdd33809aea upstream.

This control returns the unit cell size in nanometres. The struct provides
the width and the height in separated fields to take into consideration
asymmetric pixels and/or hardware binning.
This control is required for automatic calibration of sensors/cameras.

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: add V4L2_CTRL_TYPE_AREA control type
Ricardo Ribalda Delgado [Mon, 7 Oct 2019 15:06:31 +0000 (12:06 -0300)]
media: add V4L2_CTRL_TYPE_AREA control type

Commit d1dc49370f8371b00e682ac409aa1987ce641e93 upstream.

This type contains the width and the height of a rectangular area.

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agoadd Sensirion SPS30 to i2c-sensor overlay
Petr Štetiar [Sat, 7 Mar 2020 21:37:52 +0000 (22:37 +0100)]
add Sensirion SPS30 to i2c-sensor overlay

Add support for Sensirion SPS30 particulate matter sensor with fixed
address 0x69.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
4 years agoReduce noise from rpi poe hat fan
Nick B [Mon, 9 Mar 2020 13:05:39 +0000 (09:05 -0400)]
Reduce noise from rpi poe hat fan

This adds 2 extra states, at 40c and 45c, with PWM of 31 and 63 (out
of 255) for the rpi poe hat fan.  This significantly improves user
experience by providing a smoother ramp up of the fan, from a pwm 0
to 31 to 63 then finally to 150, and additionally makes it very easy
for users to further tweak the values as needed for their specific
application.

The possible concerns I have are that a hysteresis of 2000 (2c) could
be too narrow, and that running the fan more at a reduced temperature
(40000 - 40c) could cause problems.

Signed-off-by: Nick B <nick@pelagiris.org>
4 years agodrm/v3d: Replace wait_for macros to remove use of msleep (#3510)
Yukimasa Sugizaki [Fri, 20 Mar 2020 10:01:23 +0000 (19:01 +0900)]
drm/v3d: Replace wait_for macros to remove use of msleep (#3510)

commit 9daee6141cc9c75b09659b02b1cb9eeb2f5e16cc upstream.

The wait_for macro's for Broadcom V3D driver used msleep, which is
inappropriate due to its inaccuracy at low values (minimum wait time
is about 30ms on the Raspberry Pi).  This sleep was triggering in
v3d_clean_caches(), causing us to only be able to dispatch ~33 compute
jobs per second.

This patch replaces the macro with the one from the Intel i915 version
which uses usleep_range to provide more accurate waits.

v2: Split from the vc4 patch so that we can confidently apply to
    stable (by anholt)

Signed-off-by: James Hughes <james.hughes@raspberrypi.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20200217153145.13780-1-james.hughes@raspberrypi.com
Link: https://github.com/raspberrypi/linux/issues/3460
Fixes: 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")

Co-authored-by: James Hughes <james.hughes@raspberrypi.com>
4 years agodrm/modes: parse_cmdline: Explicitly memset the passed in drm_cmdline_mode struct
Hans de Goede [Mon, 18 Nov 2019 15:51:32 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Explicitly memset the passed in drm_cmdline_mode struct

Commit d1fe276b5115f0d581c3cfe6154633b3547e8aab upstream.

Instead of only setting mode->specified on false on an early exit and
leaving e.g. mode->bpp_specified and mode->refresh_specified as is,
lets be consistent and just zero out the entire passed in struct at
the top of drm_mode_parse_command_line_for_connector()

Changes in v3:
-Drop "mode->specified = false;" line instead of the "return false;" (oops)
 This crasher was reported-by: kernel test robot <lkp@intel.com>

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-11-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Remove some unnecessary code (v2)
Hans de Goede [Mon, 18 Nov 2019 15:51:31 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Remove some unnecessary code (v2)

Commit 5b926617cdef41ce0696e09834991194b1759e28 upstream.

fb_get_options() will return fb_mode_option if no video=<connector-name>
argument is present on the kernel commandline, so there is no need to also
do this in drm_mode_parse_command_line_for_connector() as our only caller
uses fb_get_options() to get the mode_option argument.

Changes in v2:
-Split out the changes dealing with the initialization of the mode struct
 into a separate patch

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-10-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Add support for specifying panel_orientation (v2)
Hans de Goede [Mon, 18 Nov 2019 15:51:30 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Add support for specifying panel_orientation (v2)

Commit 4e7a4a6fbdc669c44e6079f9d5eb25673749455f upstream.

Sometimes we want to override a connector's panel_orientation from the
kernel commandline. Either for testing and for special cases, e.g. a kiosk
like setup which uses a TV mounted in portrait mode.

Users can already specify a "rotate" option through a video= kernel cmdline
option. But that only supports 0/180 degrees (see drm_client_modeset TODO)
and only works for in kernel modeset clients, not for userspace kms users.

The "panel-orientation" connector property OTOH does support 90/270 degrees
as it leaves dealing with the rotation up to userspace and this does work
for userspace kms clients (at least those which support this property).

Changes in v2:
-Add missing ':' after @panel_orientation (reported by kbuild test robot)

BugLink: https://gitlab.freedesktop.org/plymouth/plymouth/merge_requests/83
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-9-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Allow specifying stand-alone options
Hans de Goede [Mon, 18 Nov 2019 15:51:29 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Allow specifying stand-alone options

Commit 7b1cce760afe38b40f0989cdf10b2190dccf9815 upstream.

Some options which can be specified on the commandline, such as
margin_right=..., margin_left=..., etc. are applied not only to the
specified mode, but to all modes. As such it would be nice if the user
can simply say e.g.
video=HDMI-1:margin_right=14,margin_left=24,margin_bottom=36,margin_top=42

This commit refactors drm_mode_parse_command_line_for_connector() to
add support for this, and as a nice side effect also cleans up the
function a bit.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-8-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Set bpp/refresh_specified after successful parsing
Hans de Goede [Mon, 18 Nov 2019 15:51:28 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Set bpp/refresh_specified after successful parsing

Commit 6a2d163756545aa3180d7851d5f8322b865e72be upstream.

drm_connector_get_cmdline_mode() calls
drm_mode_parse_command_line_for_connector() with &connector->cmdline_mode
as mode argument, so anything which we store in the mode arguments gets
kept even if we return false.

Avoid storing a possibly false-postive bpp/refresh_specified setting
in connector->cmdline_mode by moving the setting of these to after
successful parsing of the bpp/refresh parts of the video= argument.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-7-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Add freestanding argument to drm_mode_parse_cmdline_options()
Hans de Goede [Mon, 18 Nov 2019 15:51:27 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Add freestanding argument to drm_mode_parse_cmdline_options()

Commit 99e2716e053734b70434502867be24d20a3e2d84 upstream.

Add a freestanding function argument to drm_mode_parse_cmdline_options()
similar to how drm_mode_parse_cmdline_extra() already has this.

This is a preparation patch for allowing parsing of stand-alone options
without a mode before them, e.g.: video=HDMI-1:margin_right=14,...

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-6-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Rework drm_mode_parse_cmdline_options()
Hans de Goede [Mon, 18 Nov 2019 15:51:26 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Rework drm_mode_parse_cmdline_options()

Commit 739b200c2edcaaa7a86f37b0c11db57956433dfb upstream.

Refactor drm_mode_parse_cmdline_options() so that it takes a pointer
to the first option, rather then a pointer to the ',' before the first
option.

This is a preparation patch for allowing parsing of stand-alone options
without a mode before them, e.g.: video=HDMI-1:margin_right=14,...

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-5-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Accept extras directly after mode combined with options
Hans de Goede [Mon, 18 Nov 2019 15:51:25 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Accept extras directly after mode combined with options

Commit cfb0881b8f621b656a9e23b31944a5db94cf5842 upstream.

Before this commit it was impossible to combine an extra mode argument
specified directly after the resolution with an option, e.g.
video=HDMI-1:720x480e,rotate=180 would not work, either the "e" to force
enable would need to be dropped or the ",rotate=180", otherwise the
mode_option would not be accepted.

This commit fixes this by setting parse_extras to true in this case, so
that drm_mode_parse_cmdline_res_mode() parses the extra arguments directly
after the resolution.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-4-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Stop parsing extras after bpp / refresh at ', '
Hans de Goede [Mon, 18 Nov 2019 15:51:24 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Stop parsing extras after bpp / refresh at ', '

Commit c2ed3e941901810ad3d55ce1935fa22c5007fee4 upstream.

Before this commit it was impossible to add an extra mode argument after
a bpp or refresh specifier, combined with an option, e.g.
video=HDMI-1:720x480-24e,rotate=180 would not work, either the "e" to
force enable would need to be dropped or the ",rotate=180", otherwise
the mode_option would not be accepted.

This commit fixes this by fixing the length calculation if extras_ptr
is set to stop the extra parsing at the start of the options (stop at the
',' options_ptr points to).

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-3-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Make various char pointers const
Hans de Goede [Mon, 18 Nov 2019 15:51:23 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Make various char pointers const

Commit 83e14ea3a64f00897cc31974d3ae4e27e5a7405b upstream.

We are not supposed to modify the passed in string, make char pointers
used in drm_mode_parse_cmdline_options() const char * where possible.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-2-hdegoede@redhat.com
4 years agodrm/modes: parse_cmdline: Fix possible reference past end of string
Hans de Goede [Mon, 18 Nov 2019 15:51:22 +0000 (16:51 +0100)]
drm/modes: parse_cmdline: Fix possible reference past end of string

Commit 8582e244e5fe72d2e9ace186fa8f3ed3bb4122e1 upstream.

Before this commit, if the last option of a video=... option is for
example "rotate" without a "=<value>" after it then delim will point to
the terminating 0 of the string, and value which is sets to <delim + 1>
will point one position past the end of the string.

This commit fixes this by enforcing that the contents of delim equals '='
as it should be for options which take a value, this check is done in a
new drm_mode_parse_cmdline_int helper function which factors out the
common integer parsing code for all the options which take an int.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191118155134.30468-1-hdegoede@redhat.com
4 years agonet: bcmgenet: Clear ID_MODE_DIS in EXT_RGMII_OOB_CTRL when not needed
Nicolas Saenz Julienne [Tue, 25 Feb 2020 13:11:59 +0000 (14:11 +0100)]
net: bcmgenet: Clear ID_MODE_DIS in EXT_RGMII_OOB_CTRL when not needed

commit 402482a6a78e5c61d8a2ec6311fc5b4aca392cd6 upstream.

Outdated Raspberry Pi 4 firmware might configure the external PHY as
rgmii although the kernel currently sets it as rgmii-rxid. This makes
connections unreliable as ID_MODE_DIS is left enabled. To avoid this,
explicitly clear that bit whenever we don't need it.

Fixes: da38802211cc ("net: bcmgenet: Add RGMII_RXID support")
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Matthias Reichl <hias@horus.com>
4 years agoARM: dts: bcm271x: Use a53 pmu, drop RPI364
Phil Elwell [Thu, 19 Mar 2020 10:04:46 +0000 (10:04 +0000)]
ARM: dts: bcm271x: Use a53 pmu, drop RPI364

The upstream bcm2837.dtsi uses cortex-a53-pmu, so we can do the same
but with a fallback to the cortex-a7-pmu which is supported by the
32-bit kernel.

Now that we're using the natural fallback mechanism of compatible
strings, the RPI364 macro no longer serves any purpose - remove it.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoARM: dts: bcm2711: Add 32-bit PMU compatibility
Phil Elwell [Tue, 17 Mar 2020 16:39:07 +0000 (16:39 +0000)]
ARM: dts: bcm2711: Add 32-bit PMU compatibility

The "arm" architecture has no support for the cortex-a72 as such, but
the performance and measurement unit from the cortex-a15 seems to be
compatible.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoAdd support for merus-amp soundcard and ma120x0p codec
AMuszkat [Mon, 24 Feb 2020 21:56:59 +0000 (22:56 +0100)]
Add support for merus-amp soundcard and ma120x0p codec

correct checkpatch warnings and errors

Signed-off-by: AMuszkat <ariel.muszkat@gmail.com>
4 years agogpio-ir-overlay: add parameter to configure signal polarity (#3490)
Matthias Reichl [Fri, 6 Mar 2020 10:08:10 +0000 (11:08 +0100)]
gpio-ir-overlay: add parameter to configure signal polarity (#3490)

Standard IR receivers use inverted / active-low signalling
and the gpio-ir overlay configures the GPIO appropriately
as GPIO_ACTIVE_LOW (1).

In order to support (rather rare) non-inverted / active-high
signalling the GPIO needs to be configured as GPIO_ACTIVE_HIGH (0).

Add an "invert" parameter to override this like in the gpio-ir-tx
overlay.

Signed-off-by: Matthias Reichl <hias@horus.com>
4 years agodrm/vc4: Add DRM_FORMAT_P030 support to firmware-kms
Dave Stevenson [Fri, 24 Jan 2020 14:24:33 +0000 (14:24 +0000)]
drm/vc4: Add DRM_FORMAT_P030 support to firmware-kms

Adds support for this format which is 3 10bit samples packed into
4 bytes, as used by the HEVC codec block.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agodrm/fourcc: Add packed 10bit YUV 4:2:0 format
Dave Stevenson [Fri, 24 Jan 2020 14:22:06 +0000 (14:22 +0000)]
drm/fourcc: Add packed 10bit YUV 4:2:0 format

Adds a format that is 3 10bit YUV 4:2:0 samples packed into
a 32bit work (with 2 spare bits).

Supported on Broadcom BCM2711 chips.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agodrm/vc4: fkms: Change crtc_state structure name to avoid conflict
Maxime Ripard [Thu, 26 Dec 2019 14:44:31 +0000 (15:44 +0100)]
drm/vc4: fkms: Change crtc_state structure name to avoid conflict

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
4 years agomedia: ov5647: change defaults to better match raw camera applications.
David Plowman [Wed, 29 Jan 2020 15:31:32 +0000 (15:31 +0000)]
media: ov5647: change defaults to better match raw camera applications.

Specifically:

* AWB is now off by default.

* AEC/AGC is also off by default.

* The default mode is changed to the 10-bit 2x2 binned mode.

AWB and AEC/AGC can be re-enabled using the usual V4L2 controls. The
original 8-bit mode will be respected if an application requests the
8-bit format.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agomedia: ov5647: Add extra 10-bit sensor modes.
David Plowman [Wed, 29 Jan 2020 15:31:28 +0000 (15:31 +0000)]
media: ov5647: Add extra 10-bit sensor modes.

The 8-bit VGA mode remains, we add the following 10-bit modes:

Mode 0: 2592x1944 full resolution.

Mode 1: 1920x1080 full resolution, but centre-cropped.
(This mode achieves 30fps, mode 0 does not.)

Mode 2: 1296x972 full field-of-view 2x2 binned mode.

Mode 3: VGA full field of view mode.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agomedia: ov5647: Add V4L2 controls for analogue gain, exposure and AWB
David Plowman [Wed, 29 Jan 2020 15:31:23 +0000 (15:31 +0000)]
media: ov5647: Add V4L2 controls for analogue gain, exposure and AWB

Added basic v4l2_ctrl_handler infrastructure (there was none
previously).

Added controls to let AWB/AEC/AGC run in the sensor's auto mode or
manually. Also controls to set exposure (in lines) and analogue gain
(as a register code) from user code.

Also delete registers (just the one) from the VGA mode register set
that are now controlled by the new V4L2 controls.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agomedia: ov5647: Add basic support for multiple sensor modes.
David Plowman [Wed, 29 Jan 2020 15:30:53 +0000 (15:30 +0000)]
media: ov5647: Add basic support for multiple sensor modes.

Specifically:

Added a structure ov5647_mode and a list of supported_modes (though no
actual new modes as yet). The state object points to the "current mode".

ov5647_enum_mbus_code, ov5647_enum_frame_size, ov5647_set_fmt and
ov5647_get_fmt all needed upgrading to cope with multiple modes.

__sensor_init (which writes all the registers) is now called by
ov5647_stream_on (once the mode is known) rather than by
ov5647_sensor_power.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agomedia: ov5647: Fix return codes from ov5647_write/ov5647_read functions.
David Plowman [Wed, 15 Jan 2020 13:40:38 +0000 (13:40 +0000)]
media: ov5647: Fix return codes from ov5647_write/ov5647_read functions.

Previously they were returning positive non-zero codes for success,
which were getting passed up the call stack. Since release 4.19,
do_dentry_open (fs/open.c) has been catching these and flagging an
error. (So this driver has been broken since that date.)

Fixes: 3c2472a [media] media: i2c: Add support for OV5647 sensor
Signed-off-by: David Plowman <david.plowman@raspberrypi.org>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
4 years agoKbuild: Allow .dtbo overlays to be built, adjust.
Nataliya Korovkina [Thu, 12 Mar 2020 21:22:53 +0000 (17:22 -0400)]
Kbuild: Allow .dtbo overlays to be built, adjust.

This is adjustment to commit
d368ceaacdccd7732dc97d1d7987bdf7149d62e3 "kbuild: Allow .dtbo overlays to be built piecemeal"

prepare3 target has gone from mainline tree in branch 5.4.y

Signed-off-by: Nataliya Korovkina <malus.brandywine@gmail.com>
4 years agooverlays: imx219: Correct link frequency to match the upstream driver
Dave Stevenson [Wed, 11 Mar 2020 12:07:57 +0000 (12:07 +0000)]
overlays: imx219: Correct link frequency to match the upstream driver

The upstream driver is checking the link frequency parameter, and
the overlay had the wrong value.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
4 years agomedia: i2c: Add driver for Sony IMX219 sensor
Dave Stevenson [Mon, 20 Jan 2020 08:15:58 +0000 (05:15 -0300)]
media: i2c: Add driver for Sony IMX219 sensor

Commit 1283b3b8f82b9004fbb94398cade5c8e797a2c8d upstream.
(Currently on linux-media/master, queued for 5.7)

Adds a driver for the 8MPix Sony IMX219 CSI2 sensor.
Whilst the sensor supports 2 or 4 CSI2 data lanes, this driver
currently only supports 2 lanes.
8MPix @ 15fps, 1080P @ 30fps (cropped FOV), and 1640x1232 (2x2 binned)
@ 30fps are currently supported.

[Sakari Ailus: make imx219_check_hwcfg static]

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agomedia: dt-bindings: media: i2c: Add IMX219 CMOS sensor binding
Andrey Konovalov [Mon, 20 Jan 2020 08:15:57 +0000 (05:15 -0300)]
media: dt-bindings: media: i2c: Add IMX219 CMOS sensor binding

Commit 9d730f2cf4c0391785855dd231577d2de2594df9 upstream.
(Currently on linux-media/master, queued for 5.7)

Add YAML device tree binding for IMX219 CMOS image sensor, and
the relevant MAINTAINERS entries.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
4 years agoRevert "media: dt-bindings: Add binding for the Sony IMX219 sensor"
Dave Stevenson [Wed, 11 Mar 2020 12:14:58 +0000 (12:14 +0000)]
Revert "media: dt-bindings: Add binding for the Sony IMX219 sensor"

This reverts commit e3dca865875b345a2fa45e8295e32d701c666334.

4 years agoRevert "media: i2c: Add driver for Sony IMX219 sensor"
Dave Stevenson [Wed, 11 Mar 2020 12:14:49 +0000 (12:14 +0000)]
Revert "media: i2c: Add driver for Sony IMX219 sensor"

This reverts commit 39d484cb87cbe5da5035199fbdec1f3c0b71d2ea.

4 years agobcm2711-rpi.dtsi: Use upstream pcie node
Phil Elwell [Mon, 2 Mar 2020 15:05:25 +0000 (15:05 +0000)]
bcm2711-rpi.dtsi: Use upstream pcie node

Now that the upstream bcm2711 DT has a pcie DT node there's no need to
define one downstream.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoPCI: brcmstb: Fix build on 32bit ARM platforms with older compilers
Marek Szyprowski [Thu, 27 Feb 2020 11:51:46 +0000 (12:51 +0100)]
PCI: brcmstb: Fix build on 32bit ARM platforms with older compilers

commit 73a7a271b3eee7b83f29b13866163776f1cbef89 upstream.

Some older compilers have no implementation for the helper for 64-bit
unsigned division/modulo, so linking pcie-brcmstb driver causes the
"undefined reference to `__aeabi_uldivmod'" error.

*rc_bar2_size is always a power of two, because it is calculated as:
"1ULL << fls64(entry->res->end - entry->res->start)", so the modulo
operation in the subsequent check can be replaced by a simple logical
AND with a proper mask.

Link: https://lore.kernel.org/r/20200227115146.24515-1-m.szyprowski@samsung.com
Fixes: c0452137034b ("PCI: brcmstb: Add Broadcom STB PCIe host controller driver")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
4 years agoPCI: brcmstb: Add MSI support
Jim Quinlan [Mon, 16 Dec 2019 11:01:10 +0000 (12:01 +0100)]
PCI: brcmstb: Add MSI support

commit 40ca1bf580ef24df30702032ba5e40dfdcaa200b upstream.

This adds MSI support to the Broadcom STB PCIe host controller. The MSI
controller is physically located within the PCIe block, however, there
is no reason why the MSI controller could not be moved elsewhere in the
future. MSIX is not supported by the HW.

Since the internal Brcmstb MSI controller is intertwined with the PCIe
controller, it is not its own platform device but rather part of the
PCIe platform device.

Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Co-developed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
4 years agoPCI: brcmstb: Add Broadcom STB PCIe host controller driver
Jim Quinlan [Mon, 16 Dec 2019 11:01:09 +0000 (12:01 +0100)]
PCI: brcmstb: Add Broadcom STB PCIe host controller driver

commit c0452137034bda8f686dd9a2e167949bfffd6776 upstream.

This adds a basic driver for Broadcom's STB PCIe controller, for now
aimed at Raspberry Pi 4's SoC, bcm2711.

Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Co-developed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
[lorenzo.pieralisi@arm.com: updated brcm_pcie_get_rc_bar2_size_and_offset()according to https://lore.kernel.org/linux-pci/be8ddb33a7360af1815cf686f77f3f0913d02be3.camel@suse.de]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
4 years agoARM: dts: bcm2711: Enable PCIe controller
Nicolas Saenz Julienne [Mon, 16 Dec 2019 11:01:08 +0000 (12:01 +0100)]
ARM: dts: bcm2711: Enable PCIe controller

commit d5c8dc0d4c880fbde5293cc186b1ab23466254c4 upstream.

This enables bcm2711's PCIe bus, which is hardwired to a VIA
Technologies XHCI USB 3.0 controller.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
4 years agodma-mapping: treat dev->bus_dma_mask as a DMA limit
Nicolas Saenz Julienne [Thu, 21 Nov 2019 09:26:44 +0000 (10:26 +0100)]
dma-mapping: treat dev->bus_dma_mask as a DMA limit

commit a7ba70f1787f977f970cd116076c6fce4b9e01cc upstream.

Using a mask to represent bus DMA constraints has a set of limitations.
The biggest one being it can only hold a power of two (minus one). The
DMA mapping code is already aware of this and treats dev->bus_dma_mask
as a limit. This quirk is already used by some architectures although
still rare.

With the introduction of the Raspberry Pi 4 we've found a new contender
for the use of bus DMA limits, as its PCIe bus can only address the
lower 3GB of memory (of a total of 4GB). This is impossible to represent
with a mask. To make things worse the device-tree code rounds non power
of two bus DMA limits to the next power of two, which is unacceptable in
this case.

In the light of this, rename dev->bus_dma_mask to dev->bus_dma_limit all
over the tree and treat it as such. Note that dev->bus_dma_limit should
contain the higher accessible DMA address.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
4 years agodma-direct: exclude dma_direct_map_resource from the min_low_pfn check
Christoph Hellwig [Tue, 19 Nov 2019 16:38:58 +0000 (17:38 +0100)]
dma-direct: exclude dma_direct_map_resource from the min_low_pfn check

commit 68a33b1794665ba8a1d1ef1d3bfcc7c587d380a6 upstream.

The valid memory address check in dma_capable only makes sense when mapping
normal memory, not when using dma_map_resource to map a device resource.
Add a new boolean argument to dma_capable to exclude that check for the
dma_map_resource case.

Fixes: b12d66278dd6 ("dma-direct: check for overflows on 32 bit DMA addresses")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 years agodma-direct: avoid a forward declaration for phys_to_dma
Christoph Hellwig [Tue, 12 Nov 2019 16:07:43 +0000 (17:07 +0100)]
dma-direct: avoid a forward declaration for phys_to_dma

Move dma_capable down a bit so that we don't need a forward declaration
for phys_to_dma.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
(cherry picked from commit c7345159f7db6fb69ec1c3b3f8f28cd05c731be2)

4 years agodma-direct: unify the dma_capable definitions
Christoph Hellwig [Tue, 12 Nov 2019 16:06:04 +0000 (17:06 +0100)]
dma-direct: unify the dma_capable definitions

commit 130c1ccbf55330b55e82612a6e54eebb82c9d746 upstream.

Currently each architectures that wants to override dma_to_phys and
phys_to_dma also has to provide dma_capable.  But there isn't really
any good reason for that.  powerpc and mips just have copies of the
generic one minus the latests fix, and the arm one was the inspiration
for said fix, but misses the bus_dma_mask handling.
Make all architectures use the generic version instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
4 years agoPCI: of: Add inbound resource parsing to helpers
Rob Herring [Wed, 30 Oct 2019 22:30:57 +0000 (17:30 -0500)]
PCI: of: Add inbound resource parsing to helpers

Extend devm_of_pci_get_host_bridge_resources() and
pci_parse_request_of_pci_ranges() helpers to also parse the inbound
addresses from DT 'dma-ranges' and populate a resource list with the
translated addresses. This will help ensure 'dma-ranges' is always
parsed in a consistent way.

Tested-by: Srinath Mannam <srinath.mannam@broadcom.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> # for AArdvark
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Srinath Mannam <srinath.mannam@broadcom.com>
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Gustavo Pimentel <gustavo.pimentel@synopsys.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Will Deacon <will@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Toan Le <toan@os.amperecomputing.com>
Cc: Ley Foon Tan <lftan@altera.com>
Cc: Tom Joseph <tjoseph@cadence.com>
Cc: Ray Jui <rjui@broadcom.com>
Cc: Scott Branden <sbranden@broadcom.com>
Cc: bcm-kernel-feedback-list@broadcom.com
Cc: Ryder Lee <ryder.lee@mediatek.com>
Cc: Karthikeyan Mitran <m.karthikeyan@mobiveil.co.in>
Cc: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Cc: Simon Horman <horms@verge.net.au>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: rfi@lists.rocketboards.org
Cc: linux-mediatek@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-rockchip@lists.infradead.org
(cherry picked from commit 331f63457165a30c708280de2c77f1742c6351dc)

4 years agox86/PCI: sta2x11: use default DMA address translation
Nicolas Saenz Julienne [Thu, 7 Nov 2019 15:06:45 +0000 (16:06 +0100)]
x86/PCI: sta2x11: use default DMA address translation

commit e380a0394c36a3a878c858418d5dd7f5f195b6fc upstream.

The devices found behind this PCIe chip have unusual DMA mapping
constraints as there is an AMBA interconnect placed in between them and
the different PCI endpoints. The offset between physical memory
addresses and AMBA's view is provided by reading a PCI config register,
which is saved and used whenever DMA mapping is needed.

It turns out that this DMA setup can be represented by properly setting
'dma_pfn_offset', 'dma_bus_mask' and 'dma_mask' during the PCI device
enable fixup. And ultimately allows us to get rid of this device's
custom DMA functions.

Aside from the code deletion and DMA setup, sta2x11_pdev_to_mapping() is
moved to avoid warnings whenever CONFIG_PM is not enabled.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
4 years agodma-direct: check for overflows on 32 bit DMA addresses
Nicolas Saenz Julienne [Thu, 7 Nov 2019 15:06:44 +0000 (16:06 +0100)]
dma-direct: check for overflows on 32 bit DMA addresses

As seen on the new Raspberry Pi 4 and sta2x11's DMA implementation it is
possible for a device configured with 32 bit DMA addresses and a partial
DMA mapping located at the end of the address space to overflow. It
happens when a higher physical address, not DMAable, is translated to
it's DMA counterpart.

For example the Raspberry Pi 4, configurable up to 4 GB of memory, has
an interconnect capable of addressing the lower 1 GB of physical memory
with a DMA offset of 0xc0000000. It transpires that, any attempt to
translate physical addresses higher than the first GB will result in an
overflow which dma_capable() can't detect as it only checks for
addresses bigger then the maximum allowed DMA address.

Fix this by verifying in dma_capable() if the DMA address range provided
is at any point lower than the minimum possible DMA address on the bus.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
(cherry picked from commit b12d66278dd627cbe1ea7c000aa4715aaf8830c8)

4 years agodma/direct: turn ARCH_ZONE_DMA_BITS into a variable
Nicolas Saenz Julienne [Mon, 14 Oct 2019 18:31:03 +0000 (20:31 +0200)]
dma/direct: turn ARCH_ZONE_DMA_BITS into a variable

commit 8b5369ea580964dbc982781bfb9fb93459fc5e8d upstream.

Some architectures, notably ARM, are interested in tweaking this
depending on their runtime DMA addressing limitations.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoresource: Add a resource_list_first_type helper
Rob Herring [Mon, 28 Oct 2019 16:32:32 +0000 (11:32 -0500)]
resource: Add a resource_list_first_type helper

commit 494f8b10d832456a96be4ee7317425f6936cabc8 upstream.

A common pattern is looping over a resource_list just to get a matching
entry with a specific type. Add resource_list_first_type() helper which
implements this.

Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
4 years agomm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type'
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:46 +0000 (20:25 +0200)]
mm: refresh ZONE_DMA and ZONE_DMA32 comments in 'enum zone_type'

commit 734f9246e791d8da278957b2c326d7709b2a97c0 upstream.

These zones usage has evolved with time and the comments were outdated.
This joins both ZONE_DMA and ZONE_DMA32 explanation and gives up to date
examples on how they are used on different architectures.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoarm64: use both ZONE_DMA and ZONE_DMA32
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:45 +0000 (20:25 +0200)]
arm64: use both ZONE_DMA and ZONE_DMA32

commit 1a8e1cef7603e218339ac63cb3178b25554524e5 upstream.

So far all arm64 devices have supported 32 bit DMA masks for their
peripherals. This is not true anymore for the Raspberry Pi 4 as most of
it's peripherals can only address the first GB of memory on a total of
up to 4 GB.

This goes against ZONE_DMA32's intent, as it's expected for ZONE_DMA32
to be addressable with a 32 bit mask. So it was decided to re-introduce
ZONE_DMA in arm64.

ZONE_DMA will contain the lower 1G of memory, which is currently the
memory area addressable by any peripheral on an arm64 device.
ZONE_DMA32 will contain the rest of the 32 bit addressable memory.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoarm64: rename variables used to calculate ZONE_DMA32's size
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:44 +0000 (20:25 +0200)]
arm64: rename variables used to calculate ZONE_DMA32's size

commit a573cdd7973dedd87e62196c400332896bb236c8 upstream.

Let the name indicate that they are used to calculate ZONE_DMA32's size
as opposed to ZONE_DMA.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoarm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys()
Nicolas Saenz Julienne [Wed, 11 Sep 2019 18:25:43 +0000 (20:25 +0200)]
arm64: mm: use arm64_dma_phys_limit instead of calling max_zone_dma_phys()

commit ae970dc096b2d39f65f2e18d142e3978dc9ee1c7 upstream.

By the time we call zones_sizes_init() arm64_dma_phys_limit already
contains the result of max_zone_dma_phys(). We use the variable instead
of calling the function directly to save some precious cpu time.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
4 years agoof: Make of_dma_get_range() work on bus nodes
Robin Murphy [Wed, 3 Jul 2019 17:42:20 +0000 (18:42 +0100)]
of: Make of_dma_get_range() work on bus nodes

commit 951d48855d86e72e0d6de73440fe09d363168064 upstream.

Since the "dma-ranges" property is only valid for a node representing a
bus, of_dma_get_range() currently assumes the node passed in is a leaf
representing a device, and starts the walk from its parent. In cases
like PCI host controllers on typical FDT systems, however, where the PCI
endpoints are probed dynamically the initial leaf node represents the
'bus' itself, and this logic means we fail to consider any "dma-ranges"
describing the host bridge itself. Rework the logic such that
of_dma_get_range() also works correctly starting from a bus node
containing "dma-ranges".

While this does mean "dma-ranges" could incorrectly be in a device leaf
node, there isn't really any way in this function to ensure that a leaf
node is or isn't a bus node.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
[robh: Allow for the bus child node to still be passed in]
Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
4 years agoof/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'
Rob Herring [Wed, 4 Sep 2019 10:43:30 +0000 (11:43 +0100)]
of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'

commit 81db12ee15cb83926e290a8a3654a2dfebc80935 upstream.

'dma-ranges' frequently exists without parent nodes having 'dma-ranges'.
While this is an error for 'ranges', this is fine because DMA capable
devices always have a translatable DMA address. Also, with no
'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with
no restrictions unless perhaps the device itself has implicit
restrictions.

Cc: Robin Murphy <robin.murphy@arm.com>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
4 years agoof: Factor out #{addr,size}-cells parsing
Robin Murphy [Tue, 2 Jul 2019 17:42:39 +0000 (18:42 +0100)]
of: Factor out #{addr,size}-cells parsing

In some cases such as PCI host controllers, we may have a "parent bus"
which is an OF leaf node, but still need to correctly parse ranges from
the point of view of that bus. For that, factor out variants of the
"#addr-cells" and "#size-cells" parsers which do not assume they have a
device node and thus immediately traverse upwards before reading the
relevant property.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
[robh: don't make of_bus_n_{addr,size}_cells() public]
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
(cherry picked from commit b68ac8dc22ebbf003e26e44bf4dd3030c076df5a)

4 years agoof: address: Follow DMA parent for "dma-coherent"
Robin Murphy [Wed, 3 Jul 2019 13:47:31 +0000 (14:47 +0100)]
of: address: Follow DMA parent for "dma-coherent"

commit c60bf3eb888a362100aa1bdbea351dab681e262a upstream.

Much like for address translation, when checking for DMA coherence we
should be sure to walk up the DMA hierarchy, rather than the MMIO one,
now that we can accommodate them being different.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
4 years agoof/address: Introduce of_get_next_dma_parent() helper
Robin Murphy [Wed, 3 Jul 2019 17:23:01 +0000 (18:23 +0100)]
of/address: Introduce of_get_next_dma_parent() helper

commit 862ab5578f754117742c8b8c8e5ddf98bdb190ba upstream.

Add of_get_next_dma_parent() helper which is similar to
__of_get_dma_parent(), but can be used in iterators and decrements the
ref count on the prior parent.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Rob Herring <robh@kernel.org>
4 years agoRevert "dma-direct: check for overflows on 32 bit DMA addresses"
Phil Elwell [Thu, 12 Mar 2020 14:06:04 +0000 (14:06 +0000)]
Revert "dma-direct: check for overflows on 32 bit DMA addresses"

This reverts commit e44850bd4205a8cf17f23c44668c0f8d28ad40b1.

4 years agoRevert "arm64/mm: Limit the DMA zone for arm64"
Phil Elwell [Thu, 12 Mar 2020 12:16:18 +0000 (12:16 +0000)]
Revert "arm64/mm: Limit the DMA zone for arm64"

This reverts commit 47fec0dcefa53f44985e95785021447d646daa2b.

4 years agoRevert "PCI: brcmstb: Add Broadcom STB PCIe host controller driver"
Phil Elwell [Mon, 9 Mar 2020 10:10:54 +0000 (10:10 +0000)]
Revert "PCI: brcmstb: Add Broadcom STB PCIe host controller driver"

This reverts commit 79624ca23c53064fefee774a89952a587b72cc01.

4 years agoRevert "PCI: brcmstb: Add dma-range mapping for inbound traffic"
Phil Elwell [Mon, 9 Mar 2020 10:08:49 +0000 (10:08 +0000)]
Revert "PCI: brcmstb: Add dma-range mapping for inbound traffic"

This reverts commit d45590eb858ac7a2578d477791881ba7ffb1e615.

4 years agoRevert "PCI: brcmstb: Add MSI capability"
Phil Elwell [Mon, 9 Mar 2020 10:08:35 +0000 (10:08 +0000)]
Revert "PCI: brcmstb: Add MSI capability"

This reverts commit b1619c83208e7b804e2c3547dbf24bb02b3be239.

4 years agoRevert "pcie-brcmstb: Changes for BCM2711"
Phil Elwell [Mon, 9 Mar 2020 10:07:39 +0000 (10:07 +0000)]
Revert "pcie-brcmstb: Changes for BCM2711"

This reverts commit 1dab5ded41ed07adc12f26e529aa64209a7c44b6.

4 years agoRevert "bcm2835-dma: Add proper 40-bit DMA support"
Phil Elwell [Mon, 9 Mar 2020 10:07:15 +0000 (10:07 +0000)]
Revert "bcm2835-dma: Add proper 40-bit DMA support"

This reverts commit 773a2db89ad2785d72b215673d87c0a51d769f61.

4 years agoRevert "bcm2835-dma: Correct SoC name"
Phil Elwell [Mon, 9 Mar 2020 10:06:59 +0000 (10:06 +0000)]
Revert "bcm2835-dma: Correct SoC name"

This reverts commit f498861a16d0b9a189a329080da1aa64d6e9bda7.

4 years agoRevert "pcie-brcmstb: Don't set DMA ops for root complex"
Phil Elwell [Fri, 6 Mar 2020 17:00:16 +0000 (17:00 +0000)]
Revert "pcie-brcmstb: Don't set DMA ops for root complex"

This reverts commit 510a127017a0aada2734dbf57d25aaa0189198ff.

4 years agoRevert "Ported pcie-brcmstb bounce buffer implementation to ARM64. (#3144)"
Phil Elwell [Fri, 6 Mar 2020 17:00:01 +0000 (17:00 +0000)]
Revert "Ported pcie-brcmstb bounce buffer implementation to ARM64. (#3144)"

This reverts commit 60f3db31d4cb785befed715b80c430f60f647701.

4 years agoRevert "pcie-brcmstb-bounce64.c: dev_err() -> dev_info() for info messages"
Phil Elwell [Fri, 6 Mar 2020 16:59:51 +0000 (16:59 +0000)]
Revert "pcie-brcmstb-bounce64.c: dev_err() -> dev_info() for info messages"

This reverts commit 2340a88a493d750dc3fcfa48de880fc4b8e479d2.

4 years agoRevert "pcie-brcmstb: Eliminate arch_dma_ops error message"
Phil Elwell [Fri, 6 Mar 2020 16:59:39 +0000 (16:59 +0000)]
Revert "pcie-brcmstb: Eliminate arch_dma_ops error message"

This reverts commit 27cf0ad95cdf30f52a5fc6c69014a0d7bf5a1222.

4 years agoRevert "pcie-brcmstb: Bounce buffer support is for BCM2711B0"
Phil Elwell [Fri, 6 Mar 2020 16:59:23 +0000 (16:59 +0000)]
Revert "pcie-brcmstb: Bounce buffer support is for BCM2711B0"

This reverts commit 58ac2d4474e531300f9f83773aa4d09e95ee2626.

4 years agoRevert "pcie-brcmstb: Correct SoC name"
Phil Elwell [Fri, 6 Mar 2020 16:59:11 +0000 (16:59 +0000)]
Revert "pcie-brcmstb: Correct SoC name"

This reverts commit 900b4ad0814df7dbacb01318bf49af5bab605fa0.

4 years agooverlays: sc16ic750-i2c: Fix xtal parameter
Phil Elwell [Tue, 3 Mar 2020 09:43:41 +0000 (09:43 +0000)]
overlays: sc16ic750-i2c: Fix xtal parameter

The xtal parameter is targetting the wrong node - fix it.

See: https://github.com/raspberrypi/linux/issues/3156

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add KVM support to arm64 bcm2711_defconfig
Phil Elwell [Wed, 5 Feb 2020 17:25:52 +0000 (17:25 +0000)]
configs: Add KVM support to arm64 bcm2711_defconfig

See: https://github.com/raspberrypi/linux/issues/3035

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add CONFIG_EXT4_ENCRYPTION=y
Phil Elwell [Thu, 27 Feb 2020 11:23:09 +0000 (11:23 +0000)]
configs: Add CONFIG_EXT4_ENCRYPTION=y

Enable EXT4 encryption support for all configurations except those
based on the original BCM2835, i.e. not on B+, Zero, etc. This
exception is because it would consume at least an additional 68KB,
which is a lot on a platform that may only have 128MB.

See: https://github.com/raspberrypi/linux/issues/2486

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoconfigs: Add CONFIG_HID_STEAM=m
Phil Elwell [Mon, 24 Feb 2020 11:13:09 +0000 (11:13 +0000)]
configs: Add CONFIG_HID_STEAM=m

See: https://github.com/raspberrypi/linux/issues/3344

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agoof: overlay: Correct symbol path fixups
Phil Elwell [Thu, 6 Feb 2020 12:23:15 +0000 (12:23 +0000)]
of: overlay: Correct symbol path fixups

When symbols from overlays are added to the live tree their paths must
be rebased. The translated symbol is normally the result of joining
the fragment-relative path (with a leading "/") to the target path
(either copied directly from the "target-path" property or resolved
from the phandle). This translation fails when the target is the root
node (a common case for Raspberry Pi overlays) because the resulting
path starts with a double slash. For example, if target-path is "/" and
the fragment adds a node called "newnode", the label associated with
that node will be assigned the path "//newnode", which can't be found
in the tree.

Fix the failure case by explicitly replacing a target path of "/" with
an empty string.

Fixes: d1651b03c2df ("of: overlay: add overlay symbols to live device tree")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
4 years agobcmrpi3_defconfig: align RC config with bcm2711_defconfig
Matthias Reichl [Mon, 10 Feb 2020 17:21:02 +0000 (18:21 +0100)]
bcmrpi3_defconfig: align RC config with bcm2711_defconfig

Signed-off-by: Matthias Reichl <hias@horus.com>