Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIPS: uaccess: emulate Ingenic LXW/LXH/LXHU uaccess #14

Closed
wants to merge 32 commits into from

Conversation

SiarheiVolkau
Copy link

The patch tries to emulate unaligned access for Ingenic LXW/LXH/LXHU instructions of MXU subsystem.

The unaligned access is produced by GCC compiler with patches for adding LX__ instructions but observed only on mips32r2, mips32r1 seems to be unaffected.

pcercuei and others added 30 commits December 12, 2022 00:16
This allows the battery node in Ingenic SoCs to have a "power-supplies"
property.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add ingenic,jz4760-battery and ingenic,jz4760b-battery compatible
strings for the JZ4760 and JZ4760B SoCs respectively.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add the ingenic,jz4760-phy and ingenic,jz4760b-phy compatible strings,
and make the ingenic,jz4770-phy compatible string require
ingenic,jz4760-phy as a fallback, since both work the same, and the
JZ4760 SoC is older.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The JZ4760B is pin-compatible with the JZ4760, but has configurable skew
rate and drive strength that the JZ4760 lacks.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The MIPS CI20 board has a Ingenic IW8103 chip, which is supposedly just
a rebranded Broadcom BCM4330.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Create YAML bindings for the Active-semi PMICs and remove the old text
files.

The bindings aren't perfect, for instance I couldn't find good
descriptions for the vendor properties in the "charger" node of the
ACT8945A because I am not familiar with the hardware and these
properties were not documented anywhere.

The YAML schemas are a bit different than what is described in the old
text files, because these were sometimes wrong or had missing
information. This is the case for the ACT8600 documentation, which
specified the valid node names for the regulators, while the driver was
expecting different names. This led to the current situation where we
have two different boards using different names for the regulators:
- arch/mips/boot/dts/ingenic/ci20.dts uses the names documented in the
  text file,
- arch/mips/boot/dts/ingenic/gcw0.dts uses the names that the driver
  expects.
In theory, the driver should be fixed to follow the documentation, and
accept both naming schemes. In practice though, when the PMIC node was
added to the ci20.dts board file, the names were already wrong in
regards to what the driver expected, so it never really worked
correctly and wasn't tested properly. Furthermore, in that board the
consumers of the regulators aren't working for various other reasons
(invalid GPIOs, etc.).

For that reason, for the ACT8600 bindings I decided to only use the node
names that the driver expects (and that gcw0.dts uses), instead of
accepting both old and new names. A follow-up patch will update the CI20
board to use the new regulator names.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>

---
v2:
- Avoid | character in descriptions that can be single-line
- Remove unevaluatedProperties when additionalProperties is also present
- Remove useless inner parentheses in regular expressions
- Rename I2C nodes to just... i2c
- Remove node handles

v3:
- Fix alignment in examples
- Drop useless status = "okay"; in examples
- I set myself as the maintainer, which I only did because nobody else
  seems to care.

Cheers,
-Paul
This will make it easier later to introduce support for new chips in
this driver.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add support for the IT6610 HDMI encoder.

The hardware is very similar, and therefore the driver did not require
too many changes. Some bits are only available on the IT66121, and
vice-versa. Also, the IT6610 requires specific polarities on the DE and
pixel lines.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add support for the YLM (known as the Anbernic in the western
world) RG-280V, RG-280M, RG-300X, RG-350, RG-350M, and the Wolsen
PocketGo2 (aka. PlayGo) Rev. 1 & 2.

The YLM RG-280V is almost a carbon copy of the GCW-Zero, with a
different LCD panel (320x480 non-square pixels in diamond pattern),
L2/R2 and Vol +/- buttons added, and with the analog stick, ACT8600
regulator, RDA5807 radio, MXC6225 accelerometer, ITE6610 HDMI chips
removed.

The YLM RG-280M v1.1 is a RG-280V with a clickable analog stick. The
v1.0 additionally has a ITE66121 chip.

The Wolsen PocketGo2 Rev. 1 & 2 are similar to the RG-280V, with a
proper 320x240 IPS screen this time.

The RG-350 is a RG-280M v1.0 with two clickable analog sticks, and
a proper 320x240 IPS screen.

The RG-350M is a RG-350 with a 640x480 IPS screen.

The RG-300X is a RG-350 without joysticks.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add Kconfig symbols and Device Tree files to support the JZ4760 and
JZ4760B SoCs from Ingenic.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The RS-97 from Shenzhen Yangliming Electronic Technology Co., Ltd,
aka YLM, aka Anbernic, is a simple handheld console based around the
JZ4760 SoC.

The RG-300 has the exact same board design, but uses a different LCD
panel and a JZ4760B SoC.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Add support for the QishengLong Gopher 2, which is a handheld that
features the Ingenic JZ4760 SoC.

Also support the QishengLong Gopher 2B, which is the exact same handheld
with some cosmetic changes, and a JZ4760B SoC.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The Wolsen LDK are small handhelds with a 320x480 4:3 TFT LCD screen
(non-square pixels).

Two versions exist, one with a vertical layout (buttons below the
screen) and one with a horizontal layout (buttons on the sides of the
screen). Apart from that difference, the vertical version uses the
JZ4760B SoC, while the horizontal version uses the JZ4760 SoC.

Both are carbon copies of the RS-97 board, except for the different SoC
(for the vertical LDK) and a different panel used.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Make sure that the handheld won't power on, unless the reset pin is
active for 500ms or more.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
These flags are useless in this case as the code referencing these data
structures is always seen by the compiler (and not behind #ifdef
guards).

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The JZ4750, JZ4755 and JZ4760 (non-B version) support using a 24 MHz
external crystal oscillator instead of the typical 12 MHz one.

However, most of the SoC's IP blocks only work with a 12 MHz clock.
Thanksfully, there is a /2 divider we can enable when a 24 MHz external
crystal is present.

Force-enable this /2 divider when the oscillator is 24 MHz, so that the
SoC always uses a 12 MHz clock internally.

It is done here, and not in the clocks driver, because we need the EXT
clock to be 12 MHz for the early console to work, and the clocks driver
probes way too late.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The RTC module does provide a clock named "osc32k". On the CI20 board,
this clock is supplied to the Bluetooth module and must be enabled for
the Bluetooth and WiFi functionalities to work properly.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The regulators don't have any "reg" property, and therefore shouldn't
use an unit address in their node names.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The reset line is called PWRST#, annotated as "active low" in the
binding documentation, and is driven low and then high by the driver to
reset the chip. However in device tree for CI20 board it was incorrectly
marked as "active high". Fix it.

Because (as far as I know) the ci20.dts is always built in the kernel I
elected not to also add a quirk to gpiolib to force the polarity there.

Fixes: db49ca3 ("net: davicom: dm9000: switch to using gpiod API")
Reported-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
The regulators don't have any "reg" property, and therefore shouldn't
use an unit address in their node names.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
No need to specify the GPIO_ACTIVE_LOW flag, it will be ignored.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The Device Tree was using invalid node names for the ACT8600 regulators.
To be fair, it is not the original committer's fault, as the
documentation did gives invalid names as well.

In theory, the fix should have been to modify the driver to accept the
alternative names. However, even though the act8865 driver spits
warnings, the kernel seemed to work fine with what is currently
supported upstream. For that reason, I think it is okay to just update
the DTS.

I removed the "regulator-name" too, since they really didn't bring any
information. The node names are enough.

Fixes: 73f2b94 ("MIPS: CI20: DTS: Add I2C nodes")
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
…drm', 'for-upstream-dts', 'for-upstream-hdmi', 'for-upstream-iio', 'for-upstream-lto', 'for-upstream-mips', 'for-upstream-mmc', 'for-upstream-panel', 'for-upstream-phy', 'for-upstream-pwm', 'for-upstream-radio', 'for-upstream-remoteproc', 'for-upstream-rtc', 'for-upstream-sound', 'for-upstream-slub' and 'for-upstream-usb' into jz-6.1-base
This frees up a PTE bit so that we can use hugepages.

HACK. NOT FOR UPSTREAM
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
pcercuei and others added 2 commits December 12, 2022 00:19
The patch tries to emulate unaligned access for Ingenic
LXW/LXH/LXHU instructions of MXU subsystem.

The unaligned access is produced by GCC compiler with patches
for adding LX__ instructions but observed only on mips32r2,
mips32r1 seems to be unaffected.

Signed-off-by: Siarhei Volkau <lis8215@gmail.com>
@pcercuei
Copy link
Member

I merged it, thanks.
Since jz-6.1 is the current dev branch, it is force-pushed regularly, so the commit doesn't appear on top, but it's included.

@pcercuei pcercuei closed this Dec 19, 2022
pcercuei pushed a commit that referenced this pull request Sep 19, 2023
The cited commit holds encap tbl lock unconditionally when setting
up dests. But it may cause the following deadlock:

 PID: 1063722  TASK: ffffa062ca5d0000  CPU: 13   COMMAND: "handler8"
  #0 [ffffb14de05b7368] __schedule at ffffffffa1d5aa91
  #1 [ffffb14de05b7410] schedule at ffffffffa1d5afdb
  #2 [ffffb14de05b7430] schedule_preempt_disabled at ffffffffa1d5b528
  #3 [ffffb14de05b7440] __mutex_lock at ffffffffa1d5d6cb
  #4 [ffffb14de05b74e8] mutex_lock_nested at ffffffffa1d5ddeb
  #5 [ffffb14de05b74f8] mlx5e_tc_tun_encap_dests_set at ffffffffc12f2096 [mlx5_core]
  #6 [ffffb14de05b7568] post_process_attr at ffffffffc12d9fc5 [mlx5_core]
  #7 [ffffb14de05b75a0] mlx5e_tc_add_fdb_flow at ffffffffc12de877 [mlx5_core]
  #8 [ffffb14de05b75f0] __mlx5e_add_fdb_flow at ffffffffc12e0eef [mlx5_core]
  #9 [ffffb14de05b7660] mlx5e_tc_add_flow at ffffffffc12e12f7 [mlx5_core]
 #10 [ffffb14de05b76b8] mlx5e_configure_flower at ffffffffc12e1686 [mlx5_core]
 #11 [ffffb14de05b7720] mlx5e_rep_indr_offload at ffffffffc12e3817 [mlx5_core]
 #12 [ffffb14de05b7730] mlx5e_rep_indr_setup_tc_cb at ffffffffc12e388a [mlx5_core]
 #13 [ffffb14de05b7740] tc_setup_cb_add at ffffffffa1ab2ba8
 #14 [ffffb14de05b77a0] fl_hw_replace_filter at ffffffffc0bdec2f [cls_flower]
 #15 [ffffb14de05b7868] fl_change at ffffffffc0be6caa [cls_flower]
 MIPS#16 [ffffb14de05b7908] tc_new_tfilter at ffffffffa1ab71f0

[1031218.028143]  wait_for_completion+0x24/0x30
[1031218.028589]  mlx5e_update_route_decap_flows+0x9a/0x1e0 [mlx5_core]
[1031218.029256]  mlx5e_tc_fib_event_work+0x1ad/0x300 [mlx5_core]
[1031218.029885]  process_one_work+0x24e/0x510

Actually no need to hold encap tbl lock if there is no encap action.
Fix it by checking if encap action exists or not before holding
encap tbl lock.

Fixes: 37c3b9f ("net/mlx5e: Prevent encap offload when neigh update is running")
Signed-off-by: Chris Mi <cmi@nvidia.com>
Reviewed-by: Vlad Buslov <vladbu@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
citral23 pushed a commit to citral23/linux-1 that referenced this pull request Sep 20, 2023
[ Upstream commit 99d4850 ]

Found by leak sanitizer:
```
==1632594==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 21 byte(s) in 1 object(s) allocated from:
    #0 0x7f2953a7077b in __interceptor_strdup ../../../../src/libsanitizer/asan/asan_interceptors.cpp:439
    #1 0x556701d6fbbf in perf_env__read_cpuid util/env.c:369
    OpenDingux#2 0x556701d70589 in perf_env__cpuid util/env.c:465
    OpenDingux#3 0x55670204bba2 in x86__is_amd_cpu arch/x86/util/env.c:14
    OpenDingux#4 0x5567020487a2 in arch__post_evsel_config arch/x86/util/evsel.c:83
    OpenDingux#5 0x556701d8f78b in evsel__config util/evsel.c:1366
    OpenDingux#6 0x556701ef5872 in evlist__config util/record.c:108
    OpenDingux#7 0x556701cd6bcd in test__PERF_RECORD tests/perf-record.c:112
    OpenDingux#8 0x556701cacd07 in run_test tests/builtin-test.c:236
    OpenDingux#9 0x556701cacfac in test_and_print tests/builtin-test.c:265
    OpenDingux#10 0x556701cadddb in __cmd_test tests/builtin-test.c:402
    OpenDingux#11 0x556701caf2aa in cmd_test tests/builtin-test.c:559
    OpenDingux#12 0x556701d3b557 in run_builtin tools/perf/perf.c:323
    OpenDingux#13 0x556701d3bac8 in handle_internal_command tools/perf/perf.c:377
    OpenDingux#14 0x556701d3be90 in run_argv tools/perf/perf.c:421
    OpenDingux#15 0x556701d3c3f8 in main tools/perf/perf.c:537
    MIPS#16 0x7f2952a46189 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 21 byte(s) leaked in 1 allocation(s).
```

Fixes: f7b58cb ("perf mem/c2c: Add load store event mappings for AMD")
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Ravi Bangoria <ravi.bangoria@amd.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: https://lore.kernel.org/r/20230613235416.1650755-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
pcercuei pushed a commit that referenced this pull request Nov 29, 2023
Fix an error detected by memory sanitizer:
```
==4033==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55fb0fbedfc7 in read_alias_info tools/perf/util/pmu.c:457:6
    #1 0x55fb0fbea339 in check_info_data tools/perf/util/pmu.c:1434:2
    #2 0x55fb0fbea339 in perf_pmu__check_alias tools/perf/util/pmu.c:1504:9
    #3 0x55fb0fbdca85 in parse_events_add_pmu tools/perf/util/parse-events.c:1429:32
    #4 0x55fb0f965230 in parse_events_parse tools/perf/util/parse-events.y:299:6
    #5 0x55fb0fbdf6b2 in parse_events__scanner tools/perf/util/parse-events.c:1822:8
    #6 0x55fb0fbdf8c1 in __parse_events tools/perf/util/parse-events.c:2094:8
    #7 0x55fb0fa8ffa9 in parse_events tools/perf/util/parse-events.h:41:9
    #8 0x55fb0fa8ffa9 in test_event tools/perf/tests/parse-events.c:2393:8
    #9 0x55fb0fa8f458 in test__pmu_events tools/perf/tests/parse-events.c:2551:15
    #10 0x55fb0fa6d93f in run_test tools/perf/tests/builtin-test.c:242:9
    #11 0x55fb0fa6d93f in test_and_print tools/perf/tests/builtin-test.c:271:8
    #12 0x55fb0fa6d082 in __cmd_test tools/perf/tests/builtin-test.c:442:5
    #13 0x55fb0fa6d082 in cmd_test tools/perf/tests/builtin-test.c:564:9
    #14 0x55fb0f942720 in run_builtin tools/perf/perf.c:322:11
    #15 0x55fb0f942486 in handle_internal_command tools/perf/perf.c:375:8
    MIPS#16 0x55fb0f941dab in run_argv tools/perf/perf.c:419:2
    MIPS#17 0x55fb0f941dab in main tools/perf/perf.c:535:3
```

Fixes: 7b723db ("perf pmu: Be lazy about loading event info files from sysfs")
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: James Clark <james.clark@arm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20230914022425.1489035-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
pcercuei pushed a commit that referenced this pull request Nov 29, 2023
The following call trace shows a deadlock issue due to recursive locking of
mutex "device_mutex". First lock acquire is in target_for_each_device() and
second in target_free_device().

 PID: 148266   TASK: ffff8be21ffb5d00  CPU: 10   COMMAND: "iscsi_ttx"
  #0 [ffffa2bfc9ec3b18] __schedule at ffffffffa8060e7f
  #1 [ffffa2bfc9ec3ba0] schedule at ffffffffa8061224
  #2 [ffffa2bfc9ec3bb8] schedule_preempt_disabled at ffffffffa80615ee
  #3 [ffffa2bfc9ec3bc8] __mutex_lock at ffffffffa8062fd7
  #4 [ffffa2bfc9ec3c40] __mutex_lock_slowpath at ffffffffa80631d3
  #5 [ffffa2bfc9ec3c50] mutex_lock at ffffffffa806320c
  #6 [ffffa2bfc9ec3c68] target_free_device at ffffffffc0935998 [target_core_mod]
  #7 [ffffa2bfc9ec3c90] target_core_dev_release at ffffffffc092f975 [target_core_mod]
  #8 [ffffa2bfc9ec3ca0] config_item_put at ffffffffa79d250f
  #9 [ffffa2bfc9ec3cd0] config_item_put at ffffffffa79d2583
 #10 [ffffa2bfc9ec3ce0] target_devices_idr_iter at ffffffffc0933f3a [target_core_mod]
 #11 [ffffa2bfc9ec3d00] idr_for_each at ffffffffa803f6fc
 #12 [ffffa2bfc9ec3d60] target_for_each_device at ffffffffc0935670 [target_core_mod]
 #13 [ffffa2bfc9ec3d98] transport_deregister_session at ffffffffc0946408 [target_core_mod]
 #14 [ffffa2bfc9ec3dc8] iscsit_close_session at ffffffffc09a44a6 [iscsi_target_mod]
 #15 [ffffa2bfc9ec3df0] iscsit_close_connection at ffffffffc09a4a88 [iscsi_target_mod]
 MIPS#16 [ffffa2bfc9ec3df8] finish_task_switch at ffffffffa76e5d07
 MIPS#17 [ffffa2bfc9ec3e78] iscsit_take_action_for_connection_exit at ffffffffc0991c23 [iscsi_target_mod]
 MIPS#18 [ffffa2bfc9ec3ea0] iscsi_target_tx_thread at ffffffffc09a403b [iscsi_target_mod]
 MIPS#19 [ffffa2bfc9ec3f08] kthread at ffffffffa76d8080
 MIPS#20 [ffffa2bfc9ec3f50] ret_from_fork at ffffffffa8200364

Fixes: 36d4cb4 ("scsi: target: Avoid that EXTENDED COPY commands trigger lock inversion")
Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Link: https://lore.kernel.org/r/20230918225848.66463-1-junxiao.bi@oracle.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants