ntb_netdev: set the net_device's parent
Subsystems (2)
PATCH 1/1 ntb_netdev: set the net_device's parent
At present, ntb_netdev devices end up under /sys/devices/virtual/net completely unconnected to the ntb trees below them. This patch sets the parent of the net_device (using SET_NETDEV_DEV) to the client_dev device. This results in a better connected sysfs path for the network device:
/sys/devices/pci0000:00/0000:00:03.0/0000:03:00.1/0000:03:00.1/ntb_netdev0/net/eth2
--- drivers/net/ntb_netdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ntb_netdev.c +2 -0
@@ -418,6 +418,8 @@ static int ntb_netdev_probe(struct device *client_dev)if (!ndev)return -ENOMEM ; +SET_NETDEV_DEV (ndev, client_dev); + dev =netdev_priv (ndev); dev->ndev = ndev; dev->pdev = pdev;
Signature · 1 line
2.11.0
PATCH 1/1 ntb_transport: fix bug calculating num_qps_mw
A divide by zero error occurs if qp_count is less than mw_count because num_qps_mw is calculated to be zero. The calculation appears to be incorrect.
The requirement is for num_qps_mw to be set to qp_count / mw_count with any remainder divided among the earlier mws.
For example, if mw_count is 5 and qp_count is 12 then mws 0 and 1 will have 3 qps per window and mws 2 through 4 will have 2 qps per window. Thus, when mw_num < qp_count % mw_count, num_qps_mw is 1 higher than when mw_num >= qp_count.
--- drivers/ntb/ntb_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ntb/ntb_transport.c +2 -2
@@ -623,7 +623,7 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,if (!mw->virt_addr)return -ENOMEM ; -if (qp_count % mw_count && mw_num +1 < qp_count / mw_count) +if (mw_num < qp_count % mw_count) num_qps_mw = qp_count / mw_count +1 ;else num_qps_mw = qp_count / mw_count;
@@ -1000,7 +1000,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, qp->event_handler =NULL ;ntb_qp_link_down_reset (qp); -if (qp_count % mw_count && mw_num +1 < qp_count / mw_count) +if (mw_num < qp_count % mw_count) num_qps_mw = qp_count / mw_count +1 ;else num_qps_mw = qp_count / mw_count;
Signature · 1 line
2.11.0
RE: [PATCH] ntb_transport: fix bug calculating num_qps_mw
From: Logan Gunthorpe
Quoted 12 lines
A divide by zero error occurs if
qp_countis less thanmw_countbecausenum_qps_mwis calculated to be zero. The calculation appears to be incorrect.The requirement is for
num_qps_mwto be set toqp_count/mw_countwith any remainder divided among the earlier mws.For example, if
mw_countis 5 andqp_countis 12 then mws 0 and 1 will have 3 qps per window and mws 2 through 4 will have 2 qps per window. Thus, whenmw_num<qp_count%mw_count,num_qps_mwis 1 higher than whenmw_num>=qp_count.
Quoted 4 lines
Signed-off-by Logan Gunthorpe <[email protected]>Cc Jon Mason <[email protected]>Cc Dave Jiang <[email protected]>Cc Allen Hubbe <[email protected]>
Quoted 28 lines
--- drivers/ntb/ntb_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/ntb/ntb_transport.c +2
-3@@ -623,7 +623,7 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,if (!mw->virt_addr)return -ENOMEM ; -if (qp_count % mw_count && mw_num +1 < qp_count / mw_count) +if (mw_num < qp_count % mw_count) num_qps_mw = qp_count / mw_count +1 ;else num_qps_mw = qp_count / mw_count;@@ -1000,7 +1000,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, qp->event_handler =NULL ;ntb_qp_link_down_reset (qp); -if (qp_count % mw_count && mw_num +1 < qp_count / mw_count) +if (mw_num < qp_count % mw_count) num_qps_mw = qp_count / mw_count +1 ;else num_qps_mw = qp_count / mw_count; --2.11.0
Jon Mason
maintainerRe: [PATCH] ntb_transport: fix bug calculating num_qps_mw
Quoted 13 lines · Allen Hubbe
From: Logan Gunthorpe
Quoted 12 lines
A divide by zero error occurs if
qp_countis less thanmw_countbecausenum_qps_mwis calculated to be zero. The calculation appears to be incorrect.The requirement is for
num_qps_mwto be set toqp_count/mw_countwith any remainder divided among the earlier mws.For example, if
mw_countis 5 andqp_countis 12 then mws 0 and 1 will have 3 qps per window and mws 2 through 4 will have 2 qps per window. Thus, whenmw_num<qp_count%mw_count,num_qps_mwis 1 higher than whenmw_num>=qp_count.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Logan Gunthorpe <[email protected]>Cc Jon Mason <[email protected]>Cc Dave Jiang <[email protected]>Cc Allen Hubbe <[email protected]>Acked-by Allen Hubbe <[email protected]>
Adding to my ntb branch with the following line:
This enables the stable kernels it is a bug fix and to pick it up.
Thanks,
Jon
Quoted 31 lines
Quoted 29 lines
--- drivers/ntb/ntb_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/ntb/ntb_transport.c +2
-3@@ -623,7 +623,7 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,if (!mw->virt_addr)return -ENOMEM ; -if (qp_count % mw_count && mw_num +1 < qp_count / mw_count) +if (mw_num < qp_count % mw_count) num_qps_mw = qp_count / mw_count +1 ;else num_qps_mw = qp_count / mw_count;@@ -1000,7 +1000,7 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, qp->event_handler =NULL ;ntb_qp_link_down_reset (qp); -if (qp_count % mw_count && mw_num +1 < qp_count / mw_count) +if (mw_num < qp_count % mw_count) num_qps_mw = qp_count / mw_count +1 ;else num_qps_mw = qp_count / mw_count; --2.11.0
PATCH 1/1 ntb_transport: fix qp count bug
In reply to Logan GunthorpeIn cases where there are more mw's than spads/2-2, the mw count gets reduced to match the limitation. ntb_transport also tries to ensure that there are fewer qps than mws but uses the full mw count instead of the reduced one. When this happens, the math in 'ntb_transport_setup_qp_mw' will get confused and result in a kernel paging request bug.
This patch fixes the bug by reducing qp_count to the reduced mw count instead of the full mw count.
--- drivers/ntb/ntb_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ntb/ntb_transport.c +2 -2
@@ -1128,8 +1128,8 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) qp_count =ilog2 (qp_bitmap);if (max_num_clients && max_num_clients < qp_count) qp_count = max_num_clients; -else if (mw_count < qp_count) - qp_count = mw_count; +else if (nt->mw_count < qp_count) + qp_count = nt->mw_count; qp_bitmap &=BIT_ULL (qp_count) -1 ;
Signature · 1 line
2.11.0
RE: [PATCH] ntb_transport: fix qp count bug
From: Logan Gunthorpe
Quoted 7 lines
In cases where there are more mw's than spads/2-2, the mw count gets reduced to match the limitation.
ntb_transportalso tries to ensure that there are fewer qps than mws but uses the full mw count instead of the reduced one. When this happens, the math in 'ntb_transport_setup_qp_mw' will get confused and result in a kernel paging request bug.
Quoted 7 lines
This patch fixes the bug by reducing
qp_countto the reduced mw count instead of the full mw count.Signed-off-by Logan Gunthorpe <[email protected]>Cc Jon Mason <[email protected]>Cc Dave Jiang <[email protected]>Cc Allen Hubbe <[email protected]>
Quoted 22 lines
--- drivers/ntb/ntb_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/ntb/ntb_transport.c +2
-3@@ -1128,8 +1128,8 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) qp_count =ilog2 (qp_bitmap);if (max_num_clients && max_num_clients < qp_count) qp_count = max_num_clients; -else if (mw_count < qp_count) - qp_count = mw_count; +else if (nt->mw_count < qp_count) + qp_count = nt->mw_count; qp_bitmap &=BIT_ULL (qp_count) -1 ; --2.11.0
Jon Mason
maintainerRe: [PATCH] ntb_transport: fix qp count bug
Quoted 11 lines · Allen Hubbe
From: Logan Gunthorpe
Quoted 10 lines
In cases where there are more mw's than spads/2-2, the mw count gets reduced to match the limitation.
ntb_transportalso tries to ensure that there are fewer qps than mws but uses the full mw count instead of the reduced one. When this happens, the math in 'ntb_transport_setup_qp_mw' will get confused and result in a kernel paging request bug.This patch fixes the bug by reducing
qp_countto the reduced mw count instead of the full mw count.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Logan Gunthorpe <[email protected]>Cc Jon Mason <[email protected]>Cc Dave Jiang <[email protected]>Cc Allen Hubbe <[email protected]>Acked-by Allen Hubbe <[email protected]>
Adding to my ntb branch with the following line:
This enables the stable kernels it is a bug fix and to pick it up.
Thanks,
Jon
Quoted 25 lines
Quoted 23 lines
--- drivers/ntb/ntb_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/ntb/ntb_transport.c +2
-3@@ -1128,8 +1128,8 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) qp_count =ilog2 (qp_bitmap);if (max_num_clients && max_num_clients < qp_count) qp_count = max_num_clients; -else if (mw_count < qp_count) - qp_count = mw_count; +else if (nt->mw_count < qp_count) + qp_count = nt->mw_count; qp_bitmap &=BIT_ULL (qp_count) -1 ; --2.11.0
From: Logan Gunthorpe
Quoted 6 lines
At present,
ntb_netdevdevices end up under/sys/devices/virtual/netcompletely unconnected to the ntb trees below them. This patch sets the parent of thenet_device(usingSET_NETDEV_DEV) to theclient_devdevice. This results in a better connected sysfs path for the network device:
Quoted 6 lines
/sys/devices/pci0000:00/0000:00:03.0/0000:03:00.1/0000:03:00.1/ntb_netdev0/net/eth2
Signed-off-by Logan Gunthorpe <[email protected]>Cc Jon Mason <[email protected]>Cc Dave Jiang <[email protected]>Cc Allen Hubbe <[email protected]>
Quoted 19 lines
--- drivers/net/ntb_netdev.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/ntb_netdev.c +2
-1@@ -418,6 +418,8 @@ static int ntb_netdev_probe(struct device *client_dev)if (!ndev)return -ENOMEM ; +SET_NETDEV_DEV (ndev, client_dev); + dev =netdev_priv (ndev); dev->ndev = ndev; dev->pdev = pdev; --2.11.0
Jon Mason
maintainerQuoted 7 lines · Allen Hubbe
From: Logan Gunthorpe
Quoted 6 lines
At present,
ntb_netdevdevices end up under/sys/devices/virtual/netcompletely unconnected to the ntb trees below them. This patch sets the parent of thenet_device(usingSET_NETDEV_DEV) to theclient_devdevice. This results in a better connected sysfs path for the network device:
Quoted 8 lines
Quoted 6 lines
/sys/devices/pci0000:00/0000:00:03.0/0000:03:00.1/0000:03:00.1/ntb_netdev0/net/eth2
Signed-off-by Logan Gunthorpe <[email protected]>Cc Jon Mason <[email protected]>Cc Dave Jiang <[email protected]>Cc Allen Hubbe <[email protected]>Acked-by Allen Hubbe <[email protected]>
Adding to my ntb branch with the following line:
This enables the stable kernels it is a bug fix and to pick it up.
Thanks,
Jon
Quoted 22 lines
Quoted 20 lines
--- drivers/net/ntb_netdev.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/ntb_netdev.c +2
-1@@ -418,6 +418,8 @@ static int ntb_netdev_probe(struct device *client_dev)if (!ndev)return -ENOMEM ; +SET_NETDEV_DEV (ndev, client_dev); + dev =netdev_priv (ndev); dev->ndev = ndev; dev->pdev = pdev; --2.11.0
Quoted 2 lines · Jon Mason
Adding to my ntb branch with the following line:
Fixes a9c59ef77458 ("ntb_test: Add a selftest script for the NTB subsystem")
Thanks Jon! But you might have gotten confused here... This particular patch doesn't fix ntb_test, but I sent a different one that does which you have not merged yet.
Logan
Jon Mason
maintainerQuoted 9 lines · Logan Gunthorpe
Quoted 2 lines · Jon Mason
Adding to my ntb branch with the following line:
Fixes a9c59ef77458 ("ntb_test: Add a selftest script for the NTB subsystem")Thanks Jon! But you might have gotten confused here... This particular patch doesn't fix
ntb_test, but I sent a different one that does which you have not merged yet.
Oops, I replied to the wrong one. Sorry. Everything of yours should be moved in the ntb or ntb-next branches. Please double check me and resend if it is not present.
Quoted 9 lines
Logan
--
You received this message because you are subscribed to the Google Groups "linux-ntb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/9fa5c040-3e67-4f0b-accb-5905aa1de6f0%40deltatee.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 3 lines · Jon Mason
Oops, I replied to the wrong one. Sorry. Everything of yours should be moved in the ntb or ntb-next branches. Please double check me and resend if it is not present.
Yup, looks good. Thanks.
Logan