From 3e439f4e7f46450d52c785e218c01350067b4484 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sat, 13 Jun 2020 21:25:42 +0800 Subject: [PATCH 1/5] Revert "arm64: vdso, vdso32: add support for time" This reverts commit c4fefe3c07c1584a1a1bd2e9c767a2609c8ec6b2. Superceded by upstream commit. Change-Id: I5d0775691f88c524798bfec011631b31fc88492b Signed-off-by: Jesse Chan --- arch/arm64/include/asm/vdso/compat_gettimeofday.h | 1 - arch/arm64/include/asm/vdso/gettimeofday.h | 1 - arch/arm64/kernel/vdso/vdso.lds.S | 1 - arch/arm64/kernel/vdso/vgettimeofday.c | 5 ----- arch/arm64/kernel/vdso32/vdso.lds.S | 1 - arch/arm64/kernel/vdso32/vgettimeofday.c | 5 ----- 6 files changed, 14 deletions(-) diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h b/arch/arm64/include/asm/vdso/compat_gettimeofday.h index 7c1ccfafe144..98f683023222 100644 --- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h +++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h @@ -15,7 +15,6 @@ #define __VDSO_USE_SYSCALL ULLONG_MAX #define VDSO_HAS_CLOCK_GETRES 1 -#define VDSO_HAS_TIME 1 #define BUILD_VDSO32 1 diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h index 31581e4e1edf..cc3456416096 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -12,7 +12,6 @@ #define __VDSO_USE_SYSCALL ULLONG_MAX #define VDSO_HAS_CLOCK_GETRES 1 -#define VDSO_HAS_TIME 1 static __always_inline int gettimeofday_fallback(struct __kernel_old_timeval *_tv, diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index 9de0ffc369c5..beca249bc2f3 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -88,7 +88,6 @@ VERSION __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; - __kernel_time; local: *; }; } diff --git a/arch/arm64/kernel/vdso/vgettimeofday.c b/arch/arm64/kernel/vdso/vgettimeofday.c index 78a70ead642e..4236cf34d7d9 100644 --- a/arch/arm64/kernel/vdso/vgettimeofday.c +++ b/arch/arm64/kernel/vdso/vgettimeofday.c @@ -23,8 +23,3 @@ int __kernel_clock_getres(clockid_t clock_id, { return __cvdso_clock_getres(clock_id, res); } - -time_t __kernel_time(time_t *t) -{ - return __cvdso_time(t); -} diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S index a4673200f3c9..4fd3093ea78c 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -64,7 +64,6 @@ VERSION __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; - __vdso_time; __kernel_sigreturn_arm; __kernel_sigreturn_thumb; __kernel_rt_sigreturn_arm; diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c index f0ec88f48f35..1ca414eff9bd 100644 --- a/arch/arm64/kernel/vdso32/vgettimeofday.c +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -32,11 +32,6 @@ int __vdso_clock_getres(clockid_t clock_id, return __cvdso_clock_getres_time32(clock_id, res); } -time_t __vdso_time(time_t *t) -{ - return __cvdso_time(t); -} - /* Avoid unresolved references emitted by GCC */ void __aeabi_unwind_cpp_pr0(void) From ba6771d9299cfdb7f1383b4365d6559269caf7b3 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sat, 13 Jun 2020 21:30:03 +0800 Subject: [PATCH 2/5] Revert "HACK: arm64: vdso32: remove clock_gettime64" This reverts commit 1d03b1e41c663fa8d016ff7e58b499672dd8b453. Android bionic doesn't use clock_gettime64. Change-Id: If3c28e3e57940dfd22c432e437cfdfcfff50e504 Signed-off-by: Jesse Chan --- arch/arm64/kernel/vdso32/vdso.lds.S | 1 + arch/arm64/kernel/vdso32/vgettimeofday.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S index 4fd3093ea78c..a3944927eaeb 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -68,6 +68,7 @@ VERSION __kernel_sigreturn_thumb; __kernel_rt_sigreturn_arm; __kernel_rt_sigreturn_thumb; + __vdso_clock_gettime64; local: *; }; } diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c index 1ca414eff9bd..5acff29c5991 100644 --- a/arch/arm64/kernel/vdso32/vgettimeofday.c +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -12,13 +12,11 @@ int __vdso_clock_gettime(clockid_t clock, return __cvdso_clock_gettime32(clock, ts); } -#if 0 int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) { return __cvdso_clock_gettime(clock, ts); } -#endif int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) From fc020c1628698b5746c5647e962a0efc5639eee9 Mon Sep 17 00:00:00 2001 From: Chiawei Wang Date: Mon, 8 Jun 2020 23:38:46 +0800 Subject: [PATCH 3/5] ANDROID: arch: arm64: vdso: export the symbols for time() __cvdso_time() can be found in vDSO implementation, but the symbols for time() are not exported. Export the symbols and run bionic-benchmarks. BEFORE: bionic-benchmarks32 --bionic_extra BM_time_time ----------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------- BM_time_time 83.6 ns 83.5 ns 8385964 bionic-benchmarks64 --bionic_extra BM_time_time ----------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------- BM_time_time 63.5 ns 63.4 ns 11037509 AFTER: bionic-benchmarks32 --bionic_extra BM_time_time ----------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------- BM_time_time 8.57 ns 8.56 ns 81887312 bionic-benchmarks64 --bionic_extra BM_time_time ----------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------- BM_time_time 7.52 ns 7.51 ns 93253809 Signed-off-by: Chiawei Wang Bug: 154668398 Bug: 157925983 Test: run bionic-benchmarks --bionic_xml vdso.xml (cherry picked from fc30ad8ca60eccbce5245103fb4a2b070aa294de) Signed-off-by: Mark Salyzyn Change-Id: Ibd9835254c065801ba2f0976dffbf70d7bf0c85c --- arch/arm64/include/asm/vdso/compat_gettimeofday.h | 2 ++ arch/arm64/include/asm/vdso/gettimeofday.h | 2 ++ arch/arm64/kernel/vdso/vdso.lds.S | 1 + arch/arm64/kernel/vdso/vgettimeofday.c | 5 +++++ arch/arm64/kernel/vdso32/vdso.lds.S | 1 + arch/arm64/kernel/vdso32/vgettimeofday.c | 5 +++++ 6 files changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h b/arch/arm64/include/asm/vdso/compat_gettimeofday.h index 98f683023222..9fc362260f47 100644 --- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h +++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h @@ -16,6 +16,8 @@ #define VDSO_HAS_CLOCK_GETRES 1 +#define VDSO_HAS_TIME 1 + #define BUILD_VDSO32 1 static __always_inline diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h index cc3456416096..879e94eb7c36 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -13,6 +13,8 @@ #define VDSO_HAS_CLOCK_GETRES 1 +#define VDSO_HAS_TIME 1 + static __always_inline int gettimeofday_fallback(struct __kernel_old_timeval *_tv, struct timezone *_tz) diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index beca249bc2f3..9de0ffc369c5 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -88,6 +88,7 @@ VERSION __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; + __kernel_time; local: *; }; } diff --git a/arch/arm64/kernel/vdso/vgettimeofday.c b/arch/arm64/kernel/vdso/vgettimeofday.c index 4236cf34d7d9..09be63204e74 100644 --- a/arch/arm64/kernel/vdso/vgettimeofday.c +++ b/arch/arm64/kernel/vdso/vgettimeofday.c @@ -23,3 +23,8 @@ int __kernel_clock_getres(clockid_t clock_id, { return __cvdso_clock_getres(clock_id, res); } + +time_t __kernel_time(time_t *time) +{ + return __cvdso_time(time); +} diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S index a3944927eaeb..2222c78451b4 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -69,6 +69,7 @@ VERSION __kernel_rt_sigreturn_arm; __kernel_rt_sigreturn_thumb; __vdso_clock_gettime64; + __vdso_time; local: *; }; } diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c index 5acff29c5991..9296385e7bb8 100644 --- a/arch/arm64/kernel/vdso32/vgettimeofday.c +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -30,6 +30,11 @@ int __vdso_clock_getres(clockid_t clock_id, return __cvdso_clock_getres_time32(clock_id, res); } +time_t __vdso_time(time_t *time) +{ + return __cvdso_time(time); +} + /* Avoid unresolved references emitted by GCC */ void __aeabi_unwind_cpp_pr0(void) From 52307735aa2370ec0f2eaaa53ced3b79508f6ec6 Mon Sep 17 00:00:00 2001 From: Chiawei Wang Date: Thu, 11 Jun 2020 03:41:40 +0800 Subject: [PATCH 4/5] ANDROID: lib/vdso: use CLOCK_REALTIME_COARSE for time() CLOCK_REALTIME in vdso data won't be updated if __arch_use_vsyscall() returns false. It will let time() return an incorrect time value. Since time() is designed to return the seconds since the Epoch, using CLOCK_REALTIME_COARSE can still fulfill the request and never fails. Signed-off-by: Chiawei Wang Bug: 158635600 Bug: 154668398 Bug: 157925983 Test: run bionic-benchmarks --bionic_xml vdso.xml Test: check the time returned from time() e.g. adb bugreport and check the date suffix in the file name Signed-off-by: Mark Salyzyn Change-Id: Ibfb1b06f30f008800c0b5b61384b8fbf73b880f8 --- lib/vdso/gettimeofday.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 7303118400be..ed488a2ba1eb 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -157,7 +157,8 @@ __cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) static __maybe_unused time_t __cvdso_time(time_t *time) { const struct vdso_data *vd = __arch_get_vdso_data(); - time_t t = READ_ONCE(vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME].sec); + time_t t = READ_ONCE( + vd[CS_HRES_COARSE].basetime[CLOCK_REALTIME_COARSE].sec); if (time) *time = t; From d778757f3e286194ced41915eba2a22df9a4a16b Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Tue, 23 Jun 2020 01:55:30 +0800 Subject: [PATCH 5/5] Revert "Revert "usb: dwc3: gadget: Enable SUSPEND event after CONNECT DONE"" This reverts commit 001dd526010f4580d572e3e237ed2c56205e65bf. The change leads to USB-PD negotiation failure. Signed-off-by: Jesse Chan --- drivers/usb/dwc3/gadget.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e2f271fd0d62..9932dd575aa8 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2564,14 +2564,8 @@ static void dwc3_gadget_enable_irq(struct dwc3 *dwc) DWC3_DEVTEN_USBRSTEN | DWC3_DEVTEN_DISCONNEVTEN); - /* - * Enable SUSPENDEVENT(BIT:6) for version 230A and above - * else enable USB Link change event (BIT:3) for older version - */ if (dwc->revision < DWC3_REVISION_230A) reg |= DWC3_DEVTEN_ULSTCNGEN; - else - reg |= DWC3_DEVTEN_EOPFEN; dwc3_writel(dwc->regs, DWC3_DEVTEN, reg); } @@ -3678,6 +3672,13 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) speed = reg & DWC3_DSTS_CONNECTSPD; dwc->speed = speed; + /* Enable SUSPENDEVENT(BIT:6) for version 230A and above */ + if (dwc->revision >= DWC3_REVISION_230A) { + reg = dwc3_readl(dwc->regs, DWC3_DEVTEN); + reg |= DWC3_DEVTEN_EOPFEN; + dwc3_writel(dwc->regs, DWC3_DEVTEN, reg); + } + /* Reset the retry on erratic error event count */ dwc->retries_on_error = 0;