* Re: [PATCH] vhost: Coalesce vq_err formats, pr_fmt misuse, add missing newlines
From: Stefan Hajnoczi @ 2017-05-22 14:16 UTC (permalink / raw)
To: Joe Perches
Cc: Michael S. Tsirkin, Jason Wang, kvm, virtualization, netdev,
linux-kernel
In-Reply-To: <0e8f84aec009831d34ccb2b4ed27364e78b07e02.1495449147.git.joe@perches.com>
[-- Attachment #1: Type: text/plain, Size: 824 bytes --]
On Mon, May 22, 2017 at 03:33:43AM -0700, Joe Perches wrote:
> vhost logging uses of vq_err has a few defects and style inconsistencies.
>
> o pr_debug already uses pr_fmt so its use in vq_err is defective
> however no #defines of pr_fmt exist in this code so no actual
> defects exist
> o vq_err uses need terminating newlines so add the missing ones
> o Coalesce formats and realign arguments
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/vhost/net.c | 17 ++++++-------
> drivers/vhost/scsi.c | 17 ++++++-------
> drivers/vhost/test.c | 4 +--
> drivers/vhost/vhost.c | 70 +++++++++++++++++++++++----------------------------
> drivers/vhost/vhost.h | 11 ++++----
> 5 files changed, 54 insertions(+), 65 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply
* [PATCH 3/3] RDS: TCP: Delete an error message for a failed memory allocation in rds_tcp_init_net()
From: SF Markus Elfring @ 2017-05-22 14:13 UTC (permalink / raw)
To: linux-rdma, netdev, rds-devel, David S. Miller, Santosh Shilimkar,
Sowmini Varadhan
Cc: LKML, kernel-janitors
In-Reply-To: <44b46c51-3665-5f14-dd3b-6e6f230258a7@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 15:45:31 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/rds/tcp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/rds/tcp.c b/net/rds/tcp.c
index 431404dbdad1..b0348697dee5 100644
--- a/net/rds/tcp.c
+++ b/net/rds/tcp.c
@@ -431,10 +431,9 @@ static __net_init int rds_tcp_init_net(struct net *net)
} else {
tbl = kmemdup(rds_tcp_sysctl_table,
sizeof(rds_tcp_sysctl_table), GFP_KERNEL);
- if (!tbl) {
- pr_warn("could not set allocate syctl table\n");
+ if (!tbl)
return -ENOMEM;
- }
+
rtn->ctl_table = tbl;
}
tbl[RDS_TCP_SNDBUF].data = &rtn->sndbuf_size;
--
2.13.0
^ permalink raw reply related
* [PATCH 2/3] RDS: IB: Improve a size determination in rds_ib_add_one()
From: SF Markus Elfring @ 2017-05-22 14:12 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
rds-devel-N0ozoZBvEnrZJqsBc5GL+g, David S. Miller,
Santosh Shilimkar, Sowmini Varadhan
Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <44b46c51-3665-5f14-dd3b-6e6f230258a7-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Mon, 22 May 2017 15:40:21 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
net/rds/ib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/rds/ib.c b/net/rds/ib.c
index c5514d058171..ed37bf011704 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -131,7 +131,7 @@ static void rds_ib_add_one(struct ib_device *device)
if (device->node_type != RDMA_NODE_IB_CA)
return;
- rds_ibdev = kzalloc_node(sizeof(struct rds_ib_device), GFP_KERNEL,
+ rds_ibdev = kzalloc_node(sizeof(*rds_ibdev), GFP_KERNEL,
ibdev_to_node(device));
if (!rds_ibdev)
return;
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH 1/3] RDS: IB: Delete an error message for a failed memory allocation in rds_ib_add_one()
From: SF Markus Elfring @ 2017-05-22 14:11 UTC (permalink / raw)
To: linux-rdma, netdev, rds-devel, David S. Miller, Santosh Shilimkar,
Sowmini Varadhan
Cc: LKML, kernel-janitors
In-Reply-To: <44b46c51-3665-5f14-dd3b-6e6f230258a7@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 15:34:28 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/rds/ib.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 7a64c8db81ab..c5514d058171 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -166,8 +166,5 @@ static void rds_ib_add_one(struct ib_device *device)
- if (!rds_ibdev->vector_load) {
- pr_err("RDS/IB: %s failed to allocate vector memory\n",
- __func__);
+ if (!rds_ibdev->vector_load)
goto put_dev;
- }
rds_ibdev->dev = device;
rds_ibdev->pd = ib_alloc_pd(device, 0);
--
2.13.0
^ permalink raw reply related
* [PATCH 0/3] RDS: Adjustments for two function implementations
From: SF Markus Elfring @ 2017-05-22 14:10 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
rds-devel-N0ozoZBvEnrZJqsBc5GL+g, David S. Miller,
Santosh Shilimkar, Sowmini Varadhan
Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA
From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Mon, 22 May 2017 16:02:03 +0200
Three update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation in rds_ib_add_one()
Improve a size determination in rds_ib_add_one()
Delete an error message for a failed memory allocation in rds_tcp_init_net()
net/rds/ib.c | 7 ++-----
net/rds/tcp.c | 5 ++---
2 files changed, 4 insertions(+), 8 deletions(-)
--
2.13.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: vhost/scsi: Delete error messages for failed memory allocations in five functions
From: Stefan Hajnoczi @ 2017-05-22 14:09 UTC (permalink / raw)
To: SF Markus Elfring
Cc: kvm, netdev, virtualization, kernel-janitors, Jason Wang,
Michael S. Tsirkin, LKML, Wolfram Sang
In-Reply-To: <e6658e56-a2b0-4ecc-0a95-0ba193ff2c97@users.sourceforge.net>
[-- Attachment #1: Type: text/plain, Size: 861 bytes --]
On Mon, May 22, 2017 at 01:34:34PM +0200, SF Markus Elfring wrote:
> >> Do you find information from a Linux allocation failure report sufficient
> >> for any function implementations here?
> >
> > If kmalloc() and friends guarantee to print a warning and backtrace on
> > every allocation failure, then there's no need for error messages in
> > callers.
> >
> > That seems like good justification that can go in the commit
> > description, but I'm not sure if kmalloc() and friends guarantee to show
> > a message (not just the first time, but for every failed allocation)?
>
> I am also looking for a more complete and easier accessible documentation
> for this aspect of the desired exception handling.
> How would we like to resolve any remaining open issues there?
No objection from me but please make sure to keep vq_err().
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply
* Re: [PATCH 2/2] vhost/scsi: Delete error messages for failed memory allocations in five functions
From: Stefan Hajnoczi @ 2017-05-22 14:08 UTC (permalink / raw)
To: Dan Carpenter
Cc: kvm, Michael S. Tsirkin, netdev, Wolfram Sang, kernel-janitors,
LKML, virtualization, SF Markus Elfring
In-Reply-To: <20170522123833.asx2biaw4xaz4qpv@mwanda>
[-- Attachment #1.1: Type: text/plain, Size: 433 bytes --]
On Mon, May 22, 2017 at 03:38:33PM +0300, Dan Carpenter wrote:
> On Mon, May 22, 2017 at 12:23:20PM +0100, Stefan Hajnoczi wrote:
> > I'm not sure if kmalloc() and friends guarantee to show
> > a message (not just the first time, but for every failed allocation)?
> >
>
> It prints multiple times, but it's ratelimited. It can also be disabled
> using a config option.
>
> See slab_out_of_memory().
Thanks!
Stefan
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply
* [PATCH] kernel: bpf: remove dead code
From: Gustavo A. R. Silva @ 2017-05-22 14:07 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann
Cc: netdev, linux-kernel, Gustavo A. R. Silva
Execution cannot reach NET_IP_ALIGN inside the following statement:
ip_align = strict ? 2 : NET_IP_ALIGN
Addresses-Coverity-ID: 1409762
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
NOTE: variable ip_align could also be removed and use value 2 directly.
kernel/bpf/verifier.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 1eddb71..94f6e46 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -812,7 +812,7 @@ static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg,
* we force this to 2 which is universally what architectures use
* when they don't set CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.
*/
- ip_align = strict ? 2 : NET_IP_ALIGN;
+ ip_align = 2;
if ((ip_align + reg_off + off) % size != 0) {
verbose("misaligned packet access off %d+%d+%d size %d\n",
ip_align, reg_off, off, size);
--
2.5.0
^ permalink raw reply related
* Re: [PATCH] net: fec: add post PHY reset delay DT property
From: Quentin Schulz @ 2017-05-22 14:00 UTC (permalink / raw)
To: Andrew Lunn
Cc: fugang.duan-3arQi8VN3Tc, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
mark.rutland-5wv7dgnIgG8, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
In-Reply-To: <20170522135705.GB29447-g2DYL2Zd6BY@public.gmane.org>
Hi Andrew
On 22/05/2017 15:57, Andrew Lunn wrote:
> On Mon, May 22, 2017 at 11:15:17AM +0200, Quentin Schulz wrote:
>> Some PHY require to wait for a bit after the reset GPIO has been
>> toggled. This adds support for the DT property `phy-reset-post-delay`
>> which gives the delay in milliseconds to wait after reset.
>>
>> If the DT property is not given, no delay is observed. Post reset delay
>> greater than 1000ms are invalid and are default to 1ms.
>
> Hi Quentin
>
> If it is invalid, please return -EINVAL.
>
Just copying the wording and behavior of phy-reset-duration. Should we
then change the behavior of phy-reset-duration as well to return -EINVAL
in that case or I just leave both as is?
Quentin
>> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
>> ---
>> Documentation/devicetree/bindings/net/fsl-fec.txt | 5 +++++
>> drivers/net/ethernet/freescale/fec_main.c | 17 +++++++++++++++--
>> 2 files changed, 20 insertions(+), 2 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
>> index a1e3693cca16..8795e8ca5793 100644
>> --- a/Documentation/devicetree/bindings/net/fsl-fec.txt
>> +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
>> @@ -15,6 +15,11 @@ Optional properties:
>> - phy-reset-active-high : If present then the reset sequence using the GPIO
>> specified in the "phy-reset-gpios" property is reversed (H=reset state,
>> L=operation state).
>> +- phy-reset-post-delay : Post reset delay in milliseconds. If present then
>> + a delay of phy-reset-post-delay milliseconds will be observed after the
>> + phy-reset-gpios has been toggled. Can be omitted thus no delay is
>> + observed. Delay is in range of 1ms to 1000ms. If given delay is higher
>> + than 1000ms, 1ms delay is done instead.
>> - phy-supply : regulator that powers the Ethernet PHY.
>> - phy-handle : phandle to the PHY device connected to this device.
>> - fixed-link : Assume a fixed link. See fixed-link.txt in the same directory.
>> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
>> index 56a563f90b0b..00a7fd0bcd59 100644
>> --- a/drivers/net/ethernet/freescale/fec_main.c
>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>> @@ -3192,7 +3192,7 @@ static int fec_reset_phy(struct platform_device *pdev)
>> {
>> int err, phy_reset;
>> bool active_high = false;
>> - int msec = 1;
>> + int msec = 1, phy_post_delay = 0;
>> struct device_node *np = pdev->dev.of_node;
>>
>> if (!np)
>> @@ -3210,7 +3210,6 @@ static int fec_reset_phy(struct platform_device *pdev)
>> return 0;
>>
>> active_high = of_property_read_bool(np, "phy-reset-active-high");
>> -
>> err = devm_gpio_request_one(&pdev->dev, phy_reset,
>> active_high ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
>> "phy-reset");
>
> No white space changes please.
>
> Andrew
>
--
Quentin Schulz, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] net: fec: add post PHY reset delay DT property
From: Andrew Lunn @ 2017-05-22 13:57 UTC (permalink / raw)
To: Quentin Schulz
Cc: fugang.duan-3arQi8VN3Tc, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
mark.rutland-5wv7dgnIgG8, netdev-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
In-Reply-To: <20170522091517.6857-1-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
On Mon, May 22, 2017 at 11:15:17AM +0200, Quentin Schulz wrote:
> Some PHY require to wait for a bit after the reset GPIO has been
> toggled. This adds support for the DT property `phy-reset-post-delay`
> which gives the delay in milliseconds to wait after reset.
>
> If the DT property is not given, no delay is observed. Post reset delay
> greater than 1000ms are invalid and are default to 1ms.
Hi Quentin
If it is invalid, please return -EINVAL.
> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
> Documentation/devicetree/bindings/net/fsl-fec.txt | 5 +++++
> drivers/net/ethernet/freescale/fec_main.c | 17 +++++++++++++++--
> 2 files changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
> index a1e3693cca16..8795e8ca5793 100644
> --- a/Documentation/devicetree/bindings/net/fsl-fec.txt
> +++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
> @@ -15,6 +15,11 @@ Optional properties:
> - phy-reset-active-high : If present then the reset sequence using the GPIO
> specified in the "phy-reset-gpios" property is reversed (H=reset state,
> L=operation state).
> +- phy-reset-post-delay : Post reset delay in milliseconds. If present then
> + a delay of phy-reset-post-delay milliseconds will be observed after the
> + phy-reset-gpios has been toggled. Can be omitted thus no delay is
> + observed. Delay is in range of 1ms to 1000ms. If given delay is higher
> + than 1000ms, 1ms delay is done instead.
> - phy-supply : regulator that powers the Ethernet PHY.
> - phy-handle : phandle to the PHY device connected to this device.
> - fixed-link : Assume a fixed link. See fixed-link.txt in the same directory.
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index 56a563f90b0b..00a7fd0bcd59 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -3192,7 +3192,7 @@ static int fec_reset_phy(struct platform_device *pdev)
> {
> int err, phy_reset;
> bool active_high = false;
> - int msec = 1;
> + int msec = 1, phy_post_delay = 0;
> struct device_node *np = pdev->dev.of_node;
>
> if (!np)
> @@ -3210,7 +3210,6 @@ static int fec_reset_phy(struct platform_device *pdev)
> return 0;
>
> active_high = of_property_read_bool(np, "phy-reset-active-high");
> -
> err = devm_gpio_request_one(&pdev->dev, phy_reset,
> active_high ? GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
> "phy-reset");
No white space changes please.
Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [Patch net] vsock: use new wait API for vsock_stream_sendmsg()
From: Stefan Hajnoczi @ 2017-05-22 13:56 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, Jorgen Hansen, Michael S. Tsirkin, Claudio Imbrenda
In-Reply-To: <1495218119-12358-1-git-send-email-xiyou.wangcong@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 960 bytes --]
On Fri, May 19, 2017 at 11:21:59AM -0700, Cong Wang wrote:
> As reported by Michal, vsock_stream_sendmsg() could still
> sleep at vsock_stream_has_space() after prepare_to_wait():
>
> vsock_stream_has_space
> vmci_transport_stream_has_space
> vmci_qpair_produce_free_space
> qp_lock
> qp_acquire_queue_mutex
> mutex_lock
>
> Just switch to the new wait API like we did for commit
> d9dc8b0f8b4e ("net: fix sleeping for sk_wait_event()").
>
> Reported-by: Michal Kubecek <mkubecek@suse.cz>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> Cc: Jorgen Hansen <jhansen@vmware.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
> net/vmw_vsock/af_vsock.c | 21 ++++++++-------------
> 1 file changed, 8 insertions(+), 13 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply
* Re: [kernel-hardening] [PATCH v4 next 0/3] modules: automatic module loading restrictions
From: Djalal Harouni @ 2017-05-22 13:49 UTC (permalink / raw)
To: Solar Designer
Cc: linux-kernel, netdev-u79uwXL29TY76Z2rM5mHXA, LSM List,
kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8,
Andy Lutomirski, Kees Cook, Andrew Morton, Rusty Russell,
Serge E. Hallyn, Jessica Yu, David S. Miller, James Morris,
Paul Moore, Stephen Smalley, Greg Kroah-Hartman, Tetsuo Handa,
Ingo Molnar, Linux API, Dongsu Park, Casey Schaufler <ca
In-Reply-To: <20170522120848.GA3003-cxoSlKxDwOJWk0Htik3J/w@public.gmane.org>
Hi Alexander,
On Mon, May 22, 2017 at 2:08 PM, Solar Designer <solar-cxoSlKxDwOJWk0Htik3J/w@public.gmane.org> wrote:
> Hi Djalal,
>
> Thank you for your work on this!
>
> On Mon, May 22, 2017 at 01:57:03PM +0200, Djalal Harouni wrote:
>> *) When modules_autoload_mode is set to (2), automatic module loading is
>> disabled for all. Once set, this value can not be changed.
>
> What purpose does this securelevel-like property ("Once set, this value
> can not be changed.") serve here? I think this mode 2 is needed, but
> without this extra property, which is bypassable by e.g. explicitly
> loaded kernel modules anyway (and that's OK).
My reasoning about "Once set, this value can not be changed" is mainly for:
If you have some systems where modules are not updated for any given
reason, then the only one who will be able to load a module is an
administrator, basically this is a shortcut for:
* Apps/services can run with CAP_NET_ADMIN but they are not allowed to
auto-load 'netdev' modules.
* Explicitly loading modules can be guarded by seccomp filters *per*
app, so even if these apps have
CAP_SYS_MODULE they won't be able to explicitly load modules, one
has to remount some sysctl /proc/ entries read-only here and remove
CAP_SYS_ADMIN for all apps anyway.
This mainly serves the purpose of these systems that do not receive
updates, if I don't want to expose those kernel interfaces what should
I do ? then if I want to unload old versions and replace them with new
ones what operation should be allowed ? and only real root of the
system can do it. Hence, the "Once set, this value can not be changed"
is more of a shortcut, also the idea was put in my mind based on how
"modules_disabled" is disabled forever, and some other interfaces. I
would say: it is easy to handle a transition from 1) "hey this system
is still up to date, some features should be exposed" to 2) "this
system is not up to date anymore, only root should expose some
features..."
Hmm, I am not sure if this answers your question ? :-)
I definitively don't want to fall into "modules_disabled" trap where
is it too strict! "Once set, this value can not be changed" means for
some users do not set it otherwise the system is unusable...
Maybe an extra "4" mode for that ? better get it right.
Thanks!
--
tixxdz
^ permalink raw reply
* [PATCH 2/2] Add missing <sys/types.h> include
From: Baruch Siach @ 2017-05-22 13:27 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Thomas Petazzoni, Baruch Siach
In-Reply-To: <8afdd8babb9e82bcfde78e851b24b698436a6f9f.1495459674.git.baruch@tkos.co.il>
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
The u_intXX_t types are defined in <sys/types.h>, so it should be
included before using those types. Otherwise, with certain C
libraries, the build fails with:
In file included from ../include/iptables.h:4:0,
from m_ipt.c:18:
../include/iptables_common.h:47:16: error: unknown type name ‘u_int32_t’
#define __le32 u_int32_t
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
include/iptables_common.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/iptables_common.h b/include/iptables_common.h
index 9099667ffa6d..2c27a4b61fcd 100644
--- a/include/iptables_common.h
+++ b/include/iptables_common.h
@@ -43,6 +43,8 @@ extern char *lib_dir;
extern void init_extensions(void);
#endif
+#include <sys/types.h>
+
#define __be32 u_int32_t
#define __le32 u_int32_t
#define __be16 u_int16_t
--
2.11.0
^ permalink raw reply related
* [PATCH 1/2] ip: include libc headers first
From: Baruch Siach @ 2017-05-22 13:27 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Baruch Siach
Including libc headers first helps as a workaround to redefinition of struct
ethhdr with a suitably patched musl libc that suppresses the kernel
if_ether.h.
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
ip/iplink_bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
index 818b43c89b5b..cccdec1c203a 100644
--- a/ip/iplink_bridge.c
+++ b/ip/iplink_bridge.c
@@ -13,9 +13,9 @@
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
+#include <netinet/ether.h>
#include <linux/if_link.h>
#include <linux/if_bridge.h>
-#include <netinet/ether.h>
#include <net/if.h>
#include "rt_names.h"
--
2.11.0
^ permalink raw reply related
* Re: [RFC V1 1/1] net: cdc_ncm: Reduce memory use when kernel memory low
From: Oliver Neukum @ 2017-05-22 13:27 UTC (permalink / raw)
To: David Laight, 'Bjørn Mork'
Cc: 'Jim Baxter',
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DCFFFAC2B-VkEWCZq2GCInGFn1LkZF6NBPR1lH4CV8@public.gmane.org>
Am Freitag, den 19.05.2017, 14:46 +0000 schrieb David Laight:
> For XHCI it isn't too bad because it will do arbitrary scatter-gather
> (apart from the ring end).
> But I believe the earlier controllers only support fragments that
> end on usb packet boundaries.
>
> I looked at the usbnet code a few years ago, I'm sure it ought to
> be possible to shortcut most of the code that uses URB and directly
> write to the xhci (in particular) ring descriptors.
Hi,
we cannot break the layering. URBs can support scatter/gather and
that infrastructure must be used. And usbnet will work with sg used
in skbs. What you should honor in general is not splitting packets.
So 512 byte chunks.
Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses
From: Joe Perches @ 2017-05-22 13:13 UTC (permalink / raw)
To: Jan Kiszka, Giuseppe Cavallaro, Alexandre Torgue, David Miller
Cc: netdev, linux-kernel, Andy Shevchenko
In-Reply-To: <72ff21ba-f774-b3d5-23b4-e70095cedbef@siemens.com>
On Mon, 2017-05-22 at 14:49 +0200, Jan Kiszka wrote:
> On 2017-05-22 13:33, Joe Perches wrote:
> > On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
> > > Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
> >
> > []
> > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> >
> > []
> > > @@ -31,65 +31,78 @@
> >
> > []
> > > +static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
> > > {
> > > - .name = "GalileoGen2",
> > > .func = 6,
> > > .phy_addr = 1,
> > > },
> > > {
> > > - .name = "SIMATIC IOT2000",
> > > - .asset_tag = "6ES7647-0AA00-0YA2",
> > > - .func = 6,
> > > + .func = 7,
> >
> > Why change this from 6 to 7?
> >
>
> The diff is confusing here: If you look at the outcome, we now have
> galileo_stmmac_dmi_data with function 6 only (also used for the
> IOT2020), and iot2040_stmmac_dmi_data with both function 6 and 7 (both
> MACs are wired up).
Right. Apologies for noise.
^ permalink raw reply
* Re: [PATCH v2 1/4] net-next: stmmac: Convert new_state to bool
From: Joe Perches @ 2017-05-22 13:07 UTC (permalink / raw)
To: Corentin Labbe, peppe.cavallaro, alexandre.torgue; +Cc: netdev, linux-kernel
In-Reply-To: <20170522123347.5295-2-clabbe.montjoie@gmail.com>
On Mon, 2017-05-22 at 14:33 +0200, Corentin Labbe wrote:
> This patch convert new_state from int to bool since it store only 1 or 0
[]
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
[]
> @@ -849,11 +849,11 @@ static void stmmac_adjust_link(struct net_device *dev)
> writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
>
> if (!priv->oldlink) {
> - new_state = 1;
> + new_state = true;
> priv->oldlink = 1;
> }
> } else if (priv->oldlink) {
> - new_state = 1;
> + new_state = true;
> priv->oldlink = 0;
> priv->speed = SPEED_UNKNOWN;
> priv->oldduplex = DUPLEX_UNKNOWN;
It seems oldlink could be bool as well.
drivers/net/ethernet/stmicro/stmmac/stmmac.h: int oldlink;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: if (!priv->oldlink) {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: priv->oldlink = 1;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: } else if (priv->oldlink) {
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: priv->oldlink = 0;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: priv->oldlink = 0;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: priv->oldlink = 0;
^ permalink raw reply
* Re: arch: arm: bpf: Converting cBPF to eBPF for arm 32 bit
From: Daniel Borkmann @ 2017-05-22 13:01 UTC (permalink / raw)
To: Shubham Bansal
Cc: Kees Cook, David Miller, Mircea Gherzan, Network Development,
kernel-hardening@lists.openwall.com,
linux-arm-kernel@lists.infradead.org, ast
In-Reply-To: <CAHgaXdKKbRVSpX-036TXpV5z=1=QCnPoku0+CeHxHco8-aasPQ@mail.gmail.com>
On 05/20/2017 10:01 PM, Shubham Bansal wrote:
[...]
> Before I send the patch, I have tested the JIT compiler on ARMv7 but
> not on ARMv5 or ARMv6. So can you tell me which arch versions I should
> test it for?
> Also for my testing, CONFIG_FRAME_POINTER and CONFIG_CPU_BIG_ENDIAN
> are both disabled. But I need to test JIT with these flags as well.
> Whenever I put these flags in .config file, the arm kernel is not
> getting compiler with these flags. Can you tell me why? If you need
> more information regarding this, please let me know.
Maybe Mircea, Kees or someone from linux-arm-kernel can help you out
on that.
With regards to the below benchmark, I was mentioning how it compares
to the interpreter. With only the numbers for jit it's hard to compare.
So would be great to see the output for the following three cases:
1) Interpreter:
echo 0 > /proc/sys/net/core/bpf_jit_enable
2) JIT enabled:
echo 1 > /proc/sys/net/core/bpf_jit_enable
3) JIT + blinding enabled:
echo 1 > /proc/sys/net/core/bpf_jit_enable
echo 2 > /proc/sys/net/core/bpf_jit_harden
> With current config for ARMv7, benchmarks are :
>
> [root@vexpress modules]# insmod test_bpf.ko
> [ 25.797766] test_bpf: #0 TAX jited:1 180 170 169 PASS
> [ 25.811395] test_bpf: #1 TXA jited:1 93 89 111 PASS
> [ 25.815073] test_bpf: #2 ADD_SUB_MUL_K jited:1 94 PASS
> [ 25.816779] test_bpf: #3 DIV_MOD_KX jited:1 983 PASS
> [ 25.827310] test_bpf: #4 AND_OR_LSH_K jited:1 94 93 PASS
> [ 25.829843] test_bpf: #5 LD_IMM_0 jited:1 83 PASS
> [ 25.831260] test_bpf: #6 LD_IND jited:1 338 266 305 PASS
[...]
Thanks,
Daniel
^ permalink raw reply
* [PATCH 2/2] NFC: digital: Delete an error message for a failed memory allocation in digital_in_send()
From: SF Markus Elfring @ 2017-05-22 13:00 UTC (permalink / raw)
To: linux-wireless, netdev, David S. Miller, Samuel Ortiz,
Thierry Escande
Cc: LKML, kernel-janitors
In-Reply-To: <7e27a76c-de7a-22ec-cf8a-31aee2000e29@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 14:24:24 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/nfc/digital_core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index 3baf91f3ef80..8e02a3e1b319 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -710,7 +710,5 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
- if (!data_exch) {
- pr_err("Failed to allocate data_exch struct\n");
+ if (!data_exch)
return -ENOMEM;
- }
data_exch->cb = cb;
data_exch->cb_context = cb_context;
--
2.13.0
^ permalink raw reply related
* [PATCH 1/2] NFC: digital: Improve a size determination in four functions
From: SF Markus Elfring @ 2017-05-22 12:58 UTC (permalink / raw)
To: linux-wireless, netdev, David S. Miller, Samuel Ortiz,
Thierry Escande
Cc: LKML, kernel-janitors
In-Reply-To: <7e27a76c-de7a-22ec-cf8a-31aee2000e29@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 14:11:01 +0200
Replace the specification of four data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/nfc/digital_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c
index 0fd5518bf252..3baf91f3ef80 100644
--- a/net/nfc/digital_core.c
+++ b/net/nfc/digital_core.c
@@ -240,5 +240,5 @@ int digital_send_cmd(struct nfc_digital_dev *ddev, u8 cmd_type,
{
struct digital_cmd *cmd;
- cmd = kzalloc(sizeof(struct digital_cmd), GFP_KERNEL);
+ cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
if (!cmd)
@@ -287,5 +287,5 @@ static int digital_tg_listen_mdaa(struct nfc_digital_dev *ddev, u8 rf_tech)
{
struct digital_tg_mdaa_params *params;
- params = kzalloc(sizeof(struct digital_tg_mdaa_params), GFP_KERNEL);
+ params = kzalloc(sizeof(*params), GFP_KERNEL);
if (!params)
@@ -706,5 +706,5 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target,
struct digital_data_exch *data_exch;
int rc;
- data_exch = kzalloc(sizeof(struct digital_data_exch), GFP_KERNEL);
+ data_exch = kzalloc(sizeof(*data_exch), GFP_KERNEL);
if (!data_exch) {
@@ -764,5 +764,5 @@ struct nfc_digital_dev *nfc_digital_allocate_device(struct nfc_digital_ops *ops,
!ops->switch_rf || (ops->tg_listen_md && !ops->tg_get_rf_tech))
return NULL;
- ddev = kzalloc(sizeof(struct nfc_digital_dev), GFP_KERNEL);
+ ddev = kzalloc(sizeof(*ddev), GFP_KERNEL);
if (!ddev)
--
2.13.0
^ permalink raw reply related
* [PATCH 0/2] NFC-digital: Adjustments for four function implementations
From: SF Markus Elfring @ 2017-05-22 12:57 UTC (permalink / raw)
To: linux-wireless, netdev, David S. Miller, Samuel Ortiz,
Thierry Escande
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 May 2017 14:50:05 +0200
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Improve a size determination in four functions
Delete an error message for a failed memory allocation in digital_in_send()
net/nfc/digital_core.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
--
2.13.0
^ permalink raw reply
* [PATCH v2] cdc-ether: divorce initialisation with a filter reset and a generic method
From: Oliver Neukum @ 2017-05-22 12:50 UTC (permalink / raw)
To: davem, netdev, bjorn; +Cc: Oliver Neukum
Some devices need their multicast filter reset but others are crashed by that.
So the methods need to be separated.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reported-by: "Ridgway, Keith" <kridgway@harris.com>
---
drivers/net/usb/cdc_ether.c | 31 ++++++++++++++++++++++++-------
include/linux/usb/usbnet.h | 1 +
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index f3ae88fdf332..8ab281b478f2 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -310,6 +310,26 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
return -ENODEV;
}
+ return 0;
+
+bad_desc:
+ dev_info(&dev->udev->dev, "bad CDC descriptors\n");
+ return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind);
+
+
+/* like usbnet_generic_cdc_bind() but handles filter initialization
+ * correctly
+ */
+int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
+{
+ int rv;
+
+ rv = usbnet_generic_cdc_bind(dev, intf);
+ if (rv < 0)
+ goto bail_out;
+
/* Some devices don't initialise properly. In particular
* the packet filter is not reset. There are devices that
* don't do reset all the way. So the packet filter should
@@ -317,13 +337,10 @@ int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
*/
usbnet_cdc_update_filter(dev);
- return 0;
-
-bad_desc:
- dev_info(&dev->udev->dev, "bad CDC descriptors\n");
- return -ENODEV;
+bail_out:
+ return rv;
}
-EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind);
+EXPORT_SYMBOL_GPL(usbnet_ether_cdc_bind);
void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
{
@@ -417,7 +434,7 @@ int usbnet_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
< sizeof(struct cdc_state)));
- status = usbnet_generic_cdc_bind(dev, intf);
+ status = usbnet_ether_cdc_bind(dev, intf);
if (status < 0)
return status;
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
index 7dffa5624ea6..97116379db5f 100644
--- a/include/linux/usb/usbnet.h
+++ b/include/linux/usb/usbnet.h
@@ -206,6 +206,7 @@ struct cdc_state {
};
extern int usbnet_generic_cdc_bind(struct usbnet *, struct usb_interface *);
+extern int usbnet_ether_cdc_bind(struct usbnet *dev, struct usb_interface *intf);
extern int usbnet_cdc_bind(struct usbnet *, struct usb_interface *);
extern void usbnet_cdc_unbind(struct usbnet *, struct usb_interface *);
extern void usbnet_cdc_status(struct usbnet *, struct urb *);
--
2.12.0
^ permalink raw reply related
* Re: [PATCH 3/3] stmmac: pci: Use dmi_system_id table for retrieving PHY addresses
From: Jan Kiszka @ 2017-05-22 12:49 UTC (permalink / raw)
To: Joe Perches, Giuseppe Cavallaro, Alexandre Torgue, David Miller
Cc: netdev, linux-kernel, Andy Shevchenko
In-Reply-To: <1495452830.2093.14.camel@perches.com>
On 2017-05-22 13:33, Joe Perches wrote:
> On Mon, 2017-05-22 at 13:12 +0200, Jan Kiszka wrote:
>> Avoids reimplementation of DMI matching in stmmac_pci_find_phy_addr.
> []
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> []
>> @@ -31,65 +31,78 @@
> []
>> +static const struct stmmac_pci_dmi_data iot2040_stmmac_dmi_data[] = {
>> {
>> - .name = "GalileoGen2",
>> .func = 6,
>> .phy_addr = 1,
>> },
>> {
>> - .name = "SIMATIC IOT2000",
>> - .asset_tag = "6ES7647-0AA00-0YA2",
>> - .func = 6,
>> + .func = 7,
>
> Why change this from 6 to 7?
>
The diff is confusing here: If you look at the outcome, we now have
galileo_stmmac_dmi_data with function 6 only (also used for the
IOT2020), and iot2040_stmmac_dmi_data with both function 6 and 7 (both
MACs are wired up).
Jan
--
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply
* Re: [PATCH 2/2] vhost/scsi: Delete error messages for failed memory allocations in five functions
From: Dan Carpenter @ 2017-05-22 12:38 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: kvm, Michael S. Tsirkin, netdev, Wolfram Sang, kernel-janitors,
LKML, virtualization, SF Markus Elfring
In-Reply-To: <20170522112320.GA22806@stefanha-x1.localdomain>
On Mon, May 22, 2017 at 12:23:20PM +0100, Stefan Hajnoczi wrote:
> I'm not sure if kmalloc() and friends guarantee to show
> a message (not just the first time, but for every failed allocation)?
>
It prints multiple times, but it's ratelimited. It can also be disabled
using a config option.
See slab_out_of_memory().
regards,
dan carpenter
^ permalink raw reply
* [PATCH v2 4/4] net-next: stmmac: rework the speed selection
From: Corentin Labbe @ 2017-05-22 12:33 UTC (permalink / raw)
To: peppe.cavallaro, alexandre.torgue; +Cc: netdev, linux-kernel, Corentin Labbe
In-Reply-To: <20170522123347.5295-1-clabbe.montjoie@gmail.com>
The current stmmac_adjust_link() part which handle speed have
some if (has_platform) code and my dwmac-sun8i will add more of them.
So we need to handle better speed selection.
Moreover the struct link member speed and port are hard to guess their
purpose. And their unique usage are to be combined for writing speed.
So this patch replace speed/port by simpler
speed10/speed100/speed1000/speed_mask variables.
In dwmac4_core_init and dwmac1000_core_init, port/speed value was used
directly without using the struct link. This patch convert also their
usage to speedxxx.
Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
drivers/net/ethernet/stmicro/stmmac/common.h | 8 ++++---
.../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 26 +++++++++++++---------
.../net/ethernet/stmicro/stmmac/dwmac100_core.c | 6 +++--
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 26 +++++++++++++---------
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 21 ++++-------------
5 files changed, 43 insertions(+), 44 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index b7ce3fbb5375..e82b4b70b7be 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -549,9 +549,11 @@ extern const struct stmmac_hwtimestamp stmmac_ptp;
extern const struct stmmac_mode_ops dwmac4_ring_mode_ops;
struct mac_link {
- int port;
- int duplex;
- int speed;
+ u32 speed_mask;
+ u32 speed10;
+ u32 speed100;
+ u32 speed1000;
+ u32 duplex;
};
struct mii_regs {
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
index f3d9305e5f70..b8848a9d70c5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
@@ -45,15 +45,17 @@ static void dwmac1000_core_init(struct mac_device_info *hw, int mtu)
if (hw->ps) {
value |= GMAC_CONTROL_TE;
- if (hw->ps == SPEED_1000) {
- value &= ~GMAC_CONTROL_PS;
- } else {
- value |= GMAC_CONTROL_PS;
-
- if (hw->ps == SPEED_10)
- value &= ~GMAC_CONTROL_FES;
- else
- value |= GMAC_CONTROL_FES;
+ value &= ~hw->link.speed_mask;
+ switch (hw->ps) {
+ case SPEED_1000:
+ value |= hw->link.speed1000;
+ break;
+ case SPEED_100:
+ value |= hw->link.speed100;
+ break;
+ case SPEED_10:
+ value |= hw->link.speed10;
+ break;
}
}
@@ -531,9 +533,11 @@ struct mac_device_info *dwmac1000_setup(void __iomem *ioaddr, int mcbins,
mac->mac = &dwmac1000_ops;
mac->dma = &dwmac1000_dma_ops;
- mac->link.port = GMAC_CONTROL_PS;
mac->link.duplex = GMAC_CONTROL_DM;
- mac->link.speed = GMAC_CONTROL_FES;
+ mac->link.speed10 = GMAC_CONTROL_PS;
+ mac->link.speed100 = GMAC_CONTROL_PS | GMAC_CONTROL_FES;
+ mac->link.speed1000 = 0;
+ mac->link.speed_mask = GENMASK(15, 14);
mac->mii.addr = GMAC_MII_ADDR;
mac->mii.data = GMAC_MII_DATA;
mac->mii.addr_shift = 11;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c
index 1b3609105484..8ef517356313 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c
@@ -175,9 +175,11 @@ struct mac_device_info *dwmac100_setup(void __iomem *ioaddr, int *synopsys_id)
mac->mac = &dwmac100_ops;
mac->dma = &dwmac100_dma_ops;
- mac->link.port = MAC_CONTROL_PS;
mac->link.duplex = MAC_CONTROL_F;
- mac->link.speed = 0;
+ mac->link.speed10 = 0;
+ mac->link.speed100 = 0;
+ mac->link.speed1000 = 0;
+ mac->link.speed_mask = MAC_CONTROL_PS;
mac->mii.addr = MAC_MII_ADDR;
mac->mii.data = MAC_MII_DATA;
mac->mii.addr_shift = 11;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 48793f2e9307..d371e18b122c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -35,15 +35,17 @@ static void dwmac4_core_init(struct mac_device_info *hw, int mtu)
if (hw->ps) {
value |= GMAC_CONFIG_TE;
- if (hw->ps == SPEED_1000) {
- value &= ~GMAC_CONFIG_PS;
- } else {
- value |= GMAC_CONFIG_PS;
-
- if (hw->ps == SPEED_10)
- value &= ~GMAC_CONFIG_FES;
- else
- value |= GMAC_CONFIG_FES;
+ value &= hw->link.speed_mask;
+ switch (hw->ps) {
+ case SPEED_1000:
+ value |= hw->link.speed1000;
+ break;
+ case SPEED_100:
+ value |= hw->link.speed100;
+ break;
+ case SPEED_10:
+ value |= hw->link.speed10;
+ break;
}
}
@@ -747,9 +749,11 @@ struct mac_device_info *dwmac4_setup(void __iomem *ioaddr, int mcbins,
if (mac->multicast_filter_bins)
mac->mcast_bits_log2 = ilog2(mac->multicast_filter_bins);
- mac->link.port = GMAC_CONFIG_PS;
mac->link.duplex = GMAC_CONFIG_DM;
- mac->link.speed = GMAC_CONFIG_FES;
+ mac->link.speed10 = GMAC_CONFIG_PS;
+ mac->link.speed100 = GMAC_CONFIG_FES | GMAC_CONFIG_PS;
+ mac->link.speed1000 = 0;
+ mac->link.speed_mask = GENMASK(15, 14);
mac->mii.addr = GMAC_MDIO_ADDR;
mac->mii.data = GMAC_MDIO_DATA;
mac->mii.addr_shift = 21;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 9bf09100c199..ce99b8aa6172 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -811,29 +811,16 @@ static void stmmac_adjust_link(struct net_device *dev)
if (phydev->speed != priv->speed) {
new_state = true;
+ ctrl &= ~priv->hw->link.speed_mask;
switch (phydev->speed) {
case SPEED_1000:
- if (priv->plat->has_gmac ||
- priv->plat->has_gmac4)
- ctrl &= ~priv->hw->link.port;
+ ctrl |= priv->hw->link.speed1000;
break;
case SPEED_100:
- if (priv->plat->has_gmac ||
- priv->plat->has_gmac4) {
- ctrl |= priv->hw->link.port;
- ctrl |= priv->hw->link.speed;
- } else {
- ctrl &= ~priv->hw->link.port;
- }
+ ctrl |= priv->hw->link.speed100;
break;
case SPEED_10:
- if (priv->plat->has_gmac ||
- priv->plat->has_gmac4) {
- ctrl |= priv->hw->link.port;
- ctrl &= ~(priv->hw->link.speed);
- } else {
- ctrl &= ~priv->hw->link.port;
- }
+ ctrl |= priv->hw->link.speed10;
break;
default:
netif_warn(priv, link, priv->dev,
--
2.13.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox