Re: early x86 unseeded randomness
On Mon, Aug 14, 2017 at 10:47:47AM -0700, Linus Torvalds wrote: > Plus on modern x86, you'll always get at least the hardware > randomness, which is fundamentally much better anyway. Right, my only intention was to get rid of those: [0.00] random: get_random_bytes called from start_kernel+0x30/0x3d8 with crng_init=0 What do you propose? Keep 'em? Or fix the above, snipped bit to conditionally do rdtsc() *once* or get_random_bytes() depending on the crng state? > So this patch is utter and absolute garbage, and should be shot in the > head and buried very very deep. /me takes out a 44 magnum... > Please immediately delete it from the whole internet. Haha, lemme call a guy. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
Re: [PATCH v2 4/7] ghes_edac: avoid multiple calls to dmi_walk()
On Mon, Aug 14, 2017 at 05:52:25PM +, Kani, Toshimitsu wrote: > Yes, but this ACK is done per a GHES entry as well. So is the ghes_edac_report_mem_error() call. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
RE: [PATCH 0/5] cramfs refresh for embedded usage
On Monday, August 14, 2017, Nicolas Pitre wrote: > > However, now with your mkcramfs tool, I can no longer mount my cramfs > > image as the rootfs on boot. I was able to do that before (ie, 30 > minutes > > ago) when using the community mkcramfs (ie, 30 minutes ago). > > > > I get this: > > > > [1.712425] cramfs: checking physical address 0x1b00 for linear > cramfs image > > [1.720531] cramfs: linear cramfs image appears to be 15744 KB in > size > > [1.728656] VFS: Mounted root (cramfs_physmem filesystem) readonly on > device 0:12. > > [1.737062] devtmpfs: mounted > > [1.741139] Freeing unused kernel memory: 48K > > [1.745545] This architecture does not have kernel memory protection. > > [1.760381] Starting init: /sbin/init exists but couldn't execute it > (error -22) > > [1.769685] Starting init: /bin/sh exists but couldn't execute it > (error -14) > > Is /sbin/init a link to busybox? Yes. > I suppose it just boots if you do mkcramfs without -X? Correct. I just created another image and removed the "-X -X" when creating it. Now I can boot that image as my rootfs. (I'm using -X -X because I'm using a Cortex-A9 with MMU). > If so could you share your non-working cramfs image with me? I will send it (in a separate email) Chris
Re: [PATCH] serial: imx: Improve PIO prevention if TX DMA has been started
Hello Uwe, On Mon, Aug 14, 2017 at 08:51:49AM +0200, Uwe Kleine-König wrote: > Hello Clemens, > > On Sun, Aug 13, 2017 at 12:07:56AM +0200, Clemens Gruber wrote: > > On Sat, Aug 12, 2017 at 09:54:51PM +0200, Uwe Kleine-König wrote: > > > On Sat, Aug 12, 2017 at 05:12:10PM +0200, Clemens Gruber wrote: > > > > The imx_transmit_buffer function should return if TX DMA has already > > > > been started and not just skip over the buffer PIO write loop. (Which > > > > did fix the initial problem, but could have unintentional side-effects) > > > > > > > > Tested on an i.MX6Q board with half-duplex RS-485 and with RS-232. > > > > > > > > Cc: Ian Jamison> > > > Cc: Uwe-Kleine König > > > > Fixes: 514ab34dbad6 ("serial: imx: Prevent TX buffer PIO write when a > > > > DMA has been started") > > > > > > AFAIK no newline in the Fixes: line. > > > > Thanks. A checkpatch warning for this would be great. > > I assume that is a note to yourself to look into that? :-) It's on my TODO list ;) > > > > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > > > > index 80934e7bd67f..fce538eb8c77 100644 > > > > --- a/drivers/tty/serial/imx.c > > > > +++ b/drivers/tty/serial/imx.c > > > > @@ -452,13 +452,14 @@ static inline void imx_transmit_buffer(struct > > > > imx_port *sport) > > > > if (sport->dma_is_txing) { > > > > temp |= UCR1_TDMAEN; > > > > writel(temp, sport->port.membase + UCR1); > > > > + return; > > > > } else { > > > > writel(temp, sport->port.membase + UCR1); > > > > imx_dma_tx(sport); > > > > } > > > > > > Shouldn't the return go here? > > > > Yes, it can also go here (and probably should). The problem of > > xmit->tail jumping over xmit->head occurs only if we are already DMA > > txing and then go into the PIO loop, but not the first time after > > calling imx_dma_tx. That's why the v1 passed the tests too. > > I'll have to conduct a few more tests and if they succeed I'll send a > > v2 where we return in both cases (already txing and starting to). > > > > > Did you understand the problem? Can you say why this only hurts in RS485 > > > half-duplex but not (as it seems) in regular rs232 mode? > > > > I am not sure anyone understands (yet) why it a) only hurts RS-485 and > > b) only occurs on SMP systems. > > If you have more insight, please share it. :) > > I asked because I thought you might have understood it before patching > it ... Yeah, this patch went out way too early, sorry for that! :/ @gregkh: Please ignore this patch! About the underlying problem (b) why it only occurs on SMP systems: I think Ian's theory is correct: DMA is started, then the PIO is done until the xmit buffer is empty and immediately after that, DMA is stopped. On SMP systems, where the DMA TX thread can run on another core, it is already too late. Regarding problem (a) why it only hurts RS-485: One possibility could be the timing difference / additional delay due to for example toggling the transmit-enable GPIO via mctrl_gpio_set. Meaning that with RS-232 on SMP systems DMA is also stopped just early enough to not bork the circular xmit buffer. If this is true then the imx driver did not really use TX DMA in practice before. Thoughts? I'll try to trace this next week to verify these hypotheses. Best regards, Clemens
Re: [RESEND PATCH v5] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs
On Mon, Aug 14, 2017 at 01:01:22PM +0100, Will Deacon wrote: > Yeah, that's right, you can't use the STXR status flag to create control > dependencies. Just for my elucidation; you can't use it to create a control dependency on the store, but you can use it to create a control dependency on the corresponding load, right? Now, IIRC, we've defined control dependencies as being LOAD->STORE ordering, so in that respect nothing is lost. But maybe we should explicitly mention that if the LOAD is part of an (otherwise) atomic RmW the STORE is not constrained.
[PATCH v4 1/2] sched/clock: interface to allow timestamps early in boot
In Linux printk() can output timestamps next to every line. This is very useful for tracking regressions, and finding places that can be optimized. However, the timestamps are available only later in boot. On smaller machines it is insignificant amount of time, but on larger it can be many seconds or even minutes into the boot process. This patch adds an interface for platforms with unstable sched clock to show timestamps early in boot. In order to get this functionality a platform must do: - Implement u64 sched_clock_early() Clock that returns monotonic time - Call sched_clock_early_init() Tells sched clock that the early clock can be used - Call sched_clock_early_fini() Tells sched clock that the early clock is finished, and sched clock should hand over the operation to permanent clock. - Use weak sched_clock_early() interface to determine time from boot in arch specific read_boot_clock64() Signed-off-by: Pavel Tatashin--- arch/x86/kernel/time.c | 23 + include/linux/sched/clock.h | 4 +++ kernel/sched/clock.c| 63 - 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c index e0754cdbad37..be458ea979e7 100644 --- a/arch/x86/kernel/time.c +++ b/arch/x86/kernel/time.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -95,3 +96,25 @@ void __init time_init(void) { late_time_init = x86_late_time_init; } + +/* + * Called once during to boot to initialize boot time. + */ +void read_boot_clock64(struct timespec64 *ts) +{ + u64 ns_boot = sched_clock_early(); /* nsec from boot */ + struct timespec64 ts_now; + bool valid_clock; + u64 ns_now; + + /* Time from epoch */ + read_persistent_clock64(_now); + ns_now = timespec64_to_ns(_now); + valid_clock = ns_boot && timespec64_valid_strict(_now) && + (ns_now > ns_boot); + + if (!valid_clock) + *ts = (struct timespec64){0, 0}; + else + *ts = ns_to_timespec64(ns_now - ns_boot); +} diff --git a/include/linux/sched/clock.h b/include/linux/sched/clock.h index a55600ffdf4b..f8291fa28c0c 100644 --- a/include/linux/sched/clock.h +++ b/include/linux/sched/clock.h @@ -63,6 +63,10 @@ extern void sched_clock_tick_stable(void); extern void sched_clock_idle_sleep_event(void); extern void sched_clock_idle_wakeup_event(void); +void sched_clock_early_init(void); +void sched_clock_early_fini(void); +u64 sched_clock_early(void); + /* * As outlined in clock.c, provides a fast, high resolution, nanosecond * time source that is monotonic per cpu argument and has bounded drift diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c index ca0f8fc945c6..72beb1ba3ddb 100644 --- a/kernel/sched/clock.c +++ b/kernel/sched/clock.c @@ -80,9 +80,26 @@ EXPORT_SYMBOL_GPL(sched_clock); __read_mostly int sched_clock_running; +/* + * Because static branches cannot be altered before jump_label_init() is called, + * and early time stamps may be initialized before that, we start with sched + * clock early static branch enabled, and global status disabled. Early in boot + * it is decided whether to enable the global status as well (set + * sched_clock_early_running to true), and later, when early clock is no longer + * needed, the static branch is disabled to keep hot-path fast. + */ +static DEFINE_STATIC_KEY_TRUE(__use_sched_clock_early); +static bool __read_mostly sched_clock_early_running; + void sched_clock_init(void) { - sched_clock_running = 1; + /* +* We start clock only once early clock is finished, or if early clock +* was not running. +*/ + if (!sched_clock_early_running) + sched_clock_running = 1; + } #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK @@ -362,6 +379,11 @@ u64 sched_clock_cpu(int cpu) if (sched_clock_stable()) return sched_clock() + __sched_clock_offset; + if (static_branch_unlikely(&__use_sched_clock_early)) { + if (sched_clock_early_running) + return sched_clock_early(); + } + if (unlikely(!sched_clock_running)) return 0ull; @@ -444,6 +466,45 @@ void sched_clock_idle_wakeup_event(void) } EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event); +u64 __weak sched_clock_early(void) +{ + return 0; +} + +/* + * Is called when sched_clock_early() is about to be finished, notifies sched + * clock that after this call sched_clock_early() can't be used. + */ +void __init sched_clock_early_fini(void) +{ + struct sched_clock_data *scd = this_scd(); + u64 now_early, now_sched; + + now_early = sched_clock_early(); + now_sched = sched_clock(); + + __gtod_offset = now_early - scd->tick_gtod; + __sched_clock_offset = now_early - now_sched; + +
[PATCH v4 2/2] x86/tsc: use tsc early
tsc_early_init(): Use verious methods to determine the availability of TSC feature and its frequency early in boot, and if that is possible initialize TSC and also call sched_clock_early_init() to be able to get timestamps early in boot. tsc_early_fini() Implement the finish part of early tsc feature, print message about the offset, which can be useful to findout how much time was spent in post and boot manager, and also call sched_clock_early_fini() to let sched clock know that sched_clock_early(): TSC based implementation of weak function that is defined in sched clock. Call tsc_early_init() to initialize early boot time stamps functionality on the supported x86 platforms, and call tsc_early_fini() to finish this feature after permanent tsc has been initialized. Signed-off-by: Pavel Tatashin--- arch/x86/include/asm/tsc.h | 4 arch/x86/kernel/setup.c| 10 -- arch/x86/kernel/time.c | 1 + arch/x86/kernel/tsc.c | 47 ++ 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h index f5e6f1c417df..6dc9618b24e3 100644 --- a/arch/x86/include/asm/tsc.h +++ b/arch/x86/include/asm/tsc.h @@ -50,11 +50,15 @@ extern bool tsc_store_and_check_tsc_adjust(bool bootcpu); extern void tsc_verify_tsc_adjust(bool resume); extern void check_tsc_sync_source(int cpu); extern void check_tsc_sync_target(void); +void tsc_early_init(unsigned int khz); +void tsc_early_fini(void); #else static inline bool tsc_store_and_check_tsc_adjust(bool bootcpu) { return false; } static inline void tsc_verify_tsc_adjust(bool resume) { } static inline void check_tsc_sync_source(int cpu) { } static inline void check_tsc_sync_target(void) { } +static inline void tsc_early_init(unsigned int khz) { } +static inline void tsc_early_fini(void) { } #endif extern int notsc_setup(char *); diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 3486d0498800..413434d98a23 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -812,7 +812,11 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) return 0; } -static void __init simple_udelay_calibration(void) +/* + * Initialize early tsc to show early boot timestamps, and also loops_per_jiffy + * for udelay + */ +static void __init early_clock_calibration(void) { unsigned int tsc_khz, cpu_khz; unsigned long lpj; @@ -827,6 +831,8 @@ static void __init simple_udelay_calibration(void) if (!tsc_khz) return; + tsc_early_init(tsc_khz); + lpj = tsc_khz * 1000; do_div(lpj, HZ); loops_per_jiffy = lpj; @@ -1039,7 +1045,7 @@ void __init setup_arch(char **cmdline_p) */ init_hypervisor_platform(); - simple_udelay_calibration(); + early_clock_calibration(); x86_init.resources.probe_roms(); diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c index be458ea979e7..2c82c7e0f747 100644 --- a/arch/x86/kernel/time.c +++ b/arch/x86/kernel/time.c @@ -86,6 +86,7 @@ static __init void x86_late_time_init(void) { x86_init.timers.timer_init(); tsc_init(); + tsc_early_fini(); } /* diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 796d96bb0821..bd44c2dd4235 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -1263,6 +1263,53 @@ static int __init init_tsc_clocksource(void) */ device_initcall(init_tsc_clocksource); +#ifdef CONFIG_X86_TSC + +static struct cyc2ns_data cyc2ns_early; +static bool sched_clock_early_enabled; + +u64 sched_clock_early(void) +{ + u64 ns; + + if (!sched_clock_early_enabled) + return 0; + ns = mul_u64_u32_shr(rdtsc(), cyc2ns_early.cyc2ns_mul, +cyc2ns_early.cyc2ns_shift); + return ns + cyc2ns_early.cyc2ns_offset; +} + +/* + * Initialize clock for early time stamps + */ +void __init tsc_early_init(unsigned int khz) +{ + sched_clock_early_enabled = true; + clocks_calc_mult_shift(_early.cyc2ns_mul, + _early.cyc2ns_shift, + khz, NSEC_PER_MSEC, 0); + cyc2ns_early.cyc2ns_offset = -sched_clock_early(); + sched_clock_early_init(); +} + +void __init tsc_early_fini(void) +{ + unsigned long long t; + unsigned long r; + + /* We did not have early sched clock if multiplier is 0 */ + if (cyc2ns_early.cyc2ns_mul == 0) + return; + + t = -cyc2ns_early.cyc2ns_offset; + r = do_div(t, NSEC_PER_SEC); + + sched_clock_early_fini(); + pr_info("sched clock early is finished, offset [%lld.%09lds]\n", t, r); + sched_clock_early_enabled = false; +} +#endif /* CONFIG_X86_TSC */ + void __init tsc_init(void) { u64 lpj, cyc; -- 2.14.1
[PATCH v4 0/2] Early boot time stamps for x86
changelog - v3 - v4 - Fixed tsc_early_fini() call to be in the 2nd patch as reported by Dou Liyang - Improved comment before __use_sched_clock_early to explain why we need both booleans. - Simplified valid_clock logic in read_boot_clock64(). v2 - v3 - Addressed comment from Thomas Gleixner - Timestamps are available a little later in boot but still much earlier than in mainline. This significantly simplified this work. v1 - v2 In patch "x86/tsc: tsc early": - added tsc_adjusted_early() - fixed 32-bit compile error use do_div() Adding early boot time stamps support for x86 machines. SPARC patches for early boot time stamps are already integrated into mainline linux. Sample output - Before: https://hastebin.com/jadaqukubu.scala After: https://hastebin.com/nubipozacu.scala As seen above, currently timestamps are available from around the time when "Security Framework" is initialized. But, 26s already passed until we reached to this point. Pavel Tatashin (2): sched/clock: interface to allow timestamps early in boot x86/tsc: use tsc early arch/x86/include/asm/tsc.h | 4 +++ arch/x86/kernel/setup.c | 10 +-- arch/x86/kernel/time.c | 24 + arch/x86/kernel/tsc.c | 47 + include/linux/sched/clock.h | 4 +++ kernel/sched/clock.c| 63 - 6 files changed, 149 insertions(+), 3 deletions(-) -- 2.14.1
Re: [PATCH] i2c: core: Make comment about I2C table requirement to reflect the code
On Wed, Aug 09, 2017 at 11:21:28AM +0200, Javier Martinez Canillas wrote: > I2C drivers were required to have an I2C device ID table even if were for > devices that would only be registered using a specific firmware interface > (e.g: OF or ACPI). > > But commit da10c06a044b ("i2c: Make I2C ID tables non-mandatory for DT'ed > devices") changed the I2C core to relax the requirement and allow drivers > to avoid defining this table. > > Unfortunately it only took into account drivers for OF-only devices and > forgot about ACPI-only ones, and this was fixed by commit c647a9d1 > ("i2c: core: Allow empty id_table in ACPI case as well"). > > But the latter didn't update the original comment, so it doesn't reflect > what the code does now. > > Signed-off-by: Javier Martinez CanillasApplied to for-current, thanks! signature.asc Description: PGP signature
[PATCH v4 1/3] nvmet_execute_identify_ctrl: don't overwrite with 0-bytes
The merged version of my patch "nvmet: don't report 0-bytes in serial number" fails to remove two lines which should have been replaced, so that the space-padded strings are overwritten again with 0-bytes. Fix it. Fixes: 42de82a8b544 nvmet: don't report 0-bytes in serial number Signed-off-by: Martin Wilck--- drivers/nvme/target/admin-cmd.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 2d7a98ab53fbf..a53bb6635b837 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -199,12 +199,6 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1); copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE)); - memset(id->mn, ' ', sizeof(id->mn)); - strncpy((char *)id->mn, "Linux", sizeof(id->mn)); - - memset(id->fr, ' ', sizeof(id->fr)); - strncpy((char *)id->fr, UTS_RELEASE, sizeof(id->fr)); - id->rab = 6; /* -- 2.14.0
[PATCH v4 3/3] nvmet_execute_identify_ctrl: use memcpy_and_pad()
This changes the earlier patch "nvmet: don't report 0-bytes in serial number" to use the memcpy_and_pad() helper introduced in a previous patch. Signed-off-by: Martin Wilck--- drivers/nvme/target/admin-cmd.c | 14 +++--- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index a53bb6635b837..7ccea863e0ab5 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -168,15 +168,6 @@ static void nvmet_execute_get_log_page(struct nvmet_req *req) nvmet_req_complete(req, status); } -static void copy_and_pad(char *dst, int dst_len, const char *src, int src_len) -{ - int len = min(src_len, dst_len); - - memcpy(dst, src, len); - if (dst_len > len) - memset(dst + len, ' ', dst_len - len); -} - static void nvmet_execute_identify_ctrl(struct nvmet_req *req) { struct nvmet_ctrl *ctrl = req->sq->ctrl; @@ -196,8 +187,9 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) bin2hex(id->sn, >subsys->serial, min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2)); - copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1); - copy_and_pad(id->fr, sizeof(id->fr), UTS_RELEASE, strlen(UTS_RELEASE)); + memcpy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1, ' '); + memcpy_and_pad(id->fr, sizeof(id->fr), + UTS_RELEASE, strlen(UTS_RELEASE), ' '); id->rab = 6; -- 2.14.0
[PATCH v4 0/3] Improve readbility of NVME "wwid" attribute (target side)
Hi Christoph, I'm reposting the target-side of my patch rebased against 4.13-rc as requested. NOTE: an error has occurred while merging the previous version of my patch. This is fixed by patch 1/3 in the series - that's an important fix for 4.13, please push forward. 2/3 and 3/3 move the "copy_and_pad" functionality to a generic helper, as requested. I've split this off in case the generic function meets criticism elsewhere. Original cover letter: With the current implementation, the default "fallback" WWID generation code (if no nguid, euid etc. are defined) for Linux NVME host and target results in the following WWID format: nvme.-3163653363666438366239656630386200-4c696e757800-0002 This is not only hard to read, it poses real problems e.g. for multipath (dm WWIDs are limited to 128 characters). With this patch series, the WWID on a Linux host connected to a Linux target looks like this: nvme.-65613435333665653738613464363961-4c696e7578-0001 Changes wrt v1: * 1/3: new, moved helper to include/linux/string.h (Christoph Hellwig) (you suggested kernel.h, but I think this matches string.h better) * Dropped the last patch from the v1 series that would have changed valid WWIDs for HW NVME controllers. Changes wrt v2: * 3/3: Make sure no underflow occurs (Joe Perches) Changes wrt v3: * Rebased on 4.13-rc3. * Dropped client-side patch which was merged in nvme-4.13 already. * Split off bug fix (patch 1/3). Martin Wilck (3): nvmet_execute_identify_ctrl: don't overwrite with 0-bytes string.h: add memcpy_and_pad() nvmet_execute_identify_ctrl: use memcpy_and_pad() drivers/nvme/target/admin-cmd.c | 20 +++- include/linux/string.h | 30 ++ 2 files changed, 33 insertions(+), 17 deletions(-) -- 2.14.0
[PATCH v4 2/3] string.h: add memcpy_and_pad()
This helper function is useful for the nvme subsystem, and maybe others. Note: the warnings reported by the kbuild test robot for this patch are actually generated by the use of CONFIG_PROFILE_ALL_BRANCHES together with __FORTIFY_INLINE. Signed-off-by: Martin Wilck--- include/linux/string.h | 30 ++ 1 file changed, 30 insertions(+) diff --git a/include/linux/string.h b/include/linux/string.h index a467e617eeb08..0bec4151b0eb9 100644 --- a/include/linux/string.h +++ b/include/linux/string.h @@ -200,6 +200,7 @@ static inline const char *kbasename(const char *path) void fortify_panic(const char *name) __noreturn __cold; void __read_overflow(void) __compiletime_error("detected read beyond size of object passed as 1st parameter"); void __read_overflow2(void) __compiletime_error("detected read beyond size of object passed as 2nd parameter"); +void __read_overflow3(void) __compiletime_error("detected read beyond size of object passed as 3rd parameter"); void __write_overflow(void) __compiletime_error("detected write beyond size of object passed as 1st parameter"); #if !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE) @@ -395,4 +396,33 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q) #endif +/** + * memcpy_and_pad - Copy one buffer to another with padding + * @dest: Where to copy to + * @dest_len: The destination buffer size + * @src: Where to copy from + * @count: The number of bytes to copy + * @pad: Character to use for padding if space is left in destination. + */ +__FORTIFY_INLINE void memcpy_and_pad(void *dest, size_t dest_len, +const void *src, size_t count, int pad) +{ + size_t dest_size = __builtin_object_size(dest, 0); + size_t src_size = __builtin_object_size(src, 0); + + if (__builtin_constant_p(dest_len) && __builtin_constant_p(count)) { + if (dest_size < dest_len && dest_size < count) + __write_overflow(); + else if (src_size < dest_len && src_size < count) + __read_overflow3(); + } + if (dest_size < dest_len) + fortify_panic(__func__); + if (dest_len > count) { + memcpy(dest, src, count); + memset(dest + count, pad, dest_len - count); + } else + memcpy(dest, src, dest_len); +} + #endif /* _LINUX_STRING_H_ */ -- 2.14.0
[PATCH] platform/x86: intel_cht_int33fe: Work around BIOS bug on some devices
At least one BIOS enumerates the max17047 both through the INT33FE ACPI device (it is right there in the resources table) as well as through a separate MAX17047 device. This commit checks for the max17047 already being enumerated through a separate MAX17047 ACPI device and if so it uses the i2c-client instantiated for this and attaches the device-props for the max17047 to that i2c-client. Signed-off-by: Hans de Goede--- drivers/platform/x86/intel_cht_int33fe.c | 64 +++- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/intel_cht_int33fe.c b/drivers/platform/x86/intel_cht_int33fe.c index da706e2c4232..5f1924fb3190 100644 --- a/drivers/platform/x86/intel_cht_int33fe.c +++ b/drivers/platform/x86/intel_cht_int33fe.c @@ -34,6 +34,35 @@ struct cht_int33fe_data { struct i2c_client *pi3usb30532; }; +/* + * Grrr I severly dislike buggy BIOS-es. At least one BIOS enumerates + * the max17047 both through the INT33FE ACPI device (it is right there + * in the resources table) as well as through a separate MAX17047 device. + * + * These helpers are used to work around this by checking if an i2c-client + * for the max17047 has already been registered. + */ +int cht_int33fe_check_for_max17047(struct device *dev, void *data) +{ + const char *name = dev_name(dev); + struct i2c_client **max17047 = data; + + if (name && strcmp(name, "i2c-MAX17047:00") == 0) { + *max17047 = to_i2c_client(dev); + return 1; + } + + return 0; +} + +struct i2c_client *cht_int33fe_find_max17047(void) +{ + struct i2c_client *max17047 = NULL; + + i2c_for_each_dev(, cht_int33fe_check_for_max17047); + return max17047; +} + static const char * const max17047_suppliers[] = { "bq24190-charger" }; static const struct property_entry max17047_props[] = { @@ -46,9 +75,10 @@ static int cht_int33fe_probe(struct i2c_client *client) struct device *dev = >dev; struct i2c_board_info board_info; struct cht_int33fe_data *data; + struct i2c_client *max17047; unsigned long long ptyp; acpi_status status; - int fusb302_irq; + int ret, fusb302_irq; status = acpi_evaluate_integer(ACPI_HANDLE(dev), "PTYP", NULL, ); if (ACPI_FAILURE(status)) { @@ -75,13 +105,25 @@ static int cht_int33fe_probe(struct i2c_client *client) if (!data) return -ENOMEM; - memset(_info, 0, sizeof(board_info)); - strlcpy(board_info.type, "max17047", I2C_NAME_SIZE); - board_info.properties = max17047_props; - - data->max17047 = i2c_acpi_new_device(dev, 1, _info); - if (!data->max17047) - return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */ + /* Work around BIOS bug, see comment on cht_int33fe_find_max17047 */ + max17047 = cht_int33fe_find_max17047(); + if (max17047) { + /* Pre-existing i2c-client for the max17047, add device-props */ + ret = device_add_properties(>dev, max17047_props); + if (ret) + return ret; + /* And re-probe to get the new device-props applied. */ + ret = device_reprobe(>dev); + if (ret) + dev_warn(dev, "Reprobing max17047 error: %d\n", ret); + } else { + memset(_info, 0, sizeof(board_info)); + strlcpy(board_info.type, "max17047", I2C_NAME_SIZE); + board_info.properties = max17047_props; + data->max17047 = i2c_acpi_new_device(dev, 1, _info); + if (!data->max17047) + return -EPROBE_DEFER; /* Wait for i2c-adapter to load */ + } memset(_info, 0, sizeof(board_info)); strlcpy(board_info.type, "fusb302", I2C_NAME_SIZE); @@ -106,7 +148,8 @@ static int cht_int33fe_probe(struct i2c_client *client) i2c_unregister_device(data->fusb302); out_unregister_max17047: - i2c_unregister_device(data->max17047); + if (data->max17047) + i2c_unregister_device(data->max17047); return -EPROBE_DEFER; /* Wait for the i2c-adapter to load */ } @@ -117,7 +160,8 @@ static int cht_int33fe_remove(struct i2c_client *i2c) i2c_unregister_device(data->pi3usb30532); i2c_unregister_device(data->fusb302); - i2c_unregister_device(data->max17047); + if (data->max17047) + i2c_unregister_device(data->max17047); return 0; } -- 2.13.4
Re: [PATCH v5 10/10] lkdtm: Add test for XPFO
On Mon, Aug 14, 2017 at 12:10:47PM -0700, Kees Cook wrote: > On Wed, Aug 9, 2017 at 1:07 PM, Tycho Andersenwrote: > > From: Juerg Haefliger > > > > This test simply reads from userspace memory via the kernel's linear > > map. > > > > hugepages is only supported on x86 right now, hence the ifdef. > > I'd prefer that the #ifdef is handled in the .c file. The result is > that all architectures will have the XPFO_READ_USER_HUGE test, but it > can just fail when not available. This means no changes are needed for > lkdtm in the future and the test provides an actual test of hugepages > coverage. If failing tests is okay, I think we can just drop that hunk entirely. Everything compiles fine, it just doesn't work :). I'll do that for the next version. Tycho
Re: [PATCH v3] platform/x86: ideapad-laptop: Expose conservation mode switch
On Mon, Aug 14, 2017 at 7:13 PM, Hao Wei Teewrote: > This exposes the battery conservation mode present on some (?) IdeaPads. > The mode is set by calling ACPI method SBMC with argument 3 (on) or > 5 (off). Status is reported in bit 5 of the return value of ACPI method > GBMD. > Pushed to testing, thanks! > Signed-off-by: Hao Wei Tee > --- > v3: Stylistic changes > > drivers/platform/x86/ideapad-laptop.c | 69 > +++ > 1 file changed, 69 insertions(+) > > diff --git a/drivers/platform/x86/ideapad-laptop.c > b/drivers/platform/x86/ideapad-laptop.c > index 603fc6050971..fe98d4ac0df3 100644 > --- a/drivers/platform/x86/ideapad-laptop.c > +++ b/drivers/platform/x86/ideapad-laptop.c > @@ -42,6 +42,8 @@ > > #define IDEAPAD_RFKILL_DEV_NUM (3) > > +#define BM_CONSERVATION_BIT (5) > + > #define CFG_BT_BIT (16) > #define CFG_3G_BIT (17) > #define CFG_WIFI_BIT (18) > @@ -54,6 +56,11 @@ static const char *const ideapad_wmi_fnesc_events[] = { > }; > #endif > > +enum { > + BMCMD_CONSERVATION_ON = 3, > + BMCMD_CONSERVATION_OFF = 5, > +}; > + > enum { > VPCCMD_R_VPC1 = 0x10, > VPCCMD_R_BL_MAX, > @@ -123,6 +130,23 @@ static int read_method_int(acpi_handle handle, const > char *method, int *val) > } > } > > +static int method_gbmd(acpi_handle handle, unsigned long *ret) > +{ > + int result, val; > + > + result = read_method_int(handle, "GBMD", ); > + *ret = val; > + return result; > +} > + > +static int method_sbmc(acpi_handle handle, int cmd) > +{ > + acpi_status status; > + > + status = acpi_execute_simple_method(handle, "SBMC", cmd); > + return ACPI_FAILURE(status) ? -1 : 0; > +} > + > static int method_vpcr(acpi_handle handle, int cmd, int *ret) > { > acpi_status status; > @@ -250,6 +274,13 @@ static int debugfs_status_show(struct seq_file *s, void > *data) > if (!read_ec_data(priv->adev->handle, VPCCMD_R_CAMERA, )) > seq_printf(s, "Camera status:\t%s(%lu)\n", >value ? "On" : "Off", value); > + seq_puts(s, "=\n"); > + > + if (!method_gbmd(priv->adev->handle, )) { > + seq_printf(s, "Conservation mode:\t%s(%lu)\n", > + test_bit(BM_CONSERVATION_BIT, ) ? "On" : > "Off", > + value); > + } > > return 0; > } > @@ -456,10 +487,45 @@ static ssize_t __maybe_unused touchpad_store(struct > device *dev, > > static DEVICE_ATTR_RO(touchpad); > > +static ssize_t conservation_mode_show(struct device *dev, > + struct device_attribute *attr, > + char *buf) > +{ > + struct ideapad_private *priv = dev_get_drvdata(dev); > + unsigned long result; > + > + if (method_gbmd(priv->adev->handle, )) > + return sprintf(buf, "-1\n"); > + return sprintf(buf, "%u\n", test_bit(BM_CONSERVATION_BIT, )); > +} > + > +static ssize_t conservation_mode_store(struct device *dev, > +struct device_attribute *attr, > +const char *buf, size_t count) > +{ > + struct ideapad_private *priv = dev_get_drvdata(dev); > + bool state; > + int ret; > + > + ret = kstrtobool(buf, ); > + if (ret) > + return ret; > + > + ret = method_sbmc(priv->adev->handle, state ? > + BMCMD_CONSERVATION_ON : > + BMCMD_CONSERVATION_OFF); > + if (ret < 0) > + return -EIO; > + return count; > +} > + > +static DEVICE_ATTR_RW(conservation_mode); > + > static struct attribute *ideapad_attributes[] = { > _attr_camera_power.attr, > _attr_fan_mode.attr, > _attr_touchpad.attr, > + _attr_conservation_mode.attr, > NULL > }; > > @@ -477,6 +543,9 @@ static umode_t ideapad_is_visible(struct kobject *kobj, > unsigned long value; > supported = !read_ec_data(priv->adev->handle, VPCCMD_R_FAN, > ); > + } else if (attr == _attr_conservation_mode.attr) { > + supported = acpi_has_method(priv->adev->handle, "GBMD") && > + acpi_has_method(priv->adev->handle, "SBMC"); > } else > supported = true; > > -- > 2.14.1 > -- With Best Regards, Andy Shevchenko
Re: nouveau driver locks up with 4.11 kernel
On Mon 14-08-17 15:27:20, Ilia Mirkin wrote: > On Mon, Aug 14, 2017 at 3:18 PM, Michal Hockowrote: [...] > > nouveau :03:00.0: fifo: channel 6 [mpv/vo[3535]] kick timeout > > nouveau: mpv/vo[3535]::906f: detach gr failed, -110 > > Are you using mpv in conjunction with the GL video output and > VDPAU-based acceleration? That will kill nouveau. For VDPAU, I > recommend mplayer. Well, I am using mplayer package and vo=sdl. Which video output should I try instead? Btw. xine seems to be using VDPAU as well, yet it doesn't lockup the whole X session. The videou output doesn't work properly either but at least I am able to kill xine and still have the session. -- Michal Hocko SUSE Labs
[PATCH v5 4/9] mtd: nand: sharpsl: Register partitions using the parsers
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done in the board files using this driver. Use now these parsers. Signed-off-by: Andrea Adami--- drivers/mtd/nand/sharpsl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c index 064ca17..9859546 100644 --- a/drivers/mtd/nand/sharpsl.c +++ b/drivers/mtd/nand/sharpsl.c @@ -183,7 +183,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev) /* Register the partitions */ mtd->name = "sharpsl-nand"; - err = mtd_device_parse_register(mtd, NULL, NULL, + err = mtd_device_parse_register(mtd, data->part_parsers, NULL, data->partitions, data->nr_partitions); if (err) goto err_add; -- 2.7.4
[PATCH v5 1/9] mtd: sharpslpart: Add sharpslpart partition parser
The Sharp SL Series (Zaurus) PXA handhelds have 16/64/128M of NAND flash and share the same layout of the first 7M partition, managed by Sharp FTL. The purpose of this self-contained patch is to add a common parser and remove the hardcoded sizes in the board files (these devices are not yet converted to devicetree). Users will have benefits because the mtdparts= tag will not be necessary anymore and they will be free to repartition the little sized flash. The obsolete bootloader can not pass the partitioning info to modern kernels anymore so it has to be read from flash at known logical addresses. (see http://www.h5.dion.ne.jp/~rimemoon/zaurus/memo_006.htm ) In kernel, under arch/arm/mach-pxa we have already 8 machines: MACH_POODLE, MACH_CORGI, MACH_SHEPERD, MACH_HUSKY, MACH_AKITA, MACH_SPITZ, MACH_BORZOI, MACH_TOSA. Lost after the 2.4 vendor kernel are MACH_BOXER and MACH_TERRIER. Almost every model has different factory partitioning: add to this the units can be repartitioned by users with userspace tools (nandlogical) and installers for popular (back then) linux distributions. The Parameter Area in the first (boot) partition extends from 0x0004 to 0x0007bfff (176k) and contains two copies of the partition table: ... 0x0006: Partition Info1 16k 0x00064000: Partition Info2 16k 0x00668000: Model 16k ... The first 7M partition is managed by the Sharp FTL reserving 5% + 1 blocks for wear-leveling: some blocks are remapped and one layer of translation (logical to physical) is necessary. There isn't much documentation about this FTL in the 2.4 sources, just the MTD methods for reading and writing using logical addresses and the block management (wear-leveling, use counter). For the purpose of the MTD parser only the read part of the code was taken. The NAND drivers that can use this parser are sharpsl.c and tmio_nand.c. Signed-off-by: Andrea Adami--- drivers/mtd/parsers/Kconfig | 8 + drivers/mtd/parsers/Makefile | 1 + drivers/mtd/parsers/sharpslpart.c | 376 ++ 3 files changed, 385 insertions(+) create mode 100644 drivers/mtd/parsers/sharpslpart.c diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig index d206b3c..ee5ab99 100644 --- a/drivers/mtd/parsers/Kconfig +++ b/drivers/mtd/parsers/Kconfig @@ -6,3 +6,11 @@ config MTD_PARSER_TRX may contain up to 3/4 partitions (depending on the version). This driver will parse TRX header and report at least two partitions: kernel and rootfs. + +config MTD_SHARPSL_PARTS + tristate "Sharp SL Series NAND flash partition parser" + depends on MTD_NAND_SHARPSL || MTD_NAND_TMIO || COMPILE_TEST + help + This provides the read-only FTL logic necessary to read the partition + table from the NAND flash of Sharp SL Series (Zaurus) and the MTD + partition parser using this code. diff --git a/drivers/mtd/parsers/Makefile b/drivers/mtd/parsers/Makefile index 4d9024e..5b1bcc3 100644 --- a/drivers/mtd/parsers/Makefile +++ b/drivers/mtd/parsers/Makefile @@ -1 +1,2 @@ obj-$(CONFIG_MTD_PARSER_TRX) += parser_trx.o +obj-$(CONFIG_MTD_SHARPSL_PARTS)+= sharpslpart.o diff --git a/drivers/mtd/parsers/sharpslpart.c b/drivers/mtd/parsers/sharpslpart.c new file mode 100644 index 000..2511059 --- /dev/null +++ b/drivers/mtd/parsers/sharpslpart.c @@ -0,0 +1,376 @@ +/* + * sharpslpart.c - MTD partition parser for NAND flash using the SHARP FTL + * for logical addressing, as used on the PXA models of the SHARP SL Series. + * + * Copyright (C) 2017 Andrea Adami + * + * Based on 2.4 sources: + * drivers/mtd/nand/sharp_sl_logical.c + * linux/include/asm-arm/sharp_nand_logical.h + * + * Copyright (C) 2002 SHARP + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include + +/* oob structure */ +#define NAND_NOOB_LOGADDR_00 8 +#define NAND_NOOB_LOGADDR_01 9 +#define NAND_NOOB_LOGADDR_10 10 +#define NAND_NOOB_LOGADDR_11 11 +#define NAND_NOOB_LOGADDR_20 12 +#define NAND_NOOB_LOGADDR_21 13 + +#define BLOCK_IS_RESERVED 0x +#define BLOCK_UNMASK 0x07fe +#define BLOCK_UNMASK_COMPLEMENT1 + +/* factory defaults */ +#define SHARPSL_NAND_PARTS 3 +#define SHARPSL_FTL_PARTITION_SIZE (7 * 1024 * 1024) +#define
[PATCH v5 6/9] ARM: pxa/corgi: Remove hardcoded partitioning, use sharpslpart parser
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done here in the board file. Signed-off-by: Andrea Adami--- arch/arm/mach-pxa/corgi.c | 31 --- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index 7270f0d..9546452 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -606,24 +606,6 @@ static void __init corgi_init_spi(void) static inline void corgi_init_spi(void) {} #endif -static struct mtd_partition sharpsl_nand_partitions[] = { - { - .name = "System Area", - .offset = 0, - .size = 7 * 1024 * 1024, - }, - { - .name = "Root Filesystem", - .offset = 7 * 1024 * 1024, - .size = 25 * 1024 * 1024, - }, - { - .name = "Home Filesystem", - .offset = MTDPART_OFS_APPEND, - .size = MTDPART_SIZ_FULL, - }, -}; - static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; static struct nand_bbt_descr sharpsl_bbt = { @@ -633,10 +615,16 @@ static struct nand_bbt_descr sharpsl_bbt = { .pattern = scan_ff_pattern }; +static const char * const probes[] = { + "cmdlinepart", + "ofpart", + "sharpslpart", + NULL, +}; + static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = { .badblock_pattern = _bbt, - .partitions = sharpsl_nand_partitions, - .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions), + .part_parsers = probes, }; static struct resource sharpsl_nand_resources[] = { @@ -750,9 +738,6 @@ static void __init corgi_init(void) platform_scoop_config = _pcmcia_config; - if (machine_is_husky()) - sharpsl_nand_partitions[1].size = 53 * 1024 * 1024; - platform_add_devices(devices, ARRAY_SIZE(devices)); regulator_has_full_constraints(); -- 2.7.4
[PATCH v5 5/9] mtd: nand: tmio: Register partitions using the parsers
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done in the board files using this driver. Use now these parsers. Signed-off-by: Andrea Adami--- drivers/mtd/nand/tmio_nand.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c index fc5e773..47f439f 100644 --- a/drivers/mtd/nand/tmio_nand.c +++ b/drivers/mtd/nand/tmio_nand.c @@ -440,7 +440,9 @@ static int tmio_probe(struct platform_device *dev) goto err_irq; /* Register the partitions */ - retval = mtd_device_parse_register(mtd, NULL, NULL, + retval = mtd_device_parse_register(mtd, + data ? data->part_parsers : NULL, + NULL, data ? data->partition : NULL, data ? data->num_partitions : 0); if (!retval) -- 2.7.4
[PATCH v5 2/9] mtd: nand: sharpsl: Add partition parsers platform data
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done in the board files using this driver. Thus, we need to extend sharpsl_nand_platform_data to consider the partition parsers. Signed-off-by: Andrea Adami--- include/linux/mtd/sharpsl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/mtd/sharpsl.h b/include/linux/mtd/sharpsl.h index 65e91d0..6381a7d 100644 --- a/include/linux/mtd/sharpsl.h +++ b/include/linux/mtd/sharpsl.h @@ -17,4 +17,5 @@ struct sharpsl_nand_platform_data { const struct mtd_ooblayout_ops *ecc_layout; struct mtd_partition*partitions; unsigned intnr_partitions; + const char *const *part_parsers; }; -- 2.7.4
Re: [PATCH] selftests: timers: freq-step: fix compile error
On Mon, Aug 14, 2017 at 1:17 PM, Shuah Khanwrote: > On 08/14/2017 02:12 PM, John Stultz wrote: >> On Wed, Aug 9, 2017 at 3:05 PM, Shuah Khan wrote: >>> Fix compile error due to ksft_exit_skip() update to take var_args. >>> >>> freq-step.c: In function ‘init_test’: >>> freq-step.c:234:3: error: too few arguments to function ‘ksft_exit_skip’ >>>ksft_exit_skip(); >>>^~ >>> In file included from freq-step.c:26:0: >>> ../kselftest.h:167:19: note: declared here >>> static inline int ksft_exit_skip(const char *msg, ...) >>>^~ >>> : recipe for target 'freq-step' failed >>> >>> Signed-off-by: Shuah Khan >> >> >> Acked-by: John Stultz >> >> This is a build regression in 4.13-rc so should go-to Linus promptly. >> >> (Shuah: Let me know if you want me to send this in via Thomas, or you >> want to send it in directly) >> >> thanks >> -john >> > > John, > > I am planning to send it to Linus with a few other fixes in linux-kselftest > fixes branch for 4.13-rc6 I also have two more less critical build fixups to that test to add, which I'll send out here in a second for review. thanks -john
RE: [[PATCH v1] 24/37] [CIFS] SMBD: Support for SMBD keep alive protocol
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Long Li > Sent: Wednesday, August 2, 2017 4:11 PM > To: Steve French; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org > Cc: Long Li > Subject: [[PATCH v1] 24/37] [CIFS] SMBD: Support for SMBD keep alive > protocol > > SMBD uses a keep alive protocol to help peers detect if the remote is dead. > When peer request keep alive, the transport needs to respond accordingly. The keepalive exchange is also used to replenish credits in certain pathological conditions. > + // send an emtpy response right away if requested > + if (le16_to_cpu(data_transfer->flags) | > + le16_to_cpu(SMB_DIRECT_RESPONSE_REQUESTED)) { > + info->keep_alive_requested = KEEP_ALIVE_PENDING; > + } This is clearly a typo, the condition is always true. "&"?? Tom.
RE: [[PATCH v1] 25/37] [CIFS] SMBD: Support SMBD idle connection timer
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Long Li > Sent: Wednesday, August 2, 2017 4:11 PM > To: Steve French; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org > Cc: Long Li > Subject: [[PATCH v1] 25/37] [CIFS] SMBD: Support SMBD idle connection timer > > +static int keep_alive_interval = 120; This is the recommended value, but not the only possibility. > @@ -1348,6 +1369,10 @@ struct cifs_rdma_info* cifs_create_rdma_session( > init_waitqueue_head(>wait_send_queue); > init_waitqueue_head(>wait_reassembly_queue); > > + INIT_DELAYED_WORK(>idle_timer_work, idle_connection_timer); > + schedule_delayed_work(>idle_timer_work, > + info->keep_alive_interval*HZ); > + This initialization is ok, but the timer should be rescheduled (extended) any time any packet is sent. There is no need to perform keepalives on an active SMB Direct connection. Tom.
Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray
On Mon, Aug 14, 2017 at 01:39:28PM -0700, Andi Kleen wrote: > On Mon, Aug 14, 2017 at 10:15:49PM +0200, Jiri Olsa wrote: > > On Fri, Aug 11, 2017 at 04:26:16PM -0700, Andi Kleen wrote: > > > From: Andi Kleen> > > > > > Save the original array dimensions in xyarrays, so that users can > > > retrieve them > > > later. Add some inline functions to access these fields. > > > > hi, > > is there a branch with this? > > Yes > >git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-misc.git > perf/metric-group-5 > > You didn't see the 0/0 message? nope, it seems like 1/19 was the In-reply-to message 6102 r Aug 11 Andi Kleen (1.4K) [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray 6103 O Aug 11 Andi Kleen (0.6K) ├─>[PATCH v2 06/19] perf, tools: Add missing newline to expr parser error messages > > > > > also I recall sending feedback for some of those patches, > > any changes..? > > I fixed all feedback. See the individual patches. ok jirka
Re: [PATCH] device property: use of_graph_get_remote_endpoint() for of_fwnode
On Thu, Aug 10, 2017 at 04:38:16AM +, Kuninori Morimoto wrote: > From: Kuninori Morimoto> > Now, we can use of_graph_get_remote_endpoint(). Let's use it. > > Signed-off-by: Kuninori Morimoto > --- > - not tested > > drivers/of/property.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Applied, thanks. Rob
Re: [PATCH v3] powerpc/mm: Implemented default_hugepagesz verification for powerpc
Em 2017-08-04 15:17, Mike Kravetz escreveu: On 07/24/2017 04:52 PM, Victor Aoqui wrote: Implemented default hugepage size verification (default_hugepagesz=) in order to allow allocation of defined number of pages (hugepages=) only for supported hugepage sizes. Signed-off-by: Victor Aoqui--- v2: - Renamed default_hugepage_setup_sz function to hugetlb_default_size_setup; - Added powerpc string to error message. v3: - Renamed hugetlb_default_size_setup() to hugepage_default_setup_sz(); - Implemented hugetlb_bad_default_size(); - Reimplemented hugepage_setup_sz() to just parse default_hugepagesz= and check if it's a supported size; - Added verification of default_hugepagesz= value on hugetlb_nrpages_setup() before allocating hugepages. arch/powerpc/mm/hugetlbpage.c | 15 +++ include/linux/hugetlb.h | 1 + mm/hugetlb.c | 17 +++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c index e1bf5ca..5990381 100644 --- a/arch/powerpc/mm/hugetlbpage.c +++ b/arch/powerpc/mm/hugetlbpage.c @@ -780,6 +780,21 @@ static int __init hugepage_setup_sz(char *str) } __setup("hugepagesz=", hugepage_setup_sz); +static int __init hugepage_default_setup_sz(char *str) +{ + unsigned long long size; + + size = memparse(str, ); + + if (add_huge_page_size(size) != 0) { + hugetlb_bad_default_size(); + pr_err("Invalid ppc default huge page size specified(%llu)\n", size); + } + + return 1; +} +__setup("default_hugepagesz=", hugepage_default_setup_sz); + struct kmem_cache *hugepte_cache; static int __init hugetlbpage_init(void) { diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 0ed8e41..2927200 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -361,6 +361,7 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping, int __init alloc_bootmem_huge_page(struct hstate *h); void __init hugetlb_bad_size(void); +void __init hugetlb_bad_default_size(void); void __init hugetlb_add_hstate(unsigned order); struct hstate *size_to_hstate(unsigned long size); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bc48ee7..3c24266 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -54,6 +54,7 @@ static unsigned long __initdata default_hstate_max_huge_pages; static unsigned long __initdata default_hstate_size; static bool __initdata parsed_valid_hugepagesz = true; +static bool __initdata parsed_valid_default_hugepagesz = true; /* * Protects updates to hugepage_freelists, hugepage_activelist, nr_huge_pages, @@ -2804,6 +2805,12 @@ void __init hugetlb_bad_size(void) parsed_valid_hugepagesz = false; } +/* Should be called on processing a default_hugepagesz=... option */ +void __init hugetlb_bad_default_size(void) +{ + parsed_valid_default_hugepagesz = false; +} + void __init hugetlb_add_hstate(unsigned int order) { struct hstate *h; @@ -2846,8 +2853,14 @@ static int __init hugetlb_nrpages_setup(char *s) * !hugetlb_max_hstate means we haven't parsed a hugepagesz= parameter yet, * so this hugepages= parameter goes to the "default hstate". */ - else if (!hugetlb_max_hstate) - mhp = _hstate_max_huge_pages; + else if (!hugetlb_max_hstate) { + if (!parsed_valid_default_hugepagesz) { + pr_warn("hugepages = %s cannot be allocated for " + "unsupported default_hugepagesz, ignoring\n", s); + parsed_valid_default_hugepagesz = true; + } else + mhp = _hstate_max_huge_pages; + } else mhp = _hstate->max_huge_pages; My compiler tells me, mm/hugetlb.c: In function ‘hugetlb_nrpages_setup’: mm/hugetlb.c:2873:8: warning: ‘mhp’ may be used uninitialized in this function [-Wmaybe-uninitialized] You have added a way of getting out of that big if/else if statement without setting mhp. mhp will be examined later in the code, so this is indeed a bug. Like Aneesh, I am not sure if there is great benefit in this patch. You added this change in functionality only for powerpc. IMO, it would be best if behavior was consistent in all architectures. So, if we change it for powerpc we may want to change everywhere. Hi Mike, Yes, the patch mentioned by Aneesh solves the issue. Thanks -- Victor Aoqui
Re: [PATCH V2] get_maintainer: Prepare for separate MAINTAINERS files
Hi! On Wed 2017-08-02 11:15:09, Linus Torvalds wrote: > On Wed, Aug 2, 2017 at 11:06 AM, Randy Dunlapwrote: > > > > IMO, the parse-maintainters.pl (sorting) script makes the need for separate > > MAINTAINERS files much less important since the file can be "fixed" easily > > at any time. > > For me it's not the "fixing". It's the inevitable merge mess, and the > two hundred commits that I have to go through. > > That said, the extra time just to look for MAINTAINERS files makes me > unhappy. It may be just .3s on Joe's machine, but it's presumably much > more when things aren't in the filesystem caches. I (like apparently > Joe) have an SSD so it's not a big deal for me, but.. > > Just having a single MAINTAINERS directory would alleviate that >concern. Well, I am one of those slow-spinning-rust users. (I do have SSD here, but bcache is not exactly easy to configure with already-existing setup). Using git is already pretty painful... but I believe having net/MAINTAINERS file which clearly tells you who maintains this directory would save time even for me. Grepping MAINTAINERS is not currently very easy ("is it NET subsystem or NETWORK subsystem?", is it listed as "ALSA" or "ADVANCED LINUX SOUND..."?) and splitting it to directories would help a lot. Having single directory with all the MAINTAINERS files would be even worse than current situation.. Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html signature.asc Description: Digital signature
Re: [lkp-robot] [net] 98cd1552ea: BUG:unable_to_handle_kernel
On Sun, Aug 13, 2017 at 11:10 PM, kernel test robotwrote: > FYI, we noticed the following commit: > > commit: 98cd1552ea27e512c7e99e2aa76042a26e4fb25c ("net: dsa: Mock-up driver") > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master > > in testcase: trinity > with following parameters: > > runtime: 300s > > test-description: Trinity is a linux system call fuzz tester. > test-url: http://codemonkey.org.uk/projects/trinity/ > > on test machine: qemu-system-x86_64 -enable-kvm -cpu host -smp 2 -m 1G > > caused below changes (please refer to attached dmesg/kmsg for entire > log/backtrace): > > +-+++ > | | 772c3bdad1 | > 98cd1552ea | > +-+++ > | boot_successes | 0 | 0 > | > | boot_failures | 30 | 30 > | > | WARNING:at_arch/x86/mm/dump_pagetables.c:#note_page | 30 | 30 > | > | invoked_oom-killer:gfp_mask=0x | 28 | 13 > | > | Mem-Info| 28 | 13 > | > | Out_of_memory:Kill_process | 28 | 13 > | > | BUG:unable_to_handle_kernel | 0 | 16 > | > | Oops:#[##] | 0 | 16 > | > | Kernel_panic-not_syncing:Fatal_exception| 0 | 16 > | > +-+++ > > [9.603869] BUG: unable to handle kernel NULL pointer dereference at > 01f0\ The code disassembly is 0: 55 push %rbp 1: 48 89 e5mov%rsp,%rbp 4: 41 55 push %r13 6: 41 54 push %r12 8: 41 89 f4mov%esi,%r12d b: 53 push %rbx c: 48 8b 87 10 03 00 00mov0x310(%rdi),%rax 13: 31 db xor%ebx,%ebx 15:* 4c 8b a8 f0 01 00 00mov0x1f0(%rax),%r13 <-- trapping instruction which seems to be struct dsa_switch_tree *dst = dev->dsa_ptr; struct dsa_port *cpu_dp = dsa_get_cpu_port(dst); where 'dst' is NULL (the "dsa_get_cpu_port() function is just an inline that returns "dst->cpu_dp"). So 'dev' is not NULL, but dev->dsa_ptr definitely is. Linus
Re: [PATCH v2 16/18] hwmon: add support for sensors exported via ARM SCMI
On Mon, Aug 14, 2017 at 04:09:18PM +0100, Sudeep Holla wrote: > Hi Guenter, > > On 07/08/17 13:25, Sudeep Holla wrote: > > > > > > On 04/08/17 20:32, Guenter Roeck wrote: > >> On Fri, Aug 04, 2017 at 03:31:42PM +0100, Sudeep Holla wrote: > > > > [...] > > > >>> + platform_set_drvdata(pdev, scmi_sensors); > >>> + > >>> + hwdev = devm_hwmon_device_register_with_groups(dev, "scmi_sensors", > >>> +scmi_sensors, > >>> +scmi_sensors->groups); > >> > >> Can you rework this to use devm_hwmon_device_register_with_info(), > >> and if possible let it handle the thermal registration ? > >> > > > > Thanks for the pointers. I will check on the possibility and use it if > > possible. > > > > I had a look at devm_hwmon_device_register_with_info. It mostly deals > with constant structures where all the attributes are known at the boot > time. In case of SCMI, the firmware presents all the sensors and all the > information(type, scale, name/label, ...etc). Unless I create those > structures dynamically and typecast as const during probe, I can't get > it working. Are you OK with that ? If so, I can try making those changes. > Yes, please. What operations exactly fail, though ? The idea was that the structures are not modified by the infrastructure code, not that they must be constant in the driver. Maybe some of the structure definitions are simply wrong. Thanks, Guenter
Re: RGB support prototype
Hi, On 08/13/2017 01:41 PM, Pavel Machek wrote: > Hi! > >>> You mentioned you was working on RGB support prototype. Could you post >>> copy of the patches (even if unfinished)? >> >> Unfortunately it is at the stage of unfinished proof of concept and >> I haven't managed yet to try how it fits to all API use cases we have. >> Nor is it in a shape ready to post to the lists. >> >> I think we could try to discuss the design here. I'll list all the >> issues I encountered during the implementation: >> >> Currently we set LED brightness with following API: >> >> void led_set_brightness(struct led_classdev *led_cdev, >> enum led_brightness brightness); >> >> In case of RGB LED we could have something like this: >> >> struct led_color_triplet { >> enum led_brightness red; >> enum led_brightness green; >> enum led_brightness blue; >> }; >> >> void led_rgb_set_brightness(struct led_rgb_classdev *led_rgb_cdev, >> struct led_color_triplet *color); >> >> We've agreed that LED RGB class device color could be set by writing >> space separated list of "r g b" color values to a sysfs "color" file. >> >> While the above itself shouldn't raise too many doubts, they >> arise quickly while trying to adapt it to the internal LED core >> facilities: >> >> - led_base_timer_function() >> - set_brightness_delayed() >> - led_blink_* API family >> >> All these introduce problems especially with brightness/color type. >> I tried to add a new abstraction layer by introducing >> struct led_base_cdev with a set of generic ops that could be initialized >> by particular type of LED but still the problem with brightness type >> generalization remains. One solution could be an union with fields >> mapping to either single or three brightness components. >> >> Other option could be void *brightness type which could be then >> cast to the required brightness type basing on the LED flag. > > Void *brightness is not really a good option. > > We could pass triplet even in case of single-color LEDs, and then use > just one component. > > Another option would be to store color in HSV colorspace (not RGB). Then > existing > functions would get brightness (== value in HSV), and RGB-aware functions > would > operate on all 3 components. Triggers/blinking/etc. would then continue > operating, > without modifications. > > We could even export (read-only) hue/saturation for single-color LEDs... Related patches from Heiner Kallweit are still sitting on devel branch of linux-leds.git: https://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git/log/?h=devel Possibly it can serve as a basis for further development. I liked that approach because it was compatible with monochrome LEDs and triggers. -- Best regards, Jacek Anaszewski
[v5 0/4] cgroup-aware OOM killer
This patchset makes the OOM killer cgroup-aware. v5: - Rebased on top of Michal Hocko's patches, which have changed the way how OOM victims becoming an access to the memory reserves. Dropped corresponding part of this patchset - Separated the oom_kill_process() splitting into a standalone commit - Added debug output (suggested by David Rientjes) - Some minor fixes v4: - Reworked per-cgroup oom_score_adj into oom_priority (based on ideas by David Rientjes) - Tasks with oom_score_adj -1000 are never selected if oom_kill_all_tasks is not set - Memcg victim selection code is reworked, and synchronization is based on finding tasks with OOM victim marker, rather then on global counter - Debug output is dropped - Refactored TIF_MEMDIE usage v3: - Merged commits 1-4 into 6 - Separated oom_score_adj logic and debug output into separate commits - Fixed swap accounting v2: - Reworked victim selection based on feedback from Michal Hocko, Vladimir Davydov and Johannes Weiner - "Kill all tasks" is now an opt-in option, by default only one process will be killed - Added per-cgroup oom_score_adj - Refined oom score calculations, suggested by Vladimir Davydov - Converted to a patchset v1: https://lkml.org/lkml/2017/5/18/969 Roman Gushchin (4): mm, oom: refactor the oom_kill_process() function mm, oom: cgroup-aware OOM killer mm, oom: introduce oom_priority for memory cgroups mm, oom, docs: describe the cgroup-aware OOM killer Documentation/cgroup-v2.txt | 62 +++ include/linux/memcontrol.h | 36 ++ include/linux/oom.h | 3 + mm/memcontrol.c | 259 mm/oom_kill.c | 181 +-- 5 files changed, 484 insertions(+), 57 deletions(-) -- 2.13.5
Re: [PATCH v5 02/10] mm, x86: Add support for eXclusive Page Frame Ownership (XPFO)
On 08/09/2017 01:07 PM, Tycho Andersen wrote: > diff --git a/mm/xpfo.c b/mm/xpfo.c > new file mode 100644 > index ..3cd45f68b5ad > --- /dev/null > +++ b/mm/xpfo.c > @@ -0,0 +1,208 @@ > +/* > + * Copyright (C) 2017 Hewlett Packard Enterprise Development, L.P. > + * Copyright (C) 2016 Brown University. All rights reserved. > + * > + * Authors: > + * Juerg Haefliger> + * Vasileios P. Kemerlis > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of the GNU General Public License version 2 as published > by > + * the Free Software Foundation. > + */ > + > +#include > +#include > +#include > +#include > + > +#include > + > +/* XPFO page state flags */ > +enum xpfo_flags { > + XPFO_PAGE_USER, /* Page is allocated to user-space */ > + XPFO_PAGE_UNMAPPED, /* Page is unmapped from the linear map */ > +}; > + > +/* Per-page XPFO house-keeping data */ > +struct xpfo { > + unsigned long flags;/* Page state */ > + bool inited;/* Map counter and lock initialized */ > + atomic_t mapcount; /* Counter for balancing map/unmap requests */ > + spinlock_t maplock; /* Lock to serialize map/unmap requests */ > +}; > + > +DEFINE_STATIC_KEY_FALSE(xpfo_inited); > + > +static bool xpfo_disabled __initdata; > + > +static int __init noxpfo_param(char *str) > +{ > + xpfo_disabled = true; > + > + return 0; > +} > + > +early_param("noxpfo", noxpfo_param); > + > +static bool __init need_xpfo(void) > +{ > + if (xpfo_disabled) { > + printk(KERN_INFO "XPFO disabled\n"); > + return false; > + } > + > + return true; > +} > + > +static void init_xpfo(void) > +{ > + printk(KERN_INFO "XPFO enabled\n"); > + static_branch_enable(_inited); > +} > + > +struct page_ext_operations page_xpfo_ops = { > + .size = sizeof(struct xpfo), > + .need = need_xpfo, > + .init = init_xpfo, > +}; > + > +static inline struct xpfo *lookup_xpfo(struct page *page) > +{ > + return (void *)lookup_page_ext(page) + page_xpfo_ops.offset; > +} lookup_page_ext can return NULL so this function and its callers need to account for that. Thanks, Laura
Re: [PATCH v2 4/7] ghes_edac: avoid multiple calls to dmi_walk()
On Mon, 2017-08-14 at 20:35 +0200, Borislav Petkov wrote: > On Mon, Aug 14, 2017 at 06:17:47PM +, Kani, Toshimitsu wrote: > > Right, ghes_edac_report_mem_error() gets serialized per a GHES > > entry, but not globally. > > Globally what? GHES v2's ACK is not a global lock. So, it does not guarantee that ghes_edac_report_mem_error() never gets called concurrently. > What is the actual potential scenario for concurrency issues you see? > Example pls. ghes_probe() supports multiple sources defined in acpi_hest_notify_types. Say, there are two entries for memory errors, one with ACPI_HEST_NOTIFY_EXTERNAL and the other with ACPI_HEST_NOTIFY_SCI. They may report errors independently. While ghes_edac_report_mem_error() is being called from the SCI, it can be called from the ext interrupt at a same time. I do not know how likely we see such case, but the code should be written according to the spec. Thanks, -Toshi
Re: [PATCH] spi: spidev: add exclusive bus access lock via ioctls
On Sat, Aug 12, 2017 at 05:24:03PM +0530, Vikram N wrote: > else > - status = spi_sync(spi, message); > + status = spidev->bus_locked ? spi_sync_locked(spi, message) : > + spi_sync(spi, message); Please don't abuse the ternery operator, people need to be able to read the code. > + case SPI_IOC_BUS_LOCK: > + spi_bus_lock(spi->master); > + spidev->bus_locked = true; > + break; > + > + case SPI_IOC_BUS_UNLOCK: > + spi_bus_unlock(spi->master); > + spidev->bus_locked = false; > + break; I'm not super convinced that this API is a good idea in general - it seems extremely niche to be using multiple userspace programs that don't need to coordinate at all except for a single lock (which they will all need to use to avoid just bouncing off with errors). That all seems very narrow. I'm also worried that even if there is such a use case this code is very fragile as it stands. If an application crashes then nothing will free a lock it holds and any application can through simple error drop locks that are supposed to be held by other applications. This isn't going to be terribly robust. signature.asc Description: PGP signature
RE: [[PATCH v1] 04/37] [CIFS] SMBD: Define per-channel SMBD transport parameters and default values
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Christoph Hellwig > Sent: Sunday, August 13, 2017 6:12 AM > To: Long Li> Cc: Steve French ; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org; Long Li > > Subject: Re: [[PATCH v1] 04/37] [CIFS] SMBD: Define per-channel SMBD > transport parameters and default values > > > +/* > > + * Per RDMA transport connection parameters > > + * as defined in [MS-SMBD] 3.1.1.1 > > + */ > > +static int receive_credit_max = 512; > > +static int send_credit_target = 512; > > +static int max_send_size = 8192; > > +static int max_fragmented_recv_size = 1024*1024; > > +static int max_receive_size = 8192; > > Are these protocol constants? If so please use either #defines > or enums with upper case names for them. These are not defined constants, but the values beg for some explanatory text why they are chosen. Windows uses, and negotiates by default, a 1364-byte maximum send size, and caps credits to 255. The other values match. BTW, the parameters are defined in MS-SMBD 3.1.1.1 but the chosen values are in behavior notes 2 and 7. Tom.
Re: [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR
Benjamin Herrenschmidt [b...@au1.ibm.com] wrote: > On Mon, 2017-08-14 at 17:02 +1000, Michael Neuling wrote: > > > +/* > > > + * We need to assign an unique thread id to each thread in a process. > > > This > > > + * thread id is intended to be used with the Fast Thread-wakeup (aka > > > Core- > > > + * to-core wakeup) mechanism being implemented on top of Virtual > > > Accelerator > > > + * Switchboard (VAS). > > > + * > > > + * To get a unique thread-id per process we could simply use > > > task_pid_nr() > > > + * but the problem is that task_pid_nr() is not yet available for the > > > thread > > > + * when copy_thread() is called. Fixing that would require changing more > > > + * intrusive arch-neutral code in code path in copy_process()?. > > > + * > > > + * Further, to assign unique thread ids within each process, we need an > > > + * atomic field (or an IDR) in task_struct, which again intrudes into the > > > + * arch-neutral code. > > > > Really? > > > > > + * So try to assign globally unique thraed ids for now. > > > > Yuck! I know :-) copy_process() has: retval = copy_thread_tls(clone_flags, stack_start, stack_size, p, tls); if (retval) goto bad_fork_cleanup_io; if (pid != _struct_pid) { pid = alloc_pid(p->nsproxy->pid_ns_for_children); if (IS_ERR(pid)) { so copy_thread() is called before a pid_nr is assigned to the task. But see also response to Michael Ellerman. > > Also CAPI has size limits for the TIDR afaik Ok. > > Ben.
Re: [PATCH v2 2/2] i2c: mediatek: Add i2c compatible for MediaTek MT7622
On Mon, Aug 14, 2017 at 09:36:56AM +0800, Jun Gao wrote: > On Sat, 2017-08-12 at 16:44 +0200, Wolfram Sang wrote: > > > +static const struct i2c_adapter_quirks mt7622_i2c_quirks = { > > > + .max_num_msgs = 255, > > > + .max_write_len = 65535, > > > + .max_read_len = 65535, > > > + .max_comb_1st_msg_len = 65535, > > > + .max_comb_2nd_msg_len = 65535, > > > +}; > > > > That looks like no quirks? Then just leave the quirks pointer below > > empty. > > > Compare to MT8173 i2c controller, MT7622 limits message numbers to 255. I see. But you can safely drop all the length settings. The i2c core has this comment in quirk handling: /* Check if val is exceeding the quirk IFF quirk is non 0 */ IFF means "if and only if". signature.asc Description: PGP signature
[PATCH resend] mfd: intel_soc_pmic_chtwc: Turn Kconfig option into a bool
Hi Lee, This one seems to have fallen through the cracks, would be nice to get this small fix into 4.14. Thanks & Regards, Hans
[PATCH resend] mfd: intel_soc_pmic_chtwc: Turn Kconfig option into a bool
The PMIC provides ACPI OpRegions which must be available for other drivers' PS0 / PS3 methods early-on as such it must be builtin as the Kconfig help text already states. Somehow its Kconfig option ended up being a tristate though, this fixes this. Signed-off-by: Hans de Goede--- Note, feel free to squash this in the original commit if you wish --- drivers/mfd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index fcc9232a005b..10c495a73db3 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -481,7 +481,7 @@ config INTEL_SOC_PMIC_BXTWC on these systems. config INTEL_SOC_PMIC_CHTWC - tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" + bool "Support for Intel Cherry Trail Whiskey Cove PMIC" depends on ACPI && HAS_IOMEM && I2C=y && COMMON_CLK depends on X86 || COMPILE_TEST select MFD_CORE -- 2.13.4
[PATCH v6] locking/pvqspinlock: Relax cmpxchg's to improve performance on some archs
All the locking related cmpxchg's in the following functions are replaced with the _acquire variants: - pv_queued_spin_steal_lock() - trylock_clear_pending() This change should help performance on architectures that use LL/SC. The cmpxchg in pv_kick_node() is replaced with a relaxed version with explicit memory barrier to make sure that it is fully ordered in the writing of next->lock and the reading of pn->state whether the cmpxchg is a success or failure without affecting performance in non-LL/SC architectures. On a 2-socket 12-core 96-thread Power8 system with pvqspinlock explicitly enabled, the performance of a locking microbenchmark with and without this patch on a 4.13-rc4 kernel with Xinhui's PPC qspinlock patch were as follows: # of thread w/o patchwith patch % Change --- --- 8 5054.8 Mop/s 5209.4 Mop/s +3.1% 16 3985.0 Mop/s 4015.0 Mop/s +0.8% 32 2378.2 Mop/s 2396.0 Mop/s +0.7% Suggested-by: Peter ZijlstraSigned-off-by: Waiman Long --- v5->v6: - Replace cmpxchg in pv_kick_node() by a relaxed version with explicit memory barrier. v4->v5: - Correct some grammatical issues in comment. v3->v4: - Update the comment in pv_kick_node() to mention that the code may not work in some archs. v2->v3: - Reduce scope by relaxing cmpxchg's in fast path only. v1->v2: - Add comments in changelog and code for the rationale of the change. kernel/locking/qspinlock_paravirt.h | 24 +--- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h index 4ccfcaa..4355568 100644 --- a/kernel/locking/qspinlock_paravirt.h +++ b/kernel/locking/qspinlock_paravirt.h @@ -72,7 +72,7 @@ static inline bool pv_queued_spin_steal_lock(struct qspinlock *lock) struct __qspinlock *l = (void *)lock; if (!(atomic_read(>val) & _Q_LOCKED_PENDING_MASK) && - (cmpxchg(>locked, 0, _Q_LOCKED_VAL) == 0)) { + (cmpxchg_acquire(>locked, 0, _Q_LOCKED_VAL) == 0)) { qstat_inc(qstat_pv_lock_stealing, true); return true; } @@ -101,16 +101,16 @@ static __always_inline void clear_pending(struct qspinlock *lock) /* * The pending bit check in pv_queued_spin_steal_lock() isn't a memory - * barrier. Therefore, an atomic cmpxchg() is used to acquire the lock - * just to be sure that it will get it. + * barrier. Therefore, an atomic cmpxchg_acquire() is used to acquire the + * lock just to be sure that it will get it. */ static __always_inline int trylock_clear_pending(struct qspinlock *lock) { struct __qspinlock *l = (void *)lock; return !READ_ONCE(l->locked) && - (cmpxchg(>locked_pending, _Q_PENDING_VAL, _Q_LOCKED_VAL) - == _Q_PENDING_VAL); + (cmpxchg_acquire(>locked_pending, _Q_PENDING_VAL, + _Q_LOCKED_VAL) == _Q_PENDING_VAL); } #else /* _Q_PENDING_BITS == 8 */ static __always_inline void set_pending(struct qspinlock *lock) @@ -138,7 +138,7 @@ static __always_inline int trylock_clear_pending(struct qspinlock *lock) */ old = val; new = (val & ~_Q_PENDING_MASK) | _Q_LOCKED_VAL; - val = atomic_cmpxchg(>val, old, new); + val = atomic_cmpxchg_acquire(>val, old, new); if (val == old) return 1; @@ -362,8 +362,18 @@ static void pv_kick_node(struct qspinlock *lock, struct mcs_spinlock *node) * observe its next->locked value and advance itself. * * Matches with smp_store_mb() and cmpxchg() in pv_wait_node() +* +* The write to next->locked in arch_mcs_spin_unlock_contended() +* must be ordered before the read of pn->state in the cmpxchg() +* below for the code to work correctly. To guarantee full ordering +* irrespective of the success or failure of the cmpxchg(), +* a relaxed version with explicit barrier is used. The control +* dependency will order the reading of pn->state before any +* subsequent writes. */ - if (cmpxchg(>state, vcpu_halted, vcpu_hashed) != vcpu_halted) + smp_mb__before_atomic(); + if (cmpxchg_relaxed(>state, vcpu_halted, vcpu_hashed) + != vcpu_halted) return; /* -- 1.8.3.1
Re: [PATCH v3 24/28] drm/vc4: switch to drm_*_get(), drm_*_put() helpers
On Mon, Aug 14, 2017 at 12:47:01PM -0700, Eric Anholt wrote: > Cihangir Akturkwrites: > > > Use drm_*_get() and drm_*_put() helpers instead of drm_*_reference() > > and drm_*_unreference() helpers. > > > > drm_*_reference() and drm_*_unreference() functions are just > > compatibility alias for drm_*_get() and drm_*_put() and should not be > > used by new code. So convert all users of compatibility functions to > > use the new APIs. > > Mind if I change the subject line to "drm/vc4: Continue the switch to > drm_*_put() helpers"? to distinguish from the patch that already landed? It's OK with me. Go ahead, change to whatever you want. > > (Looks like your previous patch was generated before my BO labeling code > landed, so we got another little patch here cleaning up the new code as > well) Thanks, Cihangir.
Re: [PATCH v4 00/06] clocksource: sh_cmt: DT binding rework V4
Hi Daniel, Magnus, On Thu, Aug 10, 2017 at 12:56 PM, Daniel Lezcanowrote: > On 10/08/2017 11:01, Geert Uytterhoeven wrote: >> On Tue, Jul 11, 2017 at 1:56 PM, Simon Horman wrote: >>> On Thu, Nov 24, 2016 at 11:58:43AM +0100, Simon Horman wrote: On Mon, Mar 14, 2016 at 11:23:42PM +0900, Magnus Damm wrote: > clocksource: sh_cmt: DT binding rework V4 > > [PATCH v4 01/06] devicetree: bindings: Remove sh7372 CMT binding > [PATCH v4 02/06] devicetree: bindings: R-Car Gen2 CMT0 and CMT1 bindings > [PATCH v4 03/06] devicetree: bindings: r8a73a4 and R-Car Gen2 CMT bindings > [PATCH v4 04/06] devicetree: bindings: Deprecate property, update example > [PATCH v4 05/06] devicetree: bindings: Remove unused 32-bit CMT bindings > [PATCH v4 06/06] devicetree: bindings: Remove deprecated properties > > Here is the latest and hopefully final take on updating the CMT DT > bindings for R-Car Gen2. In total there are 6 patches that have acks > and are ready to be picked up and merged. Other earlier posted changes > such as driver modification and SoC DTS bits depend on this series. I am wondering what the state of this work is. I see only one minor review comment for this series. It would be great to see it merged. >>> >>> Ping >> >> Recently, at +1800m, I realized that if we want to continue this work, we >> better do it soon, so it can be included in the big R-Car Gen2 flag day >> requiring APMU, CPG/MSSR, ICRAM, RST, and SYSC being described in DT. > > Applied. Thank you. Of course, before we can convert existing DT source files to the new bindings, we need support for the new bindings in the sh_cmt driver. Magnus: what is the status of that? Where can we find the latest code? Thanks again! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH] selftests: timers: freq-step: fix compile error
On 08/14/2017 02:12 PM, John Stultz wrote: > On Wed, Aug 9, 2017 at 3:05 PM, Shuah Khanwrote: >> Fix compile error due to ksft_exit_skip() update to take var_args. >> >> freq-step.c: In function ‘init_test’: >> freq-step.c:234:3: error: too few arguments to function ‘ksft_exit_skip’ >>ksft_exit_skip(); >>^~ >> In file included from freq-step.c:26:0: >> ../kselftest.h:167:19: note: declared here >> static inline int ksft_exit_skip(const char *msg, ...) >>^~ >> : recipe for target 'freq-step' failed >> >> Signed-off-by: Shuah Khan > > > Acked-by: John Stultz > > This is a build regression in 4.13-rc so should go-to Linus promptly. > > (Shuah: Let me know if you want me to send this in via Thomas, or you > want to send it in directly) > > thanks > -john > John, I am planning to send it to Linus with a few other fixes in linux-kselftest fixes branch for 4.13-rc6 thanks, -- Shuah
[PATCH v5 3/9] mfd: tmio: Add partition parsers platform data
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done in the board files using this driver. Thus, we need to extend tmio_nand_data to consider the partition parsers. Signed-off-by: Andrea Adami--- include/linux/mfd/tmio.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h index 26e8f8c..357b6cfd 100644 --- a/include/linux/mfd/tmio.h +++ b/include/linux/mfd/tmio.h @@ -139,6 +139,7 @@ struct tmio_nand_data { struct nand_bbt_descr *badblock_pattern; struct mtd_partition*partition; unsigned intnum_partitions; + const char *const *part_parsers; }; #define FBIO_TMIO_ACC_WRITE0x7C639300 -- 2.7.4
[PATCH v5 7/9] ARM: pxa/tosa: Remove hardcoded partitioning, use sharpslpart parser
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done here in the board file. Signed-off-by: Andrea Adami--- arch/arm/mach-pxa/tosa.c | 28 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c index 13de660..b90560b 100644 --- a/arch/arm/mach-pxa/tosa.c +++ b/arch/arm/mach-pxa/tosa.c @@ -673,24 +673,6 @@ static int tosa_tc6393xb_suspend(struct platform_device *dev) return 0; } -static struct mtd_partition tosa_nand_partition[] = { - { - .name = "smf", - .offset = 0, - .size = 7 * 1024 * 1024, - }, - { - .name = "root", - .offset = MTDPART_OFS_APPEND, - .size = 28 * 1024 * 1024, - }, - { - .name = "home", - .offset = MTDPART_OFS_APPEND, - .size = MTDPART_SIZ_FULL, - }, -}; - static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = { @@ -700,10 +682,16 @@ static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = { .pattern= scan_ff_pattern }; +static const char * const probes[] = { + "cmdlinepart", + "ofpart", + "sharpslpart", + NULL, +}; + static struct tmio_nand_data tosa_tc6393xb_nand_config = { - .num_partitions = ARRAY_SIZE(tosa_nand_partition), - .partition = tosa_nand_partition, .badblock_pattern = _tc6393xb_nand_bbt, + .part_parsers = probes, }; static int tosa_tc6393xb_setup(struct platform_device *dev) -- 2.7.4
[PATCH v5 9/9] ARM: pxa/poodle: Remove hardcoded partitioning, use sharpslpart parser
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done here in the board file. Signed-off-by: Andrea Adami--- arch/arm/mach-pxa/poodle.c | 28 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c index 62a1191..fd01d6b 100644 --- a/arch/arm/mach-pxa/poodle.c +++ b/arch/arm/mach-pxa/poodle.c @@ -333,24 +333,6 @@ static struct pxafb_mach_info poodle_fb_info = { .lcd_conn = LCD_COLOR_TFT_16BPP, }; -static struct mtd_partition sharpsl_nand_partitions[] = { - { - .name = "System Area", - .offset = 0, - .size = 7 * 1024 * 1024, - }, - { - .name = "Root Filesystem", - .offset = 7 * 1024 * 1024, - .size = 22 * 1024 * 1024, - }, - { - .name = "Home Filesystem", - .offset = MTDPART_OFS_APPEND, - .size = MTDPART_SIZ_FULL, - }, -}; - static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; static struct nand_bbt_descr sharpsl_bbt = { @@ -360,10 +342,16 @@ static struct nand_bbt_descr sharpsl_bbt = { .pattern = scan_ff_pattern }; +static const char * const probes[] = { + "cmdlinepart", + "ofpart", + "sharpslpart", + NULL, +}; + static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = { .badblock_pattern = _bbt, - .partitions = sharpsl_nand_partitions, - .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions), + .part_parsers = probes, }; static struct resource sharpsl_nand_resources[] = { -- 2.7.4
[PATCH v5 8/9] ARM: pxa/spitz: Remove hardcoded partitioning, use sharpslpart parser
With the introduction of sharpslpart partition parser we can now read the offsets from NAND: we specify the list of the parsers as platform data, with cmdlinepart and ofpart parsers first allowing to override the part. table written in NAND. This is done here in the board file. Signed-off-by: Andrea Adami--- arch/arm/mach-pxa/spitz.c | 34 +- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 67d66c7..defefa3 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -739,21 +739,6 @@ static inline void spitz_lcd_init(void) {} * NAND Flash **/ #if defined(CONFIG_MTD_NAND_SHARPSL) || defined(CONFIG_MTD_NAND_SHARPSL_MODULE) -static struct mtd_partition spitz_nand_partitions[] = { - { - .name = "System Area", - .offset = 0, - .size = 7 * 1024 * 1024, - }, { - .name = "Root Filesystem", - .offset = 7 * 1024 * 1024, - }, { - .name = "Home Filesystem", - .offset = MTDPART_OFS_APPEND, - .size = MTDPART_SIZ_FULL, - }, -}; - static uint8_t scan_ff_pattern[] = { 0xff, 0xff }; static struct nand_bbt_descr spitz_nand_bbt = { @@ -808,10 +793,16 @@ static const struct mtd_ooblayout_ops akita_ooblayout_ops = { .free = akita_ooblayout_free, }; +static const char * const probes[] = { + "cmdlinepart", + "ofpart", + "sharpslpart", + NULL, +}; + static struct sharpsl_nand_platform_data spitz_nand_pdata = { .badblock_pattern = _nand_bbt, - .partitions = spitz_nand_partitions, - .nr_partitions = ARRAY_SIZE(spitz_nand_partitions), + .part_parsers = probes, }; static struct resource spitz_nand_resources[] = { @@ -834,14 +825,7 @@ static struct platform_device spitz_nand_device = { static void __init spitz_nand_init(void) { - if (machine_is_spitz()) { - spitz_nand_partitions[1].size = 5 * 1024 * 1024; - } else if (machine_is_akita()) { - spitz_nand_partitions[1].size = 58 * 1024 * 1024; - spitz_nand_bbt.len = 1; - spitz_nand_pdata.ecc_layout = _ooblayout_ops; - } else if (machine_is_borzoi()) { - spitz_nand_partitions[1].size = 32 * 1024 * 1024; + if (machine_is_akita() || machine_is_borzoi()) { spitz_nand_bbt.len = 1; spitz_nand_pdata.ecc_layout = _ooblayout_ops; } -- 2.7.4
[PATCH] selftests/seccomp: Add simple seccomp overhead benchmark
This attempts to produce a comparison between native getpid() and a RET_ALLOW-filtered getpid(), to measure the overhead cost of using seccomp(). Signed-off-by: Kees Cook--- As with the other, I'd like this to go via the seccomp tree. Getting an Ack would be great. :) Thanks! --- tools/testing/selftests/seccomp/Makefile | 18 ++-- .../testing/selftests/seccomp/seccomp_benchmark.c | 99 ++ 2 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 tools/testing/selftests/seccomp/seccomp_benchmark.c diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index aeb0c805f3ca..553d870b4ca9 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,8 +1,16 @@ -TEST_GEN_PROGS := seccomp_bpf -CFLAGS += -Wl,-no-as-needed -Wall -LDFLAGS += -lpthread +all: include ../lib.mk -$(TEST_GEN_PROGS): seccomp_bpf.c ../kselftest_harness.h - $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ +.PHONY: all clean + +BINARIES := seccomp_bpf seccomp_benchmark +CFLAGS += -Wl,-no-as-needed -Wall + +seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h + $(CC) $(CFLAGS) $(LDFLAGS) -lpthread $< -o $@ + +TEST_PROGS += $(BINARIES) +EXTRA_CLEAN := $(BINARIES) + +all: $(BINARIES) diff --git a/tools/testing/selftests/seccomp/seccomp_benchmark.c b/tools/testing/selftests/seccomp/seccomp_benchmark.c new file mode 100644 index ..5838c8697ec3 --- /dev/null +++ b/tools/testing/selftests/seccomp/seccomp_benchmark.c @@ -0,0 +1,99 @@ +/* + * Strictly speaking, this is not a test. But it can report during test + * runs so relative performace can be measured. + */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ARRAY_SIZE(a)(sizeof(a) / sizeof(a[0])) + +unsigned long long timing(clockid_t clk_id, unsigned long long samples) +{ + pid_t pid, ret; + unsigned long long i; + struct timespec start, finish; + + pid = getpid(); + assert(clock_gettime(clk_id, ) == 0); + for (i = 0; i < samples; i++) { + ret = syscall(__NR_getpid); + assert(pid == ret); + } + assert(clock_gettime(clk_id, ) == 0); + + i = finish.tv_sec - start.tv_sec; + i *= 10; + i += finish.tv_nsec - start.tv_nsec; + + printf("%lu.%09lu - %lu.%09lu = %llu\n", + finish.tv_sec, finish.tv_nsec, + start.tv_sec, start.tv_nsec, + i); + + return i; +} + +unsigned long long calibrate(void) +{ + unsigned long long i; + + printf("Calibrating reasonable sample size...\n"); + + for (i = 5; ; i++) { + unsigned long long samples = 1 << i; + + /* Find something that takes more than 5 seconds to run. */ + if (timing(CLOCK_REALTIME, samples) / 10ULL > 5) + return samples; + } +} + +int main(int argc, char *argv[]) +{ + struct sock_filter filter[] = { + BPF_STMT(BPF_RET|BPF_K, SECCOMP_RET_ALLOW), + }; + struct sock_fprog prog = { + .len = (unsigned short)ARRAY_SIZE(filter), + .filter = filter, + }; + long ret; + unsigned long long samples; + unsigned long long native, filtered; + + if (argc > 1) + samples = strtoull(argv[1], NULL, 0); + else + samples = calibrate(); + + printf("Benchmarking %llu samples...\n", samples); + + native = timing(CLOCK_PROCESS_CPUTIME_ID, samples) / samples; + printf("getpid native: %llu ns\n", native); + + ret = prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); + assert(ret == 0); + + ret = prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, ); + assert(ret == 0); + + filtered = timing(CLOCK_PROCESS_CPUTIME_ID, samples) / samples; + printf("getpid RET_ALLOW: %llu ns\n", filtered); + + printf("Estimated seccomp overhead per syscall: %llu ns\n", + filtered - native); + + if (filtered == native) + printf("Trying running again with more samples.\n"); + + return 0; +} -- 2.7.4 -- Kees Cook Pixel Security
Re: [PATCH 3/3] x86/intel_rdt/cqm: Improve limbo list processing
On Mon, 14 Aug 2017, Shivappa Vikas wrote: On Mon, 14 Aug 2017, Thomas Gleixner wrote: On Wed, 9 Aug 2017, Vikas Shivappa wrote: @@ -426,6 +426,9 @@ static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_domain *d) GFP_KERNEL); if (!d->rmid_busy_llc) return -ENOMEM; + INIT_DELAYED_WORK(>cqm_limbo, cqm_handle_limbo); + if (has_busy_rmid(r, d)) + cqm_setup_limbo_handler(d); This is beyond silly. d->rmid_busy_llc is allocated a few lines above. How would a bit be set here? If we logically offline all cpus in a package and bring it back, the worker needs to be scheduled on the package if there were busy RMIDs on this package. Otherwise that RMID never gets freed as its rmid->busy stays 1.. I needed to scan the limbo list and set the bits for all limbo RMIDs after the alloc and before doing the 'has_busy_rmid' check. Will fix Tony pointed out that there is no guarentee that a domain will come back up once its down, so the above issue of rmid->busy staying at > 0 can still happen. So I will delete this - if (has_busy_rmid(r, d)) cqm_setup_limbo_handler(d); and add this when a domain is powered down - for each rmid in d->rmid_busy_llc if (--entry->busy) free_rmid(rmid); We have no way to know if the L3 was indeed flushed (or package was powered off). This may lead to incorrect counts in rare scenarios but can document the same. Thanks, vikas
[PATCH 9/9] ASoC: cygnus: Tidy up of structure access
Adds copies of the frequently accessed io handles to each ports data structure, making it more convenient to access. Also, a small cleanup to the type names used in cygnus_pcm. None of this should result in a functional change to the driver. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-pcm.c | 50 sound/soc/bcm/cygnus-ssp.c | 298 + sound/soc/bcm/cygnus-ssp.h | 22 ++-- 3 files changed, 178 insertions(+), 192 deletions(-) diff --git a/sound/soc/bcm/cygnus-pcm.c b/sound/soc/bcm/cygnus-pcm.c index d616e096..d82bf55 100644 --- a/sound/soc/bcm/cygnus-pcm.c +++ b/sound/soc/bcm/cygnus-pcm.c @@ -329,24 +329,24 @@ static void enable_intr(struct snd_pcm_substream *substream) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { /* Clear interrupt status before enabling them */ - writel(clear_mask, aio->cygaud->audio + ESR0_STATUS_CLR_OFFSET); - writel(clear_mask, aio->cygaud->audio + ESR1_STATUS_CLR_OFFSET); - writel(clear_mask, aio->cygaud->audio + ESR3_STATUS_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR0_STATUS_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR1_STATUS_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR3_STATUS_CLR_OFFSET); /* Unmask the interrupts of the given port*/ - writel(clear_mask, aio->cygaud->audio + ESR0_MASK_CLR_OFFSET); - writel(clear_mask, aio->cygaud->audio + ESR1_MASK_CLR_OFFSET); - writel(clear_mask, aio->cygaud->audio + ESR3_MASK_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR0_MASK_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR1_MASK_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR3_MASK_CLR_OFFSET); writel(ANY_PLAYBACK_IRQ, - aio->cygaud->audio + INTH_R5F_MASK_CLEAR_OFFSET); + aio->audio + INTH_R5F_MASK_CLEAR_OFFSET); } else { - writel(clear_mask, aio->cygaud->audio + ESR2_STATUS_CLR_OFFSET); - writel(clear_mask, aio->cygaud->audio + ESR4_STATUS_CLR_OFFSET); - writel(clear_mask, aio->cygaud->audio + ESR2_MASK_CLR_OFFSET); - writel(clear_mask, aio->cygaud->audio + ESR4_MASK_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR2_STATUS_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR4_STATUS_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR2_MASK_CLR_OFFSET); + writel(clear_mask, aio->audio + ESR4_MASK_CLR_OFFSET); writel(ANY_CAPTURE_IRQ, - aio->cygaud->audio + INTH_R5F_MASK_CLEAR_OFFSET); + aio->audio + INTH_R5F_MASK_CLEAR_OFFSET); } } @@ -366,12 +366,12 @@ static void disable_intr(struct snd_pcm_substream *substream) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { /* Mask the interrupts of the given port*/ - writel(set_mask, aio->cygaud->audio + ESR0_MASK_SET_OFFSET); - writel(set_mask, aio->cygaud->audio + ESR1_MASK_SET_OFFSET); - writel(set_mask, aio->cygaud->audio + ESR3_MASK_SET_OFFSET); + writel(set_mask, aio->audio + ESR0_MASK_SET_OFFSET); + writel(set_mask, aio->audio + ESR1_MASK_SET_OFFSET); + writel(set_mask, aio->audio + ESR3_MASK_SET_OFFSET); } else { - writel(set_mask, aio->cygaud->audio + ESR2_MASK_SET_OFFSET); - writel(set_mask, aio->cygaud->audio + ESR4_MASK_SET_OFFSET); + writel(set_mask, aio->audio + ESR2_MASK_SET_OFFSET); + writel(set_mask, aio->audio + ESR4_MASK_SET_OFFSET); } } @@ -415,13 +415,13 @@ static void cygnus_pcm_period_elapsed(struct snd_pcm_substream *substream) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { /* Set the ring buffer to full */ - regval = readl(aio->cygaud->audio + p_rbuf->rdaddr); + regval = readl(aio->audio + p_rbuf->rdaddr); regval = regval ^ BIT(31); - writel(regval, aio->cygaud->audio + p_rbuf->wraddr); + writel(regval, aio->audio + p_rbuf->wraddr); } else { /* Set the ring buffer to empty */ - regval = readl(aio->cygaud->audio + p_rbuf->wraddr); - writel(regval, aio->cygaud->audio + p_rbuf->rdaddr); + regval = readl(aio->audio + p_rbuf->wraddr); + writel(regval, aio->audio + p_rbuf->rdaddr); } } @@ -690,7 +690,7 @@ static int cygnus_pcm_prepare(struct snd_pcm_substream *substream) is_play = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 1 : 0; - ringbuf_set_initial(aio->cygaud->audio, p_rbuf, is_play, start, + ringbuf_set_initial(aio->audio, p_rbuf,
[PATCH 8/9] ASoC: cygnus: Add EXPORT_SYMBOL for helper function
The helper function cygnus_ssp_set_custom_fsync_width() is intended to be called from an ASoC machine driver, need to export symbol if using modules. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-ssp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index e72d8a8..97bf67a 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -875,6 +875,7 @@ int cygnus_ssp_set_custom_fsync_width(struct snd_soc_dai *cpu_dai, int len) return -EINVAL; } } +EXPORT_SYMBOL_GPL(cygnus_ssp_set_custom_fsync_width); static int cygnus_ssp_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) { -- 1.9.1
[PATCH 3/9] ASoC: cygnus: Allow each port to select its clock source
Add the ability to assign which of the 3 audio PLL outputs are to be used by each port. Remove the suspend and resume handlers because the only thing they were doing was unnecessarily maintaining the clock state. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-ssp.c | 332 ++--- sound/soc/bcm/cygnus-ssp.h | 15 +- 2 files changed, 103 insertions(+), 244 deletions(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index 1a57a4e..00fd4dc 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -25,8 +25,6 @@ #include "cygnus-ssp.h" -#define DEFAULT_VCO1354750204 - #define CAPTURE_FCI_ID_BASE 0x180 #define CYGNUS_SSP_TRISTATE_MASK 0x001fff #define CYGNUS_PLLCLKSEL_MASK 0xf @@ -95,22 +93,10 @@ #define SPDIF_FORMAT_CFG_OFFSET 0xad8 #define SPDIF_MCLK_CFG_OFFSET0xadc -/* AUD_FMM_IOP_PLL_0_xxx regs */ -#define IOP_PLL_0_MACRO_OFFSET0xb00 -#define IOP_PLL_0_MDIV_Ch0_OFFSET 0xb14 -#define IOP_PLL_0_MDIV_Ch1_OFFSET 0xb18 -#define IOP_PLL_0_MDIV_Ch2_OFFSET 0xb1c - -#define IOP_PLL_0_ACTIVE_MDIV_Ch0_OFFSET 0xb30 -#define IOP_PLL_0_ACTIVE_MDIV_Ch1_OFFSET 0xb34 -#define IOP_PLL_0_ACTIVE_MDIV_Ch2_OFFSET 0xb38 - -/* AUD_FMM_IOP_xxx regs */ -#define IOP_PLL_0_CONTROL_OFFSET 0xb04 -#define IOP_PLL_0_USER_NDIV_OFFSET 0xb08 -#define IOP_PLL_0_ACTIVE_NDIV_OFFSET 0xb20 -#define IOP_PLL_0_RESET_OFFSET 0xb5c +/* + * Register offsets for i2s_in io space + */ /* AUD_FMM_IOP_IN_I2S_xxx regs */ #define IN_I2S_0_STREAM_CFG_OFFSET 0x00 #define IN_I2S_0_CFG_OFFSET0x04 @@ -173,12 +159,6 @@ #define SPDIF_0_OUT_DITHER_ENA 3 #define SPDIF_0_OUT_STREAM_ENA31 -/* AUD_FMM_IOP_PLL_0_USER */ -#define IOP_PLL_0_USER_NDIV_FRAC 10 - -/* AUD_FMM_IOP_PLL_0_ACTIVE */ -#define IOP_PLL_0_ACTIVE_NDIV_FRAC 10 - #define INIT_SSP_REGS(num) (struct cygnus_ssp_regs){ \ .i2s_stream_cfg = OUT_I2S_ ##num## _STREAM_CFG_OFFSET, \ @@ -193,41 +173,6 @@ .bf_sourcech_grp = BF_SRC_GRP ##num## _OFFSET \ } -struct pll_macro_entry { - u32 mclk; - u32 pll_ch_num; -}; - -/* - * PLL has 3 output channels (1x, 2x, and 4x). Below are - * the common MCLK frequencies used by audio driver - */ -static const struct pll_macro_entry pll_predef_mclk[] = { - { 4096000, 0}, - { 8192000, 1}, - {16384000, 2}, - - { 5644800, 0}, - {11289600, 1}, - {22579200, 2}, - - { 6144000, 0}, - {12288000, 1}, - {24576000, 2}, - - {12288000, 0}, - {24576000, 1}, - {49152000, 2}, - - {22579200, 0}, - {45158400, 1}, - {90316800, 2}, - - {24576000, 0}, - {49152000, 1}, - {98304000, 2}, -}; - #define CYGNUS_RATE_MIN 8000 #define CYGNUS_RATE_MAX 384000 @@ -488,59 +433,6 @@ static int audio_ssp_out_disable(struct cygnus_aio_port *aio) return status; } -static int pll_configure_mclk(struct cygnus_audio *cygaud, u32 mclk, - struct cygnus_aio_port *aio) -{ - int i = 0, error; - bool found = false; - const struct pll_macro_entry *p_entry; - struct clk *ch_clk; - - for (i = 0; i < ARRAY_SIZE(pll_predef_mclk); i++) { - p_entry = _predef_mclk[i]; - if (p_entry->mclk == mclk) { - found = true; - break; - } - } - if (!found) { - dev_err(cygaud->dev, - "%s No valid mclk freq (%u) found!\n", __func__, mclk); - return -EINVAL; - } - - ch_clk = cygaud->audio_clk[p_entry->pll_ch_num]; - - if ((aio->clk_trace.cap_en) && (!aio->clk_trace.cap_clk_en)) { - error = clk_prepare_enable(ch_clk); - if (error) { - dev_err(cygaud->dev, "%s clk_prepare_enable failed %d\n", - __func__, error); - return error; - } - aio->clk_trace.cap_clk_en = true; - } - - if ((aio->clk_trace.play_en) && (!aio->clk_trace.play_clk_en)) { - error = clk_prepare_enable(ch_clk); - if (error) { - dev_err(cygaud->dev, "%s clk_prepare_enable failed %d\n", - __func__, error); - return error; - } - aio->clk_trace.play_clk_en = true; - } - - error = clk_set_rate(ch_clk, mclk); - if (error) { - dev_err(cygaud->dev, "%s Set MCLK rate failed: %d\n", - __func__, error); - return error; - } - - return p_entry->pll_ch_num; -} - static int cygnus_ssp_set_clocks(struct cygnus_aio_port *aio) { u32 value; @@ -723,26 +615,68 @@ static int cygnus_ssp_hw_params(struct snd_pcm_substream *substream, } /* + * Check
[PATCH 1/9] ASoC: cygnus: Add support for 384kHz frame rates
Allow the audio ports to operate at 384kHz. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-ssp.c | 235 +++-- 1 file changed, 55 insertions(+), 180 deletions(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index e710bb0..1a57a4e 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -27,12 +27,6 @@ #define DEFAULT_VCO1354750204 -#define CYGNUS_TDM_RATE \ - (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | \ - SNDRV_PCM_RATE_11025 | SNDRV_PCM_RATE_22050 | \ - SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ - SNDRV_PCM_RATE_48000) - #define CAPTURE_FCI_ID_BASE 0x180 #define CYGNUS_SSP_TRISTATE_MASK 0x001fff #define CYGNUS_PLLCLKSEL_MASK 0xf @@ -234,152 +228,20 @@ struct pll_macro_entry { {98304000, 2}, }; +#define CYGNUS_RATE_MIN 8000 +#define CYGNUS_RATE_MAX 384000 + /* List of valid frame sizes for tdm mode */ static const int ssp_valid_tdm_framesize[] = {32, 64, 128, 256, 512}; -/* - * Use this relationship to derive the sampling rate (lrclk) - * lrclk = (mclk) / ((2*mclk_to_sclk_ratio) * (32 * SCLK))). - * - * Use mclk and pll_ch from the table above - * - * Valid SCLK = 0/1/2/4/8/12 - * - * mclk_to_sclk_ratio = number of MCLK per SCLK. Division is twice the - * value programmed in this field. - * Valid mclk_to_sclk_ratio = 1 through to 15 - * - * eg: To set lrclk = 48khz, set mclk = 12288000, mclk_to_sclk_ratio = 2, - * SCLK = 64 - */ -struct _ssp_clk_coeff { - u32 mclk; - u32 sclk_rate; - u32 rate; - u32 mclk_rate; +static const unsigned int cygnus_rates[] = { +8000, 11025, 16000, 22050, 32000, 44100, 48000, + 88200, 96000, 176400, 192000, 352800, 384000 }; -static const struct _ssp_clk_coeff ssp_clk_coeff[] = { - { 4096000, 32, 16000, 4}, - { 4096000, 32, 32000, 2}, - { 4096000, 64, 8000, 4}, - { 4096000, 64, 16000, 2}, - { 4096000, 64, 32000, 1}, - { 4096000, 128, 8000, 2}, - { 4096000, 128, 16000, 1}, - { 4096000, 256, 8000, 1}, - - { 6144000, 32, 16000, 6}, - { 6144000, 32, 32000, 3}, - { 6144000, 32, 48000, 2}, - { 6144000, 32, 96000, 1}, - { 6144000, 64, 8000, 6}, - { 6144000, 64, 16000, 3}, - { 6144000, 64, 48000, 1}, - { 6144000, 128, 8000, 3}, - - { 8192000, 32, 32000, 4}, - { 8192000, 64, 16000, 4}, - { 8192000, 64, 32000, 2}, - { 8192000, 128, 8000, 4}, - { 8192000, 128, 16000, 2}, - { 8192000, 128, 32000, 1}, - { 8192000, 256, 8000, 2}, - { 8192000, 256, 16000, 1}, - { 8192000, 512, 8000, 1}, - - {12288000, 32, 32000, 6}, - {12288000, 32, 48000, 4}, - {12288000, 32, 96000, 2}, - {12288000, 32, 192000, 1}, - {12288000, 64, 16000, 6}, - {12288000, 64, 32000, 3}, - {12288000, 64, 48000, 2}, - {12288000, 64, 96000, 1}, - {12288000, 128, 8000, 6}, - {12288000, 128, 16000, 3}, - {12288000, 128, 48000, 1}, - {12288000, 256, 8000, 3}, - - {16384000, 64, 32000, 4}, - {16384000, 128, 16000, 4}, - {16384000, 128, 32000, 2}, - {16384000, 256, 8000, 4}, - {16384000, 256, 16000, 2}, - {16384000, 256, 32000, 1}, - {16384000, 512, 8000, 2}, - {16384000, 512, 16000, 1}, - - {24576000, 32, 96000, 4}, - {24576000, 32, 192000, 2}, - {24576000, 64, 32000, 6}, - {24576000, 64, 48000, 4}, - {24576000, 64, 96000, 2}, - {24576000, 64, 192000, 1}, - {24576000, 128, 16000, 6}, - {24576000, 128, 32000, 3}, - {24576000, 128, 48000, 2}, - {24576000, 256, 8000, 6}, - {24576000, 256, 16000, 3}, - {24576000, 256, 48000, 1}, - {24576000, 512, 8000, 3}, - - {49152000, 32, 192000, 4}, - {49152000, 64, 96000, 4}, - {49152000, 64, 192000, 2}, - {49152000, 128, 32000, 6}, - {49152000, 128, 48000, 4}, - {49152000, 128, 96000, 2}, - {49152000, 128, 192000, 1}, - {49152000, 256, 16000, 6}, - {49152000, 256, 32000, 3}, - {49152000, 256, 48000, 2}, - {49152000, 256, 96000, 1}, - {49152000, 512, 8000, 6}, - {49152000, 512, 16000, 3}, - {49152000, 512, 48000, 1}, - - { 5644800, 32, 22050, 4}, - { 5644800, 32, 44100, 2}, - { 5644800, 32, 88200, 1}, - { 5644800, 64, 11025, 4}, - { 5644800, 64, 22050, 2}, - { 5644800, 64, 44100, 1}, - - {11289600, 32, 44100, 4}, - {11289600, 32, 88200, 2}, - {11289600, 32, 176400, 1}, - {11289600, 64, 22050, 4}, - {11289600, 64, 44100, 2}, - {11289600, 64, 88200, 1}, - {11289600, 128, 11025, 4}, - {11289600, 128,
[PATCH net-next] bpf/verifier: track liveness for pruning
State of a register doesn't matter if it wasn't read in reaching an exit; a write screens off all reads downstream of it from all explored_states upstream of it. This allows us to prune many more branches; here are some processed insn counts for some Cilium programs: Program before after bpf_lb_opt_-DLB_L3.o 6515 3361 bpf_lb_opt_-DLB_L4.o 8976 5176 bpf_lb_opt_-DUNKNOWN.o 2960 1137 bpf_lxc_opt_-DDROP_ALL.o 95412 48537 bpf_lxc_opt_-DUNKNOWN.o 141706 79048 bpf_netdev.o 24251 17995 bpf_overlay.o 10999 9385 The runtime is also improved; here are 'time' results in ms: Program before after bpf_lb_opt_-DLB_L3.o 24 6 bpf_lb_opt_-DLB_L4.o 26 11 bpf_lb_opt_-DUNKNOWN.o 11 2 bpf_lxc_opt_-DDROP_ALL.o 1288152 bpf_lxc_opt_-DUNKNOWN.o1768257 bpf_netdev.o 62 31 bpf_overlay.o15 13 Signed-off-by: Edward Cree--- include/linux/bpf_verifier.h | 11 ++- kernel/bpf/verifier.c| 181 +-- 2 files changed, 151 insertions(+), 41 deletions(-) diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index c61c3033..91d07ef 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -21,6 +21,12 @@ */ #define BPF_MAX_VAR_SIZINT_MAX +enum bpf_reg_liveness { + REG_LIVE_NONE = 0, /* reg hasn't been read or written this branch */ + REG_LIVE_READ, /* reg was read, so we're sensitive to initial value */ + REG_LIVE_WRITTEN, /* reg was written first, screening off later reads */ +}; + struct bpf_reg_state { enum bpf_reg_type type; union { @@ -40,7 +46,7 @@ struct bpf_reg_state { * came from, when one is tested for != NULL. */ u32 id; - /* These five fields must be last. See states_equal() */ + /* Ordering of fields matters. See states_equal() */ /* For scalar types (SCALAR_VALUE), this represents our knowledge of * the actual value. * For pointer types, this represents the variable part of the offset @@ -57,6 +63,8 @@ struct bpf_reg_state { s64 smax_value; /* maximum possible (s64)value */ u64 umin_value; /* minimum possible (u64)value */ u64 umax_value; /* maximum possible (u64)value */ + /* This field must be last, for states_equal() reasons. */ + enum bpf_reg_liveness live; }; enum bpf_stack_slot_type { @@ -74,6 +82,7 @@ struct bpf_verifier_state { struct bpf_reg_state regs[MAX_BPF_REG]; u8 stack_slot_type[MAX_BPF_STACK]; struct bpf_reg_state spilled_regs[MAX_BPF_STACK / BPF_REG_SIZE]; + struct bpf_verifier_state *parent; }; /* linked list of verifier states used to prune search */ diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index ecc590e..dcfe6ab 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -629,8 +629,10 @@ static void init_reg_state(struct bpf_reg_state *regs) { int i; - for (i = 0; i < MAX_BPF_REG; i++) + for (i = 0; i < MAX_BPF_REG; i++) { mark_reg_not_init(regs, i); + regs[i].live = REG_LIVE_NONE; + } /* frame pointer */ regs[BPF_REG_FP].type = PTR_TO_STACK; @@ -647,9 +649,26 @@ enum reg_arg_type { DST_OP_NO_MARK /* same as above, check only, don't mark */ }; -static int check_reg_arg(struct bpf_reg_state *regs, u32 regno, +static void mark_reg_read(const struct bpf_verifier_state *state, u32 regno) +{ + struct bpf_verifier_state *parent = state->parent; + + while (parent) { + /* if read wasn't screened by an earlier write ... */ + if (state->regs[regno].live & REG_LIVE_WRITTEN) + break; + /* ... then we depend on parent's value */ + parent->regs[regno].live |= REG_LIVE_READ; + state = parent; + parent = state->parent; + } +} + +static int check_reg_arg(struct bpf_verifier_env *env, u32 regno, enum reg_arg_type t) { + struct bpf_reg_state *regs = env->cur_state.regs; + if (regno >= MAX_BPF_REG) { verbose("R%d is invalid\n", regno); return -EINVAL; @@ -661,12 +680,14 @@ static int check_reg_arg(struct bpf_reg_state *regs, u32 regno, verbose("R%d !read_ok\n", regno); return -EACCES; } + mark_reg_read(>cur_state, regno); } else { /* check whether register used as dest operand can be written to */ if (regno == BPF_REG_FP) { verbose("frame pointer is read only\n"); return -EACCES; } + regs[regno].live |= REG_LIVE_WRITTEN; if (t == DST_OP)
Re: [PATCH 4/4] MIPS/ptrace: Add PTRACE_SET_SYSCALL operation
On Mon, Aug 14, 2017 at 2:41 AM, James Hoganwrote: > On Fri, Aug 11, 2017 at 03:23:34PM -0700, Kees Cook wrote: >> On Fri, Aug 11, 2017 at 1:56 PM, James Hogan wrote: >> > Add a PTRACE_SET_SYSCALL ptrace operation to allow the system call to be >> > cancelled independently to the value of the v0 system call number >> > register. >> > >> > This is needed for SECCOMP_RET_TRACE when the tracer wants to cancel the >> > system call, since it has to set both the system call number to -1 and >> > the chosen return value, both of which reside in the same register (v0). >> > The tracer should set the return value first, followed by >> > PTRACE_SET_SYSCALL to set the system call number to -1. >> > >> > That is in contrast to the normal ptrace syscall hook which triggers the >> > tracer on both entry and exit, allowing the system call to be cancelled >> > during the entry hook (setting system call number register to -1, or >> > optionally using PTRACE_SET_SYSCALL), separately to setting the return >> > value during the exit hook. >> > >> > Positive values (to change the syscall that should be executed instead >> > of cancelling it entirely) are explicitly disallowed at the moment. The >> > same thing can be done safely already by writing the v0 system call >> > number register and the argument registers, and allowing >> > thread_info::syscall to be changed to a different value independently of >> > the v0 register would potentially allow seccomp or the syscall trace >> > events to be fooled into thinking a different system call was being >> > executed. >> >> Wouldn't the sycall be reloaded, so no spoofing could occur? > > The case I was thinking of was: > - PTRACE_POKEUSR v0 = __NR_some_disallowed_syscall > - PTRACE_SET_SYSCALL __NR_some_allowed_syscall > > syscall_get_nr() will return __NR_some_allowed_syscall, so seccomp will > allow, but when syscall_trace_enter() returns to syscall_trace_entry in > arch/mips/kernel/scall32-o32.S, it will reload the syscall number from > v0 (i.e. __NR_some_disallowed_syscall). IIUC, the issue is that v0 holds syscall on entry and syscall return on exit. Isn't it possible to rework all the entry logic to examine only thread_info->syscall and ignore v0 during the ptrace and seccomp events? i.e. SET_SYSCALL can modify ti->syscall, and only if it goes to -1 only then will v0 be examined for a result? (If I'm reading scall32-o32.S, I think this means loading the new syscall from thread_info instead of registers after syscall_trace_enter.) If that is possible, it doesn't have to happen in this patch, obviously. Incremental is fine. :) >> Regardless, can you update >> tools/testing/selftests/seccomp/seccomp_bpf.c to update or eliminate >> the MIPS-only SYSCALL_NUM_RET_SHARE_REG special-case? (Or maybe it >> needs to be further special-cased to split syscall-changing from >> syscall-cancelling?) > > Sure, i'll look into that, > > Thanks for reviewing, Sure thing, thanks! -Kees -- Kees Cook Pixel Security
RE: [PATCH 0/5] cramfs refresh for embedded usage
On Monday, August 14, 2017, Nicolas Pitre wrote: > > I just applied the patches tried this simple test: > > - tested with a Renesas RZ/A1 (Cortex-A9...so it has an MMU). > > - I set the sticky bit for busybox before using mkcramfs > > You need the newer mkcramfs I linked to in the documentation. With it > you don't need to play tricks with the sticky bit anymore. However you > need to specify -X twice (or just once for no-MMU targets) and it will > make every ELF files XIPable automatically. OK. Now I am getting bigger images that makes me think all the ELF files are uncompressed. > > However, at this point I'm not sure how I can confirm that the XIP > > busybox actually executed as XIP or not. > > Just use busybox's built-in cat command and dump the content of > /proc/self/maps. You should see an offset that refers to a physical > address within your cramfs image for those segments marked read-only and > executable. It works! Pretty cool. $ /mnt/bin/busybox cat /proc/self/maps 8000-000a1000 r-xp 1b005000 00:10 18192 /mnt/bin/busybox (my cramfs flash image is at physical address 0x1B00) However, now with your mkcramfs tool, I can no longer mount my cramfs image as the rootfs on boot. I was able to do that before (ie, 30 minutes ago) when using the community mkcramfs (ie, 30 minutes ago). I get this: [1.712425] cramfs: checking physical address 0x1b00 for linear cramfs image [1.720531] cramfs: linear cramfs image appears to be 15744 KB in size [1.728656] VFS: Mounted root (cramfs_physmem filesystem) readonly on device 0:12. [1.737062] devtmpfs: mounted [1.741139] Freeing unused kernel memory: 48K [1.745545] This architecture does not have kernel memory protection. [1.760381] Starting init: /sbin/init exists but couldn't execute it (error -22) [1.769685] Starting init: /bin/sh exists but couldn't execute it (error -14) [1.776956] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. [1.791192] CPU: 0 PID: 1 Comm: init Not tainted 4.13.0-rc1-00014-g53182a0b7245 #667 [1.798959] Hardware name: Generic R7S72100 (Flattened Device Tree) [1.805519] [] (unwind_backtrace) from [] (show_stack+0xb/0xc) [1.813228] [] (show_stack) from [] (panic+0x6f/0x18c) [1.820163] [] (panic) from [] (kernel_init+0x6b/0x98) [1.827078] [] (kernel_init) from [] (ret_from_fork+0x11/0x20) [1.834747] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. Chris
Re: early x86 unseeded randomness
On Mon, Aug 14, 2017 at 11:00 AM, Borislav Petkovwrote: > On Mon, Aug 14, 2017 at 10:47:47AM -0700, Linus Torvalds wrote: >> Plus on modern x86, you'll always get at least the hardware >> randomness, which is fundamentally much better anyway. > > Right, my only intention was to get rid of those: > > [0.00] random: get_random_bytes called from start_kernel+0x30/0x3d8 > with crng_init=0 Ok, guys, you ALL need to learn that blindly just trying to get rid of warnings IS A HORRIBLE IDEA. People also need to learn that *adding* warnings isn't always a good idea, exactly because then people will mindlessly react to them. I *detest* bad compiler warnings for this reason. The number of garbage patches that actually break working code that I've seen over the year is mind-numbing. > What do you propose? Keep 'em? Keeping the warning (or removing the warning itself without changing the code) is certainly preferable to trying to "fix" the warning by bogus measures, yes. > Or fix the above, snipped bit to conditionally do rdtsc() *once* or > get_random_bytes() depending on the crng state? Neither. Let's aim to make sure to fix the warning the *only* correct way - by making sure the initialization _ordering_ is correct, not by hacking around the caller code. Maybe the warning message should be clarified to say that too. Make it clear that the only acceptable fix is to change code ordering, not to play games with randomness. But maybe those places that currently trigger the warning should just use "get_random_u32()" instead. That at least gets rid of the warning if there's a fast architected hardware random thing (ie modern x86). Linus
RE: [PATCH 0/5] cramfs refresh for embedded usage
On Mon, 14 Aug 2017, Chris Brandt wrote: > On Monday, August 14, 2017, Nicolas Pitre wrote: > > > I just applied the patches tried this simple test: > > > - tested with a Renesas RZ/A1 (Cortex-A9...so it has an MMU). > > > - I set the sticky bit for busybox before using mkcramfs > > > > You need the newer mkcramfs I linked to in the documentation. With it > > you don't need to play tricks with the sticky bit anymore. However you > > need to specify -X twice (or just once for no-MMU targets) and it will > > make every ELF files XIPable automatically. > > OK. Now I am getting bigger images that makes me think all the ELF files > are uncompressed. Yeah. No way around that of course. I listed a few TODO items to mitigate the alignment losses if you have many executables. > > > However, at this point I'm not sure how I can confirm that the XIP > > > busybox actually executed as XIP or not. > > > > Just use busybox's built-in cat command and dump the content of > > /proc/self/maps. You should see an offset that refers to a physical > > address within your cramfs image for those segments marked read-only and > > executable. > > It works! Pretty cool. > > $ /mnt/bin/busybox cat /proc/self/maps > 8000-000a1000 r-xp 1b005000 00:10 18192 /mnt/bin/busybox > > (my cramfs flash image is at physical address 0x1B00) Good! Independent validation is always nice. > However, now with your mkcramfs tool, I can no longer mount my cramfs > image as the rootfs on boot. I was able to do that before (ie, 30 minutes > ago) when using the community mkcramfs (ie, 30 minutes ago). > > I get this: > > [1.712425] cramfs: checking physical address 0x1b00 for linear cramfs > image > [1.720531] cramfs: linear cramfs image appears to be 15744 KB in size > [1.728656] VFS: Mounted root (cramfs_physmem filesystem) readonly on > device 0:12. > [1.737062] devtmpfs: mounted > [1.741139] Freeing unused kernel memory: 48K > [1.745545] This architecture does not have kernel memory protection. > [1.760381] Starting init: /sbin/init exists but couldn't execute it > (error -22) > [1.769685] Starting init: /bin/sh exists but couldn't execute it (error > -14) Is /sbin/init a link to busybox? I suppose it just boots if you do mkcramfs without -X? If so could you share your non-working cramfs image with me? Nicolas
Re: [PATCH v2 4/7] ghes_edac: avoid multiple calls to dmi_walk()
On Mon, 2017-08-14 at 20:05 +0200, Borislav Petkov wrote: > On Mon, Aug 14, 2017 at 05:52:25PM +, Kani, Toshimitsu wrote: > > Yes, but this ACK is done per a GHES entry as well. > > So is the ghes_edac_report_mem_error() call. Right, ghes_edac_report_mem_error() gets serialized per a GHES entry, but not globally. Thanks, -Toshi
[v5 3/4] mm, oom: introduce oom_priority for memory cgroups
Introduce a per-memory-cgroup oom_priority setting: an integer number within the [-1, 1] range, which defines the order in which the OOM killer selects victim memory cgroups. OOM killer prefers memory cgroups with larger priority if they are populated with elegible tasks. The oom_priority value is compared within sibling cgroups. The root cgroup has the oom_priority 0, which cannot be changed. Signed-off-by: Roman GushchinCc: Michal Hocko Cc: Vladimir Davydov Cc: Johannes Weiner Cc: David Rientjes Cc: Tejun Heo Cc: Tetsuo Handa Cc: kernel-t...@fb.com Cc: cgro...@vger.kernel.org Cc: linux-...@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux...@kvack.org --- include/linux/memcontrol.h | 3 +++ mm/memcontrol.c| 55 -- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 79dc3282..3c1ab3aedebe 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -206,6 +206,9 @@ struct mem_cgroup { /* cached OOM score */ long oom_score; + /* OOM killer priority */ + short oom_priority; + /* handle for "memory.events" */ struct cgroup_file events_file; diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0b81dc55c6ac..f61e9a9c8bdc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2724,12 +2724,21 @@ static void select_victim_memcg(struct mem_cgroup *root, struct oom_control *oc) for (;;) { struct cgroup_subsys_state *css; struct mem_cgroup *memcg = NULL; + short prio = SHRT_MIN; long score = LONG_MIN; css_for_each_child(css, >css) { struct mem_cgroup *iter = mem_cgroup_from_css(css); - if (iter->oom_score > score) { + if (iter->oom_score == 0) + continue; + + if (iter->oom_priority > prio) { + memcg = iter; + prio = iter->oom_priority; + score = iter->oom_score; + } else if (iter->oom_priority == prio && + iter->oom_score > score) { memcg = iter; score = iter->oom_score; } @@ -2796,7 +2805,15 @@ bool mem_cgroup_select_oom_victim(struct oom_control *oc) * For system-wide OOMs we should consider tasks in the root cgroup * with oom_score larger than oc->chosen_points. */ - if (!oc->memcg) { + if (!oc->memcg && !(oc->chosen_memcg && + oc->chosen_memcg->oom_priority > 0)) { + /* +* Root memcg has priority 0, so if chosen memcg has lower +* priority, any task in root cgroup is preferable. +*/ + if (oc->chosen_memcg && oc->chosen_memcg->oom_priority < 0) + oc->chosen_points = 0; + select_victim_root_cgroup_task(oc); if (oc->chosen && oc->chosen_memcg) { @@ -5392,6 +5409,34 @@ static ssize_t memory_oom_kill_all_tasks_write(struct kernfs_open_file *of, return nbytes; } +static int memory_oom_priority_show(struct seq_file *m, void *v) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); + + seq_printf(m, "%d\n", memcg->oom_priority); + + return 0; +} + +static ssize_t memory_oom_priority_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); + int oom_priority; + int err; + + err = kstrtoint(strstrip(buf), 0, _priority); + if (err) + return err; + + if (oom_priority < -1 || oom_priority > 1) + return -EINVAL; + + memcg->oom_priority = (short)oom_priority; + + return nbytes; +} + static int memory_events_show(struct seq_file *m, void *v) { struct mem_cgroup *memcg = mem_cgroup_from_css(seq_css(m)); @@ -5518,6 +5563,12 @@ static struct cftype memory_files[] = { .write = memory_oom_kill_all_tasks_write, }, { + .name = "oom_priority", + .flags = CFTYPE_NOT_ON_ROOT, + .seq_show = memory_oom_priority_show, + .write = memory_oom_priority_write, + }, + { .name = "events", .flags = CFTYPE_NOT_ON_ROOT, .file_offset = offsetof(struct mem_cgroup, events_file), -- 2.13.5
Re: [tip:perf/core] perf test shell: Install shell tests
Hi Arnaldo! Maybe this would be the right time to incorporate the shell-based perftool-testsuite [1] into perf-test, wouldn't it? It already contains bunch of shell-based perf tests that cover 25+ RH bugs... A little problem might be different design, since the testsuite has multiple levels of hierarchy of sub-sub-sub-tests, like: ... -- [ PASS ] -- perf_probe :: test_probe_syntax :: custom named probe :: add -- [ PASS ] -- perf_probe :: test_probe_syntax :: custom named probe :: list -- [ PASS ] -- perf_probe :: test_probe_syntax :: custom named probe :: use -- [ PASS ] -- perf_probe :: test_probe_syntax :: various syntax forms :: vfs_read@fs/read_write.c -- [ PASS ] -- perf_probe :: test_probe_syntax :: various syntax forms :: vfs_read:11@fs/read_write.c -- [ PASS ] -- perf_probe :: test_probe_syntax :: various syntax forms :: vfs_read@fs/read_write.c:11 -- [ PASS ] -- perf_probe :: test_probe_syntax :: various syntax forms :: vfs_read%return -- [ PASS ] -- perf_probe :: test_probe_syntax :: various syntax forms :: test.c:29 -- [ PASS ] -- perf_probe :: test_probe_syntax :: various syntax forms :: func%return $retval ## [ PASS ] ## perf_probe :: test_probe_syntax SUMMARY -- [ PASS ] -- perf_probe :: test_sdt :: adding SDT tracepoints as probes -- [ PASS ] -- perf_probe :: test_sdt :: listing added probes -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf stat (N = 13) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf stat (N = 128) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf stat (N = 241) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf record (N = 37) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf report (N = 37) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf script (N = 37) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf record (N = 97) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf report (N = 97) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf script (N = 97) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf record (N = 237) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf report (N = 237) -- [ PASS ] -- perf_probe :: test_sdt :: using probes :: perf script (N = 237) ## [ PASS ] ## perf_probe :: test_sdt SUMMARY ... ... which does not exactly match how perf-test is structured, however, I think that the multi-level structure of the testsuite is important for keeping some order in it... What do you think? Cheers, Michael [1] https://github.com/rfmvh/perftool-testsuite On Mon, 14 Aug 2017, tip-bot for Arnaldo Carvalho de Melo wrote: > Commit-ID: 122e0b947052f6106595fa29d63d514d2ebcdad9 > Gitweb: http://git.kernel.org/tip/122e0b947052f6106595fa29d63d514d2ebcdad9 > Author: Arnaldo Carvalho de Melo> AuthorDate: Fri, 4 Aug 2017 12:19:44 -0300 > Committer: Arnaldo Carvalho de Melo > CommitDate: Fri, 11 Aug 2017 16:06:28 -0300 > > perf test shell: Install shell tests > > Now that we have shell tests, install them. > > Developers don't need this pass, as 'perf test' will look first at the > in tree scripts at tools/perf/tests/shell/. > > Cc: Adrian Hunter > Cc: David Ahern > Cc: Jiri Olsa > Cc: Michael Petlan > Cc: Namhyung Kim > Cc: Thomas Richter > Cc: Wang Nan > Link: http://lkml.kernel.org/n/tip-j21u4v0jsehi0lpwqwjb4...@git.kernel.org > Signed-off-by: Arnaldo Carvalho de Melo > --- > tools/perf/Makefile.perf | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf > index c1f7884..eb13567 100644 > --- a/tools/perf/Makefile.perf > +++ b/tools/perf/Makefile.perf > @@ -760,7 +760,9 @@ install-tests: all install-gtk > $(INSTALL) -d -m 755 > '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \ > $(INSTALL) tests/attr.py > '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests'; \ > $(INSTALL) -d -m 755 > '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \ > - $(INSTALL) tests/attr/* > '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr' > + $(INSTALL) tests/attr/* > '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/attr'; \ > + $(INSTALL) -d -m 755 > '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell'; \ > + $(INSTALL) tests/shell/*.sh > '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/tests/shell' > > install-bin: install-tools install-tests install-traceevent-plugins > >
Re: linux-next: manual merge of the akpm-current tree with the tip tree
On Mon, Aug 14, 2017 at 12:09:14PM +0900, Minchan Kim wrote: > @@ -446,9 +450,7 @@ void tlb_finish_mmu(struct mmu_gather *tlb, >* >*/ > bool force = mm_tlb_flush_nested(tlb->mm); > - > arch_tlb_finish_mmu(tlb, start, end, force); > - dec_tlb_flush_pending(tlb->mm); > } No, I think this breaks all the mm_tlb_flush_pending() users. They need the decrement to not be visible until the TLB flush is complete.
[PATCH v1 3/4] clk: iproc: Allow plls to do minor rate changes without reset
From: Lori HikichiThe iproc plls are capable of doing small rate changes without the need for a full reset and re-lock procedure. This feature will allow for small tweaks to the PLL rate to occur smoothly. Signed-off-by: Lori Hikichi --- drivers/clk/bcm/clk-iproc-pll.c | 47 + 1 file changed, 47 insertions(+) diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c index 7df010b..ab10819 100644 --- a/drivers/clk/bcm/clk-iproc-pll.c +++ b/drivers/clk/bcm/clk-iproc-pll.c @@ -285,6 +285,40 @@ static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp, iproc_pll_write(pll, pll->control_base, reset->offset, val); } +/* + * Determines if the change to be applied to the PLL is minor (just an update + * or the fractional divider). If so, then we can avoid going through a + * disruptive reset and lock sequence. + */ +static bool pll_fractional_change_only(struct iproc_pll *pll, + struct iproc_pll_vco_param *vco) +{ + const struct iproc_pll_ctrl *ctrl = pll->ctrl; + u32 val; + u32 ndiv_int; + unsigned int pdiv; + + /* PLL needs to be locked */ + val = readl(pll->status_base + ctrl->status.offset); + if ((val & (1 << ctrl->status.shift)) == 0) + return false; + + val = readl(pll->control_base + ctrl->ndiv_int.offset); + ndiv_int = (val >> ctrl->ndiv_int.shift) & + bit_mask(ctrl->ndiv_int.width); + + if (ndiv_int != vco->ndiv_int) + return false; + + val = readl(pll->control_base + ctrl->pdiv.offset); + pdiv = (val >> ctrl->pdiv.shift) & bit_mask(ctrl->pdiv.width); + + if (pdiv != vco->pdiv) + return false; + + return true; +} + static int pll_set_rate(struct iproc_clk *clk, struct iproc_pll_vco_param *vco, unsigned long parent_rate) { @@ -333,6 +367,19 @@ static int pll_set_rate(struct iproc_clk *clk, struct iproc_pll_vco_param *vco, return ret; } + if (pll_fractional_change_only(clk->pll, vco)) { + /* program fractional part of NDIV */ + if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) { + val = readl(pll->control_base + ctrl->ndiv_frac.offset); + val &= ~(bit_mask(ctrl->ndiv_frac.width) << +ctrl->ndiv_frac.shift); + val |= vco->ndiv_frac << ctrl->ndiv_frac.shift; + iproc_pll_write(pll, pll->control_base, + ctrl->ndiv_frac.offset, val); + return 0; + } + } + /* put PLL in reset */ __pll_put_in_reset(pll); -- 1.9.1
Re: early x86 unseeded randomness
On Mon, Aug 14, 2017 at 11:17:37AM -0700, Linus Torvalds wrote: > Ok, guys, you ALL need to learn that blindly just trying to get rid of > warnings IS A HORRIBLE IDEA. Not blindly - I was actually suggesting/asking whether falling back to the TSC that early during boot might make more sense than using unseeded randomness. Especially add the least significant 32 bits to the most significant i.e., that thing: tsc + (tsc << 32UL) as they're more unpredictable. > But maybe those places that currently trigger the warning should just > use "get_random_u32()" instead. That at least gets rid of the warning > if there's a fast architected hardware random thing (ie modern x86). Right, that is better, at least for the RDRAND machines. We'd still need a proper fix for the older ones. And I don't see an easy way to change the init ordering for the stack canary as it gets setup very very early in start_kernel() vs crng_initialize() being an early_initcall()... Need to sleep on it. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.
[PATCH v1 4/4] clk: iproc: Minor tidy up of iproc pll data structures
From: Lori HikichiThere were a few fields in the iproc pll data structures that were holding information that was not true state information. Using stack variables is sufficient and simplifies the structure. There are not any functional changes in this commit. Signed-off-by: Lori Hikichi --- drivers/clk/bcm/clk-iproc-pll.c | 83 ++--- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c index ab10819..43a58ae 100644 --- a/drivers/clk/bcm/clk-iproc-pll.c +++ b/drivers/clk/bcm/clk-iproc-pll.c @@ -69,16 +69,6 @@ enum vco_freq_range { VCO_MAX = 40U, }; -struct iproc_pll; - -struct iproc_clk { - struct clk_hw hw; - const char *name; - struct iproc_pll *pll; - unsigned long rate; - const struct iproc_clk_ctrl *ctrl; -}; - struct iproc_pll { void __iomem *status_base; void __iomem *control_base; @@ -88,9 +78,12 @@ struct iproc_pll { const struct iproc_pll_ctrl *ctrl; const struct iproc_pll_vco_param *vco_param; unsigned int num_vco_entries; +}; - struct clk_hw_onecell_data *clk_data; - struct iproc_clk *clks; +struct iproc_clk { + struct clk_hw hw; + struct iproc_pll *pll; + const struct iproc_clk_ctrl *ctrl; }; #define to_iproc_clk(hw) container_of(hw, struct iproc_clk, hw) @@ -329,6 +322,7 @@ static int pll_set_rate(struct iproc_clk *clk, struct iproc_pll_vco_param *vco, u32 val; enum kp_band kp_index; unsigned long ref_freq; + const char *clk_name = clk_hw_get_name(>hw); /* * reference frequency = parent frequency / PDIV @@ -351,19 +345,19 @@ static int pll_set_rate(struct iproc_clk *clk, struct iproc_pll_vco_param *vco, kp_index = KP_BAND_HIGH_HIGH; } else { pr_err("%s: pll: %s has invalid rate: %lu\n", __func__, - clk->name, rate); + clk_name, rate); return -EINVAL; } kp = get_kp(ref_freq, kp_index); if (kp < 0) { - pr_err("%s: pll: %s has invalid kp\n", __func__, clk->name); + pr_err("%s: pll: %s has invalid kp\n", __func__, clk_name); return kp; } ret = __pll_enable(pll); if (ret) { - pr_err("%s: pll: %s fails to enable\n", __func__, clk->name); + pr_err("%s: pll: %s fails to enable\n", __func__, clk_name); return ret; } @@ -433,7 +427,7 @@ static int pll_set_rate(struct iproc_clk *clk, struct iproc_pll_vco_param *vco, ret = pll_wait_for_lock(pll); if (ret < 0) { - pr_err("%s: pll: %s failed to lock\n", __func__, clk->name); + pr_err("%s: pll: %s failed to lock\n", __func__, clk_name); return ret; } @@ -469,16 +463,15 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw, u32 val; u64 ndiv, ndiv_int, ndiv_frac; unsigned int pdiv; + unsigned long rate; if (parent_rate == 0) return 0; /* PLL needs to be locked */ val = readl(pll->status_base + ctrl->status.offset); - if ((val & (1 << ctrl->status.shift)) == 0) { - clk->rate = 0; + if ((val & (1 << ctrl->status.shift)) == 0) return 0; - } /* * PLL output frequency = @@ -500,14 +493,14 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw, val = readl(pll->control_base + ctrl->pdiv.offset); pdiv = (val >> ctrl->pdiv.shift) & bit_mask(ctrl->pdiv.width); - clk->rate = (ndiv * parent_rate) >> 20; + rate = (ndiv * parent_rate) >> 20; if (pdiv == 0) - clk->rate *= 2; + rate *= 2; else - clk->rate /= pdiv; + rate /= pdiv; - return clk->rate; + return rate; } static int iproc_pll_determine_rate(struct clk_hw *hw, @@ -632,6 +625,7 @@ static unsigned long iproc_clk_recalc_rate(struct clk_hw *hw, struct iproc_pll *pll = clk->pll; u32 val; unsigned int mdiv; + unsigned long rate; if (parent_rate == 0) return 0; @@ -642,11 +636,11 @@ static unsigned long iproc_clk_recalc_rate(struct clk_hw *hw, mdiv = 256; if (ctrl->flags & IPROC_CLK_MCLK_DIV_BY_2) - clk->rate = parent_rate / (mdiv * 2); + rate = parent_rate / (mdiv * 2); else - clk->rate = parent_rate / mdiv; + rate = parent_rate / mdiv; - return clk->rate; + return rate; } static int iproc_clk_determine_rate(struct clk_hw *hw, @@ -698,10 +692,6 @@ static int iproc_clk_set_rate(struct clk_hw *hw,
[PATCH v1 1/4] clk: iproc: Allow iproc pll to runtime calculate vco parameters
Add the ability for the iproc pll to calculate the pll parameters at runtime instead of only using predefined tables. This ability allows the clock users to select from the full range of vco frequencies. The old method of table based programming is retained so that existing users will retain expected behavior. The flag IPROC_CLK_PLL_CALC_PARAM will need to be set to enable the new runtime calculation method. Currently, this is only being enabled for the audio pll. This feature also revealed a problem with the driver using the round_rate api. The round_rate api does not allow for frequencies larger than 2^31 to be returned. Those large frequencies are interpreted as an error code. Therefore, we are moving to the determine_rate api which solves this problem. Signed-off-by: Simran RaiSigned-off-by: Lori Hikichi --- drivers/clk/bcm/clk-cygnus.c| 25 +++ drivers/clk/bcm/clk-iproc-pll.c | 97 ++--- drivers/clk/bcm/clk-iproc.h | 5 +++ 3 files changed, 92 insertions(+), 35 deletions(-) diff --git a/drivers/clk/bcm/clk-cygnus.c b/drivers/clk/bcm/clk-cygnus.c index 464fdc4..b8d073e 100644 --- a/drivers/clk/bcm/clk-cygnus.c +++ b/drivers/clk/bcm/clk-cygnus.c @@ -269,23 +269,10 @@ static void __init cygnus_asiu_init(struct device_node *node) } CLK_OF_DECLARE(cygnus_asiu_clk, "brcm,cygnus-asiu-clk", cygnus_asiu_init); -/* - * AUDIO PLL VCO frequency parameter table - * - * PLL output frequency = ((ndiv_int + ndiv_frac / 2^20) * - * (parent clock rate / pdiv) - * - * On Cygnus, parent is the 25MHz oscillator - */ -static const struct iproc_pll_vco_param audiopll_vco_params[] = { - /* rate (Hz) ndiv_int ndiv_frac pdiv */ - { 1354750204UL, 54, 199238, 1 }, - { 1769470191UL, 70, 816639, 1 }, -}; - static const struct iproc_pll_ctrl audiopll = { .flags = IPROC_CLK_PLL_NEEDS_SW_CFG | IPROC_CLK_PLL_HAS_NDIV_FRAC | - IPROC_CLK_PLL_USER_MODE_ON | IPROC_CLK_PLL_RESET_ACTIVE_LOW, + IPROC_CLK_PLL_USER_MODE_ON | IPROC_CLK_PLL_RESET_ACTIVE_LOW | + IPROC_CLK_PLL_CALC_PARAM, .reset = RESET_VAL(0x5c, 0, 1), .dig_filter = DF_VAL(0x48, 0, 3, 6, 4, 3, 3), .sw_ctrl = SW_CTRL_VAL(0x4, 0), @@ -300,8 +287,7 @@ static void __init cygnus_asiu_init(struct device_node *node) static const struct iproc_clk_ctrl audiopll_clk[] = { [BCM_CYGNUS_AUDIOPLL_CH0] = { .channel = BCM_CYGNUS_AUDIOPLL_CH0, - .flags = IPROC_CLK_AON | - IPROC_CLK_MCLK_DIV_BY_2, + .flags = IPROC_CLK_AON | IPROC_CLK_MCLK_DIV_BY_2, .enable = ENABLE_VAL(0x14, 8, 10, 9), .mdiv = REG_VAL(0x14, 0, 8), }, @@ -321,9 +307,8 @@ static void __init cygnus_asiu_init(struct device_node *node) static void __init cygnus_audiopll_clk_init(struct device_node *node) { - iproc_pll_clk_setup(node, , audiopll_vco_params, - ARRAY_SIZE(audiopll_vco_params), audiopll_clk, - ARRAY_SIZE(audiopll_clk)); + iproc_pll_clk_setup(node, , NULL, 0, + audiopll_clk, ARRAY_SIZE(audiopll_clk)); } CLK_OF_DECLARE(cygnus_audiopll, "brcm,cygnus-audiopll", cygnus_audiopll_clk_init); diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c index 375d8dd..9514ecf 100644 --- a/drivers/clk/bcm/clk-iproc-pll.c +++ b/drivers/clk/bcm/clk-iproc-pll.c @@ -95,6 +95,39 @@ struct iproc_pll { #define to_iproc_clk(hw) container_of(hw, struct iproc_clk, hw) +static int pll_calc_param(unsigned long target_rate, + unsigned long parent_rate, + struct iproc_pll_vco_param *vco_out) +{ + u64 ndiv_int, ndiv_frac, residual; + + ndiv_int = target_rate / parent_rate; + + if (!ndiv_int || (ndiv_int > 255)) + return -EINVAL; + + residual = target_rate - (ndiv_int * parent_rate); + residual <<= 20; + + /* +* Add half of the divisor so the result will be rounded to closest +* instead of rounded down. +*/ + residual += (parent_rate / 2); + ndiv_frac = div64_u64((u64)residual, (u64)parent_rate); + + vco_out->ndiv_int = ndiv_int; + vco_out->ndiv_frac = ndiv_frac; + vco_out->pdiv = 1; + + vco_out->rate = vco_out->ndiv_int * parent_rate; + residual = (u64)vco_out->ndiv_frac * (u64)parent_rate; + residual >>= 20; + vco_out->rate += residual; + + return 0; +} + /* * Based on the target frequency, find a match from the VCO frequency parameter * table and return its index @@ -252,11 +285,10 @@ static void __pll_bring_out_reset(struct iproc_pll *pll, unsigned int kp, iproc_pll_write(pll, pll->control_base, reset->offset, val); } -static int pll_set_rate(struct iproc_clk *clk,
[PATCH v1 0/4] clk: iproc: Enable glitchless pll rate change
This patchset enables the ability for the iproc plls to do small rate changes without glitching the clock. Lori Hikichi (4): clk: iproc: Allow iproc pll to runtime calculate vco parameters clk: iproc: Fix error in the pll post divider rate calculation clk: iproc: Allow plls to do minor rate changes without reset clk: iproc: Minor tidy up of iproc pll data structures drivers/clk/bcm/clk-cygnus.c| 25 +--- drivers/clk/bcm/clk-iproc-pll.c | 260 drivers/clk/bcm/clk-iproc.h | 5 + 3 files changed, 192 insertions(+), 98 deletions(-) -- 1.9.1
Re: [PATCH] i2c: slave-eeprom: Add an OF device ID table
On Wed, Aug 09, 2017 at 12:12:56PM +0200, Javier Martinez Canillas wrote: > The driver doesn't have a struct of_device_id table but supported devices > are registered via Device Trees as shown in the following DT binding doc: > > Documentation/devicetree/bindings/i2c/i2c-designware.txt Uhhh, that needs to be fixed to something else! I don't think i2c slave functionality should be described in DT. The slave functionality is pure software, so IMO it doesn't match the "HW description" requirement. > But this works on the assumption that a I2C device registered via OF will > always match a legacy I2C device ID and that the MODALIAS reported will > always be of the form i2c:. > > And this could change in the future so the correct approach is to have an > OF device ID table if the devices are registered via OF. > > Signed-off-by: Javier Martinez CanillasThanks for finding the issue, still NAK to this patch. Are you interested in updating the docs? signature.asc Description: PGP signature
RE: [[PATCH v1] 05/37] [CIFS] SMBD: Implement API for upper layer to create SMBD transport and establish RDMA connection
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Long Li > Sent: Wednesday, August 2, 2017 4:10 PM > To: Steve French; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org > Cc: Long Li > Subject: [[PATCH v1] 05/37] [CIFS] SMBD: Implement API for upper layer to > create SMBD transport and establish RDMA connection > > From: Long Li > > Implement the code for connecting to SMBD server. The client and server are > connected using RC Queue Pair over RDMA API, which suppports Infiniband, > RoCE and iWARP. Upper layer code can call cifs_create_rdma_session to > establish a SMBD RDMA connection. > > +/* Upcall from RDMA CM */ > +static int cifs_rdma_conn_upcall( > + struct rdma_cm_id *id, struct rdma_cm_event *event) > +{ > + struct cifs_rdma_info *info = id->context; > + > + log_rdma_event("event=%d status=%d\n", event->event, event->status); > + > + switch (event->event) { > + case RDMA_CM_EVENT_ADDR_RESOLVED: > + case RDMA_CM_EVENT_ROUTE_RESOLVED: > + info->ri_rc = 0; > + complete(>ri_done); > + break; > + > + case RDMA_CM_EVENT_ADDR_ERROR: > + info->ri_rc = -EHOSTUNREACH; > + complete(>ri_done); > + break; > + > + case RDMA_CM_EVENT_ROUTE_ERROR: > + info->ri_rc = -ENETUNREACH; > + complete(>ri_done); > + break; > + > + case RDMA_CM_EVENT_ESTABLISHED: > + case RDMA_CM_EVENT_CONNECT_ERROR: > + case RDMA_CM_EVENT_UNREACHABLE: > + case RDMA_CM_EVENT_REJECTED: > + case RDMA_CM_EVENT_DEVICE_REMOVAL: > + log_rdma_event("connected event=%d\n", event->event); > + info->connect_state = event->event; > + break; > + > + case RDMA_CM_EVENT_DISCONNECTED: > + break; > + > + default: > + break; > + } > + > + return 0; > +} This code looks a lot like the connection stuff in the NFS/RDMA RPC transport. Does your code have the same needs? If so, you might consider moving this to a common RDMA handler. > +/* Upcall from RDMA QP */ > +static void > +cifs_rdma_qp_async_error_upcall(struct ib_event *event, void *context) > +{ > + struct cifs_rdma_info *info = context; > + log_rdma_event("%s on device %s info %p\n", > + ib_event_msg(event->event), event->device->name, info); > + > + switch (event->event) > + { > + case IB_EVENT_CQ_ERR: > + case IB_EVENT_QP_FATAL: > + case IB_EVENT_QP_REQ_ERR: > + case IB_EVENT_QP_ACCESS_ERR: > + > + default: > + break; > + } > +} Ditto. But, what's up with the empty switch(event->event) processing? > +static struct rdma_cm_id* cifs_rdma_create_id( > + struct cifs_rdma_info *info, struct sockaddr *dstaddr) > +{ ... > + log_rdma_event("connecting to IP %pI4 port %d\n", > + _in->sin_addr, ntohs(addr_in->sin_port)); >... and then... > + if (dstaddr->sa_family == AF_INET6) > + sport = &((struct sockaddr_in6 *)dstaddr)->sin6_port; > + else > + sport = &((struct sockaddr_in *)dstaddr)->sin_port; > + > + *sport = htons(445); ...and > +out: > + // try port number 5445 if port 445 doesn't work > + if (*sport == htons(445)) { > + *sport = htons(5445); > + goto try_again; > + } Suggest rearranging the log_rdma_event() call to reflect reality. The IANA-assigned port for SMB Direct is 5445, and port 445 will be listening on TCP. Should you really be probing that port before 5445? I suggest not doing so unconditionally. > +struct cifs_rdma_info* cifs_create_rdma_session( > + struct TCP_Server_Info *server, struct sockaddr *dstaddr) > +{ > ... > + int max_pending = receive_credit_max + send_credit_target; >... > + if (max_pending > info->id->device->attrs.max_cqe || > + max_pending > info->id->device->attrs.max_qp_wr) { > + log_rdma_event("consider lowering receive_credit_max and " > + "send_credit_target. Possible CQE overrun, device " > + "reporting max_cpe %d max_qp_wr %d\n", > + info->id->device->attrs.max_cqe, > + info->id->device->attrs.max_qp_wr); > + goto out2; > + } I don't understand this. Why are you directing both Receive and Send completions to the same CQ, won't that make it very hard to manage completions and their interrupts? Also, what device(s) have you seen trigger this log? CQ's are generally allowed to be quite large. > + conn_param.responder_resources = 32; > + if (info->id->device->attrs.max_qp_rd_atom < 32) > +
Re: [PATCH 2/2] of: Restrict DMA configuration
+linuxppc-dev On Fri, Aug 11, 2017 at 11:29 AM, Robin Murphywrote: > Moving DMA configuration to happen later at driver probe time had the > unnoticed side-effect that we now perform DMA configuration for *every* > device represented in DT, rather than only those explicitly created by > the of_platform and PCI code. > > As Christoph points out, this is not really the best thing to do. Whilst > there may well be other DMA-capable buses that can benefit from having > their children automatically configured after the bridge has probed, > there are also plenty of others like USB, MDIO, etc. that definitely do > not support DMA and should not be indiscriminately processed. > > The good news is that DT already gives us the ammunition to do the right > thing - anything lacking a "dma-ranges" property should be considered > not to have a mapping of DMA address space from its children to its > parent, thus anything for which of_dma_get_range() does not succeed does > not need DMA configuration. > > The bad news is that strictly enforcing that would likely break just > about every FDT platform out there, since most authors have either not > considered the property at all or have mistakenly assumed that omitting > "dma-ranges" is equivalent to including the empty property. Thus we have > little choice but to special-case platform, AMBA and PCI devices so they > continue to receive configuration unconditionally as before. At least > anything new will have to get it right in future... By "anything new", you mean new buses, not new platforms, right? What's a platform bus device today could be a different kernel bus type tomorrow with no DT change. So this isn't really enforceable. I don't completely agree that omitting dma-ranges is wrong and that new DTs have to have dma-ranges simply because there is much precedent of DTs with dma-ranges omitted (just go look at PPC). If a bus has no bus to cpu address translation nor size restrictions, then no dma-ranges should be allowed. Of course, DT standards can and do evolve and we could decide to be stricter here, but that hasn't happened. If it does, then we need to make that clear in the spec and enforce it. Rob > > Fixes: 09515ef5ddad ("of/acpi: Configure dma operations at probe time for > platform/amba/pci bus devices") > Reported-by: Christoph Hellwig > Signed-off-by: Robin Murphy > --- > drivers/of/device.c | 48 > 1 file changed, 32 insertions(+), 16 deletions(-) > > diff --git a/drivers/of/device.c b/drivers/of/device.c > index e0a28ea341fe..04c4c952dc57 100644 > --- a/drivers/of/device.c > +++ b/drivers/of/device.c > @@ -9,6 +9,9 @@ > #include > #include > #include > +#include > +#include > +#include > > #include > #include "of_private.h" > @@ -84,31 +87,28 @@ int of_device_add(struct platform_device *ofdev) > */ > int of_dma_configure(struct device *dev, struct device_node *np) > { > - u64 dma_addr, paddr, size; > + u64 dma_addr, paddr, size = 0; > int ret; > bool coherent; > unsigned long offset; > const struct iommu_ops *iommu; > u64 mask; > > - /* > -* Set default coherent_dma_mask to 32 bit. Drivers are expected to > -* setup the correct supported mask. > -*/ > - if (!dev->coherent_dma_mask) > - dev->coherent_dma_mask = DMA_BIT_MASK(32); > - > - /* > -* Set it to coherent_dma_mask by default if the architecture > -* code has not set it. > -*/ > - if (!dev->dma_mask) > - dev->dma_mask = >coherent_dma_mask; > - > ret = of_dma_get_range(np, _addr, , ); > if (ret < 0) { > + /* > +* For legacy reasons, we have to assume some devices need > +* DMA configuration regardless of whether "dma-ranges" is > +* correctly specified or not. > +*/ > + if (!dev_is_pci(dev) && > +#ifdef CONFIG_ARM_AMBA > + dev->bus != _bustype && > +#endif > + dev->bus != _bus_type) > + return ret == -ENODEV ? 0 : ret; > + > dma_addr = offset = 0; > - size = max(dev->coherent_dma_mask, dev->coherent_dma_mask + > 1); > } else { > offset = PFN_DOWN(paddr - dma_addr); > > @@ -129,6 +129,22 @@ int of_dma_configure(struct device *dev, struct > device_node *np) > dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset); > } > > + /* > +* Set default coherent_dma_mask to 32 bit. Drivers are expected to > +* setup the correct supported mask. > +*/ > + if (!dev->coherent_dma_mask) > + dev->coherent_dma_mask = DMA_BIT_MASK(32); > + /* > +* Set it to coherent_dma_mask by default if the architecture > +* code has not set
Re: [PATCH v1] i2c: aspeed: fixed potential null pointer dereference
On Fri, Jul 28, 2017 at 06:00:12PM -0700, Brendan Higgins wrote: > Before I skipped null checks when the master is in the STOP state; this > fixes that. > > Signed-off-by: Brendan HigginsApplied to for-current, thanks! signature.asc Description: PGP signature
RE: [[PATCH v1] 07/37] [CIFS] SMBD: Implement receive buffer for handling SMBD response
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Long Li > Sent: Wednesday, August 2, 2017 4:10 PM > To: Steve French; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org > Cc: Long Li > Subject: [[PATCH v1] 07/37] [CIFS] SMBD: Implement receive buffer for > handling SMBD response > > +/* > + * Receive buffer operations. > + * For each remote send, we need to post a receive. The receive buffers are > + * pre-allocated in advance. > + */ This approach appears to have been derived from the NFS/RDMA one. The SMB protocol operates very differently! It is not a strict request/ response protocol. Many operations can become asynchronous by the server choosing to make a STATUS_PENDING reply. A second reply then comes later. The SMB2_CANCEL operation normally has no reply at all. And callbacks for oplocks can occur at any time. Even within a single request, many replies can be received. For example, an SMB2_READ response which exceeds your negotiated receive size of 8192. These will be fragmented by SMB Direct into a "train" of multiple messages, which will be logically reassembled by the receiver. Each of them will consume a credit. Thanks to SMB Direct crediting, the connection is not failing, but you are undoubtedly spending a lot of time and ping-ponging to re-post receives and allow the message trains to flow. And, because it's never one-to-one, there are also unneeded receives posted before and after such exchanges. You need to use SMB Direct crediting to post a more traffic-sensitive pool of receives, and simply manage its depth when posting client requests. As a start, I'd suggest simply choosing a constant number, approximately whatever credit value you actually negotiate with the peer. Then, just replenish (re-post) receive buffers as they are completed by the adapter. You can get more sophisticated about this strategy later. Tom. > +static struct cifs_rdma_response* get_receive_buffer(struct cifs_rdma_info > *info) > +{ > + struct cifs_rdma_response *ret = NULL; > + unsigned long flags; > + > + spin_lock_irqsave(>receive_queue_lock, flags); > + if (!list_empty(>receive_queue)) { > + ret = list_first_entry( > + >receive_queue, > + struct cifs_rdma_response, list); > + list_del(>list); > + info->count_receive_buffer--; > + info->count_get_receive_buffer++; > + } > + spin_unlock_irqrestore(>receive_queue_lock, flags); > + > + return ret; > +} > + > +static void put_receive_buffer( > + struct cifs_rdma_info *info, struct cifs_rdma_response *response) > +{ > + unsigned long flags; > + > + ib_dma_unmap_single(info->id->device, response->sge.addr, > + response->sge.length, DMA_FROM_DEVICE); > + > + spin_lock_irqsave(>receive_queue_lock, flags); > + list_add_tail(>list, >receive_queue); > + info->count_receive_buffer++; > + info->count_put_receive_buffer++; > + spin_unlock_irqrestore(>receive_queue_lock, flags); > +} > + > +static int allocate_receive_buffers(struct cifs_rdma_info *info, int num_buf) > +{ > + int i; > + struct cifs_rdma_response *response; > + > + INIT_LIST_HEAD(>receive_queue); > + spin_lock_init(>receive_queue_lock); > + > + for (i=0; i + response = mempool_alloc(info->response_mempool, GFP_KERNEL); > + if (!response) > + goto allocate_failed; > + > + response->info = info; > + list_add_tail(>list, >receive_queue); > + info->count_receive_buffer++; > + } > + > + return 0; > + > +allocate_failed: > + while (!list_empty(>receive_queue)) { > + response = list_first_entry( > + >receive_queue, > + struct cifs_rdma_response, list); > + list_del(>list); > + info->count_receive_buffer--; > + > + mempool_free(response, info->response_mempool); > + } > + return -ENOMEM; > +} > + > +static void destroy_receive_buffers(struct cifs_rdma_info *info) > +{ > + struct cifs_rdma_response *response; > + while ((response = get_receive_buffer(info))) > + mempool_free(response, info->response_mempool); > +} > +
Re: [PATCH v2 01/19] perf, tools: Save max_x, max_y in xyarray
On Fri, Aug 11, 2017 at 04:26:16PM -0700, Andi Kleen wrote: > From: Andi Kleen> > Save the original array dimensions in xyarrays, so that users can retrieve > them > later. Add some inline functions to access these fields. hi, is there a branch with this? also I recall sending feedback for some of those patches, any changes..? jirka
RE: [[PATCH v1] 15/37] [CIFS] SMBD: Post a SMBD data transfer message with data payload
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Long Li > Sent: Wednesday, August 2, 2017 4:10 PM > To: Steve French; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org > Cc: Long Li > Subject: [[PATCH v1] 15/37] [CIFS] SMBD: Post a SMBD data transfer message > with data payload > > Similar to sending transfer message with page payload, this function creates a > SMBD data packet and send it over to RDMA, from iov passed from upper layer. The following routine is heavily redundant with 14/37 cifs_rdma_post_send_page(). Because they share quite a bit of protocol and DMA mapping logic, strongly suggest they be merged. Tom. > +static int cifs_rdma_post_send_data( > + struct cifs_rdma_info *info, > + struct kvec *iov, int n_vec, int remaining_data_length); > static int cifs_rdma_post_send_page(struct cifs_rdma_info *info, > struct page *page, unsigned long offset, > size_t size, int remaining_data_length); > @@ -671,6 +674,122 @@ static int cifs_rdma_post_send_page(struct > cifs_rdma_info *info, struct page *pa > }
Re: [PATCH] nokia n900: update dts with camera support
* Sakari Ailus[170814 13:20]: > Hi Pavel, > > Thanks for the patch. > > I understand Tony already applied this one. I'd have a few comments below, > could you address them in another patch, please? Oops sorry about that. It looked trivial enough for me. Yes an incremental patces to follow-up please. Regards, Tony
Re: [PATCH v4 0/4] seccomp: Implement SECCOMP_RET_KILL_PROCESS action
On Fri, Aug 11, 2017 at 6:05 PM, Kees Cookwrote: > This series is the result of Fabricio, Tyler, Will and I going around a > few times on possible solutions for finding a way to enhance RET_KILL > to kill the process group. There's a lot of ways this could be done, > but I wanted something that felt cleanest. My sense of what constitutes > "clean" has shifted a few times, and after continually running into > weird corner cases, I decided to make changes to the seccomp action mask, > which shouldn't be too invasive to userspace as it turns out. Everything > else becomes much easier, especially after being able to use Tyler's > new SECCOMP_GET_ACTION_AVAIL operation. > > This renames SECCOMP_RET_KILL to SECCOMP_RET_KILL_THREAD and adds > SECCOMP_RET_KILL_PROCESS. I just took a very quick look and I'm not seeing anything that would cause any backwards compatibility issues for libseccomp. You could try running the libseccomp tests against a patched kernel to make sure; the README has all the info you need (pay special attention to the "live" tests, although those are pretty meager at the moment). -- paul moore www.paul-moore.com
Re: [PATCH 0/4] SELinux: Fine-tuning for some function implementations
On Sun, Aug 13, 2017 at 10:43 AM, SF Markus Elfringwrote: > From: Markus Elfring > Date: Sun, 13 Aug 2017 16:25:43 +0200 > > A few update suggestions were taken into account > from static source code analysis. > > Markus Elfring (4): > Delete eight unnecessary variable assignments > Adjust jump targets in ebitmap_read() > Delete an unnecessary return statement in ebitmap_destroy() > Adjust five checks for null pointers Hi Markus, I merged many of your patches in the past because I wanted to help encourage your involvement, but you will remember I mentioned at the time that I generally dislike merging these trivial, and often style-only, patches. I believe I even pointed you in the direction of our SELinux kernel issue tracker for a list of areas where you could help contribute in a meaningful way (link below). My earlier comments still apply; if you want to continue to contribute to SELinux in the kernel, please focus your attention on more meaningful changes. I am not going to merge any of these patches. * https://github.com/SELinuxProject/selinux-kernel/issues -- paul moore www.paul-moore.com
RE: [[PATCH v1] 22/37] [CIFS] SMBD: Implement API for upper layer to receive data to page
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Long Li > Sent: Wednesday, August 2, 2017 4:11 PM > To: Steve French; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org > Cc: Long Li > Subject: [[PATCH v1] 22/37] [CIFS] SMBD: Implement API for upper layer to > receive data to page > > /* > + * Read a page from receive reassembly queue > + * page: the page to read data into > + * to_read: the length of data to read > + * return value: actual data read > + */ > +int cifs_rdma_read_page(struct cifs_rdma_info *info, > + struct page *page, unsigned int to_read) > +{ Same comment as for cifs_rdma_write() - this name is confusing as it does not perform an RDMA Read. Needs to be changed. Tom.
Re: [PATCH] pciehp: Fix infinite interupt handler loop
On Tue, Aug 01, 2017 at 03:11:52AM -0400, Keith Busch wrote: > We've encountered a particular platform that under some circumstances > always has the power fault detected status raised. The pciehp irq handler > would loop forever because it thinks it is handling new events when in > fact the power fault is not new. This patch fixes that by masking off > the power fault status from new events if the driver hasn't seen the > power fault clear from the previous handling attempt. Can you say which platform this is? If this is a hardware defect, it'd be interesting to know where it happens. But I'm not sure we handle PCI_EXP_SLTSTA correctly. We basically have this: pciehp_isr() { pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, ); events = status & (); pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, events); } The write to PCI_EXP_SLTSTA clears PCI_EXP_SLTSTA_PFD because it's RW1C. But we haven't done anything that would actually change the situation that caused a power fault, so I don't think it would be surprising if the hardware immediately reasserted it. So maybe this continual assertion of power fault is really a software bug, not a hardware problem? > Fixes: fad214b0aa72 ("PCI: pciehp: Process all hotplug events before looking > for new ones") > > Cc:# 4.9+ > Cc: Mayurkumar Patel > Signed-off-by: Keith Busch > --- > Resending due to send-email setup error; this patch may appear twice > for some. > > drivers/pci/hotplug/pciehp_hpc.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/hotplug/pciehp_hpc.c > b/drivers/pci/hotplug/pciehp_hpc.c > index 026830a..8ecbc13 100644 > --- a/drivers/pci/hotplug/pciehp_hpc.c > +++ b/drivers/pci/hotplug/pciehp_hpc.c > @@ -583,7 +583,9 @@ static irqreturn_t pciehp_isr(int irq, void *dev_id) >* Slot Status contains plain status bits as well as event >* notification bits; right now we only want the event bits. >*/ > - events = status & (PCI_EXP_SLTSTA_ABP | PCI_EXP_SLTSTA_PFD | > + events = status & (PCI_EXP_SLTSTA_ABP | > + (ctrl->power_fault_detected ? > + 0 : PCI_EXP_SLTSTA_PFD) | > PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_CC | > PCI_EXP_SLTSTA_DLLSC); > if (!events) > -- > 2.5.5 >
Re: [PATCH v2] PCI/MSI: Improve MSI alias detection
On Tue, Aug 01, 2017 at 06:59:08PM +0100, Robin Murphy wrote: > Currently, we handle all DMA aliases equally when calculating MSI > requester IDs for the generic infrastructure. This turns out to be the > wrong thing to do in the face of pure DMA quirks like those of Marvell > SATA cards, where in the usual case the last thing seen in the alias > walk is the DMA phantom function: we end up configuring the MSI > doorbell to expect that alias, then find we have no interrupts since > the MSI writes still come from the 'real' RID, thus get filtered out > and ignored. > > Improve the alias walk to only account for the topological aliases that > matter, based on the logic from the Intel IRQ remapping code. > > Signed-off-by: Robin MurphyApplied with Marc's ack to pci/msi for v4.14, thanks! I used the subject line: PCI/MSI: Assume MSIs use real Requester ID, not an alias > --- > > v2: Properly document the rationale. > > drivers/pci/msi.c | 27 ++- > 1 file changed, 22 insertions(+), 5 deletions(-) > > diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c > index 253d92409bb3..2f0dd02d78b7 100644 > --- a/drivers/pci/msi.c > +++ b/drivers/pci/msi.c > @@ -1458,13 +1458,30 @@ struct irq_domain *pci_msi_create_irq_domain(struct > fwnode_handle *fwnode, > } > EXPORT_SYMBOL_GPL(pci_msi_create_irq_domain); > > +/* > + * Users of the generic MSI infrastructure expect a device to have a single > ID, > + * so with DMA aliases we have to pick the least-worst compromise. Devices > with > + * DMA phantom functions tend to still emit MSIs from the real function > number, > + * so we ignore those and only consider topological aliases where either the > + * alias device or RID appears on a different bus number. We also make the > + * reasonable assumption that bridges are walked in an upstream direction (so > + * the last one seen wins), and the much braver assumption that the most > likely > + * case is that of PCI->PCIe so we should always use the alias RID. This > echoes > + * the logic from intel_irq_remapping's set_msi_sid(), which presumably works > + * well enough in practice; in the face of the horrible PCIe<->PCI-X > conditions > + * for taking ownership all we can really do is close our eyes and hope... > + */ > static int get_msi_id_cb(struct pci_dev *pdev, u16 alias, void *data) > { > u32 *pa = data; > + u8 bus = PCI_BUS_NUM(*pa); > + > + if (pdev->bus->number != bus || PCI_BUS_NUM(alias) != bus) > + *pa = alias; > > - *pa = alias; > return 0; > } > + > /** > * pci_msi_domain_get_msi_rid - Get the MSI requester id (RID) > * @domain: The interrupt domain > @@ -1478,7 +1495,7 @@ static int get_msi_id_cb(struct pci_dev *pdev, u16 > alias, void *data) > u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev > *pdev) > { > struct device_node *of_node; > - u32 rid = 0; > + u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn); > > pci_for_each_dma_alias(pdev, get_msi_id_cb, ); > > @@ -1494,14 +1511,14 @@ u32 pci_msi_domain_get_msi_rid(struct irq_domain > *domain, struct pci_dev *pdev) > * @pdev:The PCI device > * > * Use the firmware data to find a device-specific MSI domain > - * (i.e. not one that is ste as a default). > + * (i.e. not one that is set as a default). > * > - * Returns: The coresponding MSI domain or NULL if none has been found. > + * Returns: The corresponding MSI domain or NULL if none has been found. > */ > struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev) > { > struct irq_domain *dom; > - u32 rid = 0; > + u32 rid = PCI_DEVID(pdev->bus->number, pdev->devfn); > > pci_for_each_dma_alias(pdev, get_msi_id_cb, ); > dom = of_msi_map_get_device_domain(>dev, rid); > -- > 2.12.2.dirty >
RE: [[PATCH v1] 26/37] [CIFS] SMBD: Send an immediate packet when it's needed
> -Original Message- > From: linux-cifs-ow...@vger.kernel.org [mailto:linux-cifs- > ow...@vger.kernel.org] On Behalf Of Long Li > Sent: Wednesday, August 2, 2017 4:11 PM > To: Steve French; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org > Cc: Long Li > Subject: [[PATCH v1] 26/37] [CIFS] SMBD: Send an immediate packet when it's > needed > > +/* > + * Check and schedule to send an immediate packet > + * This is used to extend credtis to remote peer to keep the transport busy > + */ > +static void check_and_send_immediate(struct cifs_rdma_info *info) > +{ > + info->send_immediate = true; > + > + // promptly send a packet if running low on receive credits ...if *our peer* is running low on credits. > + if (atomic_read(>receive_credits) < > + atomic_read(>receive_credit_target) -1 ) Why read the receive_credit_target atomically? It's a mostly unchanging local value? Tom.
[PATCH 6/9] ASoc: cygnus: Fix problems with multichannel transfers
Problems were found with multi-channel (4+) TDM transfers. The alignment of the channels within the frame could shift when starting a new transfer. In order to implement a fix the register programming sequence needed to be revised. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-ssp.c | 539 - sound/soc/bcm/cygnus-ssp.h | 14 +- 2 files changed, 394 insertions(+), 159 deletions(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index 5b6e345..5292c04 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -121,6 +121,7 @@ #define I2S_OUT_STREAM_ENA 31 #define I2S_OUT_STREAM_CFG_GROUP_ID 20 #define I2S_OUT_STREAM_CFG_CHANNEL_GROUPING 24 +#define I2S_OUT_STREAM_CFG_FCI_ID_MASK 0x3ff /* AUD_FMM_IOP_IN_I2S_x_CAP */ #define I2S_IN_STREAM_CFG_CAP_ENA 31 @@ -129,7 +130,11 @@ /* AUD_FMM_IOP_OUT_I2S_x_I2S_CFG_REG */ #define I2S_OUT_CFGX_CLK_ENA 0 #define I2S_OUT_CFGX_DATA_ENABLE 1 +#define I2S_OUT_CFGX_LRCK_POLARITY 4 +#define I2S_OUT_CFGX_SCLK_POLARITY 5 #define I2S_OUT_CFGX_DATA_ALIGNMENT 6 +#define I2S_OUT_CFGX_BITS_PER_SAMPLE 8 +#define I2S_OUT_CFGX_BIT_PER_SAMPLE_MASK 0x1f #define I2S_OUT_CFGX_BITS_PER_SLOT 13 #define I2S_OUT_CFGX_VALID_SLOT 14 #define I2S_OUT_CFGX_FSYNC_WIDTH18 @@ -137,14 +142,27 @@ #define I2S_OUT_CFGX_SLAVE_MODE 30 #define I2S_OUT_CFGX_TDM_MODE 31 +#define I2S_IN_CFGX_DATA_ALIGNMENT 6 +#define I2S_IN_CFGX_BITS_PER_SAMPLE 8 +#define I2S_IN_CFGX_BIT_PER_SAMPLE_MASK 0x1f +#define I2S_IN_CFGX_BITS_PER_SLOT 13 +#define I2S_IN_CFGX_VALID_SLOT 14 +#define I2S_IN_CFGX_SLAVE_MODE 30 +#define I2S_IN_CFGX_TDM_MODE31 + /* AUD_FMM_BF_CTRL_SOURCECH_CFGx_REG */ #define BF_SRC_CFGX_SFIFO_ENA 0 #define BF_SRC_CFGX_BUFFER_PAIR_ENABLE 1 #define BF_SRC_CFGX_SAMPLE_CH_MODE 2 #define BF_SRC_CFGX_SFIFO_SZ_DOUBLE5 #define BF_SRC_CFGX_NOT_PAUSE_WHEN_EMPTY 10 +#define BF_SRC_CFGX_SAMPLE_REPEAT_ENABLE 11 #define BF_SRC_CFGX_BIT_RES 20 #define BF_SRC_CFGX_PROCESS_SEQ_ID_VALID 31 +#define BF_SRC_CFGX_BITRES_MASK 0x1f + +/* AUD_FMM_BF_CTRL_SOURCECH_CTRLx_REG */ +#define BF_SOURCECH_CTRL_PLAY_RUN 0 /* AUD_FMM_BF_CTRL_DESTCH_CFGx_REG */ #define BF_DST_CFGX_CAP_ENA 0 @@ -154,11 +172,16 @@ #define BF_DST_CFGX_FCI_ID 12 #define BF_DST_CFGX_CAP_MODE24 #define BF_DST_CFGX_PROC_SEQ_ID_VALID 31 +#define BF_DST_CFGX_BITRES_MASK 0x1f + +/* AUD_FMM_BF_CTRL_DESTCH_CTRLX */ +#define BF_DESTCH_CTRLX_CAP_RUN 0x1 /* AUD_FMM_IOP_OUT_SPDIF_xxx */ #define SPDIF_0_OUT_DITHER_ENA 3 #define SPDIF_0_OUT_STREAM_ENA31 +#define IOP_LOGIC_RESET_IN_OFFSET(x) ((x) + 7) /* Capture ports offset by 7 */ #define INIT_SSP_REGS(num) (struct cygnus_ssp_regs){ \ .i2s_stream_cfg = OUT_I2S_ ##num## _STREAM_CFG_OFFSET, \ @@ -169,8 +192,7 @@ .bf_destch_ctrl = BF_DST_CTRL ##num## _OFFSET, \ .bf_destch_cfg = BF_DST_CFG ##num## _OFFSET, \ .bf_sourcech_ctrl = BF_SRC_CTRL ##num## _OFFSET, \ - .bf_sourcech_cfg = BF_SRC_CFG ##num## _OFFSET, \ - .bf_sourcech_grp = BF_SRC_GRP ##num## _OFFSET \ + .bf_sourcech_cfg = BF_SRC_CFG ##num## _OFFSET \ } #define CYGNUS_RATE_MIN 8000 @@ -189,6 +211,8 @@ .list = cygnus_rates, }; +static void update_ssp_cfg(struct cygnus_aio_port *aio); + static struct cygnus_aio_port *cygnus_dai_get_portinfo(struct snd_soc_dai *dai) { struct cygnus_audio *cygaud = snd_soc_dai_get_drvdata(dai); @@ -201,15 +225,17 @@ static int audio_ssp_init_portregs(struct cygnus_aio_port *aio) u32 value, fci_id; int status = 0; + /* Set Group ID */ + writel(0, aio->cygaud->audio + BF_SRC_GRP0_OFFSET); + writel(1, aio->cygaud->audio + BF_SRC_GRP1_OFFSET); + writel(2, aio->cygaud->audio + BF_SRC_GRP2_OFFSET); + writel(3, aio->cygaud->audio + BF_SRC_GRP3_OFFSET); + switch (aio->port_type) { case PORT_TDM: value = readl(aio->cygaud->audio + aio->regs.i2s_stream_cfg); value &= ~I2S_STREAM_CFG_MASK; - /* Set Group ID */ - writel(aio->portnum, - aio->cygaud->audio + aio->regs.bf_sourcech_grp); - /* Configure the AUD_FMM_IOP_OUT_I2S_x_STREAM_CFG reg */ value |= aio->portnum << I2S_OUT_STREAM_CFG_GROUP_ID; value |= aio->portnum; /* FCI ID is the port num */ @@ -219,6 +245,7 @@ static int audio_ssp_init_portregs(struct cygnus_aio_port *aio) /* Configure the AUD_FMM_BF_CTRL_SOURCECH_CFGX reg */ value = readl(aio->cygaud->audio + aio->regs.bf_sourcech_cfg); value &= ~BIT(BF_SRC_CFGX_NOT_PAUSE_WHEN_EMPTY); + value &=
[PATCH 5/9] ASoC: cygnus: Remove support for 8 bit audio and for mono
These modes of operation were not working properly. There is little to be gained by enabling these modes and the changes required to potentially fix these modes would complicate the driver. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-ssp.c | 24 +--- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index 4c476ce..5b6e345 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -547,23 +547,10 @@ static int cygnus_ssp_hw_params(struct snd_pcm_substream *substream, if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { value = readl(aio->cygaud->audio + aio->regs.bf_sourcech_cfg); value &= ~BIT(BF_SRC_CFGX_BUFFER_PAIR_ENABLE); - /* Configure channels as mono or stereo/TDM */ - if (params_channels(params) == 1) - value |= BIT(BF_SRC_CFGX_SAMPLE_CH_MODE); - else - value &= ~BIT(BF_SRC_CFGX_SAMPLE_CH_MODE); + value &= ~BIT(BF_SRC_CFGX_SAMPLE_CH_MODE); writel(value, aio->cygaud->audio + aio->regs.bf_sourcech_cfg); switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S8: - if (aio->port_type == PORT_SPDIF) { - dev_err(aio->cygaud->dev, - "SPDIF does not support 8bit format\n"); - return -EINVAL; - } - bitres = 8; - break; - case SNDRV_PCM_FORMAT_S16_LE: bitres = 16; break; @@ -1008,19 +995,18 @@ static int cygnus_ssp_set_pll(struct snd_soc_dai *cpu_dai, int pll_id, #define INIT_CPU_DAI(num) { \ .name = "cygnus-ssp" #num, \ .playback = { \ - .channels_min = 1, \ + .channels_min = 2, \ .channels_max = 16, \ .rates = SNDRV_PCM_RATE_KNOT, \ - .formats = SNDRV_PCM_FMTBIT_S8 | \ - SNDRV_PCM_FMTBIT_S16_LE | \ + .formats = SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S32_LE, \ }, \ .capture = { \ .channels_min = 2, \ .channels_max = 16, \ .rates = SNDRV_PCM_RATE_KNOT, \ - .formats = SNDRV_PCM_FMTBIT_S16_LE | \ - SNDRV_PCM_FMTBIT_S32_LE, \ + .formats = SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S32_LE, \ }, \ .ops = _ssp_dai_ops, \ } -- 1.9.1
[PATCH 7/9] ASoC: cygnus: Remove set_fmt from SPDIF dai ops
The SPDIF port cannot modify its format so a set_fmt function is not needed. Previously, we used a generic set_fmt for all ports and returned an error code for the SPDIF port. It is cleaner to not populate the set_fmt field. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-ssp.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index 5292c04..e72d8a8 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -1222,6 +1222,13 @@ static void update_ssp_cfg(struct cygnus_aio_port *aio) .set_pll= cygnus_ssp_set_pll, }; +static const struct snd_soc_dai_ops cygnus_spdif_dai_ops = { + .startup= cygnus_ssp_startup, + .shutdown = cygnus_ssp_shutdown, + .trigger= cygnus_ssp_trigger, + .hw_params = cygnus_ssp_hw_params, + .set_sysclk = cygnus_ssp_set_sysclk, +}; #define INIT_CPU_DAI(num) { \ .name = "cygnus-ssp" #num, \ @@ -1255,9 +1262,9 @@ static void update_ssp_cfg(struct cygnus_aio_port *aio) .channels_max = 2, .rates = SNDRV_PCM_RATE_KNOT, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S32_LE, + SNDRV_PCM_FMTBIT_S32_LE, }, - .ops = _ssp_dai_ops, + .ops = _spdif_dai_ops, }; static struct snd_soc_dai_driver cygnus_ssp_dai[CYGNUS_MAX_PORTS]; -- 1.9.1
[PATCH 0/9] ASoC: cygnus: Various improvements and fixes
This patch series contains an number of improvements and refinements to the driver. There is also a fix for a problem when transferring four or more channels in TDM mode. Lori Hikichi (9): ASoC: cygnus: Add support for 384kHz frame rates ASoC: cygnus: Update bindings for audio clock changes ASoC: cygnus: Allow each port to select its clock source ASoC: cygnus: Only enable MCLK pins when in use ASoC: cygnus: Remove support for 8 bit audio and for mono ASoc: cygnus: Fix problems with multichannel transfers ASoC: cygnus: Remove set_fmt from SPDIF dai ops ASoC: cygnus: Add EXPORT_SYMBOL for helper function ASoC: cygnus: Tidy up of structure access .../bindings/sound/brcm,cygnus-audio.txt | 70 +- sound/soc/bcm/cygnus-pcm.c | 50 +- sound/soc/bcm/cygnus-ssp.c | 1336 ++-- sound/soc/bcm/cygnus-ssp.h | 51 +- 4 files changed, 739 insertions(+), 768 deletions(-) -- 1.9.1
Re: [PATCH] pciehp: Fix infinite interupt handler loop
On Mon, Aug 14, 2017 at 03:59:48PM -0500, Bjorn Helgaas wrote: > On Tue, Aug 01, 2017 at 03:11:52AM -0400, Keith Busch wrote: > > We've encountered a particular platform that under some circumstances > > always has the power fault detected status raised. The pciehp irq handler > > would loop forever because it thinks it is handling new events when in > > fact the power fault is not new. This patch fixes that by masking off > > the power fault status from new events if the driver hasn't seen the > > power fault clear from the previous handling attempt. > > Can you say which platform this is? If this is a hardware defect, > it'd be interesting to know where it happens. > > But I'm not sure we handle PCI_EXP_SLTSTA correctly. We basically > have this: > > pciehp_isr() > { > pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, ); > events = status & (); > pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, events); > > } > > The write to PCI_EXP_SLTSTA clears PCI_EXP_SLTSTA_PFD because it's > RW1C. But we haven't done anything that would actually change the > situation that caused a power fault, so I don't think it would be > surprising if the hardware immediately reasserted it. > > So maybe this continual assertion of power fault is really a software > bug, not a hardware problem? I *think* it's a software bug for the exact reason you provided, but I'm sure it must be isolated to certain conditions with certain hardware. We'd have heard about this regression during 4.9 if it was more wide-spread. This is on a PEX8733 bridge, and it reports power fault detected status as long as the power fault exists. While we can write 1 to clear the event, that just rearms the port to retrigger power fault detected status for as long as the power controller detects its faulted. The status is cleared for good only when the power fault no longer exists rather than when it is acknowledged. The spec seems to support that view (Table (7-21: Slot Status Register): Power Fault Detected – If a Power Controller that supports power fault detection is implemented, this bit is Set when the Power Controller detects a power fault at this slot.
[PATCH 2/9] ASoC: cygnus: Update bindings for audio clock changes
Allow each audio port to select which clock (if any) it wants to use. Signed-off-by: Lori Hikichi--- .../bindings/sound/brcm,cygnus-audio.txt | 70 ++ 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/brcm,cygnus-audio.txt b/Documentation/devicetree/bindings/sound/brcm,cygnus-audio.txt index b139e66..2ef2f2c 100644 --- a/Documentation/devicetree/bindings/sound/brcm,cygnus-audio.txt +++ b/Documentation/devicetree/bindings/sound/brcm,cygnus-audio.txt @@ -9,19 +9,28 @@ Required properties: Valid names are "aud" and "i2s_in". "aud" contains a set of DMA, I2S_OUT and SPDIF registers. "i2s_in" contains a set of I2S_IN registers. - - clocks: PLL and leaf clocks used by audio ports - - assigned-clocks: PLL and leaf clocks - - assigned-clock-parents: parent clocks of the assigned clocks - (usually the PLL) - - assigned-clock-rates: List of clock frequencies of the - assigned clocks - - clock-names: names of 3 leaf clocks used by audio ports - Valid names are "ch0_audio", "ch1_audio", "ch2_audio" - interrupts: audio DMA interrupt number +Optional properties: + - assigned-clocks: only valid choice is audiopll + - assigned-clock-rates: clock frequency for audiopll +If none of the ports need an internal master clock then there no need to +initialize the pll clock. + + SSP Subnode properties: -- reg: The index of ssp port interface to use - Valid value are 0, 1, 2, or 3 (for spdif) +Required: + - reg: The index of ssp port interface to use + Valid value are 0, 1, 2, or 3 (for spdif) +Optional: + - clocks: clock used by audio port + one of the audiopll outputs (see brcm,iproc-clocks.txt). + - clock-names: Must be "ssp_clk" + - brcm,ssp-clk-mux = Needed if a clock is named and used. This value is + used to program the mux within the audio driver which selects + the incoming clock. Here is the mapping. + audio_pll output 0 = 0, output 1 = 1, and output 2 = 2 + Example: cygnus_audio: audio@180ae000 { @@ -30,38 +39,49 @@ Example: #size-cells = <0>; reg = <0x180ae000 0xafd>, <0x180aec00 0x1f8>; reg-names = "aud", "i2s_in"; - clocks = < BCM_CYGNUS_AUDIOPLL_CH0>, - < BCM_CYGNUS_AUDIOPLL_CH1>, - < BCM_CYGNUS_AUDIOPLL_CH2>; - assigned-clocks = < BCM_CYGNUS_AUDIOPLL>, - < BCM_CYGNUS_AUDIOPLL_CH0>, - < BCM_CYGNUS_AUDIOPLL_CH1>, - < BCM_CYGNUS_AUDIOPLL_CH2>; - assigned-clock-parents = < BCM_CYGNUS_AUDIOPLL>; - assigned-clock-rates = <1769470191>, - <0>, - <0>, - <0>; - clock-names = "ch0_audio", "ch1_audio", "ch2_audio"; + + assigned-clocks = < BCM_CYGNUS_AUDIOPLL>; + assigned-clock-rates = <1376255989>; + interrupts = ; ssp0: ssp_port@0 { reg = <0>; + + clocks = < BCM_CYGNUS_AUDIOPLL_CH0>; + clock-names = "ssp_clk"; + brcm,ssp-clk-mux = <0>; + status = "okay"; }; ssp1: ssp_port@1 { reg = <1>; - status = "disabled"; + + clocks = < BCM_CYGNUS_AUDIOPLL_CH1>; + clock-names = "ssp_clk"; + brcm,ssp-clk-mux = <1>; + + status = "okay"; }; ssp2: ssp_port@2 { reg = <2>; - status = "disabled"; + + clocks = < BCM_CYGNUS_AUDIOPLL_CH2>; + clock-names = "ssp_clk"; + brcm,ssp-clk-mux = <2>; + + status = "okay"; }; spdif: spdif_port@3 { reg = <3>; + + clocks = < BCM_CYGNUS_AUDIOPLL_CH2>; + clock-names = "ssp_clk"; + brcm,ssp-clk-mux = <2>; + status = "disabled"; }; }; -- 1.9.1
[PATCH 4/9] ASoC: cygnus: Only enable MCLK pins when in use
The MCLK pins are now only enabled when they are in use. Signed-off-by: Lori Hikichi--- sound/soc/bcm/cygnus-ssp.c | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index 00fd4dc..4c476ce 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -41,10 +41,10 @@ /* Begin register offset defines */ #define AUD_MISC_SEROUT_OE_REG_BASE 0x01c #define AUD_MISC_SEROUT_SPDIF_OE 12 -#define AUD_MISC_SEROUT_MCLK_OE 3 -#define AUD_MISC_SEROUT_LRCK_OE 2 -#define AUD_MISC_SEROUT_SCLK_OE 1 -#define AUD_MISC_SEROUT_SDAT_OE 0 +#define AUD_MISC_SEROUT_MCLK_OE3 +#define AUD_MISC_SEROUT_LRCK_OE2 +#define AUD_MISC_SEROUT_SCLK_OE1 +#define AUD_MISC_SEROUT_SDAT_OE0 /* AUD_FMM_BF_CTRL_xxx regs */ #define BF_DST_CFG0_OFFSET 0x100 @@ -684,6 +684,11 @@ static int cygnus_ssp_set_sysclk(struct snd_soc_dai *dai, value |= (sel << I2S_OUT_PLLCLKSEL_SHIFT); writel(value, aio->cygaud->audio + aio->regs.i2s_mclk_cfg); + /* Clear bit for active */ + value = readl(aio->cygaud->audio + AUD_MISC_SEROUT_OE_REG_BASE); + value &= ~BIT(AUD_MISC_SEROUT_MCLK_OE + (aio->portnum * 4)); + writel(value, aio->cygaud->audio + AUD_MISC_SEROUT_OE_REG_BASE); + return 0; } @@ -827,15 +832,12 @@ static int cygnus_ssp_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) * Shift the mask based upon port number. */ mask = BIT(AUD_MISC_SEROUT_LRCK_OE) - | BIT(AUD_MISC_SEROUT_SCLK_OE) - | BIT(AUD_MISC_SEROUT_MCLK_OE); + | BIT(AUD_MISC_SEROUT_SCLK_OE); mask = mask << (aio->portnum * 4); if (aio->is_slave) - /* Set bit for tri-state */ - val |= mask; + val |= mask; /* Set bit for tri-state */ else - /* Clear bit for drive */ - val &= ~mask; + val &= ~mask; /* Clear bit for drive */ dev_dbg(aio->cygaud->dev, "%s Set OE bits 0x%x\n", __func__, val); writel(val, aio->cygaud->audio + AUD_MISC_SEROUT_OE_REG_BASE); -- 1.9.1
[PATCH v2] msleep() delays - replace with usleep_range() in TPM 1.2/2.0 generic drivers
The patch simply replaces all msleep function calls with usleep_range calls in the generic drivers. Tested with an Infineon TPM 1.2, using the generic tpm-tis module, for a thousand PCR extends, we see results going from 1m57s unpatched to 40s with the new patch. We obtain similar results when using the original and patched tpm_infineon driver, which is also part of the patch. Similarly with a STM TPM 2.0, using the CRB driver, it takes about 20ms per extend unpatched and around 7ms with the new patch. Note that the PCR consistency is untouched with this patch, each TPM has been tested with 10 million extends and the aggregated PCR value is continuously verified to be correct. As an extension of this work, this could potentially and easily be applied to other vendor's drivers. Still, these changes are not included in the proposed patch as they are untested. Signed-off-by: Hamza Attak--- drivers/char/tpm/tpm-interface.c | 10 +- drivers/char/tpm/tpm.h | 9 - drivers/char/tpm/tpm2-cmd.c | 2 +- drivers/char/tpm/tpm_infineon.c | 6 +++--- drivers/char/tpm/tpm_tis_core.c | 8 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index bd2128e..123a73a 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -395,7 +395,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz, goto out; } - msleep(TPM_TIMEOUT);/* CHECK */ + tpm_msleep(TPM_TIMEOUT); rmb(); } while (time_before(jiffies, stop)); @@ -862,7 +862,7 @@ int tpm_do_selftest(struct tpm_chip *chip) dev_info( >dev, HW_ERR "TPM command timed out during continue self test"); - msleep(delay_msec); + tpm_msleep(delay_msec); continue; } @@ -877,7 +877,7 @@ int tpm_do_selftest(struct tpm_chip *chip) } if (rc != TPM_WARN_DOING_SELFTEST) return rc; - msleep(delay_msec); + tpm_msleep(delay_msec); } while (--loops > 0); return rc; @@ -977,7 +977,7 @@ again: } } else { do { - msleep(TPM_TIMEOUT); + tpm_msleep(TPM_TIMEOUT); status = chip->ops->status(chip); if ((status & mask) == mask) return 0; @@ -1045,7 +1045,7 @@ int tpm_pm_suspend(struct device *dev) */ if (rc != TPM_WARN_RETRY) break; - msleep(TPM_TIMEOUT_RETRY); + tpm_msleep(TPM_TIMEOUT_RETRY); } if (rc) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 4937b56..255ecdc 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -46,7 +46,8 @@ enum tpm_const { enum tpm_timeout { TPM_TIMEOUT = 5,/* msecs */ - TPM_TIMEOUT_RETRY = 100 /* msecs */ + TPM_TIMEOUT_RETRY = 100, /* msecs */ + TPM_TIMEOUT_RANGE_US = 300 /* usecs */ }; /* TPM addresses */ @@ -509,6 +510,12 @@ int tpm_pm_resume(struct device *dev); int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, wait_queue_head_t *queue, bool check_cancel); +static inline void tpm_msleep(unsigned int delay_msec) +{ + usleep_range(delay_msec * 1000, +(delay_msec * 1000) + TPM_TIMEOUT_RANGE_US); +}; + struct tpm_chip *tpm_chip_find_get(int chip_num); __must_check int tpm_try_get_ops(struct tpm_chip *chip); void tpm_put_ops(struct tpm_chip *chip); diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 881aea9..13c77fc 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -961,7 +961,7 @@ static int tpm2_do_selftest(struct tpm_chip *chip) if (rc != TPM2_RC_TESTING) break; - msleep(delay_msec); + tpm_msleep(delay_msec); } return rc; diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c index e3cf9f3..690d948 100644 --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c @@ -191,7 +191,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit) /* check the status-register if wait_for_bit is set */ if (status & 1 << wait_for_bit) break; - msleep(TPM_MSLEEP_TIME); + tpm_msleep(TPM_MSLEEP_TIME); } if (i == TPM_MAX_TRIES) { /* timeout occurs */ if (wait_for_bit == STAT_XFE) @@ -226,7 +226,7 @@ static void
Re: [PATCH 2/2] PCI: dwc: spear13xx: utilize dw_pcie_readX_dbi/dw_pcie_writeX_dbi macros
On Fri, Jul 14, 2017 at 02:07:35PM +0200, Niklas Cassel wrote: > Signed-off-by: Niklas CasselPratyush, are you OK with this? > --- > drivers/pci/dwc/pcie-spear13xx.c | 22 ++ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/drivers/pci/dwc/pcie-spear13xx.c > b/drivers/pci/dwc/pcie-spear13xx.c > index 80897291e0fb..7ebfbf6086fe 100644 > --- a/drivers/pci/dwc/pcie-spear13xx.c > +++ b/drivers/pci/dwc/pcie-spear13xx.c > @@ -92,34 +92,32 @@ static int spear13xx_pcie_establish_link(struct > spear13xx_pcie *spear13xx_pcie) >* default value in capability register is 512 bytes. So force >* it to 128 here. >*/ > - dw_pcie_read(pci->dbi_base + exp_cap_off + PCI_EXP_DEVCTL, 2, ); > + val = dw_pcie_readw_dbi(pci, exp_cap_off + PCI_EXP_DEVCTL); > val &= ~PCI_EXP_DEVCTL_READRQ; > - dw_pcie_write(pci->dbi_base + exp_cap_off + PCI_EXP_DEVCTL, 2, val); > + dw_pcie_writew_dbi(pci, exp_cap_off + PCI_EXP_DEVCTL, val); > > - dw_pcie_write(pci->dbi_base + PCI_VENDOR_ID, 2, 0x104A); > - dw_pcie_write(pci->dbi_base + PCI_DEVICE_ID, 2, 0xCD80); > + dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, 0x104A); > + dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, 0xCD80); > > /* >* if is_gen1 is set then handle it, so that some buggy card >* also works >*/ > if (spear13xx_pcie->is_gen1) { > - dw_pcie_read(pci->dbi_base + exp_cap_off + PCI_EXP_LNKCAP, > - 4, ); > + val = dw_pcie_readl_dbi(pci, exp_cap_off + PCI_EXP_LNKCAP); > if ((val & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) { > val &= ~((u32)PCI_EXP_LNKCAP_SLS); > val |= PCI_EXP_LNKCAP_SLS_2_5GB; > - dw_pcie_write(pci->dbi_base + exp_cap_off + > - PCI_EXP_LNKCAP, 4, val); > + dw_pcie_writel_dbi(pci, exp_cap_off + PCI_EXP_LNKCAP, > +val); > } > > - dw_pcie_read(pci->dbi_base + exp_cap_off + PCI_EXP_LNKCTL2, > - 2, ); > + val = dw_pcie_readw_dbi(pci, exp_cap_off + PCI_EXP_LNKCTL2); > if ((val & PCI_EXP_LNKCAP_SLS) != PCI_EXP_LNKCAP_SLS_2_5GB) { > val &= ~((u32)PCI_EXP_LNKCAP_SLS); > val |= PCI_EXP_LNKCAP_SLS_2_5GB; > - dw_pcie_write(pci->dbi_base + exp_cap_off + > - PCI_EXP_LNKCTL2, 2, val); > + dw_pcie_writew_dbi(pci, exp_cap_off + PCI_EXP_LNKCTL2, > +val); > } > } > > -- > 2.11.0 >
RE: [[PATCH v1] 16/37] [CIFS] SMBD: Post a SMBD message with no payload
> -Original Message- > From: Christoph Hellwig [mailto:h...@infradead.org] > Sent: Sunday, August 13, 2017 3:24 AM > To: Long Li> Cc: Steve French ; linux-c...@vger.kernel.org; samba- > techni...@lists.samba.org; linux-kernel@vger.kernel.org; Long Li > > Subject: Re: [[PATCH v1] 16/37] [CIFS] SMBD: Post a SMBD message with no > payload > > On Wed, Aug 02, 2017 at 01:10:27PM -0700, Long Li wrote: > > From: Long Li > > > > Implement the function to send a SMBD message with no payload. This is > required at times when we want to extend credtis to server to have it > continue to send data, without sending any actual data payload. > > Shouldn't this just be implemented as a special case in the version that posts > data? It uses a different packet format "struct smbd_data_transfer_no_data". I can restructure some common code to share between packet sending functions.
[PATCH] checkpatch: Add --strict check for ifs with unnecessary parentheses
An if statement test like if ((foo == bar) && (baz != qux)) can arguably be better written without the parentheses as if (foo == bar && baz != qux) Add a test to find these cases. Signed-off-by: Joe Perches--- David Miller recently commented on the use of unnecessary parentheses around simple checks like the above. Perhaps this is an overly subjective/strict interpretation for code that is not especially better written one way or another. Anyway, here is an addition for a --strict test that might allow some fewer resubmissions to satisfy that particular desired style. scripts/checkpatch.pl | 24 1 file changed, 24 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2287a0bca863..143ab5ca2c41 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4496,6 +4496,30 @@ sub process { } } +# check for unnecessary parentheses around comparisons in if uses + if ($^V && $^V ge 5.10.0 && defined($stat) && + $stat =~ /(^.\s*if\s*($balanced_parens))/) { + my $if_stat = $1; + my $test = substr($2, 1, -1); + my $herectx; + while ($test =~ /(?:^|[^\w\&\!\~])+\s*\(\s*([\&\!\~]?\s*$Lval\s*(?:$Compare\s*$FuncArg)?)\s*\)/g) { + my $match = $1; + # avoid parentheses around potential macro args + next if ($match =~ /^\s*\w+\s*$/); + if (!defined($herectx)) { + $herectx = $here . "\n"; + my $cnt = statement_rawlines($if_stat); + for (my $n = 0; $n < $cnt; $n++) { + my $rl = raw_line($linenr, $n); + $herectx .= $rl . "\n"; + last if $rl =~ /^[ \+].*\{/; + } + } + CHK("UNNECESSARY_PARENTHESES", + "Unnecessary parentheses around '$match'\n" . $herectx); + } + } + #goto labels aren't indented, allow a single space however if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { -- 2.10.0.rc2.1.g053435c
Re: [PATCH] arm64: bcm2837 dts: enable bcm2708 frambuffer driver for the raspberry pi-3
VOTARY GITHUBwrites: > From 3200cb6fd787390df1bccf1bb1f7a67ca04136fd Mon Sep 17 00:00:00 2001 > From: VT-Github-Raspberrypi > Date: Tue, 8 Aug 2017 16:57:15 +0530 > Subject: [PATCH] arm64: bcm2837 dts: enable bcm2708 frambuffer driver for the > raspberry pi-3 > > This fb drivers to make rendering full boot up logs on the screen. > > Fixed: https://github.com/raspberrypi/linux/issues/2156 I don't think we should be adding DT nodes for the old, downstream-only fbdev driver to the upstream tree. We have nodes already for the open source driver that directly programs the hardware, which will disable the firmware's closed-source modesetting interfaces used by bcm2708 fbdev. For early boot display, the proper solution is simplefb, not a custom fbdev driver. signature.asc Description: PGP signature
[PATCH v2] sctp: fully initialize the IPv6 address in sctp_v6_to_addr()
KMSAN reported use of uninitialized sctp_addr->v4.sin_addr.s_addr and sctp_addr->v6.sin6_scope_id in sctp_v6_cmp_addr() (see below). Make sure all fields of an IPv6 address are initialized, which guarantees that the IPv4 fields are also initialized. == BUG: KMSAN: use of uninitialized memory in sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 CPU: 2 PID: 31056 Comm: syz-executor1 Not tainted 4.11.0-rc5+ #2944 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: dump_stack+0x172/0x1c0 lib/dump_stack.c:42 is_logbuf_locked mm/kmsan/kmsan.c:59 [inline] kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:938 native_save_fl arch/x86/include/asm/irqflags.h:18 [inline] arch_local_save_flags arch/x86/include/asm/irqflags.h:72 [inline] arch_local_irq_save arch/x86/include/asm/irqflags.h:113 [inline] __msan_warning_32+0x61/0xb0 mm/kmsan/kmsan_instr.c:467 sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 sctp_v6_get_dst+0x8c7/0x1630 net/sctp/ipv6.c:290 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 sctp_assoc_add_peer+0x66d/0x16f0 net/sctp/associola.c:651 sctp_sendmsg+0x35a5/0x4f90 net/sctp/socket.c:1871 inet_sendmsg+0x498/0x670 net/ipv4/af_inet.c:762 sock_sendmsg_nosec net/socket.c:633 [inline] sock_sendmsg net/socket.c:643 [inline] SYSC_sendto+0x608/0x710 net/socket.c:1696 SyS_sendto+0x8a/0xb0 net/socket.c:1664 entry_SYSCALL_64_fastpath+0x13/0x94 RIP: 0033:0x44b479 RSP: 002b:7f6213f21c08 EFLAGS: 0286 ORIG_RAX: 002c RAX: ffda RBX: 2000 RCX: 0044b479 RDX: 0041 RSI: 20edd000 RDI: 0006 RBP: 007080a8 R08: 20b85fe4 R09: 001c R10: 00040005 R11: 0286 R12: R13: 3760 R14: 006e5820 R15: 00ff8000 origin description: dst_saddr@sctp_v6_get_dst local variable created at: sk_fullsock include/net/sock.h:2321 [inline] inet6_sk include/linux/ipv6.h:309 [inline] sctp_v6_get_dst+0x91/0x1630 net/sctp/ipv6.c:241 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 == BUG: KMSAN: use of uninitialized memory in sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 CPU: 2 PID: 31056 Comm: syz-executor1 Not tainted 4.11.0-rc5+ #2944 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 Call Trace: dump_stack+0x172/0x1c0 lib/dump_stack.c:42 is_logbuf_locked mm/kmsan/kmsan.c:59 [inline] kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:938 native_save_fl arch/x86/include/asm/irqflags.h:18 [inline] arch_local_save_flags arch/x86/include/asm/irqflags.h:72 [inline] arch_local_irq_save arch/x86/include/asm/irqflags.h:113 [inline] __msan_warning_32+0x61/0xb0 mm/kmsan/kmsan_instr.c:467 sctp_v6_cmp_addr+0x8d4/0x9f0 net/sctp/ipv6.c:517 sctp_v6_get_dst+0x8c7/0x1630 net/sctp/ipv6.c:290 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 sctp_assoc_add_peer+0x66d/0x16f0 net/sctp/associola.c:651 sctp_sendmsg+0x35a5/0x4f90 net/sctp/socket.c:1871 inet_sendmsg+0x498/0x670 net/ipv4/af_inet.c:762 sock_sendmsg_nosec net/socket.c:633 [inline] sock_sendmsg net/socket.c:643 [inline] SYSC_sendto+0x608/0x710 net/socket.c:1696 SyS_sendto+0x8a/0xb0 net/socket.c:1664 entry_SYSCALL_64_fastpath+0x13/0x94 RIP: 0033:0x44b479 RSP: 002b:7f6213f21c08 EFLAGS: 0286 ORIG_RAX: 002c RAX: ffda RBX: 2000 RCX: 0044b479 RDX: 0041 RSI: 20edd000 RDI: 0006 RBP: 007080a8 R08: 20b85fe4 R09: 001c R10: 00040005 R11: 0286 R12: R13: 3760 R14: 006e5820 R15: 00ff8000 origin description: dst_saddr@sctp_v6_get_dst local variable created at: sk_fullsock include/net/sock.h:2321 [inline] inet6_sk include/linux/ipv6.h:309 [inline] sctp_v6_get_dst+0x91/0x1630 net/sctp/ipv6.c:241 sctp_transport_route+0x101/0x570 net/sctp/transport.c:292 == Signed-off-by: Alexander PotapenkoReviewed-by: Xin Long --- v2 is identical to v1, resending per request by Marcelo Ricardo Leitner. --- net/sctp/ipv6.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 2a186b201ad2..a15d691829c6 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -513,6 +513,8 @@ static void sctp_v6_to_addr(union sctp_addr *addr, struct in6_addr *saddr, addr->sa.sa_family = AF_INET6; addr->v6.sin6_port = port; addr->v6.sin6_addr = *saddr; + addr->v6.sin6_flowinfo = 0; + addr->v6.sin6_scope_id = 0; } /* Compare addresses exactly. -- 2.14.0.434.g98096fd7a8-goog
Re: [PATCH v3 0/5] ACPI: DMA ranges management
On Thu, Aug 3, 2017 at 5:32 AM, Lorenzo Pieralisiwrote: > This patch series is v3 of a previous posting: > > v2->v3: > - Fixed DMA masks computation > - Fixed size computation overflow in acpi_dma_get_range() > > v1->v2: > - Reworked acpi_dma_get_range() flow and logs > - Added IORT named component address limits > - Renamed acpi_dev_get_resources() helper function > - Rebased against v4.13-rc3 > > v2: http://lkml.kernel.org/r/20170731152323.32488-1-lorenzo.pieral...@arm.com > v1: http://lkml.kernel.org/r/20170720144517.32529-1-lorenzo.pieral...@arm.com > > -- Original cover letter -- > > As reported in: > > http://lkml.kernel.org/r/cal85gma_sscwm80tkdkzqee+s1bewzdevdki1kpkmutdrms...@mail.gmail.com > > the bus connecting devices to an IOMMU bus can be smaller in size than > the IOMMU input address bits which results in devices DMA HW bugs in > particular related to IOVA allocation (ie chopping of higher address > bits owing to system bus HW capabilities mismatch with the IOMMU). > > Fortunately this problem can be solved through an already present but never > used ACPI 6.2 firmware bindings (ie _DMA object) allowing to define the DMA > window for a specific bus in ACPI and therefore all upstream devices > connected to it. > > This small patch series enables _DMA parsing in ACPI core code and > use it in ACPI IORT code in order to detect DMA ranges for devices and > update their data structures to make them work with their related DMA > addressing restrictions. > > Cc: Will Deacon > Cc: Hanjun Guo > Cc: Feng Kan > Cc: Jon Masters > Cc: Robert Moore > Cc: Robin Murphy > Cc: Zhang Rui > Cc: "Rafael J. Wysocki" > > Lorenzo Pieralisi (5): > ACPICA: resource_mgr: Allow _DMA method in walk resources > ACPI: Make acpi_dev_get_resources() method agnostic > ACPI: Introduce DMA ranges parsing > ACPI: Make acpi_dma_configure() DMA regions aware > ACPI/IORT: Add IORT named component memory address limits > > drivers/acpi/acpica/rsxface.c | 7 ++-- > drivers/acpi/arm64/iort.c | 57 ++- > drivers/acpi/resource.c | 82 +- > drivers/acpi/scan.c | 91 > +++ > include/acpi/acnames.h| 1 + > include/acpi/acpi_bus.h | 2 + > include/linux/acpi.h | 8 > include/linux/acpi_iort.h | 5 ++- > 8 files changed, 219 insertions(+), 34 deletions(-) > > -- > 2.10.0 > Works on XGene. Tested-by: Feng Kan
Re: [kernel-hardening] [PATCH v5 06/10] arm64/mm: Disable section mappings if XPFO is enabled
On 08/14/2017 09:22 AM, Tycho Andersen wrote: > On Sat, Aug 12, 2017 at 12:17:34PM +0100, Mark Rutland wrote: >> Hi, >> >> On Fri, Aug 11, 2017 at 03:13:02PM -0600, Tycho Andersen wrote: >>> On Fri, Aug 11, 2017 at 10:25:14AM -0700, Laura Abbott wrote: On 08/09/2017 01:07 PM, Tycho Andersen wrote: > @@ -190,7 +202,7 @@ static void init_pmd(pud_t *pud, unsigned long addr, > unsigned long end, > next = pmd_addr_end(addr, end); > > /* try section mapping first */ > - if (((addr | next | phys) & ~SECTION_MASK) == 0 && > + if (use_section_mapping(addr, next, phys) && > (flags & NO_BLOCK_MAPPINGS) == 0) { > pmd_set_huge(pmd, phys, prot); > > There is already similar logic to disable section mappings for debug_pagealloc at the start of map_mem, can you take advantage of that? >>> >>> You're suggesting something like this instead? Seems to work fine. >>> >>> diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c >>> index 38026b3ccb46..3b2c17bbbf12 100644 >>> --- a/arch/arm64/mm/mmu.c >>> +++ b/arch/arm64/mm/mmu.c >>> @@ -434,6 +434,8 @@ static void __init map_mem(pgd_t *pgd) >>> >>> if (debug_pagealloc_enabled()) >>> flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; >>> + if (IS_ENABLED(CONFIG_XPFO)) >>> + flags |= NO_BLOCK_MAPPINGS; >>> >> >> IIUC, XPFO carves out individual pages just like DEBUG_PAGEALLOC, so you'll >> also need NO_CONT_MAPPINGS. > > Yes, thanks! > > Tycho > Setting NO_CONT_MAPPINGS fixes the TLB conflict aborts I was seeing on my machine. Thanks, Laura
Re: [PATCH v5 10/10] lkdtm: Add test for XPFO
On Wed, Aug 9, 2017 at 1:07 PM, Tycho Andersenwrote: > From: Juerg Haefliger > > This test simply reads from userspace memory via the kernel's linear > map. > > hugepages is only supported on x86 right now, hence the ifdef. I'd prefer that the #ifdef is handled in the .c file. The result is that all architectures will have the XPFO_READ_USER_HUGE test, but it can just fail when not available. This means no changes are needed for lkdtm in the future and the test provides an actual test of hugepages coverage. -Kees -- Kees Cook Pixel Security
Re: [PATCH v2 1/1] i2c: aspeed: add proper support fo 24xx clock params
On Fri, Jul 28, 2017 at 01:45:58PM -0700, Brendan Higgins wrote: > 24xx BMCs have larger clock divider granularity which can cause problems > when trying to set them as 25xx clock dividers; this adds clock setting > code specific to 24xx. > > This also fixes a potential issue where clock dividers were rounded down > instead of up. > > Signed-off-by: Brendan HigginsApplied to for-next, thanks! signature.asc Description: PGP signature