From: Parav Pandit <parav@xxxxxxxxxxxx> Instead of using ib_query_gid() to query GID attribute, start using GID get/put query APIs which acquires and releases GID reference. Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> --- net/smc/smc_core.c | 18 ++++++++++-------- net/smc/smc_ib.c | 25 +++++++++++++++---------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index f44f6803f7ff..9ddd2b5cc1fc 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -16,6 +16,7 @@ #include <net/tcp.h> #include <net/sock.h> #include <rdma/ib_verbs.h> +#include <rdma/ib_cache.h> #include "smc.h" #include "smc_clc.h" @@ -383,7 +384,7 @@ static int smc_vlan_by_tcpsk(struct socket *clcsock, unsigned short *vlan_id) static int smc_link_determine_gid(struct smc_link_group *lgr) { struct smc_link *lnk = &lgr->lnk[SMC_SINGLE_LINK]; - struct ib_gid_attr gattr; + const struct ib_gid_attr *gattr; union ib_gid gid; int i; @@ -394,18 +395,19 @@ static int smc_link_determine_gid(struct smc_link_group *lgr) for (i = 0; i < lnk->smcibdev->pattr[lnk->ibport - 1].gid_tbl_len; i++) { - if (ib_query_gid(lnk->smcibdev->ibdev, lnk->ibport, i, &gid, - &gattr)) + gattr = rdma_get_gid_attr(lnk->smcibdev->ibdev, + lnk->ibport, i, &gid); + if (IS_ERR(gattr)) continue; - if (gattr.ndev) { - if (is_vlan_dev(gattr.ndev) && - vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id) { + if (gattr->ndev) { + if (is_vlan_dev(gattr->ndev) && + vlan_dev_vlan_id(gattr->ndev) == lgr->vlan_id) { lnk->gid = gid; - dev_put(gattr.ndev); + rdma_put_gid_attr(gattr); return 0; } - dev_put(gattr.ndev); } + rdma_put_gid_attr(gattr); } return -ENODEV; } diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c index 26df554f7588..374f2e113c9c 100644 --- a/net/smc/smc_ib.c +++ b/net/smc/smc_ib.c @@ -16,6 +16,7 @@ #include <linux/workqueue.h> #include <linux/scatterlist.h> #include <rdma/ib_verbs.h> +#include <rdma/ib_cache.h> #include "smc_pnet.h" #include "smc_ib.h" @@ -383,17 +384,21 @@ void smc_ib_buf_unmap_sg(struct smc_ib_device *smcibdev, static int smc_ib_fill_gid_and_mac(struct smc_ib_device *smcibdev, u8 ibport) { - struct ib_gid_attr gattr; - int rc; - - rc = ib_query_gid(smcibdev->ibdev, ibport, 0, - &smcibdev->gid[ibport - 1], &gattr); - if (rc || !gattr.ndev) - return -ENODEV; + const struct ib_gid_attr *gattr; + int rc = 0; - memcpy(smcibdev->mac[ibport - 1], gattr.ndev->dev_addr, ETH_ALEN); - dev_put(gattr.ndev); - return 0; + gattr = rdma_get_gid_attr(smcibdev->ibdev, ibport, 0, + &smcibdev->gid[ibport - 1]); + if (IS_ERR(gattr)) + return PTR_ERR(gattr); + if (!gattr->ndev) { + rc = -ENODEV; + goto done; + } + memcpy(smcibdev->mac[ibport - 1], gattr->ndev->dev_addr, ETH_ALEN); +done: + rdma_put_gid_attr(gattr); + return rc; } /* Create an identifier unique for this instance of SMC-R. -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html