On 2021/7/30 14:49, Liang Wang wrote:
> The physical address may exceed 32 bits on ARM(when ARM_LPAE enabled),
> use PFN_PHYS() in devmem_is_allowed(), or the physical address may
> overflow and be truncated.
>
> This bug was initially introduced from v2.6.37, and the function was moved
> to lib when v5.10.
>
> Fixes: 087aaffcdf9c ("ARM: implement CONFIG_STRICT_DEVMEM by disabling access to RAM via /dev/mem")
> Fixes: 527701eda5f1 ("lib: Add a generic version of devmem_is_allowed()")
> Cc: stable(a)vger.kernel.org # v2.6.37
> Signed-off-by: Liang Wang <wangliang101(a)huawei.com>
Reviewed-by: Kefeng Wang <wangkefeng.wang(a)huawei.com>
> ---
> v2: update subject and changelog
> lib/devmem_is_allowed.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/devmem_is_allowed.c b/lib/devmem_is_allowed.c
> index c0d67c541849..60be9e24bd57 100644
> --- a/lib/devmem_is_allowed.c
> +++ b/lib/devmem_is_allowed.c
> @@ -19,7 +19,7 @@
> */
> int devmem_is_allowed(unsigned long pfn)
> {
> - if (iomem_is_exclusive(pfn << PAGE_SHIFT))
> + if (iomem_is_exclusive(PFN_PHYS(pfn)))
> return 0;
> if (!page_is_ram(pfn))
> return 1;
Hi all,
Here is a the v2 improving EAS estimation precision. The v1 and discussion
can be found at:
https://lore.kernel.org/lkml/20210625152603.25960-1-lukasz.luba@arm.com/
changes:
v2:
- dropped first two patches
- implemented better resolution for 64-bit only machines according to
Peter's comment and scale_load() example
- power value multiplied by 1000 not 10000
- added 'Fixes' tag, so it could be picked into stable trees easily
- extended patch descirpion with example corenr case scenario
Regards,
Lukasz
Lukasz Luba (1):
PM: EM: Increase energy calculation precision
include/linux/energy_model.h | 16 ++++++++++++++++
kernel/power/energy_model.c | 3 ++-
2 files changed, 18 insertions(+), 1 deletion(-)
--
2.17.1
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 240246f6b913b0c23733cfd2def1d283f8cc9bbe Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn(a)suse.de>
Date: Fri, 9 Jul 2021 11:29:22 -0500
Subject: [PATCH] btrfs: mark compressed range uptodate only if all bio succeed
In compression write endio sequence, the range which the compressed_bio
writes is marked as uptodate if the last bio of the compressed (sub)bios
is completed successfully. There could be previous bio which may
have failed which is recorded in cb->errors.
Set the writeback range as uptodate only if cb->errors is zero, as opposed
to checking only the last bio's status.
Backporting notes: in all versions up to 4.4 the last argument is always
replaced by "!cb->errors".
CC: stable(a)vger.kernel.org # 4.4+
Signed-off-by: Goldwyn Rodrigues <rgoldwyn(a)suse.com>
Reviewed-by: David Sterba <dsterba(a)suse.com>
Signed-off-by: David Sterba <dsterba(a)suse.com>
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 9a023ae0f98b..30d82cdf128c 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -352,7 +352,7 @@ static void end_compressed_bio_write(struct bio *bio)
btrfs_record_physical_zoned(inode, cb->start, bio);
btrfs_writepage_endio_finish_ordered(BTRFS_I(inode), NULL,
cb->start, cb->start + cb->len - 1,
- bio->bi_status == BLK_STS_OK);
+ !cb->errors);
end_compressed_writeback(inode, cb);
/* note, our inode could be gone now */
The commit <1b6b26ae7053>("pipe: fix and clarify pipe write wakeup
logic") changed pipe write logic to wakeup readers only if the pipe
was empty at the time of write. However, there are libraries that relied
upon the older behavior for notification scheme similar to what's
described in [1]
One such library 'realm-core'[2] is used by numerous Android applications.
The library uses a similar notification mechanism as GNU Make but it
never drains the pipe until it is full. When Android moved to v5.10
kernel, all applications using this library stopped working.
The C program at the end of this email mimics the library code.
The program works with 5.4 kernel. It fails with v5.10 and I am fairly
certain it will fail wiht v5.5 as well. The single patch in this series
restores the old behavior. With the patch, the test and all affected
Android applications start working with v5.10
After reading through epoll(7), I think the pipe should be drained after
each epoll_wait() comes back. Also, that a non-empty pipe is
considered to be "ready" for readers. The problem is that prior
to the commit above, any new data written to non-empty pipes
would wakeup threads waiting in epoll(EPOLLIN|EPILLET) and thats
how this library worked.
I do think the program below is using EPOLLET wrong. However, it
used to work before and now it doesn't. So, I thought it is
worth asking if this counts as userspace break.
There was also a symmetrical change made to pipe_read in commit
<f467a6a66419> ("pipe: fix and clarify pipe read wakeup logic")
that I am not sure needs changing.
The library has since been fixed[3] but it will be a while
before all applications incorporate the updated library.
- ssp
1. https://lore.kernel.org/lkml/CAHk-=wjeG0q1vgzu4iJhW5juPkTsjTYmiqiMUYAebWW+0…
2. https://github.com/realm/realm-core
3. https://github.com/realm/realm-core/issues/4666
====
#include <stdio.h>
#include <error.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/epoll.h>
#include <sys/stat.h>
#include <sys/types.h>
#define FIFO_NAME "epoll-test-fifo"
pthread_t tid;
int max_delay_ms = 20;
int fifo_fd;
unsigned char written;
unsigned char received;
int epoll_fd;
void *wait_on_fifo(void *unused)
{
while (1) {
struct epoll_event ev;
int ret;
unsigned char c;
ret = epoll_wait(epoll_fd, &ev, 1, 5000);
if (ret == -1) {
/* If interrupted syscall, continue .. */
if (errno == EINTR)
continue;
/* epoll_wait failed, bail.. */
error(99, errno, "epoll_wait failed \n");
}
/* timeout */
if (ret == 0)
break;
if (ev.data.fd == fifo_fd) {
/* Assume this is notification where the thread is catching up.
* pipe is emptied by the writer when it detects it is full.
*/
received = written;
}
}
return NULL;
}
int write_fifo(int fd, unsigned char c)
{
while (1) {
int actual;
char buf[1024];
ssize_t ret = write(fd, &c, 1);
if (ret == 1)
break;
/*
* If the pipe's buffer is full, we need to read some of the old data in
* it to make space. We dont read in the code waiting for
* notifications so that we can notify multiple waiters with a single
* write.
*/
if (ret != 0) {
if (errno != EAGAIN)
return -EIO;
}
actual = read(fd, buf, 1024);
if (actual == 0)
return -errno;
}
return 0;
}
int create_and_setup_fifo()
{
int ret;
char fifo_path[4096];
struct epoll_event ev;
char *tmpdir = getenv("TMPDIR");
if (tmpdir == NULL)
tmpdir = ".";
ret = sprintf(fifo_path, "%s/%s", tmpdir, FIFO_NAME);
if (access(fifo_path, F_OK) == 0)
unlink(fifo_path);
ret = mkfifo(fifo_path, 0600);
if (ret < 0)
error(1, errno, "Failed to create fifo");
fifo_fd = open(fifo_path, O_RDWR | O_NONBLOCK);
if (fifo_fd < 0)
error(2, errno, "Failed to open Fifo");
ev.events = EPOLLIN | EPOLLET;
ev.data.fd = fifo_fd;
ret = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fifo_fd, &ev);
if (ret < 0)
error(4, errno, "Failed to add fifo to epoll instance");
return 0;
}
int main(int argc, char *argv[])
{
int ret, random;
unsigned char c = 1;
epoll_fd = epoll_create(1);
if (epoll_fd == -1)
error(3, errno, "Failed to create epoll instance");
ret = create_and_setup_fifo();
if (ret != 0)
error(45, EINVAL, "Failed to setup fifo");
ret = pthread_create(&tid, NULL, wait_on_fifo, NULL);
if (ret != 0)
error(2, errno, "Failed to create a thread");
srand(time(NULL));
/* Write 256 bytes to fifo one byte at a time with random delays upto 20ms */
do {
written = c;
ret = write_fifo(fifo_fd, c);
if (ret != 0)
error(55, errno, "Failed to notify fifo, write #%u", (unsigned int)c);
c++;
random = rand();
usleep((random % max_delay_ms) * 1000);
} while (written <= c); /* stop after c = 255 */
pthread_join(tid, NULL);
printf("Test: %s", written == received ? "PASS\n" : "FAIL");
if (written != received)
printf(": Written (%d) Received (%d)\n", written, received);
close(fifo_fd);
close(epoll_fd);
return 0;
}
====
Sandeep Patil (1):
fs: pipe: wakeup readers everytime new data written is to pipe
fs/pipe.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
--
2.32.0.554.ge1b32706d8-goog
A recent change in LLVM causes module_{c,d}tor sections to appear when
CONFIG_K{A,C}SAN are enabled, which results in orphan section warnings
because these are not handled anywhere:
ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_ctor) is being placed in '.text.asan.module_ctor'
ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_dtor) is being placed in '.text.asan.module_dtor'
ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.tsan.module_ctor) is being placed in '.text.tsan.module_ctor'
Place them in the TEXT_TEXT section so that these technologies continue
to work with the newer compiler versions. All of the KASAN and KCSAN
KUnit tests continue to pass after this change.
Cc: stable(a)vger.kernel.org
Link: https://github.com/ClangBuiltLinux/linux/issues/1432
Link: https://github.com/llvm/llvm-project/commit/7b789562244ee941b7bf2cefeb3fc08…
Signed-off-by: Nathan Chancellor <nathan(a)kernel.org>
---
include/asm-generic/vmlinux.lds.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 17325416e2de..3b79b1e76556 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -586,6 +586,7 @@
NOINSTR_TEXT \
*(.text..refcount) \
*(.ref.text) \
+ *(.text.asan .text.asan.*) \
TEXT_CFI_JT \
MEM_KEEP(init.text*) \
MEM_KEEP(exit.text*) \
base-commit: 4669e13cd67f8532be12815ed3d37e775a9bdc16
--
2.32.0.264.g75ae10bc75
The patch below does not apply to the 5.13-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 6be50f5d83adc9541de3d5be26e968182b5ac150 Mon Sep 17 00:00:00 2001
From: Stylon Wang <stylon.wang(a)amd.com>
Date: Wed, 21 Jul 2021 12:25:24 +0800
Subject: [PATCH] drm/amd/display: Fix ASSR regression on embedded panels
[Why]
Regression found in some embedded panels traces back to the earliest
upstreamed ASSR patch. The changed code flow are causing problems
with some panels.
[How]
- Change ASSR enabling code while preserving original code flow
as much as possible
- Simplify the code on guarding with internal display flag
Bug: https://bugzilla.kernel.org/show_bug.cgi?id=213779
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1620
Reviewed-by: Alex Deucher <alexander.deucher(a)amd.com>
Signed-off-by: Stylon Wang <stylon.wang(a)amd.com>
Signed-off-by: Alex Deucher <alexander.deucher(a)amd.com>
Cc: stable(a)vger.kernel.org
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 12066f5a53fc..9fb8c46dc606 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -1820,8 +1820,7 @@ bool perform_link_training_with_retries(
*/
panel_mode = DP_PANEL_MODE_DEFAULT;
}
- } else
- panel_mode = DP_PANEL_MODE_DEFAULT;
+ }
}
#endif
@@ -4650,7 +4649,10 @@ enum dp_panel_mode dp_get_panel_mode(struct dc_link *link)
}
}
- if (link->dpcd_caps.panel_mode_edp) {
+ if (link->dpcd_caps.panel_mode_edp &&
+ (link->connector_signal == SIGNAL_TYPE_EDP ||
+ (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT &&
+ link->is_internal_display))) {
return DP_PANEL_MODE_EDP;
}
The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 240246f6b913b0c23733cfd2def1d283f8cc9bbe Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn(a)suse.de>
Date: Fri, 9 Jul 2021 11:29:22 -0500
Subject: [PATCH] btrfs: mark compressed range uptodate only if all bio succeed
In compression write endio sequence, the range which the compressed_bio
writes is marked as uptodate if the last bio of the compressed (sub)bios
is completed successfully. There could be previous bio which may
have failed which is recorded in cb->errors.
Set the writeback range as uptodate only if cb->errors is zero, as opposed
to checking only the last bio's status.
Backporting notes: in all versions up to 4.4 the last argument is always
replaced by "!cb->errors".
CC: stable(a)vger.kernel.org # 4.4+
Signed-off-by: Goldwyn Rodrigues <rgoldwyn(a)suse.com>
Reviewed-by: David Sterba <dsterba(a)suse.com>
Signed-off-by: David Sterba <dsterba(a)suse.com>
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 9a023ae0f98b..30d82cdf128c 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -352,7 +352,7 @@ static void end_compressed_bio_write(struct bio *bio)
btrfs_record_physical_zoned(inode, cb->start, bio);
btrfs_writepage_endio_finish_ordered(BTRFS_I(inode), NULL,
cb->start, cb->start + cb->len - 1,
- bio->bi_status == BLK_STS_OK);
+ !cb->errors);
end_compressed_writeback(inode, cb);
/* note, our inode could be gone now */
The patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable(a)vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 240246f6b913b0c23733cfd2def1d283f8cc9bbe Mon Sep 17 00:00:00 2001
From: Goldwyn Rodrigues <rgoldwyn(a)suse.de>
Date: Fri, 9 Jul 2021 11:29:22 -0500
Subject: [PATCH] btrfs: mark compressed range uptodate only if all bio succeed
In compression write endio sequence, the range which the compressed_bio
writes is marked as uptodate if the last bio of the compressed (sub)bios
is completed successfully. There could be previous bio which may
have failed which is recorded in cb->errors.
Set the writeback range as uptodate only if cb->errors is zero, as opposed
to checking only the last bio's status.
Backporting notes: in all versions up to 4.4 the last argument is always
replaced by "!cb->errors".
CC: stable(a)vger.kernel.org # 4.4+
Signed-off-by: Goldwyn Rodrigues <rgoldwyn(a)suse.com>
Reviewed-by: David Sterba <dsterba(a)suse.com>
Signed-off-by: David Sterba <dsterba(a)suse.com>
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 9a023ae0f98b..30d82cdf128c 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -352,7 +352,7 @@ static void end_compressed_bio_write(struct bio *bio)
btrfs_record_physical_zoned(inode, cb->start, bio);
btrfs_writepage_endio_finish_ordered(BTRFS_I(inode), NULL,
cb->start, cb->start + cb->len - 1,
- bio->bi_status == BLK_STS_OK);
+ !cb->errors);
end_compressed_writeback(inode, cb);
/* note, our inode could be gone now */