* [meta-oe][PATCH v2 1/1] pcimem: add initial version 2.0
From: Jonathan Richardson @ 2020-02-14 19:07 UTC (permalink / raw)
To: openembedded-devel; +Cc: Randy Schacher
From: Randy Schacher <stuart.schacher@broadcom.com>
Initial revision from 09724edb1783a98da2b7ae53c5aaa87493aabc9b
Reviewed-by: Jonathan Richardson <jonathan.richardson@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Jonathan Richardson <jonathan.richardson@broadcom.com>
---
meta-oe/recipes-devtools/pcimem/pcimem_2.0.bb | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 meta-oe/recipes-devtools/pcimem/pcimem_2.0.bb
diff --git a/meta-oe/recipes-devtools/pcimem/pcimem_2.0.bb b/meta-oe/recipes-devtools/pcimem/pcimem_2.0.bb
new file mode 100644
index 000000000..107d5a8b7
--- /dev/null
+++ b/meta-oe/recipes-devtools/pcimem/pcimem_2.0.bb
@@ -0,0 +1,17 @@
+SUMMARY = "Simple program to read & write to a pci device from userspace"
+HOMEPAGE = "https://github.com/billfarrow/pcimem"
+BUGTRACKER = "https://github.com/billfarrow/pcimem/issues"
+SECTION = "devel"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263"
+
+COMPATIBLE_HOST = "(x86_64|aarch64|arm)"
+
+SRCREV = "09724edb1783a98da2b7ae53c5aaa87493aabc9b"
+SRC_URI = "git://github.com/billfarrow/pcimem.git "
+
+S = "${WORKDIR}/git"
+
+do_install() {
+ install -D -m 0755 ${B}/pcimem ${D}${bindir}/pcimem
+}
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 1/2] Revert "RDMA/isert: Fix a recently introduced regression related to logout"
From: Bart Van Assche @ 2020-02-14 19:07 UTC (permalink / raw)
To: Marciniszyn, Mike, Martin K . Petersen
Cc: target-devel@vger.kernel.org, Dakshaja Uppalapati, Sagi Grimberg,
Rahul Kundu, 'linux-rdma@vger.kernel.org'
In-Reply-To: <MWHPR1101MB227101D7C2DFEB8ABACD0FCB86150@MWHPR1101MB2271.namprd11.prod.outlook.com>
On 2/14/20 6:28 AM, Marciniszyn, Mike wrote:
>>
>> [PATCH 0/2] Revert two recent iSCSI / iSER patches
>>
>
> Bart,
>
> This will mean we will again see failures in our internal iSer testing.
>
> What is the status of a final fix?
>
> If you have something to try, I would be glad to test...
Hi Mike,
Please take another look at this patch series. No new regressions should
be introduced except if someone runs a bisect that lands in the middle
of this patch series. Patch 1/2 reintroduces a regression but patches
1/2 and 2/2 combined should restore iSER to the state of that driver in
kernel v5.4.
Thanks,
Bart.
^ permalink raw reply
* Re: [PATCH 1/2] Revert "RDMA/isert: Fix a recently introduced regression related to logout"
From: Bart Van Assche @ 2020-02-14 19:07 UTC (permalink / raw)
To: Marciniszyn, Mike, Martin K . Petersen
Cc: target-devel@vger.kernel.org, Dakshaja Uppalapati, Sagi Grimberg,
Rahul Kundu, 'linux-rdma@vger.kernel.org'
In-Reply-To: <MWHPR1101MB227101D7C2DFEB8ABACD0FCB86150@MWHPR1101MB2271.namprd11.prod.outlook.com>
On 2/14/20 6:28 AM, Marciniszyn, Mike wrote:
>>
>> [PATCH 0/2] Revert two recent iSCSI / iSER patches
>>
>
> Bart,
>
> This will mean we will again see failures in our internal iSer testing.
>
> What is the status of a final fix?
>
> If you have something to try, I would be glad to test...
Hi Mike,
Please take another look at this patch series. No new regressions should
be introduced except if someone runs a bisect that lands in the middle
of this patch series. Patch 1/2 reintroduces a regression but patches
1/2 and 2/2 combined should restore iSER to the state of that driver in
kernel v5.4.
Thanks,
Bart.
^ permalink raw reply
* Re: [PATCH v2 01/12] drm: ingenic-drm: add MODULE_DEVICE_TABLE
From: Paul Cercueil @ 2020-02-14 19:06 UTC (permalink / raw)
To: H. Nikolaus Schaller
Cc: Paul Boddie, Rob Herring, Mark Rutland, Ralf Baechle, Paul Burton,
David Airlie, Daniel Vetter, Andi Kleen, Miquel Raynal, Kees Cook,
devicetree, linux-mips, linux-kernel, dri-devel, letux-kernel,
kernel
In-Reply-To: <1b5475c88032b3851c6d33443e688b432af42a9f.1581696624.git.hns@goldelico.com>
Hi Nikolaus,
Please rebase this patch on top of drm-misc-next and send it apart - it
should go through the DRM tree.
Le ven., févr. 14, 2020 at 17:10, H. Nikolaus Schaller
<hns@goldelico.com> a écrit :
> Add MODULE_DEVICE_TABLE so that the driver can load by
> matching the device tree if compiled as module.
>
> Signed-off-by: H. Nikolaus Schaller <hns@goldelico.com>
> ---
> drivers/gpu/drm/ingenic/ingenic-drm.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm.c
> b/drivers/gpu/drm/ingenic/ingenic-drm.c
> index 6d47ef7b148c..d8617096dd8e 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm.c
> @@ -844,6 +844,8 @@ static const struct of_device_id
> ingenic_drm_of_match[] = {
> { /* sentinel */ },
> };
>
> +MODULE_DEVICE_TABLE(of, ingenic_drm_of_match);
Also please remove the blank line above MODULE_DEVICE_TABLE.
Cheers,
-Paul
> +
> static struct platform_driver ingenic_drm_driver = {
> .driver = {
> .name = "ingenic-drm",
> --
> 2.23.0
>
^ permalink raw reply
* [PATCH AUTOSEL 4.14 038/186] powerpc/pseries/vio: Fix iommu_table use-after-free refcount warning
From: Sasha Levin @ 2020-02-14 16:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Sasha Levin, Tyrel Datwyler, Alexey Kardashevskiy, Tyrel Datwyler,
linuxppc-dev
In-Reply-To: <20200214161715.18113-1-sashal@kernel.org>
From: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>
[ Upstream commit aff8c8242bc638ba57247ae1ec5f272ac3ed3b92 ]
Commit e5afdf9dd515 ("powerpc/vfio_spapr_tce: Add reference counting to
iommu_table") missed an iommu_table allocation in the pseries vio code.
The iommu_table is allocated with kzalloc and as a result the associated
kref gets a value of zero. This has the side effect that during a DLPAR
remove of the associated virtual IOA the iommu_tce_table_put() triggers
a use-after-free underflow warning.
Call Trace:
[c0000002879e39f0] [c00000000071ecb4] refcount_warn_saturate+0x184/0x190
(unreliable)
[c0000002879e3a50] [c0000000000500ac] iommu_tce_table_put+0x9c/0xb0
[c0000002879e3a70] [c0000000000f54e4] vio_dev_release+0x34/0x70
[c0000002879e3aa0] [c00000000087cfa4] device_release+0x54/0xf0
[c0000002879e3b10] [c000000000d64c84] kobject_cleanup+0xa4/0x240
[c0000002879e3b90] [c00000000087d358] put_device+0x28/0x40
[c0000002879e3bb0] [c0000000007a328c] dlpar_remove_slot+0x15c/0x250
[c0000002879e3c50] [c0000000007a348c] remove_slot_store+0xac/0xf0
[c0000002879e3cd0] [c000000000d64220] kobj_attr_store+0x30/0x60
[c0000002879e3cf0] [c0000000004ff13c] sysfs_kf_write+0x6c/0xa0
[c0000002879e3d10] [c0000000004fde4c] kernfs_fop_write+0x18c/0x260
[c0000002879e3d60] [c000000000410f3c] __vfs_write+0x3c/0x70
[c0000002879e3d80] [c000000000415408] vfs_write+0xc8/0x250
[c0000002879e3dd0] [c0000000004157dc] ksys_write+0x7c/0x120
[c0000002879e3e20] [c00000000000b278] system_call+0x5c/0x68
Further, since the refcount was always zero the iommu_tce_table_put()
fails to call the iommu_table release function resulting in a leak.
Fix this issue be initilizing the iommu_table kref immediately after
allocation.
Fixes: e5afdf9dd515 ("powerpc/vfio_spapr_tce: Add reference counting to iommu_table")
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1579558202-26052-1-git-send-email-tyreld@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/powerpc/platforms/pseries/vio.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
index d86938260a867..fc778865a4124 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -1195,6 +1195,8 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
if (tbl == NULL)
return NULL;
+ kref_init(&tbl->it_kref);
+
of_parse_dma_window(dev->dev.of_node, dma_window,
&tbl->it_index, &offset, &size);
--
2.20.1
^ permalink raw reply related
* Re: [PATCH v2 5/8] serial: 8250_port: Don't use power management for kernel console
From: Tony Lindgren @ 2020-02-14 19:06 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Russell King - ARM Linux admin, Greg Kroah-Hartman, Jiri Slaby,
linux-serial, Sebastian Andrzej Siewior
In-Reply-To: <20200214184251.GR16391@atomide.com>
* Tony Lindgren <tony@atomide.com> [200214 10:42]:
> OK. So far no luck getting console UART idled after detaching the
> console with:
>
> # echo N > /sys/class/tty/ttyS2/console
>
> Any ideas what might be missing still?
Looks like echo Y keeps increasing the usage count while
echo N will never decrease it currently. Is port->dev
maybe already NULL in serial8250_console_exit() or something?
This is still without the series you listed as a dependency
though. I need to test with that later on today when I get
a chance.
Regards,
Tony
^ permalink raw reply
* Re: [PATCH 0/3] rtnl: add missing APIs
From: Denis Kenzior @ 2020-02-14 19:05 UTC (permalink / raw)
To: ell
In-Reply-To: <20200214185253.32658-1-wagi@monom.org>
[-- Attachment #1: Type: text/plain, Size: 803 bytes --]
Hi Daniel,
On 2/14/20 12:52 PM, Daniel Wagner wrote:
> The first two patches make the API for both protocol version
> complete. The last patch adds the table, priority and preference to
> the extract functions, which is a very uselful information.
>
> This series is based on the cleanup series send before.
>
> Daniel Wagner (3):
> rtnl: Add l_rtnl_route6_dump() and l_rtnl_route6_extract()
> unit: Add unit test for l_rtnl_route6_{dump|extract}
> rtnl: Extract table, priority and pref
>
> ell/rtnl.c | 130 ++++++++++++++++++++++++++++++++---------------
> ell/rtnl.h | 10 +++-
> unit/test-rtnl.c | 42 +++++++++++++--
> 3 files changed, 137 insertions(+), 45 deletions(-)
>
All applied. I did split the last patch into two.
Regards,
-Denis
^ permalink raw reply
* [PATCH] kcsan, trace: Make KCSAN compatible with tracing
From: Marco Elver @ 2020-02-14 19:05 UTC (permalink / raw)
To: elver
Cc: paulmck, andreyknvl, glider, dvyukov, kasan-dev, linux-kernel,
rostedt, mingo, Qian Cai
Previously the system would lock up if ftrace was enabled together with
KCSAN. This is due to recursion on reporting if the tracer code is
instrumented with KCSAN.
To avoid this for all types of tracing, disable KCSAN instrumentation
for all of kernel/trace.
Signed-off-by: Marco Elver <elver@google.com>
Reported-by: Qian Cai <cai@lca.pw>
Cc: Paul E. McKenney <paulmck@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
---
kernel/kcsan/Makefile | 2 ++
kernel/trace/Makefile | 3 +++
2 files changed, 5 insertions(+)
diff --git a/kernel/kcsan/Makefile b/kernel/kcsan/Makefile
index df6b7799e4927..d4999b38d1be5 100644
--- a/kernel/kcsan/Makefile
+++ b/kernel/kcsan/Makefile
@@ -4,6 +4,8 @@ KCOV_INSTRUMENT := n
UBSAN_SANITIZE := n
CFLAGS_REMOVE_core.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_debugfs.o = $(CC_FLAGS_FTRACE)
+CFLAGS_REMOVE_report.o = $(CC_FLAGS_FTRACE)
CFLAGS_core.o := $(call cc-option,-fno-conserve-stack,) \
$(call cc-option,-fno-stack-protector,)
diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index f9dcd19165fa2..6b601d88bf71e 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -6,6 +6,9 @@ ifdef CONFIG_FUNCTION_TRACER
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
+# Avoid recursion due to instrumentation.
+KCSAN_SANITIZE := n
+
ifdef CONFIG_FTRACE_SELFTEST
# selftest needs instrumentation
CFLAGS_trace_selftest_dynamic.o = $(CC_FLAGS_FTRACE)
--
2.25.0.265.gbab2e86ba0-goog
^ permalink raw reply related
* Re: [PATCH] cifs: make sure we do not overflow the max EA buffer size
From: Pavel Shilovsky @ 2020-02-14 19:04 UTC (permalink / raw)
To: Steve French; +Cc: Ronnie Sahlberg, linux-cifs
In-Reply-To: <CAH2r5ms0Bz6gVS1guJS6_=3fwQSbdd2yOh7PKJCkrvqFeyUgnQ@mail.gmail.com>
We can't receive packets bigger that 16k in the memory pool buffers.
In order to support bigger response buffer we would need to allocate
individual pages and receive the packet directly into them (like we do
for writes).
--
Best regards,
Pavel Shilovsky
чт, 13 февр. 2020 г. в 22:14, Steve French <smfrench@gmail.com>:
>
> We should be allowing these to be larger than ~16000 bytes
>
> Should be XATTR_SIZE_MAX 65536
>
> but that can be done with different patch
>
> On Wed, Feb 12, 2020 at 8:15 PM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
> >
> > RHBZ: 1752437
> >
> > Before we add a new EA we should check that this will not overflow
> > the maximum buffer we have available to read the EAs back.
> > Otherwise we can get into a situation where the EAs are so big that
> > we can not read them back to the client and thus we can not list EAs
> > anymore or delete them.
> >
> > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> > ---
> > fs/cifs/smb2ops.c | 35 ++++++++++++++++++++++++++++++++++-
> > 1 file changed, 34 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> > index baa825f4cec0..3c76f69f4ca7 100644
> > --- a/fs/cifs/smb2ops.c
> > +++ b/fs/cifs/smb2ops.c
> > @@ -1116,7 +1116,8 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
> > void *data[1];
> > struct smb2_file_full_ea_info *ea = NULL;
> > struct kvec close_iov[1];
> > - int rc;
> > + struct smb2_query_info_rsp *rsp;
> > + int rc, used_len = 0;
> >
> > if (smb3_encryption_required(tcon))
> > flags |= CIFS_TRANSFORM_REQ;
> > @@ -1139,6 +1140,38 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
> > cifs_sb);
> > if (rc == -ENODATA)
> > goto sea_exit;
> > + } else {
> > + /* If we are adding a attribute we should first check
> > + * if there will be enough space available to store
> > + * the new EA. If not we should not add it since we
> > + * would not be able to even read the EAs back.
> > + */
> > + rc = smb2_query_info_compound(xid, tcon, utf16_path,
> > + FILE_READ_EA,
> > + FILE_FULL_EA_INFORMATION,
> > + SMB2_O_INFO_FILE,
> > + CIFSMaxBufSize -
> > + MAX_SMB2_CREATE_RESPONSE_SIZE -
> > + MAX_SMB2_CLOSE_RESPONSE_SIZE,
> > + &rsp_iov[1], &resp_buftype[1], cifs_sb);
> > + if (rc == 0) {
> > + rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base;
> > + used_len = rsp->OutputBufferLength;
> > + }
> > + free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
> > + resp_buftype[1] = CIFS_NO_BUFFER;
> > + memset(&rsp_iov[1], 0, sizeof(rsp_iov[1]));
> > + rc = 0;
> > +
> > + /* Use a fudge factor of 256 bytes in case we collide
> > + * with a different set_EAs command.
> > + */
> > + if(CIFSMaxBufSize - MAX_SMB2_CREATE_RESPONSE_SIZE -
> > + MAX_SMB2_CLOSE_RESPONSE_SIZE - 256 <
> > + used_len + ea_name_len + ea_value_len + 1) {
> > + rc = -ENOSPC;
> > + goto sea_exit;
> > + }
> > }
> > }
> >
> > --
> > 2.13.6
> >
>
>
> --
> Thanks,
>
> Steve
^ permalink raw reply
* Re: [RFC v2 4/6] tpm: Separate TPM_TIS and TPM_TIS_ISA configs
From: Philippe Mathieu-Daudé @ 2020-02-14 19:03 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, stefanb, qemu-devel, qemu-arm,
peter.maydell
Cc: marcandre.lureau, lersek, ardb
In-Reply-To: <20200214183704.14389-5-eric.auger@redhat.com>
On 2/14/20 7:37 PM, Eric Auger wrote:
> Let's separate the compilation of tpm_tis_common.c from
> the compilation of tpm_tis_isa.c
>
> The common part will be also compiled along with the
> tpm_tis_sysbus device.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> default-configs/i386-softmmu.mak | 2 +-
> hw/i386/Kconfig | 2 +-
> hw/tpm/Kconfig | 7 ++++++-
> hw/tpm/Makefile.objs | 3 ++-
> tests/qtest/Makefile.include | 4 ++--
> 5 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
> index 4cc64dafa2..84d1a2487c 100644
> --- a/default-configs/i386-softmmu.mak
> +++ b/default-configs/i386-softmmu.mak
> @@ -20,7 +20,7 @@
> #CONFIG_SGA=n
> #CONFIG_TEST_DEVICES=n
> #CONFIG_TPM_CRB=n
> -#CONFIG_TPM_TIS=n
> +#CONFIG_TPM_TIS_ISA=n
> #CONFIG_VTD=n
>
> # Boards:
> diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig
> index cdc851598c..c93f32f657 100644
> --- a/hw/i386/Kconfig
> +++ b/hw/i386/Kconfig
> @@ -20,7 +20,7 @@ config PC
> imply SGA
> imply TEST_DEVICES
> imply TPM_CRB
> - imply TPM_TIS
> + imply TPM_TIS_ISA
> imply VGA_PCI
> imply VIRTIO_VGA
> select FDC
> diff --git a/hw/tpm/Kconfig b/hw/tpm/Kconfig
> index 9e67d990e8..686f8206bb 100644
> --- a/hw/tpm/Kconfig
> +++ b/hw/tpm/Kconfig
> @@ -2,9 +2,14 @@ config TPMDEV
> bool
> depends on TPM
>
> -config TPM_TIS
> +config TPM_TIS_ISA
> bool
> depends on TPM && ISA_BUS
Maybe you can relax to "depends on ISA_BUS" ...
> + select TPM_TIS
> +
> +config TPM_TIS
> + bool
> + depends on TPM
... since TPM_TIS depends on TPM.
> select TPMDEV
>
> config TPM_CRB
> diff --git a/hw/tpm/Makefile.objs b/hw/tpm/Makefile.objs
> index fcc4c2f27c..3ef2036cca 100644
> --- a/hw/tpm/Makefile.objs
> +++ b/hw/tpm/Makefile.objs
> @@ -1,6 +1,7 @@
> common-obj-$(CONFIG_TPM) += tpm_util.o
> obj-$(call lor,$(CONFIG_TPM_TIS),$(CONFIG_TPM_CRB)) += tpm_ppi.o
> -common-obj-$(CONFIG_TPM_TIS) += tpm_tis_isa.o tpm_tis_common.o
> +common-obj-$(CONFIG_TPM_TIS_ISA) += tpm_tis_isa.o
> +common-obj-$(CONFIG_TPM_TIS) += tpm_tis_common.o
> common-obj-$(CONFIG_TPM_CRB) += tpm_crb.o
> common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o
> common-obj-$(CONFIG_TPM_EMULATOR) += tpm_emulator.o
> diff --git a/tests/qtest/Makefile.include b/tests/qtest/Makefile.include
> index eb0f23b108..33dd3c89cc 100644
> --- a/tests/qtest/Makefile.include
> +++ b/tests/qtest/Makefile.include
> @@ -54,8 +54,8 @@ check-qtest-i386-y += q35-test
> check-qtest-i386-y += vmgenid-test
> check-qtest-i386-$(CONFIG_TPM_CRB) += tpm-crb-swtpm-test
> check-qtest-i386-$(CONFIG_TPM_CRB) += tpm-crb-test
> -check-qtest-i386-$(CONFIG_TPM_TIS) += tpm-tis-swtpm-test
> -check-qtest-i386-$(CONFIG_TPM_TIS) += tpm-tis-test
> +check-qtest-i386-$(CONFIG_TPM_TIS_ISA) += tpm-tis-swtpm-test
> +check-qtest-i386-$(CONFIG_TPM_TIS_ISA) += tpm-tis-test
> check-qtest-i386-$(CONFIG_SLIRP) += test-netfilter
> check-qtest-i386-$(CONFIG_POSIX) += test-filter-mirror
> check-qtest-i386-$(CONFIG_RTL8139_PCI) += test-filter-redirector
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply
* Re: [PATCH v2 04/15] pack-bitmap: refuse to do a bitmap traversal with pathspecs
From: Junio C Hamano @ 2020-02-14 19:03 UTC (permalink / raw)
To: Jeff King; +Cc: git
In-Reply-To: <20200214182216.GD150965@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> It would also prepare us for a day where this case _is_ handled, but
> that's pretty unlikely. E.g., we could use bitmaps to generate the set
> of commits, and then diff each commit to see if it matches the pathspec.
Would the gs/commit-graph-path-filter topic possibly help in this regard?
I was wondering how it would fit within the framework this series sets
up to teach object-filtering and reachability-bitmap codepaths to
work well together.
^ permalink raw reply
* Re: [PATCH v2 19/28] stat: handle fsid mappings
From: Tycho Andersen @ 2020-02-14 19:03 UTC (permalink / raw)
To: Christian Brauner
Cc: Stéphane Graber, Eric W. Biederman, Aleksa Sarai, Jann Horn,
Kees Cook, Jonathan Corbet, linux-kernel, containers, smbarber,
Seth Forshee, linux-security-module, Alexander Viro, linux-api,
linux-fsdevel, Alexey Dobriyan
In-Reply-To: <20200214183554.1133805-20-christian.brauner@ubuntu.com>
On Fri, Feb 14, 2020 at 07:35:45PM +0100, Christian Brauner wrote:
> @@ -471,8 +484,13 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf)
> #endif
> tmp.st_mode = stat->mode;
> tmp.st_nlink = stat->nlink;
> - tmp.st_uid = from_kuid_munged(current_user_ns(), stat->uid);
> - tmp.st_gid = from_kgid_munged(current_user_ns(), stat->gid);
> + if (stat->userns_visible) {
> + tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid);
> + tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid);
> + } else {
> + tmp.st_uid, from_kfsuid_munged(current_user_ns(), stat->uid);
> + tmp.st_gid, from_kfsgid_munged(current_user_ns(), stat->gid);
> + }
I suppose this should be = ?
Tycho
^ permalink raw reply
* Re: [PATCH] CIFS: unlock file across process
From: Pavel Shilovsky @ 2020-02-14 19:03 UTC (permalink / raw)
To: Murphy Zhou; +Cc: Jeff Layton, linux-cifs, Steve French
In-Reply-To: <20200214142836.2rhitx3jfa5nxada@xzhoux.usersys.redhat.com>
Also, please make sure that resulting patch works against Windows file
share since the locking semantics may be different there.
Depending on a kind of lease we have on a file, locks may be cached or
not. We probably don't want to have different behavior for cached and
non-cached locks. Especially given the fact that a lease may be broken
in the middle of app execution and the different behavior will be
applied immediately.
--
Best regards,
Pavel Shilovsky
пт, 14 февр. 2020 г. в 06:30, Murphy Zhou <jencce.kernel@gmail.com>:
>
> On Fri, Feb 14, 2020 at 07:26:46AM -0500, Jeff Layton wrote:
> > On Fri, 2020-02-14 at 12:35 +0800, Murphy Zhou wrote:
> > > Now child can't unlock the same file that has been locked by
> > > parent. Fix this by not skipping unlock if requesting from
> > > different process.
> > >
> > > Patch tested by LTP and xfstests using samba server.
> > >
> > > Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> > > ---
> > > fs/cifs/smb2file.c | 2 --
> > > 1 file changed, 2 deletions(-)
> > >
> > > diff --git a/fs/cifs/smb2file.c b/fs/cifs/smb2file.c
> > > index afe1f03aabe3..b5bca0e13d51 100644
> > > --- a/fs/cifs/smb2file.c
> > > +++ b/fs/cifs/smb2file.c
> > > @@ -151,8 +151,6 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
> > > (flock->fl_start + length) <
> > > (li->offset + li->length))
> > > continue;
> > > - if (current->tgid != li->pid)
> > > - continue;
> > > if (cinode->can_cache_brlcks) {
> > > /*
> > > * We can cache brlock requests - simply remove a lock
> >
> > I'm not as familiar with this code as I once was, but...
> >
> > From fork(2) manpage:
> >
> > * The child does not inherit process-associated record locks from its
> > parent (fcntl(2)). (On the other hand, it does inherit fcntl(2)
> > open file description locks and flock(2) locks from its parent.)
> >
> > It looks like cifs_setlk calls mand_unlock_range, and that gets called
> > from both fcntl and flock codepaths.
> >
> > So, I'm not sure about just removing this. It seems like the pid check
> > is probably correct for traditional posix locks, but probably not for
> > OFD and flock locks? What ensures that completely unrelated tasks can't
> > unlock your locks?
>
> You are right Jeff. Just removing this is not right. We need to handle
> at least 3 types of locks: posix, OFD and flock.
>
> Thanks very much for reviewing! I'll try to sort this out.
> > --
> > Jeff Layton <jlayton@kernel.org>
> >
^ permalink raw reply
* Re: [PATCH v2 5/8] serial: 8250_port: Don't use power management for kernel console
From: Tony Lindgren @ 2020-02-14 19:02 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial,
Sebastian Andrzej Siewior, Russell King
In-Reply-To: <20200214185645.GQ10400@smile.fi.intel.com>
* Andy Shevchenko <andriy.shevchenko@linux.intel.com> [200214 18:57]:
> On Fri, Feb 14, 2020 at 10:14:07AM -0800, Tony Lindgren wrote:
> > * Andy Shevchenko <andriy.shevchenko@linux.intel.com> [200214 11:44]:
> > > --- a/drivers/tty/serial/8250/8250_core.c
> > > +++ b/drivers/tty/serial/8250/8250_core.c
> > > @@ -608,6 +608,14 @@ static int univ8250_console_setup(struct console *co, char *options)
> > > return retval;
> > > }
> > >
> > > +static int univ8250_console_exit(struct console *co)
> > > +{
> > > + struct uart_port *port;
> > > +
> > > + port = &serial8250_ports[co->index].port;
> > > + return serial8250_console_exit(port);
> > > +}
> > > +
> > > /**
> > > * univ8250_console_match - non-standard console matching
> > > * @co: registering console
> > > @@ -666,6 +674,7 @@ static struct console univ8250_console = {
> > > .write = univ8250_console_write,
> > > .device = uart_console_device,
> > > .setup = univ8250_console_setup,
> > > + .exit = univ8250_console_exit,
> > > .match = univ8250_console_match,
> > > .flags = CON_PRINTBUFFER | CON_ANYTIME,
> > > .index = -1,
> >
> > You're missing adding exit to struct console or these patches
> > are based on some tree I don't have. I had to add the following
> > change to compile for you to fold into this patch.
>
> In cover letter the [1] link answers to this.
> Can you try again with that series being applied first?
Ah OK thanks will try with that applied.
Regards,
Tony
^ permalink raw reply
* [PATCH AUTOSEL 4.14 017/186] powerpc/powernv/iov: Ensure the pdn for VFs always contains a valid PE number
From: Sasha Levin @ 2020-02-14 16:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Alexey Kardashevskiy, Oliver O'Halloran, linuxppc-dev,
Sasha Levin
In-Reply-To: <20200214161715.18113-1-sashal@kernel.org>
From: Oliver O'Halloran <oohall@gmail.com>
[ Upstream commit 3b5b9997b331e77ce967eba2c4bc80dc3134a7fe ]
On pseries there is a bug with adding hotplugged devices to an IOMMU
group. For a number of dumb reasons fixing that bug first requires
re-working how VFs are configured on PowerNV. For background, on
PowerNV we use the pcibios_sriov_enable() hook to do two things:
1. Create a pci_dn structure for each of the VFs, and
2. Configure the PHB's internal BARs so the MMIO range for each VF
maps to a unique PE.
Roughly speaking a PE is the hardware counterpart to a Linux IOMMU
group since all the devices in a PE share the same IOMMU table. A PE
also defines the set of devices that should be isolated in response to
a PCI error (i.e. bad DMA, UR/CA, AER events, etc). When isolated all
MMIO and DMA traffic to and from devicein the PE is blocked by the
root complex until the PE is recovered by the OS.
The requirement to block MMIO causes a giant headache because the P8
PHB generally uses a fixed mapping between MMIO addresses and PEs. As
a result we need to delay configuring the IOMMU groups for device
until after MMIO resources are assigned. For physical devices (i.e.
non-VFs) the PE assignment is done in pcibios_setup_bridge() which is
called immediately after the MMIO resources for downstream
devices (and the bridge's windows) are assigned. For VFs the setup is
more complicated because:
a) pcibios_setup_bridge() is not called again when VFs are activated, and
b) The pci_dev for VFs are created by generic code which runs after
pcibios_sriov_enable() is called.
The work around for this is a two step process:
1. A fixup in pcibios_add_device() is used to initialised the cached
pe_number in pci_dn, then
2. A bus notifier then adds the device to the IOMMU group for the PE
specified in pci_dn->pe_number.
A side effect fixing the pseries bug mentioned in the first paragraph
is moving the fixup out of pcibios_add_device() and into
pcibios_bus_add_device(), which is called much later. This results in
step 2. failing because pci_dn->pe_number won't be initialised when
the bus notifier is run.
We can fix this by removing the need for the fixup. The PE for a VF is
known before the VF is even scanned so we can initialise
pci_dn->pe_number pcibios_sriov_enable() instead. Unfortunately,
moving the initialisation causes two problems:
1. We trip the WARN_ON() in the current fixup code, and
2. The EEH core clears pdn->pe_number when recovering a VF and
relies on the fixup to correctly re-set it.
The only justification for either of these is a comment in
eeh_rmv_device() suggesting that pdn->pe_number *must* be set to
IODA_INVALID_PE in order for the VF to be scanned. However, this
comment appears to have no basis in reality. Both bugs can be fixed by
just deleting the code.
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20191028085424.12006-1-oohall@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/powerpc/kernel/eeh_driver.c | 6 ------
arch/powerpc/platforms/powernv/pci-ioda.c | 19 +++++++++++++++----
arch/powerpc/platforms/powernv/pci.c | 4 ----
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index 470284f9e4f66..5a48c93aaa1b3 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -520,12 +520,6 @@ static void *eeh_rmv_device(void *data, void *userdata)
pci_iov_remove_virtfn(edev->physfn, pdn->vf_index, 0);
edev->pdev = NULL;
-
- /*
- * We have to set the VF PE number to invalid one, which is
- * required to plug the VF successfully.
- */
- pdn->pe_number = IODA_INVALID_PE;
#endif
if (rmv_data)
list_add(&edev->rmv_list, &rmv_data->edev_list);
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index d3d5796f7df60..36ef504eeab32 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1523,6 +1523,10 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)
/* Reserve PE for each VF */
for (vf_index = 0; vf_index < num_vfs; vf_index++) {
+ int vf_devfn = pci_iov_virtfn_devfn(pdev, vf_index);
+ int vf_bus = pci_iov_virtfn_bus(pdev, vf_index);
+ struct pci_dn *vf_pdn;
+
if (pdn->m64_single_mode)
pe_num = pdn->pe_num_map[vf_index];
else
@@ -1535,13 +1539,11 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)
pe->pbus = NULL;
pe->parent_dev = pdev;
pe->mve_number = -1;
- pe->rid = (pci_iov_virtfn_bus(pdev, vf_index) << 8) |
- pci_iov_virtfn_devfn(pdev, vf_index);
+ pe->rid = (vf_bus << 8) | vf_devfn;
pe_info(pe, "VF %04d:%02d:%02d.%d associated with PE#%x\n",
hose->global_number, pdev->bus->number,
- PCI_SLOT(pci_iov_virtfn_devfn(pdev, vf_index)),
- PCI_FUNC(pci_iov_virtfn_devfn(pdev, vf_index)), pe_num);
+ PCI_SLOT(vf_devfn), PCI_FUNC(vf_devfn), pe_num);
if (pnv_ioda_configure_pe(phb, pe)) {
/* XXX What do we do here ? */
@@ -1555,6 +1557,15 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)
list_add_tail(&pe->list, &phb->ioda.pe_list);
mutex_unlock(&phb->ioda.pe_list_mutex);
+ /* associate this pe to it's pdn */
+ list_for_each_entry(vf_pdn, &pdn->parent->child_list, list) {
+ if (vf_pdn->busno == vf_bus &&
+ vf_pdn->devfn == vf_devfn) {
+ vf_pdn->pe_number = pe_num;
+ break;
+ }
+ }
+
pnv_pci_ioda2_setup_dma_pe(phb, pe);
}
}
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index 961c131a5b7e8..844ca1886063b 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -978,16 +978,12 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev)
struct pnv_phb *phb = hose->private_data;
#ifdef CONFIG_PCI_IOV
struct pnv_ioda_pe *pe;
- struct pci_dn *pdn;
/* Fix the VF pdn PE number */
if (pdev->is_virtfn) {
- pdn = pci_get_pdn(pdev);
- WARN_ON(pdn->pe_number != IODA_INVALID_PE);
list_for_each_entry(pe, &phb->ioda.pe_list, list) {
if (pe->rid == ((pdev->bus->number << 8) |
(pdev->devfn & 0xff))) {
- pdn->pe_number = pe->pe_number;
pe->pdev = pdev;
break;
}
--
2.20.1
^ permalink raw reply related
* ✗ patchtest: failure for busybox: Fix typo in patch
From: Patchwork @ 2020-02-14 19:02 UTC (permalink / raw)
To: Khem Raj; +Cc: openembedded-core
In-Reply-To: <20200214185858.500028-1-raj.khem@gmail.com>
== Series Details ==
Series: busybox: Fix typo in patch
Revision: 1
URL : https://patchwork.openembedded.org/series/22636/
State : failure
== Summary ==
Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:
* Issue Series does not apply on top of target branch [test_series_merge_on_head]
Suggested fix Rebase your series on top of targeted branch
Targeted branch master (currently at 7331062f82)
If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).
---
Guidelines: https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
^ permalink raw reply
* Re: [PATCH] pinctrl: ingenic: Make unreachable path more robust
From: Paul Cercueil @ 2020-02-14 19:02 UTC (permalink / raw)
To: Josh Poimboeuf
Cc: Linus Walleij, linux-gpio, linux-kernel, Peter Zijlstra,
Randy Dunlap
In-Reply-To: <73f0c9915473d9e4b3681fb5cc55144291a43192.1581698101.git.jpoimboe@redhat.com>
Hi Josh,
Le ven., févr. 14, 2020 at 10:37, Josh Poimboeuf <jpoimboe@redhat.com>
a écrit :
> In the second loop of ingenic_pinconf_set(), it annotates the switch
> default case as unreachable(). The annotation is technically correct,
> because that same case would have resulted in an early return in the
> previous loop.
>
> However, if a bug were to get introduced later, for example if an
> additional case were added to the first loop without adjusting the
> second loop, it would result in nasty undefined behavior: most likely
> the function's generated code would fall through to the next function.
>
> Another issue is that, while objtool normally understands
> unreachable()
> annotations, there's one special case where it doesn't: when the
> annotation occurs immediately after a 'ret' instruction. That happens
> to be the case here because unreachable() is immediately before the
> return.
>
> So change the unreachable() to BUG() so that the unreachable code, if
> ever executed, would panic instead of introducing undefined behavior.
> This also makes objtool happy.
I don't like the idea that you change this driver's code just to work
around a bug in objtool, and I don't like the idea of working around a
future bug that shouldn't be introduced in the first place.
-Paul
>
> This fixes the following objtool warning:
>
> drivers/pinctrl/pinctrl-ingenic.o: warning: objtool:
> ingenic_pinconf_set() falls through to next function
> ingenic_pinconf_group_set()
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
> drivers/pinctrl/pinctrl-ingenic.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-ingenic.c
> b/drivers/pinctrl/pinctrl-ingenic.c
> index 96f04d121ebd..6b61ac6cd4d2 100644
> --- a/drivers/pinctrl/pinctrl-ingenic.c
> +++ b/drivers/pinctrl/pinctrl-ingenic.c
> @@ -2158,7 +2158,7 @@ static int ingenic_pinconf_set(struct
> pinctrl_dev *pctldev, unsigned int pin,
> break;
>
> default:
> - unreachable();
> + BUG();
> }
> }
>
> --
> 2.21.1
>
^ permalink raw reply
* Re: [RFC v2 2/6] tpm: Use TPMState as a common struct
From: Philippe Mathieu-Daudé @ 2020-02-14 19:01 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, stefanb, qemu-devel, qemu-arm,
peter.maydell
Cc: marcandre.lureau, lersek, ardb
In-Reply-To: <20200214183704.14389-3-eric.auger@redhat.com>
On 2/14/20 7:37 PM, Eric Auger wrote:
> As we plan to introdce a SysBus TPM TIS device, let's
typo "introduce"
> make the TPMState a common struct usable by both the
> ISADevice and the SysBusDevice. TPMStateISA embeds the
> struct and inherits from the ISADevice.
>
> The prototype of functions bound to be used by both
> the ISA and SysBus devices is changed to take TPMState
> handle.
>
> A bunch of structs also are renamed to be specialized
> for the ISA device. Besides those transformations, no
> functional change is expected.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/tpm/tpm_tis.c | 146 +++++++++++++++++++++++++++++------------------
> 1 file changed, 91 insertions(+), 55 deletions(-)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index c609737272..fc6d7ca579 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -65,7 +65,6 @@ typedef struct TPMLocality {
> } TPMLocality;
>
> typedef struct TPMState {
> - ISADevice busdev;
> MemoryRegion mmio;
>
> unsigned char buffer[TPM_TIS_BUFFER_MAX];
> @@ -91,7 +90,15 @@ typedef struct TPMState {
> TPMPPI ppi;
> } TPMState;
>
> -#define TPM(obj) OBJECT_CHECK(TPMState, (obj), TYPE_TPM_TIS_ISA)
> +typedef struct TPMStateISA {
> + /*< private >*/
> + ISADevice parent_obj;
> +
> + /*< public >*/
> + TPMState state; /* not a QOM object */
Maybe rename 'state' -> 'tpm'?
Anyway:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> +} TPMStateISA;
> +
> +#define TPM_TIS_ISA(obj) OBJECT_CHECK(TPMStateISA, (obj), TYPE_TPM_TIS_ISA)
>
> #define DEBUG_TIS 0
>
> @@ -281,9 +288,8 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty)
> /*
> * Callback from the TPM to indicate that the response was received.
> */
> -static void tpm_tis_request_completed(TPMIf *ti, int ret)
> +static void tpm_tis_request_completed(TPMState *s, int ret)
> {
> - TPMState *s = TPM(ti);
> uint8_t locty = s->cmd.locty;
> uint8_t l;
>
> @@ -338,7 +344,7 @@ static uint32_t tpm_tis_data_read(TPMState *s, uint8_t locty)
> }
>
> #ifdef DEBUG_TIS
> -static void tpm_tis_dump_state(void *opaque, hwaddr addr)
> +static void tpm_tis_dump_state(TPMState *s, hwaddr addr)
> {
> static const unsigned regs[] = {
> TPM_TIS_REG_ACCESS,
> @@ -353,7 +359,6 @@ static void tpm_tis_dump_state(void *opaque, hwaddr addr)
> int idx;
> uint8_t locty = tpm_tis_locality_from_addr(addr);
> hwaddr base = addr & ~0xfff;
> - TPMState *s = opaque;
>
> printf("tpm_tis: active locality : %d\n"
> "tpm_tis: state of locality %d : %d\n"
> @@ -363,7 +368,7 @@ static void tpm_tis_dump_state(void *opaque, hwaddr addr)
>
> for (idx = 0; regs[idx] != 0xfff; idx++) {
> printf("tpm_tis: 0x%04x : 0x%08x\n", regs[idx],
> - (int)tpm_tis_mmio_read(opaque, base + regs[idx], 4));
> + (int)tpm_tis_mmio_read(s, base + regs[idx], 4));
> }
>
> printf("tpm_tis: r/w offset : %d\n"
> @@ -488,7 +493,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,
> break;
> #ifdef DEBUG_TIS
> case TPM_TIS_REG_DEBUG:
> - tpm_tis_dump_state(opaque, addr);
> + tpm_tis_dump_state(s, addr);
> break;
> #endif
> }
> @@ -835,10 +840,8 @@ static const MemoryRegionOps tpm_tis_memory_ops = {
> /*
> * Get the TPMVersion of the backend device being used
> */
> -static enum TPMVersion tpm_tis_get_tpm_version(TPMIf *ti)
> +static enum TPMVersion tpm_tis_get_tpm_version(TPMState *s)
> {
> - TPMState *s = TPM(ti);
> -
> if (tpm_backend_had_startup_error(s->be_driver)) {
> return TPM_VERSION_UNSPEC;
> }
> @@ -850,9 +853,8 @@ static enum TPMVersion tpm_tis_get_tpm_version(TPMIf *ti)
> * This function is called when the machine starts, resets or due to
> * S3 resume.
> */
> -static void tpm_tis_reset(DeviceState *dev)
> +static void tpm_tis_reset(TPMState *s)
> {
> - TPMState *s = TPM(dev);
> int c;
>
> s->be_tpm_version = tpm_backend_get_tpm_version(s->be_driver);
> @@ -896,15 +898,14 @@ static void tpm_tis_reset(DeviceState *dev)
>
> /* persistent state handling */
>
> -static int tpm_tis_pre_save(void *opaque)
> +static int tpm_tis_pre_save(TPMState *s)
> {
> - TPMState *s = opaque;
> uint8_t locty = s->active_locty;
>
> trace_tpm_tis_pre_save(locty, s->rw_offset);
>
> if (DEBUG_TIS) {
> - tpm_tis_dump_state(opaque, 0);
> + tpm_tis_dump_state(s, 0);
> }
>
> /*
> @@ -929,34 +930,78 @@ static const VMStateDescription vmstate_locty = {
> }
> };
>
> -static const VMStateDescription vmstate_tpm_tis = {
> +/* ISA */
> +
> +static int tpm_tis_pre_save_isa(void *opaque)
> +{
> + TPMStateISA *isadev = opaque;
> +
> + return tpm_tis_pre_save(&isadev->state);
> +}
> +
> +static const VMStateDescription vmstate_tpm_tis_isa = {
> .name = "tpm-tis",
> .version_id = 0,
> - .pre_save = tpm_tis_pre_save,
> + .pre_save = tpm_tis_pre_save_isa,
> .fields = (VMStateField[]) {
> - VMSTATE_BUFFER(buffer, TPMState),
> - VMSTATE_UINT16(rw_offset, TPMState),
> - VMSTATE_UINT8(active_locty, TPMState),
> - VMSTATE_UINT8(aborting_locty, TPMState),
> - VMSTATE_UINT8(next_locty, TPMState),
> + VMSTATE_BUFFER(state.buffer, TPMStateISA),
> + VMSTATE_UINT16(state.rw_offset, TPMStateISA),
> + VMSTATE_UINT8(state.active_locty, TPMStateISA),
> + VMSTATE_UINT8(state.aborting_locty, TPMStateISA),
> + VMSTATE_UINT8(state.next_locty, TPMStateISA),
>
> - VMSTATE_STRUCT_ARRAY(loc, TPMState, TPM_TIS_NUM_LOCALITIES, 0,
> + VMSTATE_STRUCT_ARRAY(state.loc, TPMStateISA, TPM_TIS_NUM_LOCALITIES, 0,
> vmstate_locty, TPMLocality),
>
> VMSTATE_END_OF_LIST()
> }
> };
>
> -static Property tpm_tis_properties[] = {
> - DEFINE_PROP_UINT32("irq", TPMState, irq_num, TPM_TIS_IRQ),
> - DEFINE_PROP_TPMBE("tpmdev", TPMState, be_driver),
> - DEFINE_PROP_BOOL("ppi", TPMState, ppi_enabled, true),
> +static void tpm_tis_isa_request_completed(TPMIf *ti, int ret)
> +{
> + TPMStateISA *isadev = TPM_TIS_ISA(ti);
> + TPMState *s = &isadev->state;
> +
> + tpm_tis_request_completed(s, ret);
> +}
> +
> +static enum TPMVersion tpm_tis_isa_get_tpm_version(TPMIf *ti)
> +{
> + TPMStateISA *isadev = TPM_TIS_ISA(ti);
> + TPMState *s = &isadev->state;
> +
> + return tpm_tis_get_tpm_version(s);
> +}
> +
> +static void tpm_tis_isa_reset(DeviceState *dev)
> +{
> + TPMStateISA *isadev = TPM_TIS_ISA(dev);
> + TPMState *s = &isadev->state;
> +
> + return tpm_tis_reset(s);
> +}
> +
> +static Property tpm_tis_isa_properties[] = {
> + DEFINE_PROP_UINT32("irq", TPMStateISA, state.irq_num, TPM_TIS_IRQ),
> + DEFINE_PROP_TPMBE("tpmdev", TPMStateISA, state.be_driver),
> + DEFINE_PROP_BOOL("ppi", TPMStateISA, state.ppi_enabled, true),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> -static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
> +static void tpm_tis_isa_initfn(Object *obj)
> {
> - TPMState *s = TPM(dev);
> + TPMStateISA *isadev = TPM_TIS_ISA(obj);
> + TPMState *s = &isadev->state;
> +
> + memory_region_init_io(&s->mmio, obj, &tpm_tis_memory_ops,
> + s, "tpm-tis-mmio",
> + TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT);
> +}
> +
> +static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)
> +{
> + TPMStateISA *isadev = TPM_TIS_ISA(dev);
> + TPMState *s = &isadev->state;
>
> if (!tpm_find()) {
> error_setg(errp, "at most one TPM device is permitted");
> @@ -973,55 +1018,46 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
> return;
> }
>
> - isa_init_irq(&s->busdev, &s->irq, s->irq_num);
> + isa_init_irq(ISA_DEVICE(dev), &s->irq, s->irq_num);
>
> memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)),
> TPM_TIS_ADDR_BASE, &s->mmio);
>
> if (s->ppi_enabled) {
> tpm_ppi_init(&s->ppi, isa_address_space(ISA_DEVICE(dev)),
> - TPM_PPI_ADDR_BASE, OBJECT(s));
> + TPM_PPI_ADDR_BASE, OBJECT(dev));
> }
> }
>
> -static void tpm_tis_initfn(Object *obj)
> -{
> - TPMState *s = TPM(obj);
> -
> - memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops,
> - s, "tpm-tis-mmio",
> - TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT);
> -}
> -
> -static void tpm_tis_class_init(ObjectClass *klass, void *data)
> +static void tpm_tis_isa_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> TPMIfClass *tc = TPM_IF_CLASS(klass);
>
> - dc->realize = tpm_tis_realizefn;
> - device_class_set_props(dc, tpm_tis_properties);
> - dc->reset = tpm_tis_reset;
> - dc->vmsd = &vmstate_tpm_tis;
> + device_class_set_props(dc, tpm_tis_isa_properties);
> + dc->vmsd = &vmstate_tpm_tis_isa;
> tc->model = TPM_MODEL_TPM_TIS;
> - tc->get_version = tpm_tis_get_tpm_version;
> - tc->request_completed = tpm_tis_request_completed;
> + dc->realize = tpm_tis_isa_realizefn;
> + dc->reset = tpm_tis_isa_reset;
> + tc->request_completed = tpm_tis_isa_request_completed;
> + tc->get_version = tpm_tis_isa_get_tpm_version;
> }
>
> -static const TypeInfo tpm_tis_info = {
> +static const TypeInfo tpm_tis_isa_info = {
> .name = TYPE_TPM_TIS_ISA,
> .parent = TYPE_ISA_DEVICE,
> - .instance_size = sizeof(TPMState),
> - .instance_init = tpm_tis_initfn,
> - .class_init = tpm_tis_class_init,
> + .instance_size = sizeof(TPMStateISA),
> + .instance_init = tpm_tis_isa_initfn,
> + .class_init = tpm_tis_isa_class_init,
> .interfaces = (InterfaceInfo[]) {
> { TYPE_TPM_IF },
> { }
> }
> };
>
> -static void tpm_tis_register(void)
> +static void tpm_tis_isa_register(void)
> {
> - type_register_static(&tpm_tis_info);
> + type_register_static(&tpm_tis_isa_info);
> }
>
> -type_init(tpm_tis_register)
> +type_init(tpm_tis_isa_register)
>
^ permalink raw reply
* Re: [PATCH 2/2] rtnl: Rename l_rtnl_ifaddr{4|6|}_get to l_rntl_ifaddr{4|6}_dump
From: Denis Kenzior @ 2020-02-14 19:00 UTC (permalink / raw)
To: ell
In-Reply-To: <20200214182337.11132-3-wagi@monom.org>
[-- Attachment #1: Type: text/plain, Size: 370 bytes --]
Hi Daniel,
On 2/14/20 12:23 PM, Daniel Wagner wrote:
> These functions use NLM_F_DUMP so rename them accordingly.
> ---
> ell/rtnl.c | 4 ++--
> ell/rtnl.h | 4 ++--
> unit/test-rtnl.c | 24 ++++++++++++------------
> 3 files changed, 16 insertions(+), 16 deletions(-)
>
Applied, also after splitting this into two.
Regards,
-Denis
^ permalink raw reply
* [PATCH v5 4/4] xfs: replace mrlock_t with rw_semaphores
From: Pavel Reichl @ 2020-02-14 18:59 UTC (permalink / raw)
To: linux-xfs
In-Reply-To: <20200214185942.1147742-1-preichl@redhat.com>
Remove mrlock_t as it does not provide any extra value over
rw_semaphores. Make i_lock and i_mmaplock native rw_semaphores and
replace mr*() functions with native rwsem calls.
Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
fs/xfs/mrlock.h | 78 ----------------------------------------------
fs/xfs/xfs_inode.c | 40 +++++++++++++-----------
fs/xfs/xfs_inode.h | 4 +--
fs/xfs/xfs_iops.c | 4 +--
fs/xfs/xfs_linux.h | 2 +-
fs/xfs/xfs_super.c | 6 ++--
6 files changed, 29 insertions(+), 105 deletions(-)
delete mode 100644 fs/xfs/mrlock.h
diff --git a/fs/xfs/mrlock.h b/fs/xfs/mrlock.h
deleted file mode 100644
index 79155eec341b..000000000000
--- a/fs/xfs/mrlock.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2000-2006 Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-#ifndef __XFS_SUPPORT_MRLOCK_H__
-#define __XFS_SUPPORT_MRLOCK_H__
-
-#include <linux/rwsem.h>
-
-typedef struct {
- struct rw_semaphore mr_lock;
-#if defined(DEBUG) || defined(XFS_WARN)
- int mr_writer;
-#endif
-} mrlock_t;
-
-#if defined(DEBUG) || defined(XFS_WARN)
-#define mrinit(mrp, name) \
- do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0)
-#else
-#define mrinit(mrp, name) \
- do { init_rwsem(&(mrp)->mr_lock); } while (0)
-#endif
-
-#define mrlock_init(mrp, t,n,s) mrinit(mrp, n)
-#define mrfree(mrp) do { } while (0)
-
-static inline void mraccess_nested(mrlock_t *mrp, int subclass)
-{
- down_read_nested(&mrp->mr_lock, subclass);
-}
-
-static inline void mrupdate_nested(mrlock_t *mrp, int subclass)
-{
- down_write_nested(&mrp->mr_lock, subclass);
-#if defined(DEBUG) || defined(XFS_WARN)
- mrp->mr_writer = 1;
-#endif
-}
-
-static inline int mrtryaccess(mrlock_t *mrp)
-{
- return down_read_trylock(&mrp->mr_lock);
-}
-
-static inline int mrtryupdate(mrlock_t *mrp)
-{
- if (!down_write_trylock(&mrp->mr_lock))
- return 0;
-#if defined(DEBUG) || defined(XFS_WARN)
- mrp->mr_writer = 1;
-#endif
- return 1;
-}
-
-static inline void mrunlock_excl(mrlock_t *mrp)
-{
-#if defined(DEBUG) || defined(XFS_WARN)
- mrp->mr_writer = 0;
-#endif
- up_write(&mrp->mr_lock);
-}
-
-static inline void mrunlock_shared(mrlock_t *mrp)
-{
- up_read(&mrp->mr_lock);
-}
-
-static inline void mrdemote(mrlock_t *mrp)
-{
-#if defined(DEBUG) || defined(XFS_WARN)
- mrp->mr_writer = 0;
-#endif
- downgrade_write(&mrp->mr_lock);
-}
-
-#endif /* __XFS_SUPPORT_MRLOCK_H__ */
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 14f46f099470..1f979e46c6bf 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -191,14 +191,15 @@ xfs_ilock(
}
if (lock_flags & XFS_MMAPLOCK_EXCL)
- mrupdate_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags));
+ down_write_nested(&ip->i_mmaplock,
+ XFS_MMAPLOCK_DEP(lock_flags));
else if (lock_flags & XFS_MMAPLOCK_SHARED)
- mraccess_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags));
+ down_read_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags));
if (lock_flags & XFS_ILOCK_EXCL)
- mrupdate_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags));
+ down_write_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags));
else if (lock_flags & XFS_ILOCK_SHARED)
- mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags));
+ down_read_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags));
}
/*
@@ -242,27 +243,27 @@ xfs_ilock_nowait(
}
if (lock_flags & XFS_MMAPLOCK_EXCL) {
- if (!mrtryupdate(&ip->i_mmaplock))
+ if (!down_write_trylock(&ip->i_mmaplock))
goto out_undo_iolock;
} else if (lock_flags & XFS_MMAPLOCK_SHARED) {
- if (!mrtryaccess(&ip->i_mmaplock))
+ if (!down_read_trylock(&ip->i_mmaplock))
goto out_undo_iolock;
}
if (lock_flags & XFS_ILOCK_EXCL) {
- if (!mrtryupdate(&ip->i_lock))
+ if (!down_write_trylock(&ip->i_lock))
goto out_undo_mmaplock;
} else if (lock_flags & XFS_ILOCK_SHARED) {
- if (!mrtryaccess(&ip->i_lock))
+ if (!down_read_trylock(&ip->i_lock))
goto out_undo_mmaplock;
}
return 1;
out_undo_mmaplock:
if (lock_flags & XFS_MMAPLOCK_EXCL)
- mrunlock_excl(&ip->i_mmaplock);
+ up_write(&ip->i_mmaplock);
else if (lock_flags & XFS_MMAPLOCK_SHARED)
- mrunlock_shared(&ip->i_mmaplock);
+ up_read(&ip->i_mmaplock);
out_undo_iolock:
if (lock_flags & XFS_IOLOCK_EXCL)
up_write(&VFS_I(ip)->i_rwsem);
@@ -309,14 +310,14 @@ xfs_iunlock(
up_read(&VFS_I(ip)->i_rwsem);
if (lock_flags & XFS_MMAPLOCK_EXCL)
- mrunlock_excl(&ip->i_mmaplock);
+ up_write(&ip->i_mmaplock);
else if (lock_flags & XFS_MMAPLOCK_SHARED)
- mrunlock_shared(&ip->i_mmaplock);
+ up_read(&ip->i_mmaplock);
if (lock_flags & XFS_ILOCK_EXCL)
- mrunlock_excl(&ip->i_lock);
+ up_write(&ip->i_lock);
else if (lock_flags & XFS_ILOCK_SHARED)
- mrunlock_shared(&ip->i_lock);
+ up_read(&ip->i_lock);
trace_xfs_iunlock(ip, lock_flags, _RET_IP_);
}
@@ -335,9 +336,9 @@ xfs_ilock_demote(
~(XFS_IOLOCK_EXCL|XFS_MMAPLOCK_EXCL|XFS_ILOCK_EXCL)) == 0);
if (lock_flags & XFS_ILOCK_EXCL)
- mrdemote(&ip->i_lock);
+ downgrade_write(&ip->i_lock);
if (lock_flags & XFS_MMAPLOCK_EXCL)
- mrdemote(&ip->i_mmaplock);
+ downgrade_write(&ip->i_mmaplock);
if (lock_flags & XFS_IOLOCK_EXCL)
downgrade_write(&VFS_I(ip)->i_rwsem);
@@ -374,13 +375,16 @@ xfs_isilocked(
uint lock_flags)
{
if (lock_flags & (XFS_ILOCK_EXCL | XFS_ILOCK_SHARED)) {
- return __xfs_rwsem_islocked(&ip->i_lock.mr_lock,
+ ASSERT(!(lock_flags & ~(XFS_ILOCK_EXCL | XFS_ILOCK_SHARED)));
+ return __xfs_rwsem_islocked(&ip->i_lock,
(lock_flags & XFS_ILOCK_SHARED),
(lock_flags & XFS_ILOCK_EXCL));
}
if (lock_flags & (XFS_MMAPLOCK_EXCL | XFS_MMAPLOCK_SHARED)) {
- return __xfs_rwsem_islocked(&ip->i_mmaplock.mr_lock,
+ ASSERT(!(lock_flags &
+ ~(XFS_MMAPLOCK_EXCL | XFS_MMAPLOCK_SHARED)));
+ return __xfs_rwsem_islocked(&ip->i_mmaplock,
(lock_flags & XFS_MMAPLOCK_SHARED),
(lock_flags & XFS_MMAPLOCK_EXCL));
}
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 3d7ce355407d..a7cf112a9e4f 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -39,8 +39,8 @@ typedef struct xfs_inode {
/* Transaction and locking information. */
struct xfs_inode_log_item *i_itemp; /* logging information */
- mrlock_t i_lock; /* inode lock */
- mrlock_t i_mmaplock; /* inode mmap IO lock */
+ struct rw_semaphore i_lock; /* inode lock */
+ struct rw_semaphore i_mmaplock; /* inode mmap IO lock */
atomic_t i_pincount; /* inode pin count */
/*
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 81f2f93caec0..7c3df574cf4c 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1319,9 +1319,9 @@ xfs_setup_inode(
*/
lockdep_set_class(&inode->i_rwsem,
&inode->i_sb->s_type->i_mutex_dir_key);
- lockdep_set_class(&ip->i_lock.mr_lock, &xfs_dir_ilock_class);
+ lockdep_set_class(&ip->i_lock, &xfs_dir_ilock_class);
} else {
- lockdep_set_class(&ip->i_lock.mr_lock, &xfs_nondir_ilock_class);
+ lockdep_set_class(&ip->i_lock, &xfs_nondir_ilock_class);
}
/*
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index 8738bb03f253..8248744f1245 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -22,7 +22,6 @@ typedef __u32 xfs_nlink_t;
#include "xfs_types.h"
#include "kmem.h"
-#include "mrlock.h"
#include <linux/semaphore.h>
#include <linux/mm.h>
@@ -60,6 +59,7 @@ typedef __u32 xfs_nlink_t;
#include <linux/list_sort.h>
#include <linux/ratelimit.h>
#include <linux/rhashtable.h>
+#include <linux/rwsem.h>
#include <asm/page.h>
#include <asm/div64.h>
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 760901783944..1289ce1f4e9e 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -661,10 +661,8 @@ xfs_fs_inode_init_once(
atomic_set(&ip->i_pincount, 0);
spin_lock_init(&ip->i_flags_lock);
- mrlock_init(&ip->i_mmaplock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
- "xfsino", ip->i_ino);
- mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
- "xfsino", ip->i_ino);
+ init_rwsem(&ip->i_mmaplock);
+ init_rwsem(&ip->i_lock);
}
/*
--
2.24.1
^ permalink raw reply related
* [PATCH v5 2/4] xfs: clean up whitespace in xfs_isilocked() calls
From: Pavel Reichl @ 2020-02-14 18:59 UTC (permalink / raw)
To: linux-xfs
In-Reply-To: <20200214185942.1147742-1-preichl@redhat.com>
Make whitespace follow the same pattern in all xfs_isilocked() calls.
Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
fs/xfs/libxfs/xfs_bmap.c | 2 +-
fs/xfs/xfs_file.c | 3 ++-
fs/xfs/xfs_inode.c | 6 +++---
fs/xfs/xfs_qm.c | 2 +-
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 9a6d7a84689a..bc2be29193aa 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3906,7 +3906,7 @@ xfs_bmapi_read(
ASSERT(*nmap >= 1);
ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK|XFS_BMAPI_ENTIRE|
XFS_BMAPI_COWFORK)));
- ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED|XFS_ILOCK_EXCL));
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));
if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(ip, whichfork)) ||
XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index b8a4a3f29b36..6b65572bdb21 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -770,7 +770,8 @@ xfs_break_layouts(
bool retry;
int error;
- ASSERT(xfs_isilocked(XFS_I(inode), XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL));
+ ASSERT(xfs_isilocked(XFS_I(inode),
+ XFS_IOLOCK_SHARED | XFS_IOLOCK_EXCL));
do {
retry = false;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 3d28c4790231..14f46f099470 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2828,7 +2828,7 @@ static void
xfs_iunpin(
struct xfs_inode *ip)
{
- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL | XFS_ILOCK_SHARED));
trace_xfs_inode_unpin_nowait(ip, _RET_IP_);
@@ -3692,7 +3692,7 @@ xfs_iflush(
XFS_STATS_INC(mp, xs_iflush_count);
- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL | XFS_ILOCK_SHARED));
ASSERT(xfs_isiflocked(ip));
ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
ip->i_d.di_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK));
@@ -3824,7 +3824,7 @@ xfs_iflush_int(
struct xfs_dinode *dip;
struct xfs_mount *mp = ip->i_mount;
- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL | XFS_ILOCK_SHARED));
ASSERT(xfs_isiflocked(ip));
ASSERT(ip->i_d.di_format != XFS_DINODE_FMT_BTREE ||
ip->i_d.di_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK));
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 0b0909657bad..d2896925b5ca 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -1802,7 +1802,7 @@ xfs_qm_vop_chown_reserve(
int error;
- ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED));
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL | XFS_ILOCK_SHARED));
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
delblks = ip->i_delayed_blks;
--
2.24.1
^ permalink raw reply related
* [PATCH v5 3/4] xfs: xfs_isilocked() can only check a single lock type
From: Pavel Reichl @ 2020-02-14 18:59 UTC (permalink / raw)
To: linux-xfs
In-Reply-To: <20200214185942.1147742-1-preichl@redhat.com>
In its current form, xfs_isilocked() is only able to test one lock type
at a time - ilock, iolock, or mmap lock, but combinations are not
properly handled. The intent here is to check that both XFS_IOLOCK_EXCL
and XFS_ILOCK_EXCL are held, so test them each separately.
The commit ecfea3f0c8c6 ("xfs: split xfs_bmap_shift_extents") ORed the
flags together which was an error, so this patch reverts that part of
the change and check the locks independently.
Fixes: ecfea3f0c8c6 ("xfs: split xfs_bmap_shift_extents")
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Suggested-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
fs/xfs/libxfs/xfs_bmap.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index bc2be29193aa..c9dc94f114ed 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5829,7 +5829,8 @@ xfs_bmap_collapse_extents(
if (XFS_FORCED_SHUTDOWN(mp))
return -EIO;
- ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));
+ ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
error = xfs_iread_extents(tp, ip, whichfork);
@@ -5946,7 +5947,8 @@ xfs_bmap_insert_extents(
if (XFS_FORCED_SHUTDOWN(mp))
return -EIO;
- ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL));
+ ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
error = xfs_iread_extents(tp, ip, whichfork);
--
2.24.1
^ permalink raw reply related
* [PATCH v5 1/4] xfs: Refactor xfs_isilocked()
From: Pavel Reichl @ 2020-02-14 18:59 UTC (permalink / raw)
To: linux-xfs
Refactor xfs_isilocked() to use newly introduced __xfs_rwsem_islocked().
__xfs_rwsem_islocked() is a helper function which encapsulates checking
state of rw_semaphores hold by inode.
Signed-off-by: Pavel Reichl <preichl@redhat.com>
Suggested-by: Dave Chinner <dchinner@redhat.com>
Suggested-by: Eric Sandeen <sandeen@redhat.com>
---
fs/xfs/xfs_inode.c | 54 ++++++++++++++++++++++++++++++++--------------
fs/xfs/xfs_inode.h | 2 +-
2 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index c5077e6326c7..3d28c4790231 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -345,32 +345,54 @@ xfs_ilock_demote(
}
#if defined(DEBUG) || defined(XFS_WARN)
-int
+static inline bool
+__xfs_rwsem_islocked(
+ struct rw_semaphore *rwsem,
+ bool shared,
+ bool excl)
+{
+ bool locked = false;
+
+ if (!rwsem_is_locked(rwsem))
+ return false;
+
+ if (!debug_locks)
+ return true;
+
+ if (shared)
+ locked = lockdep_is_held_type(rwsem, 0);
+
+ if (excl)
+ locked |= lockdep_is_held_type(rwsem, 1);
+
+ return locked;
+}
+
+bool
xfs_isilocked(
- xfs_inode_t *ip,
+ struct xfs_inode *ip,
uint lock_flags)
{
- if (lock_flags & (XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)) {
- if (!(lock_flags & XFS_ILOCK_SHARED))
- return !!ip->i_lock.mr_writer;
- return rwsem_is_locked(&ip->i_lock.mr_lock);
+ if (lock_flags & (XFS_ILOCK_EXCL | XFS_ILOCK_SHARED)) {
+ return __xfs_rwsem_islocked(&ip->i_lock.mr_lock,
+ (lock_flags & XFS_ILOCK_SHARED),
+ (lock_flags & XFS_ILOCK_EXCL));
}
- if (lock_flags & (XFS_MMAPLOCK_EXCL|XFS_MMAPLOCK_SHARED)) {
- if (!(lock_flags & XFS_MMAPLOCK_SHARED))
- return !!ip->i_mmaplock.mr_writer;
- return rwsem_is_locked(&ip->i_mmaplock.mr_lock);
+ if (lock_flags & (XFS_MMAPLOCK_EXCL | XFS_MMAPLOCK_SHARED)) {
+ return __xfs_rwsem_islocked(&ip->i_mmaplock.mr_lock,
+ (lock_flags & XFS_MMAPLOCK_SHARED),
+ (lock_flags & XFS_MMAPLOCK_EXCL));
}
- if (lock_flags & (XFS_IOLOCK_EXCL|XFS_IOLOCK_SHARED)) {
- if (!(lock_flags & XFS_IOLOCK_SHARED))
- return !debug_locks ||
- lockdep_is_held_type(&VFS_I(ip)->i_rwsem, 0);
- return rwsem_is_locked(&VFS_I(ip)->i_rwsem);
+ if (lock_flags & (XFS_IOLOCK_EXCL | XFS_IOLOCK_SHARED)) {
+ return __xfs_rwsem_islocked(&VFS_I(ip)->i_rwsem,
+ (lock_flags & XFS_IOLOCK_SHARED),
+ (lock_flags & XFS_IOLOCK_EXCL));
}
ASSERT(0);
- return 0;
+ return false;
}
#endif
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 492e53992fa9..3d7ce355407d 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -416,7 +416,7 @@ void xfs_ilock(xfs_inode_t *, uint);
int xfs_ilock_nowait(xfs_inode_t *, uint);
void xfs_iunlock(xfs_inode_t *, uint);
void xfs_ilock_demote(xfs_inode_t *, uint);
-int xfs_isilocked(xfs_inode_t *, uint);
+bool xfs_isilocked(xfs_inode_t *, uint);
uint xfs_ilock_data_map_shared(struct xfs_inode *);
uint xfs_ilock_attr_map_shared(struct xfs_inode *);
--
2.24.1
^ permalink raw reply related
* [PATCH AUTOSEL 4.14 004/186] soc: fsl: qe: change return type of cpm_muram_alloc() to s32
From: Sasha Levin @ 2020-02-14 16:14 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Sasha Levin, Timur Tabi, Rasmus Villemoes, Li Yang, linuxppc-dev,
linux-arm-kernel
In-Reply-To: <20200214161715.18113-1-sashal@kernel.org>
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
[ Upstream commit 800cd6fb76f0ec7711deb72a86c924db1ae42648 ]
There are a number of problems with cpm_muram_alloc() and its
callers. Most callers assign the return value to some variable and
then use IS_ERR_VALUE to check for allocation failure. However, when
that variable is not sizeof(long), this leads to warnings - and it is
indeed broken to do e.g.
u32 foo = cpm_muram_alloc();
if (IS_ERR_VALUE(foo))
on a 64-bit platform, since the condition
foo >= (unsigned long)-ENOMEM
is tautologically false. There are also callers that ignore the
possibility of error, and then there are those that check for error by
comparing the return value to 0...
One could fix that by changing all callers to store the return value
temporarily in an "unsigned long" and test that. However, use of
IS_ERR_VALUE() is error-prone and should be restricted to things which
are inherently long-sized (stuff in pt_regs etc.). Instead, let's aim
for changing to the standard kernel style
int foo = cpm_muram_alloc();
if (foo < 0)
deal_with_it()
some->where = foo;
Changing the return type from unsigned long to s32 (aka signed int)
doesn't change the value that gets stored into any of the callers'
variables except if the caller was storing the result in a u64 _and_
the allocation failed, so in itself this patch should be a no-op.
Another problem with cpm_muram_alloc() is that it can certainly
validly return 0 - and except if some cpm_muram_alloc_fixed() call
interferes, the very first cpm_muram_alloc() call will return just
that. But that shows that both ucc_slow_free() and ucc_fast_free() are
buggy, since they assume that a value of 0 means "that field was never
allocated". We'll later change cpm_muram_free() to accept (and ignore)
a negative offset, so callers can use a sentinel of -1 instead of 0
and just unconditionally call cpm_muram_free().
Reviewed-by: Timur Tabi <timur@kernel.org>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/soc/fsl/qe/qe_common.c | 29 ++++++++++++++++-------------
include/soc/fsl/qe/qe.h | 16 ++++++++--------
2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/drivers/soc/fsl/qe/qe_common.c b/drivers/soc/fsl/qe/qe_common.c
index 104e68d9b84f2..4f60724b06b7c 100644
--- a/drivers/soc/fsl/qe/qe_common.c
+++ b/drivers/soc/fsl/qe/qe_common.c
@@ -35,7 +35,7 @@ static phys_addr_t muram_pbase;
struct muram_block {
struct list_head head;
- unsigned long start;
+ s32 start;
int size;
};
@@ -113,13 +113,14 @@ int cpm_muram_init(void)
* @algo: algorithm for alloc.
* @data: data for genalloc's algorithm.
*
- * This function returns an offset into the muram area.
+ * This function returns a non-negative offset into the muram area, or
+ * a negative errno on failure.
*/
-static unsigned long cpm_muram_alloc_common(unsigned long size,
- genpool_algo_t algo, void *data)
+static s32 cpm_muram_alloc_common(unsigned long size,
+ genpool_algo_t algo, void *data)
{
struct muram_block *entry;
- unsigned long start;
+ s32 start;
if (!muram_pool && cpm_muram_init())
goto out2;
@@ -140,7 +141,7 @@ static unsigned long cpm_muram_alloc_common(unsigned long size,
out1:
gen_pool_free(muram_pool, start, size);
out2:
- return (unsigned long)-ENOMEM;
+ return -ENOMEM;
}
/*
@@ -148,13 +149,14 @@ static unsigned long cpm_muram_alloc_common(unsigned long size,
* @size: number of bytes to allocate
* @align: requested alignment, in bytes
*
- * This function returns an offset into the muram area.
+ * This function returns a non-negative offset into the muram area, or
+ * a negative errno on failure.
* Use cpm_dpram_addr() to get the virtual address of the area.
* Use cpm_muram_free() to free the allocation.
*/
-unsigned long cpm_muram_alloc(unsigned long size, unsigned long align)
+s32 cpm_muram_alloc(unsigned long size, unsigned long align)
{
- unsigned long start;
+ s32 start;
unsigned long flags;
struct genpool_data_align muram_pool_data;
@@ -171,7 +173,7 @@ EXPORT_SYMBOL(cpm_muram_alloc);
* cpm_muram_free - free a chunk of multi-user ram
* @offset: The beginning of the chunk as returned by cpm_muram_alloc().
*/
-int cpm_muram_free(unsigned long offset)
+int cpm_muram_free(s32 offset)
{
unsigned long flags;
int size;
@@ -197,13 +199,14 @@ EXPORT_SYMBOL(cpm_muram_free);
* cpm_muram_alloc_fixed - reserve a specific region of multi-user ram
* @offset: offset of allocation start address
* @size: number of bytes to allocate
- * This function returns an offset into the muram area
+ * This function returns @offset if the area was available, a negative
+ * errno otherwise.
* Use cpm_dpram_addr() to get the virtual address of the area.
* Use cpm_muram_free() to free the allocation.
*/
-unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size)
+s32 cpm_muram_alloc_fixed(unsigned long offset, unsigned long size)
{
- unsigned long start;
+ s32 start;
unsigned long flags;
struct genpool_data_fixed muram_pool_data_fixed;
diff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h
index b3d1aff5e8ad5..deb6238416947 100644
--- a/include/soc/fsl/qe/qe.h
+++ b/include/soc/fsl/qe/qe.h
@@ -102,26 +102,26 @@ static inline void qe_reset(void) {}
int cpm_muram_init(void);
#if defined(CONFIG_CPM) || defined(CONFIG_QUICC_ENGINE)
-unsigned long cpm_muram_alloc(unsigned long size, unsigned long align);
-int cpm_muram_free(unsigned long offset);
-unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
+s32 cpm_muram_alloc(unsigned long size, unsigned long align);
+int cpm_muram_free(s32 offset);
+s32 cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
void __iomem *cpm_muram_addr(unsigned long offset);
unsigned long cpm_muram_offset(void __iomem *addr);
dma_addr_t cpm_muram_dma(void __iomem *addr);
#else
-static inline unsigned long cpm_muram_alloc(unsigned long size,
- unsigned long align)
+static inline s32 cpm_muram_alloc(unsigned long size,
+ unsigned long align)
{
return -ENOSYS;
}
-static inline int cpm_muram_free(unsigned long offset)
+static inline int cpm_muram_free(s32 offset)
{
return -ENOSYS;
}
-static inline unsigned long cpm_muram_alloc_fixed(unsigned long offset,
- unsigned long size)
+static inline s32 cpm_muram_alloc_fixed(unsigned long offset,
+ unsigned long size)
{
return -ENOSYS;
}
--
2.20.1
^ permalink raw reply related
* [PATCH 2/3] f2fs: add migration count iff migration happens
From: Jaegeuk Kim @ 2020-02-14 18:58 UTC (permalink / raw)
To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim
In-Reply-To: <20200214185855.217360-1-jaegeuk@kernel.org>
If first segment is empty and migration_granularity is 1, we can't move this
at all.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/gc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 65c0687ee2bb..bbf4db3f6bb4 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1233,12 +1233,12 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
segno, gc_type);
stat_inc_seg_count(sbi, type, gc_type);
+ migrated++;
freed:
if (gc_type == FG_GC &&
get_valid_blocks(sbi, segno, false) == 0)
seg_freed++;
- migrated++;
if (__is_large_section(sbi) && segno + 1 < end_segno)
sbi->next_victim_seg[gc_type] = segno + 1;
--
2.25.0.265.gbab2e86ba0-goog
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.