Commit Graph

4791 Commits

Author SHA1 Message Date
William Wu
62c5e6af1c usb: gadget: f_uvc: disallow the CPU to enter deeper sleep when streamon
I test on RK3399 IND EVB running Android R system, and
set the USB gadget as UVC function via configfs, both
the USB 2.0 and 3.0 UVC have preview abnormal problems.
If the CPU enter deeper sleep, the USB DMA transfer gets
corrupted, and the UVC ISOC transmission lost data.

This patch puts in a "pm_qos_latency" requirement which
will keep the CPU out of the deeper sleep states when
UVC stream on. And allow the CPU to enter deeper sleep
state after UVC stream off.

Change-Id: I808290f124c6a32da3888819348093a205bfad61
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 19:16:52 +08:00
William Wu
7bb8939e5c usb: gadget: f_uvc: add suspend and resume function
This patch adds uvc_function_suspend and uvc_function_resume
for uvc function. With this patch, if usb bus enter suspend
or resume state, the usb controller driver will call the
uvc_function_suspend or uvc_function_resume to send event
to uvc app.

Change-Id: I9c584aae25298747c5a287243cb3efd71c8adfe6
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 19:16:52 +08:00
William Wu
376cc3f4d2 usb: gadget: f_uvc: trace uvc control request
This patch add new uvc trace for setup request processing.

1. enable trace
   echo 4 > /sys/module/usb_f_uvc/parameters/trace

2. dump trace
   dmesg

Test on RV1109 EVB with UVC function when streaming on:

[  426.441316] uvcvideo: setup request a1 81 value 0100 index 0003 001a
[  426.450280] uvcvideo: uvc_send_response: req len 26
[  426.450444] uvcvideo: event_setup_out 0, data len 26
[  426.451545] uvcvideo: setup request 21 01 value 0100 index 0003 001a
[  426.460862] uvcvideo: uvc_send_response: req len 26
[  426.461014] uvcvideo: event_setup_out 1, data len 26
[  426.461173] uvcvideo: setup request a1 81 value 0100 index 0003 001a
[  426.485791] uvcvideo: uvc_send_response: req len 26
[  426.486672] uvcvideo: event_setup_out 0, data len 26
[  426.487145] uvcvideo: setup request a1 83 value 0100 index 0003 001a
[  426.496529] uvcvideo: uvc_send_response: req len 26
[  426.496655] uvcvideo: event_setup_out 0, data len 26
[  426.497485] uvcvideo: setup request a1 82 value 0100 index 0003 001a
[  426.506737] uvcvideo: uvc_send_response: req len 26
[  426.507195] uvcvideo: event_setup_out 0, data len 26

Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: If882728e891d033c249e6c466b40d3e2a28bccb6
2021-06-16 19:16:52 +08:00
William Wu
71a43ff15c usb: gadget: f_uac1: finalize wMaxPacketSize according to bandwidth
According to USB Audio Device 1.0 Spec, Ch4.6.1.1:
The wMaxPacketSize of endpoint is defined as follows:
Maximum packet size of endpoint is capable of sending
or receiving when this configuration is selected. This
is determined by the audio bandwidth constraints of
the endpoint.

In current code, the wMaxPacketSize is limited to 200,
and the bInterval is set to 4 (1ms). That is, the maximum
bandwidth over USB bus is 200 * 1000 = 200000 bytes.

We find an issue about bandwidth limitation when we try to
support UAC1 with 8ch * 16bit * 16KHz on RK3308 platform,
which needs more bandwidth than it can support.

This patch sets the wMaxPacketSize dynamically according
to the parameters of UAC1. It is similar to the same thing
done earlier for f_uac2.

Change-Id: I9af3fd7665a80b5eb0cfb5dc91ebe2c20df1dd46
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:21 +08:00
Ren Jianing
be7c4cf14b usb: gadget: u_audio: add uevent for ppm compensation
This patch add uevent to notify the application layer how much ppm
is different between USB clk and AUDIO clk.

The event include two parts USB_STATE and PPM. For example:

  g_audio_work: sent uac uevent USB_STATE=SET_AUDIO_CLK PPM=12
  g_audio_work: sent uac uevent USB_STATE=SET_AUDIO_CLK PPM=-1

Note: The ppm compensation depends on the method implement of
clk drift and compensation in the rockchip_pdm.c driver. So if
you want the ppm compensation to take effect, please make sure
the commit "ASoC: rockchip: pdm: Add support for clk compensation"
is merged.

Change-Id: Id25411397fe376342c773c11f1989ed5854f8ad9
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:21 +08:00
Ren Jianing
7e08fbf2c8 usb: gadget: f_fs: fix ep req_match error for composite device
This patch add direction index for eps_revmap, which can avoid matching
to the requests for other functions.

For example, if we config ep1in for uac and ep1out for adb, the requests
for ep1in will be matching to ffs without this patch.

Change-Id: Ic7a52fca35503656bbc306c9f0014dfdea61392b
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:21 +08:00
William Wu
bcf7606d61 usb: gadget: add transfer_type in struct usb_ep for rockchip
The usb gadget core set the chosen endpoint descriptor for
each endpoints in config_ep_by_speed(), however, we want
to get the transfer type of the endpoints earlier on the
rockchip platforms for usb controller initialization
(e.g. do tx fifos resize for rockchip usb dwc3 controller),
so this patch add transfer_type in the struct usb_ep, and
set the transfer_type in the usb_ep_autoconfig_ss().

Change-Id: Ia2added218e180dda7a7ca5da09ee18d63be1ff0
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:19 +08:00
Ren Jianing
be3429e9b2 usb: gadget: f_uac: add pktsize calculating at setting playback srate
Without this patch, we only calculate usb request packet_size when
start playback. If PC set sample rate after opening stream, the value
of packet_size will not be updated to uac driver and the gadget will
send error size of pcm data.

Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: Iaa54ed740c98e5f12bf9cf680b50cf4be931cfbd
2021-06-16 18:21:34 +08:00
William Wu
c55a0ab282 usb: gadget: f_uac: add volume and mute feature unit
This patch adds feature unit descriptor for f_uac1 and f_uac2,
and supports volume control and mute control for capture and
playback.

By default, the volume and mute feature unit descriptors are NOT
add in the UAC descriptor. The user can define whether the UAC1/
UAC2 shall support volume and mute functionality via the attributes
c_feature_unit/p_feature_unit in the UAC function directory.

For example, user can add the volume and mute feature unit descriptors
for UAC1 capture and playback:

echo 1 > /config/usb-gadget/gadget/functions/uac1.name/c_feature_unit
echo 1 > /config/usb-gadget/gadget/functions/uac1.name/p_feature_unit

This patch also adds uevents for volume and mute functionality. The
user can complete the real volume and mute control functionality in
the user space depends on these new uevents (like the uac_app in the
RV1126/RV1109 SDK).

Change-Id: I76d447a19fd69e038851040cd73e6c7d420f467d
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:15:08 +08:00
William Wu
adc23c13ff usb: gadget: f_rndis: handle the packet filter class request
This patch handles the class specific control request
"USB_CDC_SET_ETHERNET_PACKET_FILTER" for rndis. Actually,
the cdc_filter is not rndis specific, so we don't really
set the cdc_filter to the wValue of setup request for
rndis, and just return value 0 for the setup request to
avoid usb controllers stall ep0.

Change-Id: I42f9835a9812b8dfa640562b8555bc5f9b022256
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
Ren Jianing
ac1ed698c3 usb: gadget: u_audio: add uevent for set_alt and set_srate
This patch add uevent to notify the application layer when it should
playback or capture and setting the accuration sample rate.

The event consists of three parts, namely USB_STATE, STREAM_DIRECTION
and STREAM_STATE. For example:

g_audio_work: sent uac uevent USB_STATE=SET_INTERFACE STREAM_DIRECTION=IN STREAM_STATE=OFF
g_audio_work: sent uac uevent USB_STATE=SET_INTERFACE STREAM_DIRECTION=OUT STREAM_STATE=ON
g_audio_work: sent uac uevent USB_STATE=SET_SAMPLE_RATE STREAM_DIRECTION=OUT SAMPLE_RATE=44100

Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: Ia01572d92d0c3ae40b19e772571282b8806da9e5
2021-06-16 18:13:14 +08:00
Ren Jianing
37ed8f4607 FROMLIST: usb: gadget: f_uac*: Support multiple sampling rates
Implement support for multiple sampling rates in the USB Audio gadgets.
A list of sampling rates can be specified via configfs. All enabled
sampling rates are sent to the USB host on request. When the host
selects a sampling rate the internal active rate is updated. The
currently configured rates are exposed through amixer controls. Also on
pcm open from userspace the requested rated is checked against the
currently configured rate of the host.

Link: https://lore.kernel.org/patchwork/patch/805286/
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: I43dc28462062c9aa179c2b9c8e7e50c307137874
2021-06-16 18:13:14 +08:00
Ren Jianing
70267887d6 FROMLIST: usb: gadget: f_uac*: Reduce code duplication
This replaces the dedicated headers for uac1 and uac2 functions with a
shared header for both of them. Apart from unifying the struct names,
further duplicated code for configfs setup is moved out of the function
files into the shared header.

Link: https://lore.kernel.org/patchwork/patch/805285/
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: Ie866bd02f174dc91168fe0bc49b571a77d849a42
2021-06-16 18:13:14 +08:00
Julian Scheel
d390fcf2f7 FROMLIST: usb: gadget: f_uac1: Fix endpoint reading
The endpoint is stored in the lower byte of wIndex, according to USB
Audio 1.0 specification, section 5.2.1.1.

Link: https://lore.kernel.org/patchwork/patch/805284/
Change-Id: I16634151e98cfb0f7107e96463a20b8fa8d7072f
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
02d2e8fcb4 usb: gadget: uvc: allow zero bytesused for rockchip uvc
For rockchip platforms, the userspace uvc application use
bytesused == 0 as a way to indicate that the data is all
zero and unused. In that case, the uvc driver should use
the allow_zero_bytesused flag to keep bytesused 0 rather
than use the buf actual size instead. This can help to
preview 1080P@MJPG faster.

Change-Id: Ic4d561f18e85d759b5a2405db4f6fb48533e1781
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
fbb23b9e8c usb: gadget: uvc: add a new attribute uvc_num_request
This patch adds a new uvc attribute "uvc_num_request" to
set the number of uvc requests. And the maximum limit is
set to UVC_MAX_NUM_REQUESTS (8), the default value of
uvc_num_request is set to UVC_NUM_REQUESTS (4).

Change-Id: I69d6a4d6547a81b67ce447f271c7a5103671767e
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
29ef90251a usb: gadget: udc: core: fix possible NULL pointer dereference
This patch fixes the following panic when use uvc function and
do reboot during uvc preview.

Unable to handle kernel NULL pointer dereference at virtual address 000001fd
pgd = 85dd55c1
[000001fd] *pgd=00000000
Internal error: Oops: 17 [#1] PREEMPT SMP ARM
Modules linked in: galcore(O)
CPU: 0 PID: 716 Comm: xc:RkAiqCoreThr Tainted: G        W  O      4.19.111 #18
Hardware name: Generic DT based system
PC is at usb_gadget_deactivate+0x0/0x6c
LR is at usb_function_deactivate+0x54/0x74

It's because that do reboot operation will call configfs_composite_unbind()
to set cdev->gadget to NULL.

Change-Id: I6fbfe9b58f865113d04ca7ce0b74b00f8d89227c
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
Zeng Tao
02bfaf0477 FROMLIST: usb: gadget: uvc: configfs: add framebased format support
As we know, The framebased format can be used to support a lot of
formats other than YUV and MJPEG, for example: H264 or H265.
And Nowadays, the H264 and H265 is used more and more compared to the
MJPEG, so there is a need to support such usecase, although the new UVC
1.5 and the UVC1.1 extensions already support H264, but they are much
more expensive and most of the time, what we need is just a channel to
stream the video frames.

In this patch, we implement the framebased format and set it to H264 by
default, and the users could change the video format as they need through
the guid configfs attribute node.

Change-Id: Ie1c62f5fb4fa57c24a2878f9992c982e9deb302e
Signed-off-by: Zeng Tao <prime.zeng@hisilicon.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(am from https://patchwork.kernel.org/patch/10722957/)
2021-06-16 18:13:14 +08:00
William Wu
124b5f5927 usb: gadget: configfs: make sure to reactivate function on unbind
If a configs function sets bind_deactivated flag, upon removal it will be
left with an unbalanced deactivation. Let's make sure that we conditionally
call usb_function_activate() from purge_configs_funcs() and make sure
purge_configs_funcs() is called from configfs_composite_unbind().

Change-Id: Ibe91837fdb7754f8af343a18138556901a0e089f
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
2ae1313983 usb: gadget: f_uac1: add iad descriptor
According to the spec "USB Interface Association Descriptor Device
Class Code and Use Model"[1], the Interface Association Descriptor
(IAD) is needed for composite device which has multiple interfaces
controlled independently of each other. Without the IAD, the device
may not work as expected because the USB system software will not
properly bind the interfaces with drivers (e.g UAC1 && UVC composite
device not recognized in Win10).

[1] https://www.usb.org/sites/default/files/iadclasscode_r10.pdf

Change-Id: I446c771fe182bd556a054d9ae0ada1374442d1d0
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
c15a7cecb8 usb: gadget: uvc: support streaming bulk transfer
This patch adds bulk endpoint for uvc to be used as
video streaming transfer. By default, the uvc gadget
still uses isoc endpoint for video streaming.

The important difference between the bulk and isoc
method is that, alt-settings in a video streaming
interface are supported only for isoc endpoints as
there are different alt-settings for zero-bandwidth
and full-bandwidth use-cases, but the same is not
true for bulk endpoints, as they support only a single
alt-setting.

How to use:
1. Enable the bulk transfer:
   echo 1 >  /config/usb-gadget/g1/functions/uvc.name/streaming_bulk

2. Disable the bulk transfer:
   echo 0 >  /config/usb-gadget/g1/functions/uvc.name/streaming_bulk

3. Testing the uvc bulk function transfer:
   device: run the uvc-gadget program
   # uvc-gadget -b -u /dev/video<uvc video node #> -v /dev/video<vivid video node #>

   where uvc-gadget is this program:
        http://git.ideasonboard.org/uvc-gadget.git

   with these patches:

        http://www.spinics.net/lists/linux-usb/msg99220.html

Change-Id: Ifedfe3f5c4354dd2bdf07382290107e9bcc89f59
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
60767d93e5 usb: gadget: f_uac2: fix some issues for Windows recognized
We find that the UAC2 gadget can't be recognized on Windows 10.
It's because that the descriptors of UAC2 doesn't meet the
requirements of Windows.

According to the USB Audio 2.0 Drivers of Windows [1], if the
bmAttributes of OUT-EP in the audio stream interface is set
to asynchronous (use USB_ENDPOINT_SYNC_ASYNC), then a feedback
endpoint must be implemented in the respective alternate setting
of the AS interface. The Windows driver does not support implicit
feedback.

However, it's difficult to implement the feedback endpoint now.
So the patch changes the bmAttributes of OUT-EP to adaptive, and
changes the bmAttributes of IN-EP to synchronous at the same time.

This patch also sets the wTerminalType of terminal descriptor to
microphone and speaker by default.

With this patch, we also fix the wTotalLength of the ac_hdr_desc.

[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/usb-2-0-audio-drivers

Change-Id: I3597d5f321235fcbce56dbfbfe95172d02e58892
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
7ccab04742 usb: gadget: add compat_ioctl
This allows 32 bit owners of USB Class to make ioctls
into a 64 bit kernel.

Change-Id: Ia31b26147ab619f0673f94b6662eaf181a9eb5dd
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
4ac7546e3b usb: gadget: f_uvc: add extension unit descriptor
Add extension unit descriptor for uvc. Support 3
controls in this extension unit. The rockchip IQ
tool use it to transfer vendor specific control
data.

Change-Id: I219e12616629bc75548b30ce63d46136aeac6561
Signed-off-by: William Wu <william.wu@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
89f2299475 usb: gadget: f_uac1_legacy: set period size and buffer size
The default period size is only 64 frames, this
will cause usb audio playback with noise via
internal audio codec. This patch sets the period
size to (snd->rate / 10), and also sets the buffer
size to snd->rate.

Change-Id: I4a4eb1b4dd79aec65f5c44eacd8a2fa101dfbd1b
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
3ecb9e48f7 usb: gadget: f_uac1_legacy: disable ep in f_audio_disable()
The f_audio_disable() doesn't disable usb ep, and
this cause usb enumeration fail. So add usb ep
disable operation.

This patch also reinitializes the opts->bound flag
to false in f_audio_free(), and then it can setup
ALSA audio device again in f_audio_bind().

Change-Id: I7b10630f5085b1a03792bc4b9e7eabb02d2bd5a2
Signed-off-by: William Wu <william.wu@rock-chips.com>
2021-06-16 18:13:14 +08:00
Meng Dongyang
7f7344e617 usb: gadget: configfs: send connect detective event when get descriptor
In current code, the connect detective event will be send before the
connect state of controller change. The event is sent when receive
the first setup packet and the connect state of controller is changed
when receive set address command. So if disconnect interrupt trigger
between the first setup packet and set address command, the disconnect
process will not be done, while the application state has been changed
and keep in connected. As a result, the UI may still show the USB connect
option event if the device has been disconnect from PC. This patch send
the connect uevent when get descriptor of configuration which follow
set address command to make sure the application state change after
controller.

Change-Id: Icf2124327db93687b4b644672edb0dbecc8f127a
Signed-off-by: Meng Dongyang <daniel.meng@rock-chips.com>
2021-06-16 18:13:14 +08:00
William Wu
ad74683094 usb: gadget: rndis: fix class definitions for windows
The RNDIS gadget function has USB class of 2 and subclass
of 2, which matches "USB\Class_02&SubClass_02" in the
usbser.inf file in the Windows system, so the device is
initially detected as a COM port instead of RNDIS. This
is why we need to install RNDIS manually.

Refer to Defined Class Codes [1] and rndis_host of Linux [2],
this patch sets the RNDIS gadget with base class of 0xE0h
(Wireless Controller) and subclass of 0x01h and protocol
of 0x03h.

[1] https://www.usb.org/defined-class-codes
[2] http://www.embedded-os.de/en/proto-rndis_host.shtml

Change-Id: Ida366749f378a0ce770d707b4ba56b87f9e188cf
Signed-off-by: William Wu <william.wu@rock-chips.com>
2021-06-16 18:13:14 +08:00
Tao Huang
88c22e1beb Merge remote branch 'android12-5.10' of https://android.googlesource.com/kernel/common
* android12-5.10: (966 commits)
  ANDROID: Support disabling symbol trimming
  ANDROID: Incremental fs: Fix pseudo-file attributes
  ANDROID: sched: Fix missing RQCF_UPDATED in migrate_tasks
  FROMLIST: mm, thp: Relax the VM_DENYWRITE constraint on file-backed THPs
  ANDROID: GKI: Update the generic symbol list
  ANDROID: ABI: Add symbols for crypto
  ANDROID: ABI: Update the ABI XML
  Revert "ANDROID: GKI: Change UCLAMP_BUCKETS_COUNT to 20"
  ANDROID: vendor_hooks: Add hook for binder
  UPSTREAM: crypto: arm/blake2s - fix for big endian
  UPSTREAM: crypto: arm/blake2b - drop unnecessary return statement
  FROMGIT: kasan, arm64: tests supports for HW_TAGS async mode
  FROMGIT: arm64: mte: Report async tag faults before suspend
  FROMGIT: arm64: mte: Enable async tag check fault
  FROMGIT: arm64: mte: Conditionally compile mte_enable_kernel_*()
  ANDROID: ABI: Update the ABI xml
  ANDROID: ABI: Update the generic symbol list
  ANDROID: selinux: add vendor hook in selinux
  FROMGIT: arm64: mte: Enable TCO in functions that can read beyond buffer limits
  ANDROID: sched: Add vendor hooks for update_load_avg
  ...

Change-Id: I74731b47c1f6cd67cea9622113833b3f8c994544
2021-05-03 19:52:23 +08:00
Tao Huang
d648938407 Merge remote branch 'android12-5.10' of https://android.googlesource.com/kernel/common
* android12-5.10: (1647 commits)
  FROMGIT: mm/page_owner: record the timestamp of all pages during free
  UPSTREAM: mm/page_io: use pr_alert_ratelimited for swap read/write errors
  ANDROID: roll back xt_IDLETIMER to 5.10.21 upstream/vanilla version
  ANDROID: qcom: Add ip, rtnl and free related symbols
  FROMGIT: power: supply: Fix build error when CONFIG_POWER_SUPPLY is not enabled.
  FROMGIT: usb: dwc3: gadget: modify the scale in vbus_draw callback
  BACKPORT: FROMLIST: usb: dwc3: gadget: Clear DEP flags after stop transfers in ep disable
  FROMLIST: Makefile: fix GDB warning with CONFIG_RELR
  ANDROID: refresh ABI XML before enabling KMI enforcement
  Revert "Revert "ANDROID: GKI: Enable bounds sanitizer""
  Revert "ANDROID: Revert "f2fs: fix to tag FIEMAP_EXTENT_MERGED in f2fs_fiemap()""
  ANDROID: Enforce KMI stability
  ANDROID: enable options prior to enforcing KMI
  Revert "ANDROID: GKI: temporarily disable LTO/CFI"
  ANDROID: gki_defconfig: Enable NET_CLS_{BASIC,TCINDEX,MATCHALL} & NET_ACT_{GACT,MIRRED}
  FROMLIST: selftests: Add a MREMAP_DONTUNMAP selftest for shmem
  FROMLIST: mm: Extend MREMAP_DONTUNMAP to non-anonymous mappings
  ANDROID: GKI: enable CONFIG_CMA_SYSFS
  ANDROID: make cma_sysfs experimental
  FROMLIST: mm: cma: support sysfs
  ...

Change-Id: I6145eddeb253bea33164fc909e7790d30f17ef1f
2021-04-25 18:33:22 +08:00
Hemant Kumar
fcd2a56bb0 FROMGIT: usb: gadget: Fix double free of device descriptor pointers
Upon driver unbind usb_free_all_descriptors() function frees all
speed descriptor pointers without setting them to NULL. In case
gadget speed changes (i.e from super speed plus to super speed)
after driver unbind only upto super speed descriptor pointers get
populated. Super speed plus desc still holds the stale (already
freed) pointer. Fix this issue by setting all descriptor pointers
to NULL after freeing them in usb_free_all_descriptors().

Fixes: f5c61225cf ("usb: gadget: Update function for SuperSpeedPlus")
cc: stable@vger.kernel.org
Reviewed-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/1619034452-17334-1-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 43c4cab006
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I24ed655c590ebe82f8e665882acdc4b0e4c1d9a9
2021-04-22 13:57:57 +00:00
Greg Kroah-Hartman
e92949726c Merge 5.10.28 into android12-5.10
Changes in 5.10.28
	arm64: mm: correct the inside linear map range during hotplug check
	bpf: Fix fexit trampoline.
	virtiofs: Fail dax mount if device does not support it
	ext4: shrink race window in ext4_should_retry_alloc()
	ext4: fix bh ref count on error paths
	fs: nfsd: fix kconfig dependency warning for NFSD_V4
	rpc: fix NULL dereference on kmalloc failure
	iomap: Fix negative assignment to unsigned sis->pages in iomap_swapfile_activate
	ASoC: rt1015: fix i2c communication error
	ASoC: rt5640: Fix dac- and adc- vol-tlv values being off by a factor of 10
	ASoC: rt5651: Fix dac- and adc- vol-tlv values being off by a factor of 10
	ASoC: sgtl5000: set DAP_AVC_CTRL register to correct default value on probe
	ASoC: es8316: Simplify adc_pga_gain_tlv table
	ASoC: soc-core: Prevent warning if no DMI table is present
	ASoC: cs42l42: Fix Bitclock polarity inversion
	ASoC: cs42l42: Fix channel width support
	ASoC: cs42l42: Fix mixer volume control
	ASoC: cs42l42: Always wait at least 3ms after reset
	NFSD: fix error handling in NFSv4.0 callbacks
	kernel: freezer should treat PF_IO_WORKER like PF_KTHREAD for freezing
	vhost: Fix vhost_vq_reset()
	io_uring: fix ->flags races by linked timeouts
	scsi: st: Fix a use after free in st_open()
	scsi: qla2xxx: Fix broken #endif placement
	staging: comedi: cb_pcidas: fix request_irq() warn
	staging: comedi: cb_pcidas64: fix request_irq() warn
	ASoC: rt5659: Update MCLK rate in set_sysclk()
	ASoC: rt711: add snd_soc_component remove callback
	thermal/core: Add NULL pointer check before using cooling device stats
	locking/ww_mutex: Simplify use_ww_ctx & ww_ctx handling
	locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini()
	nvmet-tcp: fix kmap leak when data digest in use
	io_uring: imply MSG_NOSIGNAL for send[msg]()/recv[msg]() calls
	static_call: Align static_call_is_init() patching condition
	ext4: do not iput inode under running transaction in ext4_rename()
	io_uring: call req_set_fail_links() on short send[msg]()/recv[msg]() with MSG_WAITALL
	net: mvpp2: fix interrupt mask/unmask skip condition
	flow_dissector: fix TTL and TOS dissection on IPv4 fragments
	can: dev: move driver related infrastructure into separate subdir
	net: introduce CAN specific pointer in the struct net_device
	can: tcan4x5x: fix max register value
	brcmfmac: clear EAP/association status bits on linkdown events
	ath11k: add ieee80211_unregister_hw to avoid kernel crash caused by NULL pointer
	rtw88: coex: 8821c: correct antenna switch function
	netdevsim: dev: Initialize FIB module after debugfs
	iwlwifi: pcie: don't disable interrupts for reg_lock
	ath10k: hold RCU lock when calling ieee80211_find_sta_by_ifaddr()
	net: ethernet: aquantia: Handle error cleanup of start on open
	appletalk: Fix skb allocation size in loopback case
	net: ipa: remove two unused register definitions
	net: ipa: fix register write command validation
	net: wan/lmc: unregister device when no matching device is found
	net: 9p: advance iov on empty read
	bpf: Remove MTU check in __bpf_skb_max_len
	ACPI: tables: x86: Reserve memory occupied by ACPI tables
	ACPI: processor: Fix CPU0 wakeup in acpi_idle_play_dead()
	ALSA: usb-audio: Apply sample rate quirk to Logitech Connect
	ALSA: hda: Re-add dropped snd_poewr_change_state() calls
	ALSA: hda: Add missing sanity checks in PM prepare/complete callbacks
	ALSA: hda/realtek: fix a determine_headset_type issue for a Dell AIO
	ALSA: hda/realtek: call alc_update_headset_mode() in hp_automute_hook
	ALSA: hda/realtek: fix mute/micmute LEDs for HP 640 G8
	xtensa: fix uaccess-related livelock in do_page_fault
	xtensa: move coprocessor_flush to the .text section
	KVM: SVM: load control fields from VMCB12 before checking them
	KVM: SVM: ensure that EFER.SVME is set when running nested guest or on nested vmexit
	PM: runtime: Fix race getting/putting suppliers at probe
	PM: runtime: Fix ordering in pm_runtime_get_suppliers()
	tracing: Fix stack trace event size
	s390/vdso: copy tod_steering_delta value to vdso_data page
	s390/vdso: fix tod_steering_delta type
	mm: fix race by making init_zero_pfn() early_initcall
	drm/amdkfd: dqm fence memory corruption
	drm/amdgpu: fix offset calculation in amdgpu_vm_bo_clear_mappings()
	drm/amdgpu: check alignment on CPU page for bo map
	reiserfs: update reiserfs_xattrs_initialized() condition
	drm/imx: fix memory leak when fails to init
	drm/tegra: dc: Restore coupling of display controllers
	drm/tegra: sor: Grab runtime PM reference across reset
	vfio/nvlink: Add missing SPAPR_TCE_IOMMU depends
	pinctrl: rockchip: fix restore error in resume
	extcon: Add stubs for extcon_register_notifier_all() functions
	extcon: Fix error handling in extcon_dev_register
	firmware: stratix10-svc: reset COMMAND_RECONFIG_FLAG_PARTIAL to 0
	usb: dwc3: pci: Enable dis_uX_susphy_quirk for Intel Merrifield
	video: hyperv_fb: Fix a double free in hvfb_probe
	firewire: nosy: Fix a use-after-free bug in nosy_ioctl()
	usbip: vhci_hcd fix shift out-of-bounds in vhci_hub_control()
	USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem
	usb: musb: Fix suspend with devices connected for a64
	usb: xhci-mtk: fix broken streams issue on 0.96 xHCI
	cdc-acm: fix BREAK rx code path adding necessary calls
	USB: cdc-acm: untangle a circular dependency between callback and softint
	USB: cdc-acm: downgrade message to debug
	USB: cdc-acm: fix double free on probe failure
	USB: cdc-acm: fix use-after-free after probe failure
	usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference
	usb: dwc2: Fix HPRT0.PrtSusp bit setting for HiKey 960 board.
	usb: dwc2: Prevent core suspend when port connection flag is 0
	usb: dwc3: qcom: skip interconnect init for ACPI probe
	usb: dwc3: gadget: Clear DEP flags after stop transfers in ep disable
	soc: qcom-geni-se: Cleanup the code to remove proxy votes
	staging: rtl8192e: Fix incorrect source in memcpy()
	staging: rtl8192e: Change state information from u16 to u8
	driver core: clear deferred probe reason on probe retry
	drivers: video: fbcon: fix NULL dereference in fbcon_cursor()
	riscv: evaluate put_user() arg before enabling user access
	Revert "kernel: freezer should treat PF_IO_WORKER like PF_KTHREAD for freezing"
	bpf: Use NOP_ATOMIC5 instead of emit_nops(&prog, 5) for BPF_TRAMP_F_CALL_ORIG
	Linux 5.10.28

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ifdbbeda8de3ee22a7aa3f5d3b10becf0aba1a124
2021-04-09 09:29:17 +02:00
Tong Zhang
77c0d6af85 usb: gadget: udc: amd5536udc_pci fix null-ptr-dereference
commit 72035f4954 upstream.

init_dma_pools() calls dma_pool_create(...dev->dev) to create dma pool.
however, dev->dev is actually set after calling init_dma_pools(), which
effectively makes dma_pool_create(..NULL) and cause crash.
To fix this issue, init dma only after dev->dev is set.

[    1.317993] RIP: 0010:dma_pool_create+0x83/0x290
[    1.323257] Call Trace:
[    1.323390]  ? pci_write_config_word+0x27/0x30
[    1.323626]  init_dma_pools+0x41/0x1a0 [snps_udc_core]
[    1.323899]  udc_pci_probe+0x202/0x2b1 [amd5536udc_pci]

Fixes: 7c51247a1f (usb: gadget: udc: Provide correct arguments for 'dma_pool_create')
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
Link: https://lore.kernel.org/r/20210317230400.357756-1-ztong0001@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-04-07 15:00:12 +02:00
Jim Lin
0f882bcc64 usb: gadget: configfs: Fix KASAN use-after-free
commit 98f153a10d upstream.

When gadget is disconnected, running sequence is like this.
. composite_disconnect
. Call trace:
  usb_string_copy+0xd0/0x128
  gadget_config_name_configuration_store+0x4
  gadget_config_name_attr_store+0x40/0x50
  configfs_write_file+0x198/0x1f4
  vfs_write+0x100/0x220
  SyS_write+0x58/0xa8
. configfs_composite_unbind
. configfs_composite_bind

In configfs_composite_bind, it has
"cn->strings.s = cn->configuration;"

When usb_string_copy is invoked. it would
allocate memory, copy input string, release previous pointed memory space,
and use new allocated memory.

When gadget is connected, host sends down request to get information.
Call trace:
  usb_gadget_get_string+0xec/0x168
  lookup_string+0x64/0x98
  composite_setup+0xa34/0x1ee8

If gadget is disconnected and connected quickly, in the failed case,
cn->configuration memory has been released by usb_string_copy kfree but
configfs_composite_bind hasn't been run in time to assign new allocated
"cn->configuration" pointer to "cn->strings.s".

When "strlen(s->s) of usb_gadget_get_string is being executed, the dangling
memory is accessed, "BUG: KASAN: use-after-free" error occurs.

Cc: stable@vger.kernel.org
Signed-off-by: Jim Lin <jilin@nvidia.com>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
Link: https://lore.kernel.org/r/1615444961-13376-1-git-send-email-macpaul.lin@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-25 09:04:14 +01:00
Greg Kroah-Hartman
e8f79d9cbb Merge branch 'android12-5.10' into branch 'android12-5.10-lts'
Sync up with the android12-5.10 branch for the following commit:

c4bd1c03ba ANDROID: qcom: Add is_dma_buf_file to ABI
268088c42e ANDROID: GKI: update .xml file
a7f3a36529 ANDROID: GKI: enable KFENCE by setting the sample interval to 500ms
9d1c78d623 ANDROID: abi_gki_aarch64_qcom: Add xhci symbols to list
5896d00f9c ANDROID: vmlinux.lds.h: Define SANITIZER_DISCARDS with CONFIG_CFI_CLANG
ffacd097fc ANDROID: usb: typec: tcpci: Add vendor hook to mask vbus present
1a93d556d7 ANDROID: usb: typce: tcpci: Add vendor hook for chip specific features
08879ea0d6 ANDROID: usb: typec: tcpci: Add vendor hooks for tcpci interface
892e618852 FROMGIT: f2fs: add sysfs nodes to get runtime compression stat
58f0e25d0d ANDROID: dma-buf: Fix error path on system heaps use of the page pool
958c19b19b ANDROID: usb: typec: tcpm: Fix event storm caused by error in backport
0b6fadd02e ANDROID: GKI: USB: XHCI: add Android ABI padding to lots of xhci structures
6f00446c76 FROMGIT: KVM: arm64: Fix host's ZCR_EL2 restore on nVHE
b0671cd753 FROMGIT: KVM: arm64: Force SCTLR_EL2.WXN when running nVHE
8f25c7432f FROMGIT: KVM: arm64: Turn SCTLR_ELx_FLAGS into INIT_SCTLR_EL2_MMU_ON
f47a4d91e5 FROMGIT: KVM: arm64: Use INIT_SCTLR_EL2_MMU_OFF to disable the MMU on KVM teardown
3ff7250562 FROMGIT: arm64: Use INIT_SCTLR_EL1_MMU_OFF to disable the MMU on CPU restart
a8a9fadaf8 FROMGIT: KVM: arm64: Enable SVE support for nVHE
b0e15c8c44 FROMGIT: KVM: arm64: Save/restore SVE state for nVHE
194fd166b5 BACKPORT: FROMGIT: KVM: arm64: Trap host SVE accesses when the FPSIMD state is dirty
507e10616c FROMGIT: KVM: arm64: Save guest's ZCR_EL1 before saving the FPSIMD state
4cb78b26ea FROMGIT: KVM: arm64: Map SVE context at EL2 when available
1105b4d1ce BACKPORT: FROMGIT: KVM: arm64: Rework SVE host-save/guest-restore
57171b3636 FROMGIT: arm64: sve: Provide a conditional update accessor for ZCR_ELx
ac5f5708bb FROMGIT: KVM: arm64: Introduce vcpu_sve_vq() helper
f9bab75599 FROMGIT: KVM: arm64: Let vcpu_sve_pffr() handle HYP VAs
c2469fa4b4 FROMGIT: KVM: arm64: Use {read,write}_sysreg_el1 to access ZCR_EL1
f5e060d65e FROMGIT: KVM: arm64: Provide KVM's own save/restore SVE primitives
af855ca1c9 ANDROID: GKI: USB: Gadget: add Android ABI padding to struct usb_gadget
24149445ad ANDROID: vendor_hooks: Add hooks for memory when debug
00185a421a ANDROID: vendor_hooks: Add hooks for ufs scheduler
b8981993c2 ANDROID: GKI: sound/usb/card.h: add Android ABI padding to struct snd_usb_endpoint
5a56f5119e ANDROID: GKI: user_namespace.h: add Android ABI padding to a structure
599e75fcfd ANDROID: GKI: timer.h: add Android ABI padding to a structure
303a28f485 ANDROID: GKI: quota.h: add Android ABI padding to some structures
a06d91262a ANDROID: GKI: mmu_notifier.h: add Android ABI padding to some structures
8faaa07702 ANDROID: GKI: mm.h: add Android ABI padding to a structure
f21777c57f ANDROID: GKI: kobject.h: add Android ABI padding to some structures
31f6b7a1ae ANDROID: GKI: kernfs.h: add Android ABI padding to some structures
1a517d8668 ANDROID: GKI: irqdomain.h: add Android ABI padding to a structure
c6adf0c7b9 ANDROID: GKI: ioport.h: add Android ABI padding to a structure
c469de24a1 ANDROID: GKI: iomap.h: add Android ABI padding to a structure
3cb5c28964 ANDROID: GKI: hrtimer.h: add Android ABI padding to a structure
eff6517b1e ANDROID: GKI: genhd.h: add Android ABI padding to some structures
9a92773dc8 ANDROID: GKI: ethtool.h: add Android ABI padding to a structure
774168de67 ANDROID: GKI: dma-mapping.h: add Android ABI padding to a structure
73ff58b01f ANDROID: GKI: networking: add Android ABI padding to a lot of networking structures
f0688df6b5 ANDROID: GKI: blk_types.h: add Android ABI padding to a structure
4a895f1f2b ANDROID: GKI: scsi.h: add Android ABI padding to a structure
48691266ca ANDROID: GKI: pci: add Android ABI padding to some structures
4c95a92b84 ANDROID: GKI: add Android ABI padding to struct nf_conn
e6f5502bc3 UPSTREAM: usb: typec: tcpm: Skip sink_cap query only when VDM sm is busy
36547f2f6d FROMGIT: usb: typec: tcpm: PD3.0 sinks can send Discover Identity even in device mode
3f7ada406d UPSTREAM: usb: gadget: configfs: Fix KASAN use-after-free
9bd96584f4 UPSTREAM: usb: typec: Remove vdo[3] part of tps6598x_rx_identity_reg struct
f2e7bdcdfa UPSTREAM: usb: dwc3: gadget: Prevent EP queuing while stopping transfers
462c92e8f2 FROMGIT: usb: typec: tcpci: Added few missing TCPCI register definitions
6f85b7e0f8 UPSTREAM: usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-
8cf94785bb Revert "ANDROID: GKI: Enable bounds sanitizer"
0eecc2aa30 ANDROID: GKI: temporarily disable LTO/CFI
3520187422 ANDROID: Revert "f2fs: fix to tag FIEMAP_EXTENT_MERGED in f2fs_fiemap()"
16982b6a18 FROMLIST: KVM: arm64: Disable FWB in host stage-2
3a16a9e7be FROMLIST: KVM: arm64: Introduce KVM_PGTABLE_S2_NOFWB Stage-2 flag
bcdcab0253 FROMLIST: KVM: arm64: Protect the .hyp sections from the host
317d5a5030 FROMLIST: KVM: arm64: Disable PMU support in protected mode
6697310c08 FROMLIST: KVM: arm64: Page-align the .hyp sections
68bd98a28a FROMLIST: KVM: arm64: Wrap the host with a stage 2
5a128f0626 FROMLIST: KVM: arm64: Provide sanitized mmfr* registers at EL2
0af83133e3 FROMLIST: KVM: arm64: Add kvm_pgtable_stage2_find_range()
c3f49047ca FROMLIST: KVM: arm64: Refactor the *_map_set_prot_attr() helpers
9349978462 FROMLIST: KVM: arm64: Use page-table to track page ownership
845457f549 FROMLIST: KVM: arm64: Always zero invalid PTEs
1d349d64ba FROMLIST: KVM: arm64: Sort the hypervisor memblocks
1e798d4121 FROMLIST: KVM: arm64: Reserve memory for host stage 2
6fddc52e50 FROMLIST: KVM: arm64: Make memcache anonymous in pgtable allocator
a20c8e1c48 FROMLIST: KVM: arm64: Refactor __populate_fault_info()
21a1f89953 FROMLIST: KVM: arm64: Refactor __load_guest_stage2()
1a9bba9121 FROMLIST: KVM: arm64: Refactor kvm_arm_setup_stage2()
6d3f5c07aa FROMLIST: KVM: arm64: Set host stage 2 using kvm_nvhe_init_params
eef107d42a FROMLIST: KVM: arm64: Use kvm_arch in kvm_s2_mmu
1a76f891e1 FROMLIST: KVM: arm64: Use kvm_arch for stage 2 pgtable
d8eb170aa9 FROMLIST: KVM: arm64: Elevate hypervisor mappings creation at EL2
ae1ed8a984 FROMLIST: KVM: arm64: Prepare the creation of s1 mappings at EL2
364f0639db FROMLIST: arm64: asm: Provide set_sctlr_el2 macro
ca52b29511 FROMLIST: KVM: arm64: Factor out vector address calculation
a1180dd384 FROMLIST: KVM: arm64: Provide __flush_dcache_area at EL2
37b5552dfb FROMLIST: KVM: arm64: Enable access to sanitized CPU features at EL2
75fba96057 FROMLIST: KVM: arm64: Introduce a Hyp buddy page allocator
f6e834486a FROMLIST: KVM: arm64: Stub CONFIG_DEBUG_LIST at Hyp
01253f8e2c FROMLIST: KVM: arm64: Introduce an early Hyp page allocator
a3aad4cf4a FROMLIST: KVM: arm64: Allow using kvm_nvhe_sym() in hyp code
81181250ba FROMLIST: KVM: arm64: Make kvm_call_hyp() a function call at Hyp
542dace0bc FROMLIST: KVM: arm64: Introduce a BSS section for use at Hyp
4a4beb1005 FROMLIST: KVM: arm64: Factor memory allocation out of pgtable.c
620bb5f9c9 FROMLIST: KVM: arm64: Avoid free_page() in page-table allocator
c758e8e4b1 FROMLIST: KVM: arm64: Initialize kvm_nvhe_init_params early
ce5e848201 FROMLIST: arm64: kvm: Add standalone ticket spinlock implementation for use at hyp
9833905e2d FROMLIST: KVM: arm64: Link position-independent string routines into .hyp.text
0f63237470 FROMLIST: arm64: lib: Annotate {clear, copy}_page() as position-independent
edab6a7245 Revert "ANDROID: sched: cpufreq_schedutil: add sugov tracepoints"
187306ab1a ANDROID: Partial revert of 06881e01b5 ("ANDROID: sched: Add vendor hooks for override sugov behavior")
b542f4c389 Revert "ANDROID: sched: Add vendor hooks for skipping sugov update"
27d6dac0df Revert "ANDROID: sched: cpufreq_schedutil: move sugov traces to sched"
cc574f0d36 ANDROID: thermal: Add logic for filter on-die tz genl event.
6c6fac8f39 ANDROID: mmc: support hardware that takes key directly
e4636b47ef UPSTREAM: zram: fix broken page writeback
542d1937ba UPSTREAM: zram: fix return value on writeback_store
475aea007d ANDROID: sched: Add vendor hook for util_est_update
89ea2f1eca ANDROID: GKI: Enable DTPM framework
a3a580961b ANDROID: GKI: Add remoteproc framework symbols to symbol list
53e8099784 ANDROID: vendor_hooks: Add hooks for scheduler
7e2c33ac0e FROMGIT: configfs: fix a use-after-free in __configfs_open_file
7656aa0f48 ANDROID: lib/plist.c: Export plist-related APIs
4d63efb9ae ANDROID: module: Add vendor hook
2ff446fc4d ANDROID: bpf: Add vendor hook
dccee128b7 ANDROID: kernel: Add vendor hook in creds
0a3b407463 ANDROID: security: selinux: Add vendor hook in avc
a128ec2b2e UPSTREAM: KVM: arm64: Fix exclusive limit for IPA size
ac821b6257 UPSTREAM: KVM: arm64: Reject VM creation when the default IPA size is unsupported
d2eb8b0028 ANDROID: GKI: add android_kabi.h
45021f7679 UPSTREAM: MAINTAINERS: add entry for KFENCE
90d03f6fcf ANDROID: Clang LTO: Comment on symbol visibility workaround
169ddec367 FROMLIST: mm: fs: Invalidate BH LRU during page migration
3039d8580c BACKPORT: FROMLIST: mm: disable LRU pagevec during the migration temporarily
134ac2d4dc FROMLIST: mm: replace migrate_prep with lru_add_drain_all
a71a3e1ce6 UPSTREAM: mm: migrate: initialize err in do_migrate_pages
059eaf82c0 UPSTREAM: mm: migrate: clean up migrate_prep{_local}
be409db652 ANDROID: Clang LTO: Only set -fvisibility=hidden for x86
02efd18b77 UPSTREAM: usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro
8d03e49505 ANDROID: mm: build alloc_contig_dump_pages in page_alloc.o
28f6641041 FROMLIST: mm: page_alloc: dump migrate-failed pages
cc1f93cb20 ANDROID: sched: Add vendor hook for uclamp_eff_get
5e1e3e9387 ANDROID: cpu/hotplug: failure to offline 2nd to last cpu
2c728929c1 ANDROID: qcom: Add devm_blk_ksm_init to ABI
9108e9ba66 ANDROID: arm64: add vendor hooks for unusal abort cases
5f1e1f42a5 UPSTREAM: powercap/drivers/dtpm: Fix size of object being allocated
fd2c659694 UPSTREAM: powercap/drivers/dtpm: Fix an IS_ERR() vs NULL check
2a1cd71862 UPSTREAM: powercap/drivers/dtpm: Fix some missing unlock bugs
7112d4320f UPSTREAM: powercap/drivers/dtpm: Fix a double shift bug
578572c48c UPSTREAM: powercap/drivers/dtpm: Fix __udivdi3 and __aeabi_uldivmod unresolved symbols
7f17016dc8 UPSTREAM: powercap/drivers/dtpm: Add CPU energy model based support
082e8dcea9 UPSTREAM: powercap/drivers/dtpm: Add API for dynamic thermal power management

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: If05a0d9902893cd29e8bb5eb175bd4ce30250697
2021-03-21 15:02:08 +01:00
Greg Kroah-Hartman
3ccfc59f82 Merge 5.10.24 into android12-5.10-lts
Changes in 5.10.24
	uapi: nfnetlink_cthelper.h: fix userspace compilation error
	powerpc/perf: Fix handling of privilege level checks in perf interrupt context
	powerpc/pseries: Don't enforce MSI affinity with kdump
	ethernet: alx: fix order of calls on resume
	crypto: mips/poly1305 - enable for all MIPS processors
	ath9k: fix transmitting to stations in dynamic SMPS mode
	net: Fix gro aggregation for udp encaps with zero csum
	net: check if protocol extracted by virtio_net_hdr_set_proto is correct
	net: avoid infinite loop in mpls_gso_segment when mpls_hlen == 0
	net: l2tp: reduce log level of messages in receive path, add counter instead
	can: skb: can_skb_set_owner(): fix ref counting if socket was closed before setting skb ownership
	can: flexcan: assert FRZ bit in flexcan_chip_freeze()
	can: flexcan: enable RX FIFO after FRZ/HALT valid
	can: flexcan: invoke flexcan_chip_freeze() to enter freeze mode
	can: tcan4x5x: tcan4x5x_init(): fix initialization - clear MRAM before entering Normal Mode
	tcp: Fix sign comparison bug in getsockopt(TCP_ZEROCOPY_RECEIVE)
	tcp: add sanity tests to TCP_QUEUE_SEQ
	netfilter: nf_nat: undo erroneous tcp edemux lookup
	netfilter: x_tables: gpf inside xt_find_revision()
	net: always use icmp{,v6}_ndo_send from ndo_start_xmit
	net: phy: fix save wrong speed and duplex problem if autoneg is on
	selftests/bpf: Use the last page in test_snprintf_btf on s390
	selftests/bpf: No need to drop the packet when there is no geneve opt
	selftests/bpf: Mask bpf_csum_diff() return value to 16 bits in test_verifier
	samples, bpf: Add missing munmap in xdpsock
	libbpf: Clear map_info before each bpf_obj_get_info_by_fd
	ibmvnic: Fix possibly uninitialized old_num_tx_queues variable warning.
	ibmvnic: always store valid MAC address
	mt76: dma: do not report truncated frames to mac80211
	powerpc/603: Fix protection of user pages mapped with PROT_NONE
	mount: fix mounting of detached mounts onto targets that reside on shared mounts
	cifs: return proper error code in statfs(2)
	Revert "mm, slub: consider rest of partial list if acquire_slab() fails"
	docs: networking: drop special stable handling
	net: dsa: tag_rtl4_a: fix egress tags
	sh_eth: fix TRSCER mask for SH771x
	net: enetc: don't overwrite the RSS indirection table when initializing
	net: enetc: take the MDIO lock only once per NAPI poll cycle
	net: enetc: fix incorrect TPID when receiving 802.1ad tagged packets
	net: enetc: don't disable VLAN filtering in IFF_PROMISC mode
	net: enetc: force the RGMII speed and duplex instead of operating in inband mode
	net: enetc: remove bogus write to SIRXIDR from enetc_setup_rxbdr
	net: enetc: keep RX ring consumer index in sync with hardware
	net: ethernet: mtk-star-emac: fix wrong unmap in RX handling
	net/mlx4_en: update moderation when config reset
	net: stmmac: fix incorrect DMA channel intr enable setting of EQoS v4.10
	nexthop: Do not flush blackhole nexthops when loopback goes down
	net: sched: avoid duplicates in classes dump
	net: mscc: ocelot: properly reject destination IP keys in VCAP IS1
	net: dsa: sja1105: fix SGMII PCS being forced to SPEED_UNKNOWN instead of SPEED_10
	net: usb: qmi_wwan: allow qmimux add/del with master up
	netdevsim: init u64 stats for 32bit hardware
	cipso,calipso: resolve a number of problems with the DOI refcounts
	net: stmmac: Fix VLAN filter delete timeout issue in Intel mGBE SGMII
	stmmac: intel: Fixes clock registration error seen for multiple interfaces
	net: lapbether: Remove netif_start_queue / netif_stop_queue
	net: davicom: Fix regulator not turned off on failed probe
	net: davicom: Fix regulator not turned off on driver removal
	net: enetc: allow hardware timestamping on TX queues with tc-etf enabled
	net: qrtr: fix error return code of qrtr_sendmsg()
	s390/qeth: fix memory leak after failed TX Buffer allocation
	r8169: fix r8168fp_adjust_ocp_cmd function
	ixgbe: fail to create xfrm offload of IPsec tunnel mode SA
	tools/resolve_btfids: Fix build error with older host toolchains
	perf build: Fix ccache usage in $(CC) when generating arch errno table
	net: stmmac: stop each tx channel independently
	net: stmmac: fix watchdog timeout during suspend/resume stress test
	net: stmmac: fix wrongly set buffer2 valid when sph unsupport
	ethtool: fix the check logic of at least one channel for RX/TX
	net: phy: make mdio_bus_phy_suspend/resume as __maybe_unused
	selftests: forwarding: Fix race condition in mirror installation
	mlxsw: spectrum_ethtool: Add an external speed to PTYS register
	perf traceevent: Ensure read cmdlines are null terminated.
	perf report: Fix -F for branch & mem modes
	net: hns3: fix query vlan mask value error for flow director
	net: hns3: fix bug when calculating the TCAM table info
	s390/cio: return -EFAULT if copy_to_user() fails again
	bnxt_en: reliably allocate IRQ table on reset to avoid crash
	gpiolib: acpi: Add ACPI_GPIO_QUIRK_ABSOLUTE_NUMBER quirk
	gpiolib: acpi: Allow to find GpioInt() resource by name and index
	gpio: pca953x: Set IRQ type when handle Intel Galileo Gen 2
	gpio: fix gpio-device list corruption
	drm/compat: Clear bounce structures
	drm/amd/display: Add a backlight module option
	drm/amdgpu/display: use GFP_ATOMIC in dcn21_validate_bandwidth_fp()
	drm/amd/display: Fix nested FPU context in dcn21_validate_bandwidth()
	drm/amd/pm: bug fix for pcie dpm
	drm/amdgpu/display: simplify backlight setting
	drm/amdgpu/display: don't assert in set backlight function
	drm/amdgpu/display: handle aux backlight in backlight_get_brightness
	drm/shmem-helper: Check for purged buffers in fault handler
	drm/shmem-helper: Don't remove the offset in vm_area_struct pgoff
	drm: Use USB controller's DMA mask when importing dmabufs
	drm: meson_drv add shutdown function
	drm/shmem-helpers: vunmap: Don't put pages for dma-buf
	drm/i915: Wedge the GPU if command parser setup fails
	s390/cio: return -EFAULT if copy_to_user() fails
	s390/crypto: return -EFAULT if copy_to_user() fails
	qxl: Fix uninitialised struct field head.surface_id
	sh_eth: fix TRSCER mask for R7S9210
	media: usbtv: Fix deadlock on suspend
	media: rkisp1: params: fix wrong bits settings
	media: v4l: vsp1: Fix uif null pointer access
	media: v4l: vsp1: Fix bru null pointer access
	media: rc: compile rc-cec.c into rc-core
	cifs: fix credit accounting for extra channel
	net: hns3: fix error mask definition of flow director
	s390/qeth: don't replace a fully completed async TX buffer
	s390/qeth: remove QETH_QDIO_BUF_HANDLED_DELAYED state
	s390/qeth: improve completion of pending TX buffers
	s390/qeth: fix notification for pending buffers during teardown
	net: dsa: implement a central TX reallocation procedure
	net: dsa: tag_ksz: don't allocate additional memory for padding/tagging
	net: dsa: trailer: don't allocate additional memory for padding/tagging
	net: dsa: tag_qca: let DSA core deal with TX reallocation
	net: dsa: tag_ocelot: let DSA core deal with TX reallocation
	net: dsa: tag_mtk: let DSA core deal with TX reallocation
	net: dsa: tag_lan9303: let DSA core deal with TX reallocation
	net: dsa: tag_edsa: let DSA core deal with TX reallocation
	net: dsa: tag_brcm: let DSA core deal with TX reallocation
	net: dsa: tag_dsa: let DSA core deal with TX reallocation
	net: dsa: tag_gswip: let DSA core deal with TX reallocation
	net: dsa: tag_ar9331: let DSA core deal with TX reallocation
	net: dsa: tag_mtk: fix 802.1ad VLAN egress
	enetc: Fix unused var build warning for CONFIG_OF
	net: enetc: initialize RFS/RSS memories for unused ports too
	ath11k: peer delete synchronization with firmware
	ath11k: start vdev if a bss peer is already created
	ath11k: fix AP mode for QCA6390
	i2c: rcar: faster irq code to minimize HW race condition
	i2c: rcar: optimize cacheline to minimize HW race condition
	scsi: ufs: WB is only available on LUN #0 to #7
	udf: fix silent AED tagLocation corruption
	iommu/vt-d: Clear PRQ overflow only when PRQ is empty
	mmc: mxs-mmc: Fix a resource leak in an error handling path in 'mxs_mmc_probe()'
	mmc: mediatek: fix race condition between msdc_request_timeout and irq
	mmc: sdhci-iproc: Add ACPI bindings for the RPi
	Platform: OLPC: Fix probe error handling
	powerpc/pci: Add ppc_md.discover_phbs()
	spi: stm32: make spurious and overrun interrupts visible
	powerpc: improve handling of unrecoverable system reset
	powerpc/perf: Record counter overflow always if SAMPLE_IP is unset
	HID: logitech-dj: add support for the new lightspeed connection iteration
	powerpc/64: Fix stack trace not displaying final frame
	iommu/amd: Fix performance counter initialization
	clk: qcom: gdsc: Implement NO_RET_PERIPH flag
	sparc32: Limit memblock allocation to low memory
	sparc64: Use arch_validate_flags() to validate ADI flag
	Input: applespi - don't wait for responses to commands indefinitely.
	PCI: xgene-msi: Fix race in installing chained irq handler
	PCI: mediatek: Add missing of_node_put() to fix reference leak
	drivers/base: build kunit tests without structleak plugin
	PCI/LINK: Remove bandwidth notification
	ext4: don't try to processed freed blocks until mballoc is initialized
	kbuild: clamp SUBLEVEL to 255
	PCI: Fix pci_register_io_range() memory leak
	i40e: Fix memory leak in i40e_probe
	kasan: fix memory corruption in kasan_bitops_tags test
	s390/smp: __smp_rescan_cpus() - move cpumask away from stack
	drivers/base/memory: don't store phys_device in memory blocks
	sysctl.c: fix underflow value setting risk in vm_table
	scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling
	scsi: target: core: Add cmd length set before cmd complete
	scsi: target: core: Prevent underflow for service actions
	clk: qcom: gpucc-msm8998: Add resets, cxc, fix flags on gpu_gx_gdsc
	mmc: sdhci: Update firmware interface API
	ARM: 9029/1: Make iwmmxt.S support Clang's integrated assembler
	ARM: assembler: introduce adr_l, ldr_l and str_l macros
	ARM: efistub: replace adrl pseudo-op with adr_l macro invocation
	ALSA: usb: Add Plantronics C320-M USB ctrl msg delay quirk
	ALSA: hda/hdmi: Cancel pending works before suspend
	ALSA: hda/conexant: Add quirk for mute LED control on HP ZBook G5
	ALSA: hda/ca0132: Add Sound BlasterX AE-5 Plus support
	ALSA: hda: Drop the BATCH workaround for AMD controllers
	ALSA: hda: Flush pending unsolicited events before suspend
	ALSA: hda: Avoid spurious unsol event handling during S3/S4
	ALSA: usb-audio: Fix "cannot get freq eq" errors on Dell AE515 sound bar
	ALSA: usb-audio: Apply the control quirk to Plantronics headsets
	ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()
	ALSA: usb-audio: fix NULL ptr dereference in usb_audio_probe
	ALSA: usb-audio: fix use after free in usb_audio_disconnect
	Revert 95ebabde38 ("capabilities: Don't allow writing ambiguous v3 file capabilities")
	block: Discard page cache of zone reset target range
	block: Try to handle busy underlying device on discard
	arm64: kasan: fix page_alloc tagging with DEBUG_VIRTUAL
	arm64: mte: Map hotplugged memory as Normal Tagged
	arm64: perf: Fix 64-bit event counter read truncation
	s390/dasd: fix hanging DASD driver unbind
	s390/dasd: fix hanging IO request during DASD driver unbind
	software node: Fix node registration
	xen/events: reset affinity of 2-level event when tearing it down
	mmc: mmci: Add MMC_CAP_NEED_RSP_BUSY for the stm32 variants
	mmc: core: Fix partition switch time for eMMC
	mmc: cqhci: Fix random crash when remove mmc module/card
	cifs: do not send close in compound create+close requests
	Goodix Fingerprint device is not a modem
	USB: gadget: udc: s3c2410_udc: fix return value check in s3c2410_udc_probe()
	USB: gadget: u_ether: Fix a configfs return code
	usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot
	usb: gadget: f_uac1: stop playback on function disable
	usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement
	usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot
	usb: dwc3: qcom: add ACPI device id for sc8180x
	usb: dwc3: qcom: Honor wakeup enabled/disabled state
	USB: usblp: fix a hang in poll() if disconnected
	usb: renesas_usbhs: Clear PIPECFG for re-enabling pipe with other EPNUM
	usb: xhci: do not perform Soft Retry for some xHCI hosts
	xhci: Improve detection of device initiated wake signal.
	usb: xhci: Fix ASMedia ASM1042A and ASM3242 DMA addressing
	xhci: Fix repeated xhci wake after suspend due to uncleared internal wake state
	USB: serial: io_edgeport: fix memory leak in edge_startup
	USB: serial: ch341: add new Product ID
	USB: serial: cp210x: add ID for Acuity Brands nLight Air Adapter
	USB: serial: cp210x: add some more GE USB IDs
	usbip: fix stub_dev to check for stream socket
	usbip: fix vhci_hcd to check for stream socket
	usbip: fix vudc to check for stream socket
	usbip: fix stub_dev usbip_sockfd_store() races leading to gpf
	usbip: fix vhci_hcd attach_store() races leading to gpf
	usbip: fix vudc usbip_sockfd_store races leading to gpf
	Revert "serial: max310x: rework RX interrupt handling"
	misc/pvpanic: Export module FDT device table
	misc: fastrpc: restrict user apps from sending kernel RPC messages
	staging: rtl8192u: fix ->ssid overflow in r8192_wx_set_scan()
	staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan()
	staging: rtl8712: unterminated string leads to read overflow
	staging: rtl8188eu: fix potential memory corruption in rtw_check_beacon_data()
	staging: ks7010: prevent buffer overflow in ks_wlan_set_scan()
	staging: rtl8712: Fix possible buffer overflow in r8712_sitesurvey_cmd
	staging: rtl8192e: Fix possible buffer overflow in _rtl92e_wx_set_scan
	staging: comedi: addi_apci_1032: Fix endian problem for COS sample
	staging: comedi: addi_apci_1500: Fix endian problem for command sample
	staging: comedi: adv_pci1710: Fix endian problem for AI command data
	staging: comedi: das6402: Fix endian problem for AI command data
	staging: comedi: das800: Fix endian problem for AI command data
	staging: comedi: dmm32at: Fix endian problem for AI command data
	staging: comedi: me4000: Fix endian problem for AI command data
	staging: comedi: pcl711: Fix endian problem for AI command data
	staging: comedi: pcl818: Fix endian problem for AI command data
	sh_eth: fix TRSCER mask for R7S72100
	cpufreq: qcom-hw: fix dereferencing freed memory 'data'
	cpufreq: qcom-hw: Fix return value check in qcom_cpufreq_hw_cpu_init()
	arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory
	SUNRPC: Set memalloc_nofs_save() for sync tasks
	NFS: Don't revalidate the directory permissions on a lookup failure
	NFS: Don't gratuitously clear the inode cache when lookup failed
	NFSv4.2: fix return value of _nfs4_get_security_label()
	block: rsxx: fix error return code of rsxx_pci_probe()
	nvme-fc: fix racing controller reset and create association
	configfs: fix a use-after-free in __configfs_open_file
	arm64: mm: use a 48-bit ID map when possible on 52-bit VA builds
	perf/core: Flush PMU internal buffers for per-CPU events
	perf/x86/intel: Set PERF_ATTACH_SCHED_CB for large PEBS and LBR
	hrtimer: Update softirq_expires_next correctly after __hrtimer_get_next_event()
	powerpc/64s/exception: Clean up a missed SRR specifier
	seqlock,lockdep: Fix seqcount_latch_init()
	stop_machine: mark helpers __always_inline
	include/linux/sched/mm.h: use rcu_dereference in in_vfork()
	zram: fix return value on writeback_store
	linux/compiler-clang.h: define HAVE_BUILTIN_BSWAP*
	sched/membarrier: fix missing local execution of ipi_sync_rq_state()
	efi: stub: omit SetVirtualAddressMap() if marked unsupported in RT_PROP table
	powerpc/64s: Fix instruction encoding for lis in ppc_function_entry()
	powerpc: Fix inverted SET_FULL_REGS bitop
	powerpc: Fix missing declaration of [en/dis]able_kernel_vsx()
	binfmt_misc: fix possible deadlock in bm_register_write
	x86/unwind/orc: Disable KASAN checking in the ORC unwinder, part 2
	x86/sev-es: Introduce ip_within_syscall_gap() helper
	x86/sev-es: Check regs->sp is trusted before adjusting #VC IST stack
	x86/entry: Move nmi entry/exit into common code
	x86/sev-es: Correctly track IRQ states in runtime #VC handler
	x86/sev-es: Use __copy_from_user_inatomic()
	x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls
	KVM: x86: Ensure deadline timer has truly expired before posting its IRQ
	KVM: kvmclock: Fix vCPUs > 64 can't be online/hotpluged
	KVM: arm64: Fix range alignment when walking page tables
	KVM: arm64: Avoid corrupting vCPU context register in guest exit
	KVM: arm64: nvhe: Save the SPE context early
	KVM: arm64: Reject VM creation when the default IPA size is unsupported
	KVM: arm64: Fix exclusive limit for IPA size
	mm/userfaultfd: fix memory corruption due to writeprotect
	mm/madvise: replace ptrace attach requirement for process_madvise
	KVM: arm64: Ensure I-cache isolation between vcpus of a same VM
	mm/page_alloc.c: refactor initialization of struct page for holes in memory layout
	xen/events: don't unmask an event channel when an eoi is pending
	xen/events: avoid handling the same event on two cpus at the same time
	KVM: arm64: Fix nVHE hyp panic host context restore
	RDMA/umem: Use ib_dma_max_seg_size instead of dma_get_max_seg_size
	Linux 5.10.24

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ie53a3c1963066a18d41357b6be41cff00690bd40
2021-03-19 09:42:56 +01:00
Jim Lin
3f7ada406d UPSTREAM: usb: gadget: configfs: Fix KASAN use-after-free
When gadget is disconnected, running sequence is like this.
. composite_disconnect
. Call trace:
  usb_string_copy+0xd0/0x128
  gadget_config_name_configuration_store+0x4
  gadget_config_name_attr_store+0x40/0x50
  configfs_write_file+0x198/0x1f4
  vfs_write+0x100/0x220
  SyS_write+0x58/0xa8
. configfs_composite_unbind
. configfs_composite_bind

In configfs_composite_bind, it has
"cn->strings.s = cn->configuration;"

When usb_string_copy is invoked. it would
allocate memory, copy input string, release previous pointed memory space,
and use new allocated memory.

When gadget is connected, host sends down request to get information.
Call trace:
  usb_gadget_get_string+0xec/0x168
  lookup_string+0x64/0x98
  composite_setup+0xa34/0x1ee8

If gadget is disconnected and connected quickly, in the failed case,
cn->configuration memory has been released by usb_string_copy kfree but
configfs_composite_bind hasn't been run in time to assign new allocated
"cn->configuration" pointer to "cn->strings.s".

When "strlen(s->s) of usb_gadget_get_string is being executed, the dangling
memory is accessed, "BUG: KASAN: use-after-free" error occurs.

Cc: stable@vger.kernel.org
Signed-off-by: Jim Lin <jilin@nvidia.com>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
Link: https://lore.kernel.org/r/1615444961-13376-1-git-send-email-macpaul.lin@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 98f153a10d)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I701efe7bf8b20ab35c84e0441a52633d223224e9
2021-03-18 06:49:05 +00:00
Ruslan Bilovol
32ad0eb74e usb: gadget: f_uac1: stop playback on function disable
commit cc2ac63d4c upstream.

There is missing playback stop/cleanup in case of
gadget's ->disable callback that happens on
events like USB host resetting or gadget disconnection

Fixes: 0591bc2360 ("usb: gadget: add f_uac1 variant based on a new u_audio api")
Cc: <stable@vger.kernel.org> # 4.13+
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Link: https://lore.kernel.org/r/1614599375-8803-3-git-send-email-ruslan.bilovol@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-17 17:06:29 +01:00
Ruslan Bilovol
30a187afdb usb: gadget: f_uac2: always increase endpoint max_packet_size by one audio slot
commit 789ea77310 upstream.

As per UAC2 Audio Data Formats spec (2.3.1.1 USB Packets),
if the sampling rate is a constant, the allowable variation
of number of audio slots per virtual frame is +/- 1 audio slot.

It means that endpoint should be able to accept/send +1 audio
slot.

Previous endpoint max_packet_size calculation code
was adding sometimes +1 audio slot due to DIV_ROUND_UP
behaviour which was rounding up to closest integer.
However this doesn't work if the numbers are divisible.

It had no any impact with Linux hosts which ignore
this issue, but in case of more strict Windows it
caused rejected enumeration

Thus always add +1 audio slot to endpoint's max packet size

Fixes: 913e4a90b6 ("usb: gadget: f_uac2: finalize wMaxPacketSize according to bandwidth")
Cc: Peter Chen <peter.chen@freescale.com>
Cc: <stable@vger.kernel.org> #v4.3+
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Link: https://lore.kernel.org/r/1614599375-8803-2-git-send-email-ruslan.bilovol@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-17 17:06:29 +01:00
Dan Carpenter
50233f8220 USB: gadget: u_ether: Fix a configfs return code
commit 650bf52208 upstream.

If the string is invalid, this should return -EINVAL instead of 0.

Fixes: 73517cf49b ("usb: gadget: add RNDIS configfs options for class/subclass/protocol")
Cc: stable <stable@vger.kernel.org>
Acked-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YCqZ3P53yyIg5cn7@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-17 17:06:29 +01:00
Wei Yongjun
80091541a4 USB: gadget: udc: s3c2410_udc: fix return value check in s3c2410_udc_probe()
commit 414c20df7d upstream.

In case of error, the function devm_platform_ioremap_resource()
returns ERR_PTR() and never returns NULL. The NULL test in the
return value check should be replaced with IS_ERR().

Fixes: 188db4435a ("usb: gadget: s3c: use platform resources")
Cc: stable <stable@vger.kernel.org>
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20210305034927.3232386-1-weiyongjun1@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-03-17 17:06:29 +01:00
Tao Huang
bc69b758ef Merge remote branch 'android12-5.10' of https://android.googlesource.com/kernel/common
* android12-5.10: (176331 commits)
  ANDROID: GKI: Enable bounds sanitizer
  ANDROID: Allow HAS_LTO_CLANG with KASAN_HW_TAGS
  ANDROID: abi_gki_aarch64_qcom: Add cpufreq related symbols
  ANDROID: cpufreq: Add a restricted vendor hook for freq transition
  ANDROID: scsi: ufs: add hooks to track ufs commands
  ANDROID: Fix compilation error when CPU_FREQ is disabled
  BACKPORT: kasan, arm64: allow using KUnit tests with HW_TAGS mode
  Revert "FROMGIT: kasan, arm64: allow using KUnit tests with HW_TAGS mode"
  Revert "BACKPORT: kasan: remove redundant config option"
  UPSTREAM: arm/kasan: fix the array size of kasan_early_shadow_pte[]
  FROMGIT: KVM: arm64: Workaround firmware wrongly advertising GICv2-on-v3 compatibility
  FROMGIT: KVM: arm64: Rename __vgic_v3_get_ich_vtr_el2() to __vgic_v3_get_gic_config()
  FROMGIT: KVM: arm64: Don't access PMSELR_EL0/PMUSERENR_EL0 when no PMU is available
  FROMGIT: KVM: arm64: Turn kvm_arm_support_pmu_v3() into a static key
  FROMGIT: KVM: arm64: Fix nVHE hyp panic host context restore
  FROMGIT: KVM: arm64: Avoid corrupting vCPU context register in guest exit
  FROMLIST: arm64: cpufeatures: Fix handling of CONFIG_CMDLINE for idreg overrides
  ANDROID: sched: Add vendor hook for uclamp_eff_value
  ANDROID: abi_gki_aarch64_qcom: Add CFS scheduler symbols
  ANDROID: GKI: Add mempool APIs to the symbol list
  ...

Change-Id: I4ed13984b97bc531d1dae61920457f31b84190e9

Conflicts:
	Documentation/devicetree/bindings/nvmem/rockchip-otp.txt
	arch/arm64/boot/dts/rockchip/px30.dtsi
	arch/arm64/boot/dts/rockchip/rk3308.dtsi
	arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dts
	drivers/clk/rockchip/Kconfig
	drivers/clk/rockchip/clk-rk3308.c
	drivers/gpu/drm/rockchip/rk3066_hdmi.c
	drivers/gpu/drm/rockchip/rockchip_rgb.c
	drivers/media/i2c/imx219.c
	drivers/nvmem/rockchip-otp.c
	drivers/power/supply/cw2015_battery.c
	sound/soc/codecs/cx2072x.c
	sound/soc/codecs/cx2072x.h
	sound/soc/codecs/rk3328_codec.c
2021-03-17 18:07:51 +08:00
Tao Huang
251c226c35 rk: revert to v4.19
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
Change-Id: I502dce68b639df4ebf5a1688e0dc2e5c5763ebc2
2021-03-17 18:05:39 +08:00
Ren Jianing
0b82f4909b usb: gadget: u_audio: disable eps when usb disconnect
UAC gadget disable eps only when receiving set_alt_0. If USB is
unplugged before the packet of set_alt_0, the corresponding eps
will not be released and leading to UAC dysfunction when the next
time the usb is plugged.

Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Change-Id: I476ef8ce64a5b04cc3fec32a28126e2eb9d5ad78
2021-03-12 18:45:50 +08:00
William Wu
69e3769569 usb: gadget: f_uvc: trace uvc control request
This patch add new uvc trace for setup request processing.

1. enable trace
   echo 4 > /sys/module/usb_f_uvc/parameters/trace

2. dump trace
   dmesg

Test on RV1109 EVB with UVC function when streaming on:

[  426.441316] uvcvideo: setup request a1 81 value 0100 index 0003 001a
[  426.450280] uvcvideo: uvc_send_response: req len 26
[  426.450444] uvcvideo: event_setup_out 0, data len 26
[  426.451545] uvcvideo: setup request 21 01 value 0100 index 0003 001a
[  426.460862] uvcvideo: uvc_send_response: req len 26
[  426.461014] uvcvideo: event_setup_out 1, data len 26
[  426.461173] uvcvideo: setup request a1 81 value 0100 index 0003 001a
[  426.485791] uvcvideo: uvc_send_response: req len 26
[  426.486672] uvcvideo: event_setup_out 0, data len 26
[  426.487145] uvcvideo: setup request a1 83 value 0100 index 0003 001a
[  426.496529] uvcvideo: uvc_send_response: req len 26
[  426.496655] uvcvideo: event_setup_out 0, data len 26
[  426.497485] uvcvideo: setup request a1 82 value 0100 index 0003 001a
[  426.506737] uvcvideo: uvc_send_response: req len 26
[  426.507195] uvcvideo: event_setup_out 0, data len 26

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: If882728e891d033c249e6c466b40d3e2a28bccb6
2021-03-10 19:02:13 +08:00
Jack Pham
c9ccb0efaa usb: gadget: u_audio: Free requests only after callback
[ Upstream commit 7de8681be2 ]

As per the kernel doc for usb_ep_dequeue(), it states that "this
routine is asynchronous, that is, it may return before the completion
routine runs". And indeed since v5.0 the dwc3 gadget driver updated
its behavior to place dequeued requests on to a cancelled list to be
given back later after the endpoint is stopped.

The free_ep() was incorrectly assuming that a request was ready to
be freed after calling dequeue which results in a use-after-free
in dwc3 when it traverses its cancelled list. Fix this by moving
the usb_ep_free_request() call to the callback itself in case the
ep is disabled.

Fixes: eb9fecb9e6 ("usb: gadget: f_uac2: split out audio core")
Reported-and-tested-by: Ferry Toth <fntoth@gmail.com>
Reviewed-and-tested-by: Peter Chen <peter.chen@nxp.com>
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/20210118084642.322510-2-jbrunet@baylibre.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-04 11:37:24 +01:00
Tao Huang
b50aca0c9a Merge tag 'ASB-2021-02-05_4.19-stable' of https://android.googlesource.com/kernel/common
https://source.android.com/security/bulletin/2021-02-01
CVE-2017-18509
CVE-2020-10767

* tag 'ASB-2021-02-05_4.19-stable': (809 commits)
  ANDROID: GKI: fix up abi issues with 4.19.172
  Linux 4.19.172
  fs: fix lazytime expiration handling in __writeback_single_inode()
  writeback: Drop I_DIRTY_TIME_EXPIRE
  dm integrity: conditionally disable "recalculate" feature
  tools: Factor HOSTCC, HOSTLD, HOSTAR definitions
  tracing: Fix race in trace_open and buffer resize call
  HID: wacom: Correct NULL dereference on AES pen proximity
  futex: Handle faults correctly for PI futexes
  futex: Simplify fixup_pi_state_owner()
  futex: Use pi_state_update_owner() in put_pi_state()
  rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
  futex: Provide and use pi_state_update_owner()
  futex: Replace pointless printk in fixup_owner()
  futex: Ensure the correct return value from futex_lock_pi()
  futex: Prevent exit livelock
  futex: Provide distinct return value when owner is exiting
  futex: Add mutex around futex exit
  futex: Provide state handling for exec() as well
  futex: Sanitize exit state handling
  ...

Change-Id: Ieba6ee3a91a05d504e1f829a84e7d364e7d983f2

Conflicts:
	arch/arm64/boot/dts/rockchip/rk3328.dtsi
	drivers/md/Kconfig
	drivers/usb/gadget/function/f_uac2.c
2021-02-26 15:30:04 +08:00
Tao Huang
ab9fb85b0b Revert "usb: gadget: composite: fix dead lock when uvc disconnect"
This reverts commit b43b8174c1.

Relpaced by commit fc9f57f643 ("usb: gadget: Fix spinlock lockup on usb_function_deactivate")

Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2021-02-26 15:12:48 +08:00
Greg Kroah-Hartman
1092f698e5 Merge 5.10.15 into android12-5.10
Changes in 5.10.15
	USB: serial: cp210x: add pid/vid for WSDA-200-USB
	USB: serial: cp210x: add new VID/PID for supporting Teraoka AD2000
	USB: serial: option: Adding support for Cinterion MV31
	usb: host: xhci: mvebu: make USB 3.0 PHY optional for Armada 3720
	USB: gadget: legacy: fix an error code in eth_bind()
	usb: gadget: aspeed: add missing of_node_put
	USB: usblp: don't call usb_set_interface if there's a single alt
	usb: renesas_usbhs: Clear pipe running flag in usbhs_pkt_pop()
	usb: dwc2: Fix endpoint direction check in ep_from_windex
	usb: dwc3: fix clock issue during resume in OTG mode
	usb: xhci-mtk: fix unreleased bandwidth data
	usb: xhci-mtk: skip dropping bandwidth of unchecked endpoints
	usb: xhci-mtk: break loop when find the endpoint to drop
	ARM: OMAP1: OSK: fix ohci-omap breakage
	arm64: dts: qcom: c630: keep both touchpad devices enabled
	Input: i8042 - unbreak Pegatron C15B
	arm64: dts: amlogic: meson-g12: Set FL-adj property value
	arm64: dts: rockchip: fix vopl iommu irq on px30
	arm64: dts: rockchip: Use only supported PCIe link speed on Pinebook Pro
	ARM: dts: stm32: Fix polarity of the DH DRC02 uSD card detect
	ARM: dts: stm32: Connect card-detect signal on DHCOM
	ARM: dts: stm32: Disable WP on DHCOM uSD slot
	ARM: dts: stm32: Disable optional TSC2004 on DRC02 board
	ARM: dts: stm32: Fix GPIO hog flags on DHCOM DRC02
	vdpa/mlx5: Fix memory key MTT population
	bpf, cgroup: Fix optlen WARN_ON_ONCE toctou
	bpf, cgroup: Fix problematic bounds check
	bpf, inode_storage: Put file handler if no storage was found
	um: virtio: free vu_dev only with the contained struct device
	bpf, preload: Fix build when $(O) points to a relative path
	arm64: dts: meson: switch TFLASH_VDD_EN pin to open drain on Odroid-C4
	r8169: work around RTL8125 UDP hw bug
	rxrpc: Fix deadlock around release of dst cached on udp tunnel
	arm64: dts: ls1046a: fix dcfg address range
	SUNRPC: Fix NFS READs that start at non-page-aligned offsets
	igc: set the default return value to -IGC_ERR_NVM in igc_write_nvm_srwr
	igc: check return value of ret_val in igc_config_fc_after_link_up
	i40e: Revert "i40e: don't report link up for a VF who hasn't enabled queues"
	ibmvnic: device remove has higher precedence over reset
	net/mlx5: Fix function calculation for page trees
	net/mlx5: Fix leak upon failure of rule creation
	net/mlx5e: Update max_opened_tc also when channels are closed
	net/mlx5e: Release skb in case of failure in tc update skb
	net: lapb: Copy the skb before sending a packet
	net: mvpp2: TCAM entry enable should be written after SRAM data
	r8169: fix WoL on shutdown if CONFIG_DEBUG_SHIRQ is set
	net: ipa: pass correct dma_handle to dma_free_coherent()
	ARM: dts: sun7i: a20: bananapro: Fix ethernet phy-mode
	nvmet-tcp: fix out-of-bounds access when receiving multiple h2cdata PDUs
	vdpa/mlx5: Restore the hardware used index after change map
	memblock: do not start bottom-up allocations with kernel_end
	kbuild: fix duplicated flags in DEBUG_CFLAGS
	thunderbolt: Fix possible NULL pointer dereference in tb_acpi_add_link()
	ovl: fix dentry leak in ovl_get_redirect
	ovl: avoid deadlock on directory ioctl
	ovl: implement volatile-specific fsync error behaviour
	mac80211: fix station rate table updates on assoc
	gpiolib: free device name on error path to fix kmemleak
	fgraph: Initialize tracing_graph_pause at task creation
	tracing/kprobe: Fix to support kretprobe events on unloaded modules
	kretprobe: Avoid re-registration of the same kretprobe earlier
	tracing: Use pause-on-trace with the latency tracers
	tracepoint: Fix race between tracing and removing tracepoint
	libnvdimm/namespace: Fix visibility of namespace resource attribute
	libnvdimm/dimm: Avoid race between probe and available_slots_show()
	genirq: Prevent [devm_]irq_alloc_desc from returning irq 0
	genirq/msi: Activate Multi-MSI early when MSI_FLAG_ACTIVATE_EARLY is set
	scripts: use pkg-config to locate libcrypto
	xhci: fix bounce buffer usage for non-sg list case
	RISC-V: Define MAXPHYSMEM_1GB only for RV32
	cifs: report error instead of invalid when revalidating a dentry fails
	iommu: Check dev->iommu in dev_iommu_priv_get() before dereferencing it
	smb3: Fix out-of-bounds bug in SMB2_negotiate()
	smb3: fix crediting for compounding when only one request in flight
	mmc: sdhci-pltfm: Fix linking err for sdhci-brcmstb
	mmc: core: Limit retries when analyse of SDIO tuples fails
	Fix unsynchronized access to sev members through svm_register_enc_region
	drm/dp/mst: Export drm_dp_get_vc_payload_bw()
	drm/i915: Fix the MST PBN divider calculation
	drm/i915/gem: Drop lru bumping on display unpinning
	drm/i915/gt: Close race between enable_breadcrumbs and cancel_breadcrumbs
	drm/i915/display: Prevent double YUV range correction on HDR planes
	drm/i915: Extract intel_ddi_power_up_lanes()
	drm/i915: Power up combo PHY lanes for for HDMI as well
	drm/amd/display: Revert "Fix EDID parsing after resume from suspend"
	io_uring: don't modify identity's files uncess identity is cowed
	nvme-pci: avoid the deepest sleep state on Kingston A2000 SSDs
	KVM: SVM: Treat SVM as unsupported when running as an SEV guest
	KVM: x86/mmu: Fix TDP MMU zap collapsible SPTEs
	KVM: x86: Allow guests to see MSR_IA32_TSX_CTRL even if tsx=off
	KVM: x86: fix CPUID entries returned by KVM_GET_CPUID2 ioctl
	KVM: x86: Update emulator context mode if SYSENTER xfers to 64-bit mode
	KVM: x86: Set so called 'reserved CR3 bits in LM mask' at vCPU reset
	DTS: ARM: gta04: remove legacy spi-cs-high to make display work again
	ARM: dts; gta04: SPI panel chip select is active low
	ARM: footbridge: fix dc21285 PCI configuration accessors
	ARM: 9043/1: tegra: Fix misplaced tegra_uart_config in decompressor
	mm: hugetlbfs: fix cannot migrate the fallocated HugeTLB page
	mm: hugetlb: fix a race between freeing and dissolving the page
	mm: hugetlb: fix a race between isolating and freeing page
	mm: hugetlb: remove VM_BUG_ON_PAGE from page_huge_active
	mm, compaction: move high_pfn to the for loop scope
	mm/vmalloc: separate put pages and flush VM flags
	mm: thp: fix MADV_REMOVE deadlock on shmem THP
	mm/filemap: add missing mem_cgroup_uncharge() to __add_to_page_cache_locked()
	x86/build: Disable CET instrumentation in the kernel
	x86/debug: Fix DR6 handling
	x86/debug: Prevent data breakpoints on __per_cpu_offset
	x86/debug: Prevent data breakpoints on cpu_dr7
	x86/apic: Add extra serialization for non-serializing MSRs
	Input: goodix - add support for Goodix GT9286 chip
	Input: xpad - sync supported devices with fork on GitHub
	Input: ili210x - implement pressure reporting for ILI251x
	md: Set prev_flush_start and flush_bio in an atomic way
	igc: Report speed and duplex as unknown when device is runtime suspended
	neighbour: Prevent a dead entry from updating gc_list
	net: ip_tunnel: fix mtu calculation
	udp: ipv4: manipulate network header of NATed UDP GRO fraglist
	net: dsa: mv88e6xxx: override existent unicast portvec in port_fdb_add
	net: sched: replaced invalid qdisc tree flush helper in qdisc_replace
	Linux 5.10.15

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I15750357b4c30739515fdc0bbbd0e04b7c986171
2021-02-10 09:53:50 +01:00
kernel test robot
4025244544 usb: gadget: aspeed: add missing of_node_put
commit a55a9a4c5c upstream.

Breaking out of for_each_child_of_node requires a put on the
child value.

Generated by: scripts/coccinelle/iterators/for_each_child.cocci

Fixes: 82c2d81361 ("coccinelle: iterators: Add for_each_child.cocci script")
CC: Sumera Priyadarsini <sylphrenadin@gmail.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/alpine.DEB.2.22.394.2101211907060.14700@hadrien
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-10 09:29:10 +01:00