linux-2.6-microblaze.git
3 years agoMerge branch 'for-next' into for-linus
Takashi Iwai [Mon, 15 Feb 2021 08:06:39 +0000 (09:06 +0100)]
Merge branch 'for-next' into for-linus

Unification of 5.12-devel branches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Add implicit fb quirk for BOSS GP-10
Takashi Iwai [Sun, 14 Feb 2021 15:42:51 +0000 (16:42 +0100)]
ALSA: usb-audio: Add implicit fb quirk for BOSS GP-10

BOSS GP-10 with 0582:0185 requires the similar quirk to make the
implicit feedback working like other BOSS devices.

Reported-by: Keith Milner <kamilner@superlative.org>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210214154251.10750-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: Add another CometLake-H PCI ID
Kai Vehmanen [Fri, 12 Feb 2021 15:10:22 +0000 (17:10 +0200)]
ALSA: hda: Add another CometLake-H PCI ID

Add one more HD Audio PCI ID for CometLake-H PCH.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210212151022.2568567-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/hdmi: Drop bogus check at closing a stream
Takashi Iwai [Thu, 11 Feb 2021 08:31:39 +0000 (09:31 +0100)]
ALSA: hda/hdmi: Drop bogus check at closing a stream

Some users reported the kernel WARNING with stack traces from
hdmi_pcm_close(), and it's the line checking the per_cvt->assigned
flag.  This used to be a valid check in the past because the flag was
turned on/off only at opening and closing a PCM stream.  Meanwhile,
since the introduction of the silent-stream mode, this flag may be
turned on/off at the monitor connection/disconnection time, which
isn't always associated with the PCM open/close.  Hence this may lead
to the inconsistent per_cvt->assigned flag at closing.

As the check itself became almost useless and confuses users as if it
were a serious problem, just drop the check.

Fixes: b1a5039759cb ("ALSA: hda/hdmi: fix silent stream for first playback to DP")
Cc: <stable@vger.kernel.org>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=210987
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210211083139.29531-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: core - add missing compress device type to /proc/asound/devices
Jaroslav Kysela [Wed, 10 Feb 2021 08:37:13 +0000 (09:37 +0100)]
ALSA: core - add missing compress device type to /proc/asound/devices

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Acked-by: Vinod Koul <vkoul@kernel.org>
Link: https://lore.kernel.org/r/20210210083713.1034201-1-perex@perex.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: intel-dsp-config: Add SND_INTEL_BYT_PREFER_SOF Kconfig option
Hans de Goede [Mon, 8 Feb 2021 13:59:19 +0000 (14:59 +0100)]
ALSA: hda: intel-dsp-config: Add SND_INTEL_BYT_PREFER_SOF Kconfig option

The kernel has 2 drivers for the Low Power Engine audio-block on
Bay- and Cherry-Trail SoCs. The old SST driver and the new SOF
driver. If both drivers are enabled then the kernel will default
to using the old SST driver, unless told otherwise through the
snd_intel_dspcfg.dsp_driver module-parameter.

Add a boolean SND_INTEL_BYT_PREFER_SOF Kconfig option, which when set to Y
will make the kernel default to the new SOF driver instead.
The option defaults to n, preserving the current behavior.

Making this configurable will help distributions such as Fedora:
https://fedoraproject.org/w/index.php?title=Changes/SofDefaultForIntelLpe
to test using SOF on BYT/CHT during the transition phase where we
have both drivers (eventually the old driver and this option will
be removed).

Note that this drops the acpi_config_table[] containing 2 entries per ACPI
hardware-id if both drivers are enabled. snd_intel_acpi_dsp_find_config()
will always return the first hit, so we only need a single entry with the
flags value set depending on the Kconfig settings.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210208135919.135600-1-hdegoede@redhat.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: pcm: Use for_each_pcm_substream() macro
Takashi Iwai [Sat, 6 Feb 2021 20:36:56 +0000 (21:36 +0100)]
ALSA: pcm: Use for_each_pcm_substream() macro

There are a few places doing the same loop iterating all PCM
substreams belonging to the PCM object.  Introduce a local helper
macro, for_each_pcm_substream(), to simplify the code.

Link: https://lore.kernel.org/r/20210206203656.15959-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: pcm: Don't call sync_stop if it hasn't been stopped
Takashi Iwai [Sat, 6 Feb 2021 20:36:55 +0000 (21:36 +0100)]
ALSA: pcm: Don't call sync_stop if it hasn't been stopped

The PCM stop operation sets the stop_operating flag for indicating the
sync_stop post-process.  This flag is, however, set unconditionally
even if the PCM trigger weren't issued.  This may lead to
inconsistency in the driver side.

Correct the code to set stop_operating flag only after the trigger
STOP is actually called.

Fixes: 1e850beea278 ("ALSA: pcm: Add the support for sync-stop operation")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210206203656.15959-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: pcm: Assure sync with the pending stop operation at suspend
Takashi Iwai [Sat, 6 Feb 2021 20:36:54 +0000 (21:36 +0100)]
ALSA: pcm: Assure sync with the pending stop operation at suspend

The current PCM code calls the sync_stop at the resume action due to
the analogy to the PCM prepare call pattern.  But, it makes little
sense, as the sync should have been done rather at the suspend time,
not at the resume time.

This patch corrects the sync_stop call at suspend/resume to assure the
sync before finishing the suspend.

Fixes: 1e850beea278 ("ALSA: pcm: Add the support for sync-stop operation")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210206203656.15959-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: pcm: Call sync_stop at disconnection
Takashi Iwai [Sat, 6 Feb 2021 20:36:53 +0000 (21:36 +0100)]
ALSA: pcm: Call sync_stop at disconnection

The PCM core should perform the sync for the pending stop operations
at disconnection.  Otherwise it may lead to unexpected access.

Currently the old user of sync_stop, USB-audio driver, has its own
sync, so this isn't needed, but it's better to guarantee the sync in
the PCM core level.

This patch adds the missing sync_stop call at PCM disconnection
callback.  It also assures the IRQ sync if it's specified in the
card.  snd_pcm_sync_stop() is slightly modified to be called also for
any PCM substream object now.

Fixes: 1e850beea278 ("ALSA: pcm: Add the support for sync-stop operation")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210206203656.15959-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Don't avoid stopping the stream at disconnection
Takashi Iwai [Sat, 6 Feb 2021 20:30:52 +0000 (21:30 +0100)]
ALSA: usb-audio: Don't avoid stopping the stream at disconnection

In the later patch, we're going to issue the PCM sync_stop calls at
disconnection.  But currently the USB-audio driver can't handle it
because it has a check of shutdown flag for stopping the URBs.  This
is basically superfluous (the stopping URBs are safe at disconnection
state), so let's drop the check.

Fixes: dc5eafe7787c ("ALSA: usb-audio: Support PCM sync_stop")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210206203052.15606-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: More strict state change in EP
Takashi Iwai [Sat, 6 Feb 2021 20:30:51 +0000 (21:30 +0100)]
ALSA: usb-audio: More strict state change in EP

The endpoint management has bit flags to indicate the current state,
and we're dealing two things: the running bit and the stopping bit.
There is a thin window in transition from the running to the stopping
in stop_urbs(), and as long as the bit flags are used, it's difficult
to plug.

This patch modifies the state management code to use the atomic int
and follow the explicit three states, STOPPED, RUNNING and STOPPING.
The state change is done via atomic_cmpxhg() for avoiding possible
races, and check the state change more strictly.  The unexpected state
change is now handled as an error.

Fixes: d0f09d1e4a88 ("ALSA: usb-audio: Refactoring endpoint URB deactivation")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210206203052.15606-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Handle invalid running state at releasing EP
Takashi Iwai [Sat, 6 Feb 2021 20:30:50 +0000 (21:30 +0100)]
ALSA: usb-audio: Handle invalid running state at releasing EP

When we stop an endpoint in release_urbs(), it ignores the
inconsistent endpoint state and tries to release the resources.
This shouldn't happen in theory, but it's still safer to abort the
release and let the caller proper error handling.

Also, stop_and_unlink_urbs() called from release_urbs() does two step
works, and it's more straightforward to split this to two functions
again, so that the call from the PCM trigger won't take the path with
sleeping.

This patch modifies the EP management code to adapt two points above.

Fixes: d0f09d1e4a88 ("ALSA: usb-audio: Refactoring endpoint URB deactivation")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210206203052.15606-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: fireface: fix to parse sync status register of latter protocol
Takashi Sakamoto [Sun, 7 Feb 2021 15:47:36 +0000 (00:47 +0900)]
ALSA: fireface: fix to parse sync status register of latter protocol

Fireface UCX, UFX, and FF802 are categorized for latter protocol of the
series. Current support for FF802 (and UFX) includes failure to parse
sync status register and results in EIO.

Further investigation figures out that the content of register differs
depending on models. This commit adds tables specific to FF802 and UFX
to fix it.

Fixes: 062bb452b078b ("ALSA: fireface: add support for RME FireFace 802")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210207154736.229551-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoASoC: SOF: Intel: hda: release display power at link_power
Kai Vehmanen [Fri, 5 Feb 2021 18:46:30 +0000 (20:46 +0200)]
ASoC: SOF: Intel: hda: release display power at link_power

The i915 display power is requested both by controller (for init
and link reset) as well as by codec driver (for codec control).

There's an additional constraint that on some platforms frequent changes
to display power state may cause visible flicker. To avoid this, the SOF
hda controller requests display power whenever it is active and only
releases it when runtime suspended.

This patch utilizes the new hdac_bus link_power op to plug
into HDA link state changes. By monitoring link state changes,
we can keep the controller side display power wakeref until
the codec driver has completed its work, and only release
the wakeref when codec driver is suspended.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210205184630.1938761-4-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoASoC: SOF: Intel: hda: use hdac_ext fine-grained link management
Kai Vehmanen [Fri, 5 Feb 2021 18:46:29 +0000 (20:46 +0200)]
ASoC: SOF: Intel: hda: use hdac_ext fine-grained link management

Opt-in to use snd_hdac_ext_bus_link_power() to manage HDA link
power up/down events.

This allows to reduce power consumption in cases where some HDA codecs
are suspended, but other child devices (HDA or non-HDA codecs) remain
active and controller itself remains in active state.

By using snd_hdac_ext_bus_link_power(), the individual HDA links can be
powered off and if all HDA codecs are powered down, the command DMA can
also be shut down.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210205184630.1938761-3-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: add link_power op to hdac_bus_ops
Kai Vehmanen [Fri, 5 Feb 2021 18:46:28 +0000 (20:46 +0200)]
ALSA: hda: add link_power op to hdac_bus_ops

The extended HDA bus (hdac_ext) provides interfaces for more
fine-grained control of individual links than what plain HDA
provides for. Links can be powered off when they are not used and if
all links are released, controller can shut down the command DMA.

These interfaces are currently not used by common HDA codec drivers.
When a HDA codec is runtime suspended, it calls snd_hdac_codec_link_down(),
but there is no link to the HDA extended bus, and on controller side
the links are shut down only when all codecs are suspended.

This patch adds link_power() to hdac_bus ops. Controllers using the HDA
extended core, can use this to plug in snd_hdac_ext_bus_link_power() to
implement more fine-grained control of link power.

No change is needed for plain HDA controllers nor to existing HDA
codec drivers.

Co-developed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210205184630.1938761-2-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: azt3328: Assign boolean values to a bool variable
Jiapeng Chong [Sun, 7 Feb 2021 07:02:41 +0000 (15:02 +0800)]
ALSA: azt3328: Assign boolean values to a bool variable

Fix the following coccicheck warnings:

./sound/pci/azt3328.c:2451:2-16: WARNING: Assignment of 0/1 to bool
variable.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/1612681361-63404-1-git-send-email-jiapeng.chong@linux.alibaba.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: add mixer quirks for Pioneer DJM-900NXS2
Fabian Lesniak [Fri, 5 Feb 2021 21:51:16 +0000 (22:51 +0100)]
ALSA: usb-audio: add mixer quirks for Pioneer DJM-900NXS2

This commit adds mixer quirks for the Pioneer DJM-900NXS2 mixer. This
device has 6 capture channels, 5 of them allow setting the signal
source. This adds controls for these, similar to the DJM-250Mk2.
However, playpack channels are not controllable via software like on the
250Mk2, as they can only be set manually on the mixing console.
Read-only controls showing the currently selected playback channels are
omitted.

Signed-off-by: Fabian Lesniak <fabian@lesniak-it.de>
Link: https://lore.kernel.org/r/20210205215116.258724-2-fabian@lesniak-it.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Add DJM750 to Pioneer mixer quirk
Olivia Mackintosh [Fri, 5 Feb 2021 18:42:56 +0000 (18:42 +0000)]
ALSA: usb-audio: Add DJM750 to Pioneer mixer quirk

This allows for N different devices to use the pioneer mixer quirk for
setting capture/record type and recording level. The impementation has
not changed much with the exception of an additional mask on
private_value to allow storing of a device index:
DEVICE MASK 0xff000000
GROUP_MASK 0x00ff0000
VALUE_MASK 0x0000ffff

This could be improved by changing the arrays of wValues for each
channel to contain named definitions (e.g. SND_DJM_CAP_LINE). It would
improve readability and perhaps would allow using the same array for
multiple channels. The channel number can be specified on the control
next to the wIndex.

Feedback is very much appreciated as I'm not the most proficient C
programmer but am learning as I go.

Signed-off-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/20210205184256.10201-2-livvy@base.nu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Fix PCM buffer allocation in non-vmalloc mode
Takashi Iwai [Fri, 5 Feb 2021 14:45:59 +0000 (15:45 +0100)]
ALSA: usb-audio: Fix PCM buffer allocation in non-vmalloc mode

The commit f274baa49be6 ("ALSA: usb-audio: Allow non-vmalloc buffer
for PCM buffers") introduced the mode to allocate coherent pages for
PCM buffers, and it used bus->controller device as its DMA device.
It turned out, however, that bus->sysdev is a more appropriate device
to be used for DMA mapping in HCD code.

This patch corrects the device reference accordingly.

Note that, on most platforms, both point to the very same device,
hence this patch doesn't change anything practically.  But on
platforms like xhcd-plat hcd, the change becomes effective.

Fixes: f274baa49be6 ("ALSA: usb-audio: Allow non-vmalloc buffer for PCM buffers")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210205144559.29555-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Correct document for snd_usb_endpoint_free_all()
Takashi Iwai [Fri, 5 Feb 2021 08:28:37 +0000 (09:28 +0100)]
ALSA: usb-audio: Correct document for snd_usb_endpoint_free_all()

The kerndoc comment for the new function snd_usb_endpoint_free_all()
had a typo wrt the argument name.  Fix it.

Fixes: 00272c61827e ("ALSA: usb-audio: Avoid unnecessary interface re-setup")
Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210205082837.6327-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: core: Fix the debugfs removal at snd_card_free()
Takashi Iwai [Tue, 2 Feb 2021 22:56:29 +0000 (23:56 +0100)]
ALSA: core: Fix the debugfs removal at snd_card_free()

The commit 2d670ea2bd53 ("ALSA: jack: implement software jack
injection via debugfs") introduced a debugfs root for each sound card
object.  The debugfs entry gets removed at the card removal, too, but
it turned out that debugfs_remove() is called at a wrong place; it's
after the card object gets freed, hence it leads to use-after-free.

Fix it by moving the debugfs_remove() at the right place, the
destructor of the card device.

Fixes: 2d670ea2bd53 ("ALSA: jack: implement software jack injection via debugfs")
Reported-and-tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://lore.kernel.org/r/161228343605.1150.8862281636043446562@build.alporthouse.com
Link: https://lore.kernel.org/r/20210202225629.1965-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: Drop power save deny list entry for Clevo W65_67SB
Takashi Iwai [Tue, 2 Feb 2021 09:27:44 +0000 (10:27 +0100)]
ALSA: hda: Drop power save deny list entry for Clevo W65_67SB

As the runtime PM issue was addressed by the recent fix 4961167bf748
("ALSA: hda/via: Apply the workaround generically for Clevo machines")
for VIA codecs, we need no longer to keep the Clevo device off from
the power saving as default.  Drop the deny list entry accordingly.

Depends: 4961167bf748 ("ALSA: hda/via: Apply the workaround generically for Clevo machines")
Link: https://lore.kernel.org/r/20210202092744.20321-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Tue, 2 Feb 2021 17:48:28 +0000 (18:48 +0100)]
Merge branch 'for-linus' into for-next

Back-merge the 5.11 devel branch for further patching.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Add DJM-450 to the quirks table
Olivia Mackintosh [Tue, 2 Feb 2021 13:42:28 +0000 (13:42 +0000)]
ALSA: usb-audio: Add DJM-450 to the quirks table

As with most Pioneer devices, the device descriptor is vendor specific
and as such, the number of channels, the PCM format, endpoints and
sample rate need to be specified. This device has 8 inputs and 8 outputs
and a sample rate of 48000 only. The PCM format is S24_3LE like other
devices.

There seems to be an appetite for reducing duplication amongs these
Pioneer patches but again, I feel this is a step to be taken after
support has been added as it's not completely clear where the
commonalities are.

Signed-off-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/20210202134225.3217-3-livvy@base.nu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Add DJM450 to Pioneer format quirk
Olivia Mackintosh [Tue, 2 Feb 2021 13:42:26 +0000 (13:42 +0000)]
ALSA: usb-audio: Add DJM450 to Pioneer format quirk

Like the DJM-750, ensure that the format control message is passed to
the device when opening a stream. It seems as though fmt->sync_ep is not
always set when this function is called hence the passing of the value
at the call site. If this can be fixed, fmt->sync_up should be used as
the wvalue.

There doesn't seem to be a "cpu_to_le24" type function defined hence for
the open code but I did see a similar thing done in Bluez lib. Perhaps
we can get these definitions defined in byteorder.h. See hci_cpu_to_le24
in include/net/bluetooth/hci.h:2543 for similar usage.

Signed-off-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/20210202134225.3217-2-livvy@base.nu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: jack: implement software jack injection via debugfs
Hui Wang [Wed, 27 Jan 2021 08:56:39 +0000 (16:56 +0800)]
ALSA: jack: implement software jack injection via debugfs

This change adds audio jack injection feature through debugfs, with
this feature, we could validate alsa userspace changes by injecting
plugin or plugout events to the non-phantom audio jacks.

With this change, the sound core will build the folders
$debugfs_mount_dir/sound/cardN if SND_DEBUG and DEBUG_FS are enabled.
And if users also enable the SND_JACK_INJECTION_DEBUG, the jack
injection nodes will be built in the folder cardN like below:

$tree $debugfs_mount_dir/sound
$debugfs_mount_dir/sound
├── card0
│   ├── HDMI_DP_pcm_10_Jack
│   │   ├── jackin_inject
│   │   ├── kctl_id
│   │   ├── mask_bits
│   │   ├── status
│   │   ├── sw_inject_enable
│   │   └── type
...
│   └── HDMI_DP_pcm_9_Jack
│       ├── jackin_inject
│       ├── kctl_id
│       ├── mask_bits
│       ├── status
│       ├── sw_inject_enable
│       └── type
└── card1
    ├── HDMI_DP_pcm_5_Jack
    │   ├── jackin_inject
    │   ├── kctl_id
    │   ├── mask_bits
    │   ├── status
    │   ├── sw_inject_enable
    │   └── type
    ...
    ├── Headphone_Jack
    │   ├── jackin_inject
    │   ├── kctl_id
    │   ├── mask_bits
    │   ├── status
    │   ├── sw_inject_enable
    │   └── type
    └── Headset_Mic_Jack
        ├── jackin_inject
        ├── kctl_id
        ├── mask_bits
        ├── status
        ├── sw_inject_enable
        └── type

The nodes kctl_id, mask_bits, status and type are read-only, users
could check jack or jack_kctl's information through them.

The nodes sw_inject_enable and jackin_inject are directly used for
injection. The sw_inject_enable is read-write, users could check if
software injection is enabled or not on this jack, and users could
echo 1 or 0 to enable or disable software injection on this jack. Once
the injection is enabled, the jack will not change by hardware events
anymore, once the injection is disabled, the jack will restore the
last reported hardware events to the jack. The jackin_inject is
write-only, if the injection is enabled, users could echo 1 or 0 to
this node to inject plugin or plugout events to this jack.

For the detailed usage information on these nodes, please refer to
Documentation/sound/designs/jack-injection.rst.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20210127085639.74954-2-hui.wang@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hdsp: hardware output loopback
Jasmin Fazlic [Mon, 1 Feb 2021 14:28:52 +0000 (15:28 +0100)]
ALSA: hdsp: hardware output loopback

Output loopback is a feature where you can record what you hear.
The HDSP series of the RME interfaces provides this functionality
at the hardware level and this patch exposes controls to enable or
disable it per output (playback) channel.

This probably works on other cards but due to a lack of hardware
it is only tested and enabled for the HDSP9632 card with this patch.

Should this patch be accepted a separate patch will be posted to
https://github.com/alsa-project/alsa-tools/tree/master/hdspmixer
which adds "LPBK" buttons to each output in the playback strip for
the user to be able to control this feature from the user land.
Users from Windows tool TotalMixFX should be familiar with this.

Signed-off-by: Jasmin Fazlic <superfassl@gmail.com>
Link: https://lore.kernel.org/r/95cb3117-e85a-51a6-c2ce-bf736e70fc4c@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/realtek: modify EAPD in the ALC886
PeiSen Hou [Tue, 2 Feb 2021 09:30:22 +0000 (10:30 +0100)]
ALSA: hda/realtek: modify EAPD in the ALC886

Modify 0x20 index 7 bit 5 to 1, make the 0x15 EAPD the same as 0x14.

Signed-off-by: PeiSen Hou <pshou@realtek.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/e62c5058957f48d8b8953e97135ff108@realtek.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: intel8x0: Fix missing check in snd_intel8x0m_create
Dinghao Liu [Sun, 31 Jan 2021 10:09:14 +0000 (18:09 +0800)]
ALSA: intel8x0: Fix missing check in snd_intel8x0m_create

When device_type == DEVICE_ALI, we should also check the return
value of pci_iomap() to avoid potential null pointer dereference.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Link: https://lore.kernel.org/r/20210131100916.7915-1-dinghao.liu@zju.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: Constify static attribute_group
Rikard Falkeborn [Sun, 31 Jan 2021 00:12:41 +0000 (01:12 +0100)]
ALSA: hda: Constify static attribute_group

The only usage of hdac_dev_attr_group is to put its address in an array
of pointers to const attribute_group structs. Make it const to allow the
compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20210131001241.2278-3-rikard.falkeborn@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: ac97: Constify static struct attribute_group
Rikard Falkeborn [Sun, 31 Jan 2021 00:12:40 +0000 (01:12 +0100)]
ALSA: ac97: Constify static struct attribute_group

The only usage of ac97_adapter_attr_group is to put its address in an
array of pointers to const attribute_group structs. Make it const to
allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20210131001241.2278-2-rikard.falkeborn@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/via: Apply the workaround generically for Clevo machines
Takashi Iwai [Tue, 26 Jan 2021 16:56:03 +0000 (17:56 +0100)]
ALSA: hda/via: Apply the workaround generically for Clevo machines

We've got another report indicating a similar problem wrt the
power-saving behavior with VIA codec on Clevo machines.  Let's apply
the existing workaround generically to all Clevo devices with VIA
codecs to cover all in once.

BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1181330
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210126165603.11683-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoMerge tag 'asoc-fix-v5.11-rc5' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Tue, 26 Jan 2021 12:45:53 +0000 (13:45 +0100)]
Merge tag 'asoc-fix-v5.11-rc5' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v5.11

More fixes for v5.11, almost all driver specific issues including new
device IDs - there's one error handling fix for the topology stuff too.

3 years agoMerge tag 'tags/isa-void-remove-callback' into for-next
Takashi Iwai [Tue, 26 Jan 2021 06:51:48 +0000 (07:51 +0100)]
Merge tag 'tags/isa-void-remove-callback' into for-next

isa: Make the remove callback for isa drivers return void

Link: https://lore.kernel.org/r/20210122092449.426097-1-uwe@kleine-koenig.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoisa: Make the remove callback for isa drivers return void
Uwe Kleine-König [Fri, 22 Jan 2021 09:24:49 +0000 (10:24 +0100)]
isa: Make the remove callback for isa drivers return void

The driver core ignores the return value of the remove callback, so
don't give isa drivers the chance to provide a value.

Adapt all isa_drivers with a remove callbacks accordingly; they all
return 0 unconditionally anyhow.

Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> # for drivers/net/can/sja1000/tscan1.c
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Acked-by: Wolfram Sang <wsa@kernel.org> # for drivers/i2c/
Reviewed-by: Takashi Iway <tiwai@suse.de> # for sound/
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for drivers/media/
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20210122092449.426097-4-uwe@kleine-koenig.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agomedia/radio: Make radio_isa_common_remove() return void
Uwe Kleine-König [Fri, 22 Jan 2021 09:24:48 +0000 (10:24 +0100)]
media/radio: Make radio_isa_common_remove() return void

Instead of an unconditional return 0, return no value. One of the two
callers ignored the return value already before.

This simplifies the next patch.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Link: https://lore.kernel.org/r/20210122092449.426097-3-uwe@kleine-koenig.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agowatchdog: pcwd: drop always-false if from remove callback
Uwe Kleine-König [Fri, 22 Jan 2021 09:24:47 +0000 (10:24 +0100)]
watchdog: pcwd: drop always-false if from remove callback

If pcwd_isa_probe() succeeded pcwd_private.io_addr cannot be NULL. (And
if pcwd_isa_probe() failed, pcwd_isa_remove() isn't called.)

Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20210122092449.426097-2-uwe@kleine-koenig.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/tegra: Remove unnecessary null-check from hda_tegra_runtime_resume()
Dmitry Osipenko [Wed, 20 Jan 2021 00:31:51 +0000 (03:31 +0300)]
ALSA: hda/tegra: Remove unnecessary null-check from hda_tegra_runtime_resume()

The "chip" can't be NULL in hda_tegra_runtime_resume() because code would
crash otherwise. Let's remove the unnecessary check in order to clean up
code a tad.

Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30 audio works
Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30 boot-tested
Suggested-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210120003154.26749-4-digetx@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/tegra: Reset hardware
Dmitry Osipenko [Wed, 20 Jan 2021 00:31:50 +0000 (03:31 +0300)]
ALSA: hda/tegra: Reset hardware

Reset hardware on RPM-resume in order to bring it into a predictable
state.

Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30 audio works
Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30 boot-tested
Tested-by: Nicolas Chauvet <kwizart@gmail.com> # TK1 boot-tested
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210120003154.26749-3-digetx@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/tegra: Use clk_bulk helpers
Dmitry Osipenko [Wed, 20 Jan 2021 00:31:49 +0000 (03:31 +0300)]
ALSA: hda/tegra: Use clk_bulk helpers

Use clk_bulk helpers to make code cleaner. Note that this patch changed
the order in which clocks are enabled to make code look nicer, but this
doesn't matter in terms of hardware.

Tested-by: Peter Geis <pgwipeout@gmail.com> # Ouya T30 audio works
Tested-by: Matt Merhar <mattmerhar@protonmail.com> # Ouya T30 boot-tested
Tested-by: Nicolas Chauvet <kwizart@gmail.com> # TK1 boot-tested
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20210120003154.26749-2-digetx@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: bebob: remove an unnecessary condition in hwdep_read()
Takashi Sakamoto [Mon, 25 Jan 2021 14:02:08 +0000 (23:02 +0900)]
ALSA: bebob: remove an unnecessary condition in hwdep_read()

Drivers in ALSA firewire stack supports eventing to userspace
applications via ALSA hwdep interface. All of the drivers supports stream
lock events. Some of them supports their unique events according to
specification of target device.

ALSA bebob driver supports the stream lock event only. In the case, it's
enough to check condition only in loop with process blocking. However,
current implementation check it again after breaking the loop.

This commit removes the redundant check.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20210125140208.26318-1-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoMerge series "ASoC: SOF: partial fix to Kconfig issues" from Pierre-Louis Bossart...
Mark Brown [Mon, 25 Jan 2021 14:15:12 +0000 (14:15 +0000)]
Merge series "ASoC: SOF: partial fix to Kconfig issues" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

We've had several reports of broken dependencies. The 'right' fix is
to revisit the module dependencies as suggested by Arnd Bergmann. This
is WIP at https://github.com/thesofproject/linux/pull/2683. Since this
is taking longer than expected, I am only sharing quick fixes for now.

Pierre-Louis Bossart (2):
  ASoC: SOF: Intel: soundwire: fix select/depend unmet dependencies
  ASoC: SOF: SND_INTEL_DSP_CONFIG dependency

 sound/soc/sof/intel/Kconfig  |  3 ++-
 sound/soc/sof/sof-acpi-dev.c | 11 ++++++-----
 sound/soc/sof/sof-pci-dev.c  | 10 ++++++----
 3 files changed, 14 insertions(+), 10 deletions(-)

--
2.25.1

3 years agoALSA: fireface: remove unnecessary condition in hwdep_read()
Dan Carpenter [Mon, 25 Jan 2021 11:13:44 +0000 (14:13 +0300)]
ALSA: fireface: remove unnecessary condition in hwdep_read()

Smatch complains that "count" is not clamped when "ff->dev_lock_changed"
and it leads to an information leak.  Fortunately, that's not actually
possible and the condition can be deleted.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/YA6n6I8EcNAO5ZFs@mwanda
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: oxfw: remove an unnecessary condition in hwdep_read()
Dan Carpenter [Mon, 25 Jan 2021 11:12:54 +0000 (14:12 +0300)]
ALSA: oxfw: remove an unnecessary condition in hwdep_read()

Smatch complains that "count" isn't clamped properly and
"oxfw->dev_lock_changed" is false then it leads to an information
leak.  But it turns out that "oxfw->dev_lock_changed" is always
set and the condition can be removed.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/YA6ntkBxT/4DJ4YK@mwanda
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoASoC: Intel: sof_sdw: set proper flags for Dell TGL-H SKU 0A5E
Libin Yang [Mon, 25 Jan 2021 08:11:17 +0000 (10:11 +0200)]
ASoC: Intel: sof_sdw: set proper flags for Dell TGL-H SKU 0A5E

Add flag "SOF_RT711_JD_SRC_JD2", flag "SOF_RT715_DAI_ID_FIX"
and "SOF_SDW_FOUR_SPK" to the Dell TGL-H based SKU "0A5E".

Signed-off-by: Libin Yang <libin.yang@intel.com>
Co-developed-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Reviewed-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210125081117.814488-1-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: lpass: Fix out-of-bounds DAI ID lookup
Stephan Gerhold [Mon, 25 Jan 2021 10:44:42 +0000 (11:44 +0100)]
ASoC: qcom: lpass: Fix out-of-bounds DAI ID lookup

The "dai_id" given into LPAIF_INTFDMA_REG(...) is already the real
DAI ID, not an index into v->dai_driver. Looking it up again seems
entirely redundant.

For IPQ806x (and SC7180 since commit 09a4f6f5d21c
("ASoC: dt-bindings: lpass: Fix and common up lpass dai ids") this is
now often an out-of-bounds read because the indexes in the "dai_driver"
array no longer match the actual DAI ID.

Cc: Srinivasa Rao Mandadapu <srivasam@codeaurora.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Fixes: 7cb37b7bd0d3 ("ASoC: qcom: Add support for lpass hdmi driver")
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210125104442.135899-1-stephan@gerhold.net
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: mediatek: mt8192-mt6359: add format constraints for RT5682
Tzung-Bi Shih [Mon, 25 Jan 2021 06:14:53 +0000 (14:14 +0800)]
ASoC: mediatek: mt8192-mt6359: add format constraints for RT5682

MT8192 determines the I2S clock rates according to the sampling rates.

There is only 1 set of I2S in between MT8192 and RT5682.  If playing and
capturing via RT5682 in different sampling rates, the I2S data will be
corrupted.

Adds format constraints to the corresponding DAI links to make sure the
sampling rates are symmetric.

Fixes: 18b13ff23fab ("ASoC: mediatek: mt8192: add machine driver with mt6359, rt1015 and rt5682")
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20210125061453.1056535-1-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: ak4458: correct reset polarity
Eliot Blennerhassett [Fri, 22 Jan 2021 08:27:08 +0000 (21:27 +1300)]
ASoC: ak4458: correct reset polarity

Reset (aka power off) happens when the reset gpio is made active.
Change function name to ak4458_reset to match devicetree property "reset-gpios"

Signed-off-by: Eliot Blennerhassett <eliot@blennerhassett.gen.nz>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/ce650f47-4ff6-e486-7846-cc3d033f3601@blennerhassett.gen.nz
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: SOF: SND_INTEL_DSP_CONFIG dependency
Pierre-Louis Bossart [Fri, 22 Jan 2021 00:57:25 +0000 (18:57 -0600)]
ASoC: SOF: SND_INTEL_DSP_CONFIG dependency

The sof-pci-dev driver fails to link when built into the kernel
and CONFIG_SND_INTEL_DSP_CONFIG is set to =m:

arm-linux-gnueabi-ld: sound/soc/sof/sof-pci-dev.o: in function `sof_pci_probe':
sof-pci-dev.c:(.text+0x1c): undefined reference to `snd_intel_dsp_driver_probe'

As a temporary fix, use IS_REACHABLE to prevent the problem from
happening. A more complete solution is to move this code to
Intel-specific parts, restructure the drivers and Kconfig as discussed
with Arnd Bergmann and Takashi Iwai.

Fixes: 82d9d54a6c0e ("ALSA: hda: add Intel DSP configuration / probe code")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210122005725.94163-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: SOF: Intel: soundwire: fix select/depend unmet dependencies
Pierre-Louis Bossart [Fri, 22 Jan 2021 00:57:24 +0000 (18:57 -0600)]
ASoC: SOF: Intel: soundwire: fix select/depend unmet dependencies

The LKP bot reports the following issue:

WARNING: unmet direct dependencies detected for SOUNDWIRE_INTEL
  Depends on [m]: SOUNDWIRE [=m] && ACPI [=y] && SND_SOC [=y]
  Selected by [y]:
  - SND_SOC_SOF_INTEL_SOUNDWIRE [=y] && SOUND [=y] && !UML &&
  SND [=y] && SND_SOC [=y] && SND_SOC_SOF_TOPLEVEL [=y] &&
  SND_SOC_SOF_INTEL_TOPLEVEL [=y] && SND_SOC_SOF_INTEL_PCI [=y]

This comes from having tristates being configured independently, when
in practice the CONFIG_SOUNDWIRE needs to be aligned with the SOF
choices: when the SOF code is compiled as built-in, the
CONFIG_SOUNDWIRE also needs to be 'y'.

The easiest fix is to replace the 'depends' with a 'select' and have a
single user selection to activate SoundWire on Intel platforms. This
still allows regmap to be compiled independently as a module.

This is just a temporary fix, the select/depend usage will be
revisited and the SOF Kconfig re-organized, as suggested by Arnd
Bergman.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: a115ab9b8b93e ('ASoC: SOF: Intel: add build support for SoundWire')
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210122005725.94163-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoALSA: hda: intel-dsp-config: add PCI id for TGL-H
Bard Liao [Mon, 25 Jan 2021 08:30:51 +0000 (10:30 +0200)]
ALSA: hda: intel-dsp-config: add PCI id for TGL-H

Adding PCI id for TGL-H. Like for other TGL platforms, SOF is used if
Soundwire codecs or PCH-DMIC is detected.

Signed-off-by: Bard Liao <bard.liao@intel.com>
Reviewed-by: Xiuli Pan <xiuli.pan@intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20210125083051.828205-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: Assign boolean values to a bool variable
Jiapeng Zhong [Mon, 25 Jan 2021 07:17:27 +0000 (15:17 +0800)]
ALSA: hda: Assign boolean values to a bool variable

Fix the following coccicheck warnings:

./sound/pci/hda/hda_intel.c:2309:3-23: WARNING: Assignment of
0/1 to bool variable.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>
Link: https://lore.kernel.org/r/1611559047-106928-1-git-send-email-abaci-bugfix@linux.alibaba.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda: boolean values to a bool variable
Jiapeng Zhong [Mon, 18 Jan 2021 08:27:49 +0000 (16:27 +0800)]
ALSA: hda: boolean values to a bool variable

Fix the following coccicheck warnings:

./sound/pci/hda/patch_conexant.c:570:2-20: WARNING:
Assignment of 0/1 to bool variable.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Zhong <abaci-bugfix@linux.alibaba.com>
Link: https://lore.kernel.org/r/1610958469-65856-1-git-send-email-abaci-bugfix@linux.alibaba.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: workaround for iface reset issue
Takashi Iwai [Sat, 23 Jan 2021 15:58:42 +0000 (16:58 +0100)]
ALSA: usb-audio: workaround for iface reset issue

The recently introduced sample rate validation code seems causing a
problem on some devices; namely, after performing this, the bus gets
screwed and it influences even on other USB devices.
As a quick workaround, perform it only for the necessary devices;
currently MOTU devices are known to need the valid altset checks, so
filter out other devices.

Fixes: 93db51d06b32 ("ALSA: usb-audio: Check valid altsetting at parsing rates for UAC2/3")
Reported-by: Jamie Heilman <jamie@audible.transient.net>
BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1178203
Link: https://lore.kernel.org/r/20210123155842.22652-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: pcm: One more dependency for hw constraints
Takashi Iwai [Sat, 23 Jan 2021 15:57:30 +0000 (16:57 +0100)]
ALSA: pcm: One more dependency for hw constraints

The fix for a long-standing USB-audio bug required one more dependency
variable to be added to the hw constraints.  Unfortunately I didn't
realize at debugging that the new addition may result in the overflow
of the dependency array of each snd_pcm_hw_rule (up to three plus a
sentinel), because USB-audio driver adds one more dependency only for
a certain device and bus, hence it works as is for many devices.  But
in a bad case, a simple open always results in -EINVAL (with kernel
WARNING if CONFIG_SND_DEBUG is set) no matter what is passed.

Since the dependencies are real and unavoidable (USB-audio restricts
the hw_params per looping over the format/rate/channels combos), the
only good solution seems to raise the bar for one more dependency for
snd_pcm_hw_rule -- so does this patch: now the hw constraint
dependencies can be up to four.

Fixes: 506c203cc3de ("ALSA: usb-audio: Fix hw constraints dependencies")
Reported-by: Jamie Heilman <jamie@audible.transient.net>
Link: https://lore.kernel.org/r/20210123155730.22576-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: hda/realtek: Enable headset of ASUS B1400CEPE with ALC256
Jian-Hong Pan [Fri, 22 Jan 2021 05:47:06 +0000 (13:47 +0800)]
ALSA: hda/realtek: Enable headset of ASUS B1400CEPE with ALC256

ASUS B1400CEPE laptop's headset audio is not enabled until
ALC256_FIXUP_ASUS_HPE quirk is applied.

Here is the original pin node values:

0x12 0x40000000
0x13 0x411111f0
0x14 0x90170110
0x18 0x411111f0
0x19 0x411111f0
0x1a 0x411111f0
0x1b 0x411111f0
0x1d 0x40461b45
0x1e 0x411111f0
0x21 0x04211020

Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210122054705.48804-1-jhp@endlessos.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoASoC: Intel: Skylake: Zero snd_ctl_elem_value
Ricardo Ribalda [Thu, 21 Jan 2021 17:16:44 +0000 (18:16 +0100)]
ASoC: Intel: Skylake: Zero snd_ctl_elem_value

Clear struct snd_ctl_elem_value before calling ->put() to avoid any data
leak.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210121171644.131059-2-ribalda@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: Intel: Skylake: skl-topology: Fix OOPs ib skl_tplg_complete
Ricardo Ribalda [Thu, 21 Jan 2021 17:16:43 +0000 (18:16 +0100)]
ASoC: Intel: Skylake: skl-topology: Fix OOPs ib skl_tplg_complete

If dobj->control is not initialized we end up in an OOPs during
skl_tplg_complete:

[   26.553358] BUG: kernel NULL pointer dereference, address:
0000000000000078
[   26.561151] #PF: supervisor read access in kernel mode
[   26.566897] #PF: error_code(0x0000) - not-present page
[   26.572642] PGD 0 P4D 0
[   26.575479] Oops: 0000 [#1] PREEMPT SMP PTI
[   26.580158] CPU: 2 PID: 2082 Comm: udevd Tainted: G         C
5.4.81 #4
[   26.588232] Hardware name: HP Soraka/Soraka, BIOS
Google_Soraka.10431.106.0 12/03/2019
[   26.597082] RIP: 0010:skl_tplg_complete+0x70/0x144 [snd_soc_skl]

Fixes: 2d744ecf2b98 ("ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHL")
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Tested-by: Lukasz Majczak <lma@semihalf.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210121171644.131059-1-ribalda@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: Fix number of HDMI RDMA channels on sc7180
Stephen Boyd [Fri, 15 Jan 2021 20:33:29 +0000 (12:33 -0800)]
ASoC: qcom: Fix number of HDMI RDMA channels on sc7180

Suspending/resuming with an HDMI dongle attached leads to crashes from
an audio regmap.

 Unable to handle kernel paging request at virtual address ffffffc018068000
 Mem abort info:
   ESR = 0x96000047
   EC = 0x25: DABT (current EL), IL = 32 bits
   SET = 0, FnV = 0
   EA = 0, S1PTW = 0
 Data abort info:
   ISV = 0, ISS = 0x00000047
   CM = 0, WnR = 1
 swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000081b12000
 [ffffffc018068000] pgd=0000000275d14003, pud=0000000275d14003, pmd=000000026365d003, pte=0000000000000000
 Internal error: Oops: 96000047 [#1] PREEMPT SMP
 Call trace:
  regmap_mmio_write32le+0x2c/0x40
  regmap_mmio_write+0x48/0x6c
  _regmap_bus_reg_write+0x34/0x44
  _regmap_write+0x100/0x150
  regcache_default_sync+0xc0/0x138
  regcache_sync+0x188/0x26c
  lpass_platform_pcmops_resume+0x48/0x54 [snd_soc_lpass_platform]
  snd_soc_component_resume+0x28/0x40
  soc_resume_deferred+0x6c/0x178
  process_one_work+0x208/0x3c8
  worker_thread+0x23c/0x3e8
  kthread+0x144/0x178
  ret_from_fork+0x10/0x18
 Code: d503201f d50332bf f94002a8 8b344108 (b9000113)

I can reliably reproduce this problem by running 'tail' on the registers
file in debugfs for the hdmi regmap.

 # tail /sys/kernel/debug/regmap/62d87000.lpass-lpass_hdmi/registers
 [   84.658733] Unable to handle kernel paging request at virtual address ffffffd0128e800c

This crash happens because we're trying to read registers from the
regmap beyond the length of the mapping created by ioremap().

The number of hdmi_rdma_channels determines the size of the regmap via
this code in sound/soc/qcom/lpass-cpu.c:

  lpass_hdmi_regmap_config.max_register = LPAIF_HDMI_RDMAPER_REG(variant, variant->hdmi_rdma_channels);

According to debugfs the size of the regmap is 0x68010 but according to
the DTS file posted in [1] the size is only 0x68000 (see the first reg
property of the lpass_cpu node). Let's change the number of channels to
be 3 instead of 4 so the math works out to have a max register of
0x67010, nicely fitting inside of the region size of 0x68000.

Note: I tried to bump up the size of the register region to the next
page to include the 0x68010 register but then the tail command caused
SErrors with an async abort, implying that the register region doesn't
exist or it isn't clocked because the bus is telling us that the
register read failed. I reduce the number of channels and played audio
through the HDMI channel and it kept working so I think this is correct.

Fixes: 2ad63dc8df6b ("ASoC: qcom: sc7180: Add support for audio over DP")
Link: https://lore.kernel.org/r/1601448168-18396-2-git-send-email-srivasam@codeaurora.org
Cc: V Sujith Kumar Reddy <vsujithk@codeaurora.org>
Cc: Srinivasa Rao <srivasam@codeaurora.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Cheng-Yi Chiang <cychiang@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20210115203329.846824-1-swboyd@chromium.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoALSA: usb-audio: Fix "RANGE setting not yet supported" errors
Takashi Iwai [Wed, 20 Jan 2021 21:39:32 +0000 (22:39 +0100)]
ALSA: usb-audio: Fix "RANGE setting not yet supported" errors

At probing a UAC2/UAC3 device like NUX MG-300 USB interface, we get
error messages "RANGE setting not yet supported".  It comes the place
where the driver tries to determine the resolution of mixer volumes
via SET_CUR_RES and GET_CUR_RES verbs.  Those verbs aren't supported
on UAC2 and UAC3, hence the driver warns like the above.  Although the
driver handles this error and works as expected, it's still ugly to
show such errors unnecessarily.

This patch papers over the errors by applying the resolution detection
only for UAC1 and skipping it for UAC2/UAC3.

Reported-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210120213932.1971-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Skip the clock selector inquiry for single connections
Takashi Iwai [Wed, 20 Jan 2021 21:39:31 +0000 (22:39 +0100)]
ALSA: usb-audio: Skip the clock selector inquiry for single connections

The current USB-audio driver gets an error at probing NUX MG-300 about
parsing the clocks.  This is because the firmware doesn't return the
proper connection of the clock selector that is connected to a single
clock; it's likely that the firmware was lazy^w optimized and the
inquiry wasn't handled.  Actually it makes little sense to inquire and
set up the single connection explicitly.

This patch fixes the issue by simply skipping the clock selector
inquiry if it's a single connection.

Reported-by: Mike Oliphant <oliphant@nostatic.org>
Link: https://lore.kernel.org/r/20210120213932.1971-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoMerge series "ASoC: qcom: Fix broken lpass driver" from Srinivas Kandagatla <srinivas...
Mark Brown [Thu, 21 Jan 2021 00:00:54 +0000 (00:00 +0000)]
Merge series "ASoC: qcom: Fix broken lpass driver" from Srinivas Kandagatla <srinivas.kandagatla@linaro.org>:

LPASS driver is partially broken on DragonBoard DB410c on 5.10 and
its totally broken on other Supported Qualcomm SoCs.

This was due to DAI ids being over written by the SoC specific header files
in the dt-bindings.

Idea of having SoC specific headers is not doable when we are dealing with
a common driver. So this patchset attempts to fix this properly by creating
a common dt-bindings header for lpass which can be updated with new entries
if required. This patchset also add an simple of_xlate function to resolve
the dai names and different SoCs might not have 1:1 mapping for the
dai_driver array with dai ids.

Changes since v1:
- removed array indexes as suggested by Stephan G.
- rebased to sound/for-next branch
- collected Srinivasa tested-by tag for sc7180 platform.

Thanks,
srini

Srinivas Kandagatla (2):
  ASoC: dt-bindings: lpass: Fix and common up lpass dai ids
  ASoC: qcom: Fix broken support to MI2S TERTIARY and QUATERNARY

 include/dt-bindings/sound/apq8016-lpass.h |  7 +++----
 include/dt-bindings/sound/qcom,lpass.h    | 15 +++++++++++++++
 include/dt-bindings/sound/sc7180-lpass.h  |  6 ++----
 sound/soc/qcom/lpass-cpu.c                | 22 ++++++++++++++++++++++
 sound/soc/qcom/lpass-platform.c           | 12 ++++++++++++
 sound/soc/qcom/lpass-sc7180.c             |  9 +++------
 sound/soc/qcom/lpass.h                    |  2 +-
 7 files changed, 58 insertions(+), 15 deletions(-)
 create mode 100644 include/dt-bindings/sound/qcom,lpass.h

--
2.21.0

3 years agoMerge series "ASoC: mediatek: mt8183: ignore TDM DAI link by by default" from Tzung...
Mark Brown [Thu, 21 Jan 2021 00:00:53 +0000 (00:00 +0000)]
Merge series "ASoC: mediatek: mt8183: ignore TDM DAI link by by default" from Tzung-Bi Shih <tzungbi@google.com>:

hdmi-codec is an optional property.  The 2 patches fix DAI link binding
error when the property doesn't exist in DTS.

Tzung-Bi Shih (2):
  ASoC: mediatek: mt8183-mt6358: ignore TDM DAI link by default
  ASoC: mediatek: mt8183-da7219: ignore TDM DAI link by default

 sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c         | 5 ++++-
 sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

--
2.30.0.284.gd98b1dd5eaa7-goog

3 years agoMerge series "Add KUNIT tests for ASoC topology" from Amadeusz Sławiński<amadeuszx...
Mark Brown [Thu, 21 Jan 2021 00:00:52 +0000 (00:00 +0000)]
Merge series "Add KUNIT tests for ASoC topology" from Amadeusz Sławiński<amadeuszx.slawinski@linux.intel.com>:

This series adds unit tests for ASoC topology.

First fix problems found when developing and running test cases and
then add tests implementation.

Tests themselves are quite simple and just call
snd_soc_tplg_component_load() with various parameters and check the
result. Tests themselves are described in more detail in commits
adding them.

Goal is to expand the amount of test cases in following patches.

Prerequisity for this patchset are 2 patches which have already been
sent:
https://lore.kernel.org/alsa-devel/20210114163602.911205-1-amadeuszx.slawinski@linux.intel.com/T/#t

Description on how typical test case itself works:

In order to load topology we need to have 3 things:
card, codec component & platform component.

In typical test case we register card and platform component and bind
to dummy codec. There are of course execeptions, when we want to
test behaviour of topology API when component or card is missing.
Note that this is bit different from typical scenario (in SOF and skylake
drivers) where card is registered by machine driver and component by
platform driver, as we register both when setting up test.

If you check the test case most of them have similar architecture of:
1.
/* run test */
ret = snd_soc_register_card(&kunit_comp->card);
if (ret != 0 && ret != -EPROBE_DEFER)
KUNIT_FAIL(test, "Failed to register card");

2.
ret = snd_soc_component_initialize(&kunit_comp->comp, &test_component, test_dev);
KUNIT_EXPECT_EQ(test, 0, ret);

3.
ret = snd_soc_add_component(&kunit_comp->comp, NULL, 0);
KUNIT_EXPECT_EQ(test, 0, ret);

Ad. 1.
First we register card, which in most tests returns -EPROBE_DEFER
(from snd_soc_bind_card()), as platform component is not yet created.
I test for both 0 and -EPROBE_DEFER, as it makes it easier to reshuffle
this code around if needed and there is one test case which does it in
different order.

Ad. 2.
Then we initialize platform component with structure pointing at proper
probe function, which calls snd_soc_tplg_component_load() with test
parameters and checks expected result.

Ad. 3.
And then in follow up we call snd_soc_add_component() which creates
platform component for us and calls snd_soc_try_rebind_card() which
if everything is bound properly calls previously set probe function.

Amadeusz Sławiński (5):
  ASoC: topology: Properly unregister DAI on removal
  Revert "ASoC: soc-devres: add devm_snd_soc_register_dai()"
  ASoC: topology: KUnit: Add KUnit tests passing various arguments to
    snd_soc_tplg_component_load
  ASoC: topology: KUnit: Add KUnit tests passing empty topology with
    variants to snd_soc_tplg_component_load
  ASoC: topology: KUnit: Add KUnit tests passing topology with PCM to
    snd_soc_tplg_component_load

 include/sound/soc.h           |   4 -
 sound/soc/Kconfig             |  17 +
 sound/soc/Makefile            |   5 +
 sound/soc/soc-devres.c        |  37 --
 sound/soc/soc-topology-test.c | 843 ++++++++++++++++++++++++++++++++++
 sound/soc/soc-topology.c      |   9 +-
 6 files changed, 870 insertions(+), 45 deletions(-)
 create mode 100644 sound/soc/soc-topology-test.c

--
2.25.1

3 years agoALSA: usb-audio: Fix hw constraints dependencies
Takashi Iwai [Wed, 20 Jan 2021 20:45:54 +0000 (21:45 +0100)]
ALSA: usb-audio: Fix hw constraints dependencies

Since the recent refactoring, it's been reported that some USB-audio
devices (typically webcams) are no longer detected properly by
PulseAudio.  The debug session revealed that it's failing at probing
by PA to try the sample rate 44.1kHz while the device has discrete
sample rates other than 44.1kHz.  But the puzzle was that arecord
works as is, and some other devices with the discrete rates work,
either.

After all, this turned out to be the lack of the dependencies in a few
hw constraint rules: snd_pcm_hw_rule_add() has the (variable)
arguments specifying the dependent parameters, and some functions
didn't set the target parameter itself as the dependencies.  This
resulted in an invalid parameter that could be generated only in a
certain call pattern.  This bug itself has been present in the code,
but it didn't trigger errors just because the rules were casually
avoiding such a corner case.  After the recent refactoring and
cleanup, however, the hw constraints work "as expected", and the
problem surfaced now.

For fixing the problem above, this patch adds the missing dependent
parameters to each snd_pcm_hw_rule() call.

Fixes: bc4e94aa8e72 ("ALSA: usb-audio: Handle discrete rates properly in hw constraints")
BugLink: http://bugzilla.opensuse.org/show_bug.cgi?id=1181014
Link: https://lore.kernel.org/r/20210120204554.30177-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoASoC: mediatek: mt8183-da7219: ignore TDM DAI link by default
Tzung-Bi Shih [Wed, 20 Jan 2021 09:22:37 +0000 (17:22 +0800)]
ASoC: mediatek: mt8183-da7219: ignore TDM DAI link by default

hdmi-codec is an optional property.  Ignore to bind TDM DAI link
if the property isn't specified.

Fixes: 5bdbe9771177 ("ASoC: mediatek: mt8183-da7219: use hdmi-codec")
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20210120092237.1553938-3-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: mediatek: mt8183-mt6358: ignore TDM DAI link by default
Tzung-Bi Shih [Wed, 20 Jan 2021 09:22:36 +0000 (17:22 +0800)]
ASoC: mediatek: mt8183-mt6358: ignore TDM DAI link by default

hdmi-codec is an optional property.  Ignore to bind TDM DAI link
if the property isn't specified.

Fixes: f2024dc55fcb ("ASoC: mediatek: mt8183: use hdmi-codec")
Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
Link: https://lore.kernel.org/r/20210120092237.1553938-2-tzungbi@google.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: topology: Properly unregister DAI on removal
Amadeusz Sławiński [Wed, 20 Jan 2021 15:28:42 +0000 (16:28 +0100)]
ASoC: topology: Properly unregister DAI on removal

DAIs need to be removed when topology unload function is called (usually
done when component is being removed). We can't do this when device is
being removed, as structures we operate on when removing DAI can already
be freed.

Fixes: 6ae4902f2f34 ("ASoC: soc-topology: use devm_snd_soc_register_dai()")
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210120152846.1703655-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: topology: Fix memory corruption in soc_tplg_denum_create_values()
Dan Carpenter [Wed, 20 Jan 2021 09:59:13 +0000 (12:59 +0300)]
ASoC: topology: Fix memory corruption in soc_tplg_denum_create_values()

The allocation uses sizeof(u32) when it should use sizeof(unsigned long)
so it leads to memory corruption later in the function when the data is
initialized.

Fixes: 5aebe7c7f9c2 ("ASoC: topology: fix endianness issues")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YAf+8QZoOv+ct526@mwanda
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: lpass-ipq806x: fix bitwidth regmap field
Srinivas Kandagatla [Tue, 19 Jan 2021 17:47:00 +0000 (17:47 +0000)]
ASoC: qcom: lpass-ipq806x: fix bitwidth regmap field

BIT_WIDTH field in I2S_CTL register is two bits wide, however
recent regmap field conversion patch trimmed it down to one bit.
Fix this by correcting the bit range!

Fixes: b5022a36d28f ("ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210119174700.32639-1-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: AMD Renoir - refine DMI entries for some Lenovo products
Jaroslav Kysela [Wed, 20 Jan 2021 14:42:11 +0000 (15:42 +0100)]
ASoC: AMD Renoir - refine DMI entries for some Lenovo products

Apparently, the DMI board name LNVNB161216 is also used also
for products with the digital microphones connected to the AMD's
audio bridge. Refine the DMI table - use product name identifiers
extracted from https://bugzilla.redhat.com/show_bug.cgi?id=1892115 .

The report for Lenovo Yoga Slim 7 14ARE05 (82A2) is in buglink.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=211299
Cc: <stable@kernel.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cc: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210120144211.817937-1-perex@perex.cz
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: qcom: Fix broken support to MI2S TERTIARY and QUATERNARY
Srinivas Kandagatla [Tue, 19 Jan 2021 17:15:27 +0000 (17:15 +0000)]
ASoC: qcom: Fix broken support to MI2S TERTIARY and QUATERNARY

lpass hdmi support patch totally removed support for MI2S TERTIARY
and QUATERNARY.

One of the major issue was spotted with the design of having
separate SoC specific header files for the common lpass driver.
This design is prone to break as an when new SoC header is added
as the common DAI ids of other SoCs will be overwritten by the
new ones.

Having a common header qcom,lpass.h should fix the issue and any new
DAI ids should be added to the common header.

With this change lpass also needs a new of_xlate function to resolve
dai name.

Fixes: 7cb37b7bd0d3 ("ASoC: qcom: Add support for lpass hdmi driver")
Reported-by: Jun Nie <jun.nie@linaro.org>
Reported-by: Stephan Gerhold <stephan@gerhold.net>
Tested-by: Srinivasa Rao <srivasam@codeaurora.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Tested-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20210119171527.32145-3-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: dt-bindings: lpass: Fix and common up lpass dai ids
Srinivas Kandagatla [Tue, 19 Jan 2021 17:15:26 +0000 (17:15 +0000)]
ASoC: dt-bindings: lpass: Fix and common up lpass dai ids

Existing header file design of having separate SoC specific header files
for the common lpass driver has mutiple issues.
This design is prone to break as an when new SoC header is added
as the common DAI ids of other SoCs will be overwritten by the
new ones.

One of them surfaced by recent patch that adds support to sc7180, this
one totally broke LPASS drivers on other Qualcomm SoCs.

Before this gets worst, fix this by having a common header qcom,lpass.h.
This should fix the issue and any new DAI ids should be added to the
common header. This will be more sustainable then the existing design!

Fixes: 12fbfc4cabec6595 ("ASoC: Add sc7180-lpass binding header hdmi define")
Reported-by: Jun Nie <jun.nie@linaro.org>
Reported-by: Stephan Gerhold <stephan@gerhold.net>
Tested-by: Srinivasa Rao <srivasam@codeaurora.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210119171527.32145-2-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoALSA: hda: Balance runtime/system PM if direct-complete is disabled
Kai-Heng Feng [Tue, 19 Jan 2021 15:21:43 +0000 (23:21 +0800)]
ALSA: hda: Balance runtime/system PM if direct-complete is disabled

After hibernation, HDA controller can't be runtime-suspended after
commit 215a22ed31a1 ("ALSA: hda: Refactor codjc PM to use
direct-complete optimization"), which enables direct-complete for HDA
codec.

The HDA codec driver didn't expect direct-complete will be disabled
after it returns a positive value from prepare() callback. However,
there are some places that PM core can disable direct-complete. For
instance, system hibernation or when codec has subordinates like LEDs.

So if the codec is prepared for direct-complete but PM core still calls
codec's suspend or freeze callback, partially revert the commit and take
the original approach, which uses pm_runtime_force_*() helpers to
ensure PM refcount are balanced. Meanwhile, still keep prepare() and
complete() callbacks to enable direct-complete and request a resume for
jack detection, respectively.

Reported-by: Kenneth R. Crudup <kenny@panix.com>
Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20210119152145.346558-1-kai.heng.feng@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoMerge tag 'asoc-fix-v5.11-rc4' of https://git.kernel.org/pub/scm/linux/kernel/git...
Takashi Iwai [Mon, 18 Jan 2021 18:51:49 +0000 (19:51 +0100)]
Merge tag 'asoc-fix-v5.11-rc4' of https://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v5.11

A few more fixes for v5.11, mostly around HDA jack detection, plus
a couple of updates to the MAINTAINERS entries.

3 years agoALSA: usb-audio: Add support for Pioneer DJM-750
Olivia Mackintosh [Mon, 18 Jan 2021 13:06:21 +0000 (13:06 +0000)]
ALSA: usb-audio: Add support for Pioneer DJM-750

This adds the Pioneer DJ DJM-750 to the quirks table and ensures
skip_pioneer_sync_ep() is (also) called: this device uses the vendor
ID of 0x08e4 (I'm not sure why they use multiple vendor IDs but many
just like to be awkward it seems).

Playback on all 8 channels works. I'll likely keep this working in the
future and submit futher patches and improvements as necessary.

Signed-off-by: Olivia Mackintosh <livvy@base.nu>
Link: https://lore.kernel.org/r/20210118130621.77miiie47wp7mump@base.nu
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Mon, 18 Jan 2021 16:39:18 +0000 (17:39 +0100)]
Merge branch 'for-linus' into for-next

Back-merge of 5.11 devel branch for more works on USB-audio.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoASoC: dt-bindings: mt8192-mt6359: Fix indentation
Jonathan Neuschäfer [Sat, 16 Jan 2021 01:34:03 +0000 (02:34 +0100)]
ASoC: dt-bindings: mt8192-mt6359: Fix indentation

The items of the 'maintainers' list are indented with three spaces.
Use the usual two spaces instead, for consistency and to silence
yamllint.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Link: https://lore.kernel.org/r/20210116013403.3490518-1-j.neuschaefer@gmx.net
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoASoC: wm_adsp: Fix control name parsing for multi-fw
James Schulman [Fri, 15 Jan 2021 20:11:05 +0000 (14:11 -0600)]
ASoC: wm_adsp: Fix control name parsing for multi-fw

When switching between firmware types, the wrong control
can be selected when requesting control in kernel API.
Use the currently selected DSP firwmare type to select
the proper mixer control.

Signed-off-by: James Schulman <james.schulman@cirrus.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210115201105.14075-1-james.schulman@cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
3 years agoALSA: usb-audio: Avoid implicit feedback on Pioneer devices
Takashi Iwai [Mon, 18 Jan 2021 07:58:16 +0000 (08:58 +0100)]
ALSA: usb-audio: Avoid implicit feedback on Pioneer devices

For addressing the regression on Pioneer devices, we recently
corrected the quirk code to enable the implicit feedback mode on those
devices properly.  However, the devices still showed problems with the
full duplex operations with JACK, and after debug sessions, we figured
out that the older kernels that had worked with JACK also didn't use
the implicit feedback mode at all although they had the quirk code to
enable it; instead, the old code worked just to skip the normal sync
endpoint setup that would have been detected without it.  IOW, what
broke without the implicit-fb quirk in the past was the application of
the normal sync endpoint that is actually the capture data endpoint on
these devices.

This patch covers the overseen piece: it modifies the quirk code again
not to enable the implicit feedback mode but just to make the driver
skipping the sync endpoint detection.  This made the driver working
with JACK full-duplex mode again.

Still it's not quite clear why the implicit feedback doesn't work on
those devices yet; maybe it's about some issues in the URB setup.  But
at least, with this patch, the driver should work in the level of the
older kernels again.

Fixes: 167c9dc84ec3 ("ALSA: usb-audio: Fix implicit feedback sync setup for Pioneer devices")
Link: https://lore.kernel.org/r/20210118075816.25068-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Set sample rate for all sharing EPs on UAC1
Takashi Iwai [Mon, 18 Jan 2021 07:58:15 +0000 (08:58 +0100)]
ALSA: usb-audio: Set sample rate for all sharing EPs on UAC1

The UAC2/3 sample rate setup is based on the clock node, which is
usually shared in the interface, and can't be re-setup without
deselecting the interface once, and that's how the current code
behaves.  OTOH, the sample rate setup of UAC1 is per endpoint, hence
we basically need to call for each endpoint usage even if those share
the same interface.

This patch fixes the behavior of UAC1 to call always
snd_usb_init_sample_rate() in snd_usb_endpoint_configure().

Fixes: bf6313a0ff76 ("ALSA: usb-audio: Refactor endpoint management")
Link: https://lore.kernel.org/r/20210118075816.25068-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoALSA: usb-audio: Fix UAC1 rate setup for secondary endpoints
Takashi Iwai [Mon, 18 Jan 2021 07:58:14 +0000 (08:58 +0100)]
ALSA: usb-audio: Fix UAC1 rate setup for secondary endpoints

The current sample rate setup function for UAC1 assumes only the first
endpoint retrieved from the interface:altset pair, but the rate set up
may be needed also for the secondary endpoint.  Also, retrieving the
endpoint number from the interface descriptor is redundant; we have
already the target endpoint in the given audioformat object.

This patch simplifies the code and corrects the target endpoint as
described in the above.  It simply refers to fmt->endpoint directly.

Also, this patch drops the pioneer_djm_set_format_quirk() that is
caleld from snd_usb_set_format_quirk(); this function does the sample
rate setup but for the capture endpoint (0x82), and that's exactly
what the change above fixes.

Link: https://lore.kernel.org/r/20210118075816.25068-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
3 years agoLinux 5.11-rc4
Linus Torvalds [Mon, 18 Jan 2021 00:37:05 +0000 (16:37 -0800)]
Linux 5.11-rc4

3 years agoMerge tag 'perf-tools-fixes-2021-01-17' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sun, 17 Jan 2021 21:14:46 +0000 (13:14 -0800)]
Merge tag 'perf-tools-fixes-2021-01-17' of git://git./linux/kernel/git/acme/linux

Pull perf tools fixes from Arnaldo Carvalho de Melo:

 - Fix 'CPU too large' error in Intel PT

 - Correct event attribute sizes in 'perf inject'

 - Sync build_bug.h and kvm.h kernel copies

 - Fix bpf.h header include directive in 5sec.c 'perf trace' bpf example

 - libbpf tests fixes

 - Fix shadow stat 'perf test' for non-bash shells

 - Take cgroups into account for shadow stats in 'perf stat'

* tag 'perf-tools-fixes-2021-01-17' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
  perf inject: Correct event attribute sizes
  perf intel-pt: Fix 'CPU too large' error
  perf stat: Take cgroups into account for shadow stats
  perf stat: Introduce struct runtime_stat_data
  libperf tests: Fail when failing to get a tracepoint id
  libperf tests: If a test fails return non-zero
  libperf tests: Avoid uninitialized variable warning
  perf test: Fix shadow stat test for non-bash shells
  tools headers: Syncronize linux/build_bug.h with the kernel sources
  tools headers UAPI: Sync kvm.h headers with the kernel sources
  perf bpf examples: Fix bpf.h header include directive in 5sec.c example

3 years agoMerge tag 'powerpc-5.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
Linus Torvalds [Sun, 17 Jan 2021 20:28:58 +0000 (12:28 -0800)]
Merge tag 'powerpc-5.11-4' of git://git./linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
 "One fix for a lack of alignment in our linker script, that can lead to
  crashes depending on configuration etc.

  One fix for the 32-bit VDSO after the C VDSO conversion.

  Thanks to Andreas Schwab, Ariel Marcovitch, and Christophe Leroy"

* tag 'powerpc-5.11-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/vdso: Fix clock_gettime_fallback for vdso32
  powerpc: Fix alignment bug within the init sections

3 years agoMerge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Linus Torvalds [Sun, 17 Jan 2021 20:16:47 +0000 (12:16 -0800)]
Merge branch 'fixes' of git://git./linux/kernel/git/viro/vfs

Pull misc vfs fixes from Al Viro:
 "Several assorted fixes.

  I still think that audit ->d_name race is better fixed this way for
  the benefit of backports, with any possibly fancier variants done on
  top of it"

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  dump_common_audit_data(): fix racy accesses to ->d_name
  iov_iter: fix the uaccess area in copy_compat_iovec_from_user
  umount(2): move the flag validity checks first

3 years agomm: don't put pinned pages into the swap cache
Linus Torvalds [Sat, 16 Jan 2021 23:34:57 +0000 (15:34 -0800)]
mm: don't put pinned pages into the swap cache

So technically there is nothing wrong with adding a pinned page to the
swap cache, but the pinning obviously means that the page can't actually
be free'd right now anyway, so it's a bit pointless.

However, the real problem is not with it being a bit pointless: the real
issue is that after we've added it to the swap cache, we'll try to unmap
the page.  That will succeed, because the code in mm/rmap.c doesn't know
or care about pinned pages.

Even the unmapping isn't fatal per se, since the page will stay around
in memory due to the pinning, and we do hold the connection to it using
the swap cache.  But when we then touch it next and take a page fault,
the logic in do_swap_page() will map it back into the process as a
possibly read-only page, and we'll then break the page association on
the next COW fault.

Honestly, this issue could have been fixed in any of those other places:
(a) we could refuse to unmap a pinned page (which makes conceptual
sense), or (b) we could make sure to re-map a pinned page writably in
do_swap_page(), or (c) we could just make do_wp_page() not COW the
pinned page (which was what we historically did before that "mm:
do_wp_page() simplification" commit).

But while all of them are equally valid models for breaking this chain,
not putting pinned pages into the swap cache in the first place is the
simplest one by far.

It's also the safest one: the reason why do_wp_page() was changed in the
first place was that getting the "can I re-use this page" wrong is so
fraught with errors.  If you do it wrong, you end up with an incorrectly
shared page.

As a result, using "page_maybe_dma_pinned()" in either do_wp_page() or
do_swap_page() would be a serious bug since it is only a (very good)
heuristic.  Re-using the page requires a hard black-and-white rule with
no room for ambiguity.

In contrast, saying "this page is very likely dma pinned, so let's not
add it to the swap cache and try to unmap it" is an obviously safe thing
to do, and if the heuristic might very rarely be a false positive, no
harm is done.

Fixes: 09854ba94c6a ("mm: do_wp_page() simplification")
Reported-and-tested-by: Martin Raiber <martin@urbackup.org>
Cc: Pavel Begunkov <asml.silence@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agoMerge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Linus Torvalds [Sat, 16 Jan 2021 20:25:40 +0000 (12:25 -0800)]
Merge tag 'scsi-fixes' of git://git./linux/kernel/git/jejb/scsi

Pull SCSI fixes from James Bottomley:
 "Nine minor fixes, seven in drivers and two in the core SCSI disk
  driver (sd) which should be harmless involving removing an unused
  variable and quietening a spurious warning"

Signed-off-by: James E.J. Bottomley <jejb@linux.ibm.com>
* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: sd: Remove obsolete variable in sd_remove()
  scsi: sd: Suppress spurious errors when WRITE SAME is being disabled
  scsi: scsi_debug: Fix memleak in scsi_debug_init()
  scsi: mpt3sas: Fix spelling mistake in Kconfig "compatiblity" -> "compatibility"
  scsi: qedi: Correct max length of CHAP secret
  scsi: ufs: Correct the LUN used in eh_device_reset_handler() callback
  scsi: ufs: Relocate flush of exceptional event
  scsi: ufs: Relax the condition of UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL
  scsi: ufs: Fix possible power drain during system suspend

3 years agodump_common_audit_data(): fix racy accesses to ->d_name
Al Viro [Tue, 5 Jan 2021 19:43:46 +0000 (14:43 -0500)]
dump_common_audit_data(): fix racy accesses to ->d_name

We are not guaranteed the locking environment that would prevent
dentry getting renamed right under us.  And it's possible for
old long name to be freed after rename, leading to UAF here.

Cc: stable@kernel.org # v2.6.2+
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
3 years agoMerge tag 'block-5.11-2021-01-16' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 16 Jan 2021 19:39:58 +0000 (11:39 -0800)]
Merge tag 'block-5.11-2021-01-16' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
 "Just an nvme pull request via Christoph:

   - don't initialize hwmon for discover controllers (Sagi Grimberg)

   - fix iov_iter handling in nvme-tcp (Sagi Grimberg)

   - fix a preempt warning in nvme-tcp (Sagi Grimberg)

   - fix a possible NULL pointer dereference in nvme (Israel Rukshin)"

* tag 'block-5.11-2021-01-16' of git://git.kernel.dk/linux-block:
  nvme: don't intialize hwmon for discovery controllers
  nvme-tcp: fix possible data corruption with bio merges
  nvme-tcp: Fix warning with CONFIG_DEBUG_PREEMPT
  nvmet-rdma: Fix NULL deref when setting pi_enable and traddr INADDR_ANY

3 years agoMerge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
Linus Torvalds [Sat, 16 Jan 2021 19:12:02 +0000 (11:12 -0800)]
Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block

Pull io_uring fixes from Jens Axboe:
 "We still have a pending fix for a cancelation issue, but it's still
  being investigated. In the meantime:

   - Dead mm handling fix (Pavel)

   - SQPOLL setup error handling (Pavel)

   - Flush timeout sequence fix (Marcelo)

   - Missing finish_wait() for one exit case"

* tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block:
  io_uring: ensure finish_wait() is always called in __io_uring_task_cancel()
  io_uring: flush timeouts that should already have expired
  io_uring: do sqo disable on install_fd error
  io_uring: fix null-deref in io_disable_sqo_submit
  io_uring: don't take files/mm for a dead task
  io_uring: drop mm and files after task_work_run

3 years agoMerge tag 'riscv-for-linus-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 16 Jan 2021 19:00:08 +0000 (11:00 -0800)]
Merge tag 'riscv-for-linus-5.11-rc4' of git://git./linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:
 "There are a few more fixes than a normal rc4, largely due to the
  bubble introduced by the holiday break:

   - return -ENOSYS for syscall number -1, which previously returned an
     uninitialized value.

   - ensure of_clk_init() has been called in time_init(), without which
     clock drivers may not be initialized.

   - fix sifive,uart0 driver to properly display the baud rate. A fix to
     initialize MPIE that allows interrupts to be processed during
     system calls.

   - avoid erronously begin tracing IRQs when interrupts are disabled,
     which at least triggers suprious lockdep failures.

   - workaround for a warning related to calling smp_processor_id()
     while preemptible. The warning itself is suprious on currently
     availiable systems.

   - properly include the generic time VDSO calls. A fix to our kasan
     address mapping. A fix to the HiFive Unleashed device tree, which
     allows the Ethernet PHY to be properly initialized by Linux (as
     opposed to relying on the bootloader).

   - defconfig update to include SiFive's GPIO driver, which is present
     on the HiFive Unleashed and necessary to initialize the PHY.

   - avoid allocating memory while initializing reserved memory.

   - avoid allocating the last 4K of memory, as pointers there alias
     with syscall errors.

  There are also two cleanups that should have no functional effect but
  do fix build warnings:

   - drop a duplicated definition of PAGE_KERNEL_EXEC.

   - properly declare the asm register SP shim.

   - cleanup the rv32 memory size Kconfig entry, to reflect the actual
     size of memory availiable"

* tag 'riscv-for-linus-5.11-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  RISC-V: Fix maximum allowed phsyical memory for RV32
  RISC-V: Set current memblock limit
  RISC-V: Do not allocate memblock while iterating reserved memblocks
  riscv: stacktrace: Move register keyword to beginning of declaration
  riscv: defconfig: enable gpio support for HiFive Unleashed
  dts: phy: add GPIO number and active state used for phy reset
  dts: phy: fix missing mdio device and probe failure of vsc8541-01 device
  riscv: Fix KASAN memory mapping.
  riscv: Fixup CONFIG_GENERIC_TIME_VSYSCALL
  riscv: cacheinfo: Fix using smp_processor_id() in preemptible
  riscv: Trace irq on only interrupt is enabled
  riscv: Drop a duplicated PAGE_KERNEL_EXEC
  riscv: Enable interrupts during syscalls with M-Mode
  riscv: Fix sifive serial driver
  riscv: Fix kernel time_init()
  riscv: return -ENOSYS for syscall -1

3 years agomm: don't play games with pinned pages in clear_page_refs
Linus Torvalds [Sun, 10 Jan 2021 01:09:10 +0000 (17:09 -0800)]
mm: don't play games with pinned pages in clear_page_refs

Turning a pinned page read-only breaks the pinning after COW.  Don't do it.

The whole "track page soft dirty" state doesn't work with pinned pages
anyway, since the page might be dirtied by the pinning entity without
ever being noticed in the page tables.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agomm: fix clear_refs_write locking
Linus Torvalds [Fri, 8 Jan 2021 21:13:41 +0000 (13:13 -0800)]
mm: fix clear_refs_write locking

Turning page table entries read-only requires the mmap_sem held for
writing.

So stop doing the odd games with turning things from read locks to write
locks and back.  Just get the write lock.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
3 years agoRISC-V: Fix maximum allowed phsyical memory for RV32
Atish Patra [Mon, 11 Jan 2021 23:45:04 +0000 (15:45 -0800)]
RISC-V: Fix maximum allowed phsyical memory for RV32

Linux kernel can only map 1GB of address space for RV32 as the page offset
is set to 0xC0000000. The current description in the Kconfig is confusing
as it indicates that RV32 can support 2GB of physical memory. That is
simply not true for current kernel. In future, a 2GB split support can be
added to allow 2GB physical address space.

Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
3 years agoRISC-V: Set current memblock limit
Atish Patra [Mon, 11 Jan 2021 23:45:02 +0000 (15:45 -0800)]
RISC-V: Set current memblock limit

Currently, linux kernel can not use last 4k bytes of addressable space
because IS_ERR_VALUE macro treats those as an error. This will be an issue
for RV32 as any memblock allocator potentially allocate chunk of memory
from the end of DRAM (2GB) leading bad address error even though the
address was technically valid.

Fix this issue by limiting the memblock if available memory spans the
entire address space.

Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
3 years agoRISC-V: Do not allocate memblock while iterating reserved memblocks
Atish Patra [Mon, 11 Jan 2021 23:45:01 +0000 (15:45 -0800)]
RISC-V: Do not allocate memblock while iterating reserved memblocks

Currently, resource tree allocates memory blocks while iterating on the
list. It leads to following kernel warning because memblock allocation
also invokes memory block reservation API.

[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at kernel/resource.c:795
__insert_resource+0x8e/0xd0
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted
5.10.0-00022-ge20097fb37e2-dirty #549
[    0.000000] epc: c00125c2 ra : c001262c sp : c1c01f50
[    0.000000]  gp : c1d456e0 tp : c1c0a980 t0 : ffffcf20
[    0.000000]  t1 : 00000000 t2 : 00000000 s0 : c1c01f60
[    0.000000]  s1 : ffffcf00 a0 : ffffff00 a1 : c1c0c0c4
[    0.000000]  a2 : 80c12b15 a3 : 80402000 a4 : 80402000
[    0.000000]  a5 : c1c0c0c4 a6 : 80c12b15 a7 : f5faf600
[    0.000000]  s2 : c1c0c0c4 s3 : c1c0e000 s4 : c1009a80
[    0.000000]  s5 : c1c0c000 s6 : c1d48000 s7 : c1613b4c
[    0.000000]  s8 : 00000fff s9 : 80000200 s10: c1613b40
[    0.000000]  s11: 00000000 t3 : c1d4a000 t4 : ffffffff

This is also unnecessary as we can pre-compute the total memblocks required
for each memory region and allocate it before the loop. It save precious
boot time not going through memblock allocation code every time.

Fixes: 00ab027a3b82 ("RISC-V: Add kernel image sections to the resource tree")

Reviewed-by: Anup Patel <anup@brainfault.org>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
3 years agoiov_iter: fix the uaccess area in copy_compat_iovec_from_user
Christoph Hellwig [Mon, 11 Jan 2021 17:19:26 +0000 (18:19 +0100)]
iov_iter: fix the uaccess area in copy_compat_iovec_from_user

sizeof needs to be called on the compat pointer, not the native one.

Fixes: 89cd35c58bc2 ("iov_iter: transparently handle compat iovecs in import_iovec")
Reported-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>