Re: [PATCH V1 for-next 1/2] IB/uverbs: Enable device removal when there are active user space applications

2014-11-19 Thread Or Gerlitz

On 11/18/2014 11:42 PM, Or Gerlitz wrote:

On Tue, Nov 18, 2014 at 6:24 PM, Yishai Hadasyish...@dev.mellanox.co.il


The IB device pointer is not valid at all spots, for example after the HW
Device was removed, that's why we set this information on the uverbs device.


In 2nd thought, they must be point @ time where it is valid, right? so 
you can query/cache the whole 32bit device caps on that minute and use  
it later.


Or.
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH for-next] IB/core: Fix mgid key handling in SA agent multicast data-base

2014-11-19 Thread Or Gerlitz
From: Jack Morgenstein ja...@dev.mellanox.co.il

Applications can request that the SM assign an mgid, by passing a mcast
member request containing an mgid = 0. When the SM responds by sending
the allocated mgid, this mgid replaces the 0-mgid in the multicast group.

However, the mgid field in the group is also the key field in the IB core
multicast code red-black tree containing the multicast groups for the port.

Since this is a key field, correct handling requires that the group entry
be deleted from the rb table, and then re-inserted with the new key,
so that the table structure is properly maintained.

The current code does not do this correctly. Correct operation
requires that if the key-field gid has changed at all, it should
be deleted and re-inserted, fix that.

Note that when inserting, if the new mgid is zero (not the case here
but the code should handle this correctly), we allow duplicate entries
for 0-mgids.

Signed-off-by: Jack Morgenstein ja...@dev.mellanox.co.il
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/infiniband/core/multicast.c |   11 ---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/multicast.c 
b/drivers/infiniband/core/multicast.c
index d2360a8..fa17b55 100644
--- a/drivers/infiniband/core/multicast.c
+++ b/drivers/infiniband/core/multicast.c
@@ -525,17 +525,22 @@ static void join_handler(int status, struct 
ib_sa_mcmember_rec *rec,
if (status)
process_join_error(group, status);
else {
+   int mgids_changed, is_mgid0;
ib_find_pkey(group-port-dev-device, group-port-port_num,
 be16_to_cpu(rec-pkey), pkey_index);
 
spin_lock_irq(group-port-lock);
-   group-rec = *rec;
if (group-state == MCAST_BUSY 
group-pkey_index == MCAST_INVALID_PKEY_INDEX)
group-pkey_index = pkey_index;
-   if (!memcmp(mgid0, group-rec.mgid, sizeof mgid0)) {
+   mgids_changed = memcmp(rec-mgid, group-rec.mgid,
+  sizeof(group-rec.mgid));
+   group-rec = *rec;
+   if (mgids_changed) {
rb_erase(group-node, group-port-table);
-   mcast_insert(group-port, group, 1);
+   is_mgid0 = !memcmp(mgid0, group-rec.mgid,
+  sizeof(mgid0));
+   mcast_insert(group-port, group, is_mgid0);
}
spin_unlock_irq(group-port-lock);
}
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH for-next] IB/core: Fix mgid key handling in SA agent multicast data-base

2014-11-19 Thread Or Gerlitz

On 11/19/2014 11:08 AM, Or Gerlitz wrote:

Since this is a key field, correct handling requires that the group entry
be deleted from the rb table, and then re-inserted with the new key,
so that the table structure is properly maintained.

The current code does not do this correctly. Correct operation
requires that if the key-field gid has changed at all, it should
be deleted and re-inserted, fix that.


Sean, FWIW and even just for the fun, SB some logs from Jack's debugging 
that could help you see the problem beyond the nice analysis done by 
Jack in the change-log:


Suspected that re-balancing the rb tree confuses the find algorithm. 
Verified:

rdma_join_multicast: ENTERING
CMA: 88087e0b4c00: cma_join_ib_multicast: cma_join_ib_multicast, 
port=1, mgid = ff12:401b::::::

mcast_find. ENTERING. port = 1, node=8804543bf100
ib_sa_get_mcmember_rec: mcast_find SUCCESS. dev=mlx5_0, start_port=1, 
port=1, mgid=ff12:401b::::::

mcast_insert.ENTERING. port = 1, *link = 8804543bf100
mcast_insert. new grp mgid ::::::: , 
curr group mgid ff12:401b::::::, 
*link=8804543bf100, -1
mcast_insert. new grp mgid ::::::: , 
curr group mgid ff12:a01b:fe80:::de1e::, 
*link=88086d74a900, -1
mcast_insert. new grp mgid ::::::: , 
curr group mgid ff12:a01b:fe80:::e21e::, 
*link=88084da54ac0, -1
mcast_insert. new grp mgid ::::::: , 
curr group mgid ff12:a01b:fe80:::e41e::, 
*link=8808976f5dc0, -1
mcast_insert. new grp mgid ::::::: , 
curr group mgid ff12:a01b:fe80:::e61e::, 
*link=880892e44ec0, -1
mcast_insert. new grp mgid ::::::: , 
curr group mgid ff12:a01b:fe80:::e71e::, 
*link=8804607d2ac0, -1


mcast_insert. BEFORE insert color: root rb_node=8804543bf100
mcast_insert. AFTER root rb_node=88086d74a900 == rb tree 
rebalanced (i.e., rotated) here.


mcast_insert traversal. lgroup mgid 
:::::::, node=8807e987aac0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e71e::, node=8804607d2ac0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e61e::, node=880892e44ec0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e51e::, node=8802c5e0d700
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e41e::, node=8808976f5dc0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e31e::, node=88041a4f4f00
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e21e::, node=88084da54ac0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e11e::, node=88047244a1c0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::e01e::, node=880897de4dc0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::df1e::, node=8804904cfdc0
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::de1e::, node=88086d74a900
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::dd1e::, node=88038f5bf300
mcast_insert traversal. lgroup mgid 
ff12:a01b:fe80:::dc1e::, node=88045c023f00
mcast_insert traversal. lgroup mgid 
ff12:401b::::::0001, node=880451271b00
mcast_insert traversal. lgroup mgid 
ff12:401b::::::, node=8804543bf100  
Do not find this entry!
mcast_insert traversal. lgroup mgid 
ff12:601b::::::0001, node=88045c023800
mcast_insert traversal. lgroup mgid 
ff12:601b::::::0002, node=88046431aac0
mcast_insert traversal. lgroup mgid 
ff12:601b::::::0016, node=88045c023300
mcast_insert traversal. lgroup mgid 
ff12:601b::::0001:ff16:7520, node=88047a04c600

ucma_join_multicast: ENTERING
rdma_join_multicast: ENTERING
CMA: 880497488800: cma_join_ib_multicast: cma_join_ib_multicast, 
port=1, mgid = ff12:401b::::::

mcast_find. ENTERING. port = 1, node=88086d74a900
mcast_find. mgid ff12:401b:::::: != group gid 
ff12:a01b:fe80:::de1e::, node=88086d74a900
mcast_find. mgid ff12:401b:::::: != group gid 
ff12:a01b:fe80:::e21e::, node=88084da54ac0
mcast_find. mgid ff12:401b:::::: != group gid 
ff12:a01b:fe80:::e41e::, node=8808976f5dc0
mcast_find. mgid ff12:401b:::::: != group gid 
ff12:a01b:fe80:::e61e::, node=880892e44ec0
mcast_find. mgid ff12:401b:::::: != group gid 
ff12:a01b:fe80:::e71e::, node=8804607d2ac0
mcast_find. 

[PATCH for-next] IB/core: Do not resolve VLAN if already resolved

2014-11-19 Thread Or Gerlitz
From: Moni Shoua mo...@mellanox.com

For RoCE, resolution of layer 2 address attributes forces no VLAN if link local
gids are used. This patch enables applications that want to choose VLAN ID for
link local based RoCE gids by setting IB_QP_VID in their QP attribute mask and
prevent the core to override this choice.

Cc: Ursula Braun ursula.br...@de.ibm.com
Signed-off-by: Moni Shoua mo...@mellanox.com
Signed-off-by: Or Gerlitz ogerl...@mellanox.com
---
 drivers/infiniband/core/verbs.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index c2b89cc..f93eb8d 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -879,7 +879,8 @@ int ib_resolve_eth_l2_attrs(struct ib_qp *qp,
if (rdma_link_local_addr((struct in6_addr 
*)qp_attr-ah_attr.grh.dgid.raw)) {
rdma_get_ll_mac((struct in6_addr 
*)qp_attr-ah_attr.grh.dgid.raw, qp_attr-ah_attr.dmac);
rdma_get_ll_mac((struct in6_addr *)sgid.raw, 
qp_attr-smac);
-   qp_attr-vlan_id = rdma_get_vlan_id(sgid);
+   if (!(*qp_attr_mask  IB_QP_VID))
+   qp_attr-vlan_id = rdma_get_vlan_id(sgid);
} else {
ret = rdma_addr_find_dmac_by_grh(sgid, 
qp_attr-ah_attr.grh.dgid,
qp_attr-ah_attr.dmac, 
qp_attr-vlan_id);
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] libmlx4: add support for the s390x platform

2014-11-19 Thread Alexey Ishchuk
Since, s390x platform requires execution of privileged CPU instructions
to work with PCI I/O memory, the PCI I/O memory cannot be directly accessed
from the userspace programs via the mapped memory areas. The current
implementation of the Inifiniband verbs uses mapped memory areas to
write data to device UAR and Blueflame page to initiate the I/O
operations, these verbs currently cannot be used on the s390x platfrom
without modification.
This patch contains the changes to the libmlx4 userspace Mellanox device
driver library required to provide support for the DAPL API on the s390x
platform. The original code that directly used mapped memory areas to access
the PCI I/O memory of the Mellanox networking device is replaced with the
new system call invocation for writing the data to mapped memory areas.

Signed-off-by: Alexey Ishchuk aishc...@linux.vnet.ibm.com
---
 Makefile.am|2 
 src/doorbell.h |8 ++-
 src/mlx4.h |2 
 src/mmio.h |  115 +
 src/qp.c   |   17 
 5 files changed, 125 insertions(+), 19 deletions(-)

--- a/Makefile.am
+++ b/Makefile.am
@@ -12,7 +12,7 @@ src_libmlx4_la_LDFLAGS = -avoid-version
 mlx4confdir = $(sysconfdir)/libibverbs.d
 mlx4conf_DATA = mlx4.driver
 
-EXTRA_DIST = src/doorbell.h src/mlx4.h src/mlx4-abi.h src/wqe.h \
+EXTRA_DIST = src/doorbell.h src/mlx4.h src/mlx4-abi.h src/wqe.h src/mmio.h \
 src/mlx4.map libmlx4.spec.in mlx4.driver
 
 dist-hook: libmlx4.spec
--- a/src/doorbell.h
+++ b/src/doorbell.h
@@ -33,6 +33,8 @@
 #ifndef DOORBELL_H
 #define DOORBELL_H
 
+#include mmio.h
+
 #if SIZEOF_LONG == 8
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -45,7 +47,7 @@
 
 static inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int 
offset)
 {
-   *(volatile uint64_t *) (ctx-uar + offset) = MLX4_PAIR_TO_64(val);
+   mmio_writeq((unsigned long)(ctx-uar + offset), MLX4_PAIR_TO_64(val));
 }
 
 #else
@@ -53,8 +55,8 @@ static inline void mlx4_write64(uint32_t
 static inline void mlx4_write64(uint32_t val[2], struct mlx4_context *ctx, int 
offset)
 {
pthread_spin_lock(ctx-uar_lock);
-   *(volatile uint32_t *) (ctx-uar + offset) = val[0];
-   *(volatile uint32_t *) (ctx-uar + offset + 4) = val[1];
+   mmio_writel((unsigned long)(ctx-uar + offset), val[0]);
+   mmio_writel((unsigned long)(ctx-uar + offset + 4), val[1]);
pthread_spin_unlock(ctx-uar_lock);
 }
 
--- a/src/mlx4.h
+++ b/src/mlx4.h
@@ -74,6 +74,8 @@
 #define wc_wmb() asm volatile(sfence ::: memory)
 #elif defined(__ia64__)
 #define wc_wmb() asm volatile(fwb ::: memory)
+#elif defined(__s390x__)
+#define wc_wmb { asm volatile( : : : memory) }
 #else
 #define wc_wmb() wmb()
 #endif
--- /dev/null
+++ b/src/mmio.h
@@ -0,0 +1,115 @@
+#ifndef MMIO_H
+#define MMIO_H
+
+#include unistd.h
+#include asm/unistd.h
+#include sys/syscall.h
+#ifdef __s390x__
+
+static inline long mmio_writeb(const unsigned long mmio_addr,
+  const uint8_t val)
+{
+   return syscall(__NR_s390_pci_mmio_write, mmio_addr, val, sizeof(val));
+}
+
+static inline long mmio_writew(const unsigned long mmio_addr,
+  const uint16_t val)
+{
+   return syscall(__NR_s390_pci_mmio_write, mmio_addr, val, sizeof(val));
+}
+
+static inline long mmio_writel(const unsigned long mmio_addr,
+  const uint32_t val)
+{
+   return syscall(__NR_s390_pci_mmio_write, mmio_addr, val, sizeof(val));
+}
+
+static inline long mmio_writeq(const unsigned long mmio_addr,
+  const uint64_t val)
+{
+   return syscall(__NR_s390_pci_mmio_write, mmio_addr, val, sizeof(val));
+}
+
+static inline long mmio_write(const unsigned long mmio_addr,
+ const void *val,
+ const size_t length)
+{
+   return syscall(__NR_s390_pci_mmio_write, mmio_addr, val, length);
+}
+
+static inline long mmio_readb(const unsigned long mmio_addr, uint8_t *val)
+{
+   return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_readw(const unsigned long mmio_addr, uint16_t *val)
+{
+   return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_readl(const unsigned long mmio_addr, uint32_t *val)
+{
+   return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_readq(const unsigned long mmio_addr, uint64_t *val)
+{
+   return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, sizeof(*val));
+}
+
+static inline long mmio_read(const unsigned long mmio_addr,
+void *val,
+const size_t length)
+{
+   return syscall(__NR_s390_pci_mmio_read, mmio_addr, val, length);
+}
+
+static inline void mlx4_bf_copy(unsigned long *dst,
+   unsigned long *src,
+   unsigned 

[PATCH 1/2] libibverbs: add support for the s390x platform

2014-11-19 Thread Alexey Ishchuk
This patch adds the required platform specific code to allow execution of
the libibverbs functions on the s390x platform.

Signed-off-by: Alexey Ishchuk aishc...@linux.vnet.ibm.com
---
 include/infiniband/arch.h |7 +++
 1 file changed, 7 insertions(+)

--- a/include/infiniband/arch.h
+++ b/include/infiniband/arch.h
@@ -115,6 +115,13 @@ static inline uint64_t ntohll(uint64_t x
 #define wmb()   mb()
 #define wc_wmb() wmb()
 
+#elif defined(__s390x__)
+
+#define mb()   { asm volatile( : : : memory); }/* for s390x */
+#define rmb()  mb()/* for s390x */
+#define wmb()  mb()/* for s390x */
+#define wc_wmb() wmb() /* for s390x */
+
 #else
 
 #warning No architecture specific defines found.  Using generic implementation.

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V1 for-next 2/2] IB/mlx4_ib: Disassociate support

2014-11-19 Thread Yishai Hadas

On 11/18/2014 11:50 PM, Or Gerlitz wrote:

On Tue, Nov 18, 2014 at 7:14 PM, Yishai Hadas
yish...@dev.mellanox.co.il wrote:

On 11/18/2014 4:42 PM, Or Gerlitz wrote:



Can we somehow make this patch generic (e.g land in the IB core) such
that it can apply also for mlx5 (and other HW drivers...) basically, the
HW driver should tell the IB core which pages to zap and we should be
OK, isn't that?



We introduced a generic API that asked the low level driver to detach a
given ucontext from its HW resources. The specific driver implementation may
be different between HW devices and may not involve the zap usage, that's
why it wasn't put in IB core. In addition, the zap API should be in sync
with inflight VMA closing to prevent zapping an already unmapped address. To
achieve that the driver should implement some VMA ops and synchronize
between those flows.


Again, drivers that don't want to go the zapping way, could just avoid
this generic code.

So we have already two more low-level drivers (cxgb3/4) that would be
happily using the 95% of the mlx4_ib code you wrote after the
re-factoring I suggested.
I tend to think mlx5_ib should join too. Why not try it out, write the
code in the way which

1. under the IB core
2. easiest to use under this twist for mlx4_ib

and let cxgb3/4 and mlx5 maintainers to see if/how they can use it.


The HW driver upon mmap of its UARs needs to manage their VMAs, it 
includes saving the VMAs pointers on its internal context, set its 
private VMA open/close operations, etc. In addition, the HW Driver 
should synchronize between VMA closing to a parallel call of ucontext 
detaching.


To use the ZAP API the internal context of the HW driver should be used 
and its state should be considered, as such it makes sense that it will 
be used as part of the HW Driver. In addition, there may be some others 
vendors that may not use it as part of their ucontext detaching at all.


For that reason we believe that the correct place to use the zap call is 
in the HW driver and not in IB core, at least at first phase.




--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V1 for-next 2/2] IB/mlx4_ib: Disassociate support

2014-11-19 Thread Or Gerlitz

On 11/19/2014 2:15 PM, Yishai Hadas wrote:
For that reason we believe that the correct place to use the zap call 
is in the HW driver and not in IB core


OK let it be - get this one (after the  trivial comments are addressed) 
in and let the ones that follow see if they

can generalize/re-use the code somehow...

Or.
--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] Ibacm/ibacmp bug fixes

2014-11-19 Thread kaike . wan
From: Kaike Wan kaike@intel.com

This patch series fixes a print format error and two bugs related to SM restart.


Kaike Wan (3):
  ibacmp: missing '%' in acm_log format
  ibacm: close the provider endpoint when it fails to assign a name to
a core endpoint
  ibacm/ibacmp: fix a crash when SM restarts

 prov/acmp/src/acmp.c |6 +-
 src/acm.c|9 -
 2 files changed, 13 insertions(+), 2 deletions(-)

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] ibacm: close the provider endpoint when it fails to assign a name to a core endpoint

2014-11-19 Thread kaike . wan
From: Kaike Wan kaike@intel.com

In function acm_ep_up(), when it fails to assign any name to an endpoint, the
endpoint in the provider is not properly closed before the core endpoint is
freed. This may cause segfault when ibacmp tries to join multicast group with 
a stale core endpoint pointer.

Signed-off-by: Kaike Wan kaike@intel.com
---
 src/acm.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/acm.c b/src/acm.c
index 11fda4c..d807c73 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -1744,12 +1744,15 @@ static void acm_ep_up(struct acmc_port *port, uint16_t 
pkey)
ret = acm_assign_ep_names(ep);
if (ret) {
acm_log(0, ERROR - unable to assign EP name for pkey 0x%x\n, 
pkey);
-   goto err;
+   goto ep_close;
}
 
DListInsertHead(ep-entry, port-ep_list);
return;
 
+ep_close:
+   port-prov-close_endpoint(ep-prov_ep_context);
+
 err:
free(ep);
 }
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] ibacm/ibacmp: fix a crash when SM restarts

2014-11-19 Thread kaike . wan
From: Kaike Wan kaike@intel.com

Ibacm may cause segfault when the SM restarts: when the SM restarts, ibacm will
receive P_Key change event and instruct ibacmp to close all endpoints. However,
ibacmp only resets the core endpoint pointer in its ep structure and keeps the 
ep
in the port's ep_list. Afterwards, the ibacm core will ask ibacmp to create
an ep for each pkey enumerated from the local port. The ep will be found
from the port's ep_list if it exists. However, if an old pkey is not present
in the new SM configuration, the old ep will still be linked in the port's
ep_list with the ep-endpoint being set to NULL. When the ibacm core forwards
the client reregistration event to ibacmp, ibacmp will enumerate the ep_list and
try to join multicast group for each ep, including any one with ep-endpoint
set to NULL. In this case, it will cause segfault in acm_send_sa_mad().
Additional check should be able to avoid the crash.

Signed-off-by: Kaike Wan kaike@intel.com
---
 prov/acmp/src/acmp.c |4 
 src/acm.c|4 
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/prov/acmp/src/acmp.c b/prov/acmp/src/acmp.c
index 7568b9c..2b85958 100644
--- a/prov/acmp/src/acmp.c
+++ b/prov/acmp/src/acmp.c
@@ -1446,6 +1446,10 @@ static int acmp_port_join(void *port_context)
for (ep_entry = port-ep_list.Next; ep_entry != port-ep_list;
 ep_entry = ep_entry-Next) {
ep = container_of(ep_entry, struct acmp_ep, entry);
+   if (!ep-endpoint) {
+   /* Stale endpoint */
+   continue;
+   }
acmp_ep_join(ep);
}
acm_log(1, joins for device %s port %d complete\n,
diff --git a/src/acm.c b/src/acm.c
index d807c73..2d0d2e1 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -2352,6 +2352,10 @@ acm_alloc_sa_mad(const struct acm_endpoint *endpoint, 
void *context,
 {
struct acmc_sa_req *req;
 
+   if (!endpoint) {
+   acm_log(0, Error: NULL endpoint\n);
+   return NULL;
+   }
req = calloc(1, sizeof (*req));
if (!req) {
acm_log(0, Error: failed to allocate sa request\n);
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V1 for-next 1/2] IB/uverbs: Enable device removal when there are active user space applications

2014-11-19 Thread Or Gerlitz

On 11/18/2014 2:11 PM, Yishai Hadas wrote:

@@ -533,6 +552,12 @@ void ib_uverbs_event_handler(struct ib_event_handler 
*handler,
struct ib_uverbs_file *file =
container_of(handler, struct ib_uverbs_file, event_handler);
  
+	if (event-event == IB_EVENT_DEVICE_FATAL) {

+   if (file-fatal_event_raised)
+   return;
+   file-fatal_event_raised = 1;
+   }
+


can we avoid the fatal_event_raised flag?

In a similar manner to what defined for rdma-cm consumers, let's add 
IB_EVENT_DEVICE_REMOVAL event and generate both events from  here 
towards the uberbs consumer (the fatal for legacy apps and the device 
removal for newer apps that maybe want to distinguish between the

two)


ib_uverbs_async_handler(file, event-element.port_num, event-event,
NULL, NULL);
  }


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] ibacmp: missing '%' in acm_log format

2014-11-19 Thread kaike . wan
From: Kaike Wan kaike@intel.com

This debugging print is in function acmp_get_ep().

Signed-off-by: Kaike Wan kaike@intel.com
---
 prov/acmp/src/acmp.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/prov/acmp/src/acmp.c b/prov/acmp/src/acmp.c
index 2dd356d..7568b9c 100644
--- a/prov/acmp/src/acmp.c
+++ b/prov/acmp/src/acmp.c
@@ -2374,7 +2374,7 @@ acmp_get_ep(struct acmp_port *port, struct acm_endpoint 
*endpoint)
struct acmp_ep *ep;
DLIST_ENTRY *entry;
 
-   acm_log(1, dev 0xllx port %d pkey 0x%x\n,
+   acm_log(1, dev 0x%llx port %d pkey 0x%x\n,
endpoint-port-dev-dev_guid, endpoint-port-port_num, 
endpoint-pkey);
for (entry = port-ep_list.Next; entry != port-ep_list;
 entry = entry-Next) {
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] InfiniBand: Deletion of unnecessary checks before two function calls

2014-11-19 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Wed, 19 Nov 2014 19:19:21 +0100

The functions kfree() and pci_dev_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 drivers/infiniband/hw/mlx4/main.c | 3 +--
 drivers/infiniband/hw/mthca/mthca_reset.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/mlx4/main.c 
b/drivers/infiniband/hw/mlx4/main.c
index 8b72cf3..50dee1a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -2512,8 +2512,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int 
slave, int do_init)
if (!dm[i]) {
pr_err(failed to allocate memory for tunneling qp 
update work struct\n);
for (i = 0; i  dev-caps.num_ports; i++) {
-   if (dm[i])
-   kfree(dm[i]);
+   kfree(dm[i]);
}
goto out;
}
diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c 
b/drivers/infiniband/hw/mthca/mthca_reset.c
index 74c6a94..c521654 100644
--- a/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/drivers/infiniband/hw/mthca/mthca_reset.c
@@ -279,8 +279,7 @@ good:
}
 
 out:
-   if (bridge)
-   pci_dev_put(bridge);
+   pci_dev_put(bridge);
kfree(bridge_header);
kfree(hca_header);
 
-- 
2.1.3

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH V1 for-next 1/2] IB/uverbs: Enable device removal when there are active user space applications

2014-11-19 Thread Yishai Hadas

On 11/19/2014 4:49 PM, Or Gerlitz wrote:

On 11/18/2014 2:11 PM, Yishai Hadas wrote:

@@ -533,6 +552,12 @@ void ib_uverbs_event_handler(struct
ib_event_handler *handler,
  struct ib_uverbs_file *file =
  container_of(handler, struct ib_uverbs_file, event_handler);
+if (event-event == IB_EVENT_DEVICE_FATAL) {
+if (file-fatal_event_raised)
+return;
+file-fatal_event_raised = 1;
+}
+


can we avoid the fatal_event_raised flag?


We need this flag to prevent generating duplicate event. This may happen 
when a fatal error occurred and just later the remove one was called 
when there were active applications.




In a similar manner to what defined for rdma-cm consumers, let's add
IB_EVENT_DEVICE_REMOVAL event and generate both events from  here
towards the uberbs consumer (the fatal for legacy apps and the device
removal for newer apps that maybe want to distinguish between the
two)


Need to consider whether it's important for newer applications to 
distinguish, can be opened for other input. In case we believe so, can 
be added as an extra patch to that series.





  ib_uverbs_async_handler(file, event-element.port_num,
event-event,
  NULL, NULL);
  }


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html