[PATCH for-next 1/2] RDMA/efa: Move host info set to first ucontext allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Downstream patch will require the userspace version which is passed as
part of ucontext allocation. Move the host info set there and make sure
it's only called once (on the first allocation).

Reviewed-by: Firas JahJah <firasj@xxxxxxxxxx>
Reviewed-by: Leonid Feschuk <lfesch@xxxxxxxxxx>
Signed-off-by: Gal Pressman <galpress@xxxxxxxxxx>
---
 drivers/infiniband/hw/efa/efa.h       | 7 +++++++
 drivers/infiniband/hw/efa/efa_main.c  | 4 +---
 drivers/infiniband/hw/efa/efa_verbs.c | 3 +++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/efa/efa.h b/drivers/infiniband/hw/efa/efa.h
index e5d9712e98c4..9c9cd5867489 100644
--- a/drivers/infiniband/hw/efa/efa.h
+++ b/drivers/infiniband/hw/efa/efa.h
@@ -45,6 +45,11 @@ struct efa_stats {
 	atomic64_t keep_alive_rcvd;
 };
 
+enum {
+	EFA_FLAGS_HOST_INFO_SET_BIT,
+	EFA_FLAGS_NUM,
+};
+
 struct efa_dev {
 	struct ib_device ibdev;
 	struct efa_com_dev edev;
@@ -62,6 +67,7 @@ struct efa_dev {
 	struct efa_irq admin_irq;
 
 	struct efa_stats stats;
+	DECLARE_BITMAP(flags, EFA_FLAGS_NUM);
 };
 
 struct efa_ucontext {
@@ -117,6 +123,7 @@ struct efa_ah {
 	u8 id[EFA_GID_SIZE];
 };
 
+void efa_set_host_info(struct efa_dev *dev);
 int efa_query_device(struct ib_device *ibdev,
 		     struct ib_device_attr *props,
 		     struct ib_udata *udata);
diff --git a/drivers/infiniband/hw/efa/efa_main.c b/drivers/infiniband/hw/efa/efa_main.c
index 0f578734bddb..90a033a6af6c 100644
--- a/drivers/infiniband/hw/efa/efa_main.c
+++ b/drivers/infiniband/hw/efa/efa_main.c
@@ -191,7 +191,7 @@ static void efa_stats_init(struct efa_dev *dev)
 		atomic64_set(s, 0);
 }
 
-static void efa_set_host_info(struct efa_dev *dev)
+void efa_set_host_info(struct efa_dev *dev)
 {
 	struct efa_admin_set_feature_resp resp = {};
 	struct efa_admin_set_feature_cmd cmd = {};
@@ -301,8 +301,6 @@ static int efa_ib_device_add(struct efa_dev *dev)
 	if (err)
 		goto err_release_doorbell_bar;
 
-	efa_set_host_info(dev);
-
 	dev->ibdev.node_type = RDMA_NODE_UNSPECIFIED;
 	dev->ibdev.phys_port_cnt = 1;
 	dev->ibdev.num_comp_vectors = 1;
diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
index 2fe5708b2d9d..5c12bdc28ef0 100644
--- a/drivers/infiniband/hw/efa/efa_verbs.c
+++ b/drivers/infiniband/hw/efa/efa_verbs.c
@@ -1695,6 +1695,9 @@ int efa_alloc_ucontext(struct ib_ucontext *ibucontext, struct ib_udata *udata)
 		goto err_out;
 	}
 
+	if (!test_and_set_bit(EFA_FLAGS_HOST_INFO_SET_BIT, dev->flags))
+		efa_set_host_info(dev);
+
 	err = efa_user_comp_handshake(ibucontext, &cmd);
 	if (err)
 		goto err_out;
-- 
2.30.0




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux