Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b292fb80 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull more rdma updates from Doug Ledford:
 "This merge window was the first where Huawei had to try and coordinate
  their patches between their net driver and their new roce driver
  (similar to mlx4 and mlx5).

  They didn't do horribly, but there were some issues (and we knew that
  because they simply didn't know what to do in the beginning). As a
  result, I had a set of patches that depended on some patches that
  normally would have come to you via Dave's tree. Those patches have
  been on netdev@ for a while, so I got Dave to give me his approval to
  send them to you. As such, the other 29 patches I had behind them are
  also now ready to go.

  This catches the hns and hns-roce drivers up to current, and for
  future patches we are working with them to get them up to speed on how
  to do joint driver development so that they don't have these sorts of
  cross tree dependency issues again. BTW, Dave gave me permission to
  add his Acked-by: to the patches against the net tree, but I've had
  this branch through 0day (but not linux-next since it was off by
  itself) and I didn't want to rebase the series just to add Dave's ack
  for the 8 patches in the net area.

  Updates to the hns drivers:

   - Small patch set for hns net driver that the roce patches depend on

   - Various fixes to the hns-roce driver

   - Add connection manager support to the hns-roce driver"

* tag 'for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma: (36 commits)
  IB/hns: Fix for removal of redundant code
  IB/hns: Delete the redundant lines in hns_roce_v1_m_qp()
  IB/hns: Fix the bug when platform_get_resource() exec fail
  IB/hns: Update the rq head when modify qp state
  IB/hns: Cq has not been freed
  IB/hns: Validate mtu when modified qp
  IB/hns: Some items of qpc need to take user param
  IB/hns: The Ack timeout need a lower limit value
  IB/hns: Return bad wr while post send failed
  IB/hns: Fix bug of memory leakage for registering user mr
  IB/hns: Modify the init of iboe lock
  IB/hns: Optimize code of aeq and ceq interrupt handle and fix the bug of qpn
  IB/hns: Delete the sqp_start from the structure hns_roce_caps
  IB/hns: Fix bug of clear hem
  IB/hns: Remove unused parameter named qp_type
  IB/hns: Simplify function of pd alloc and qp alloc
  IB/hns: Fix bug of using uninit refcount and free
  IB/hns: Remove parameters of resize cq
  IB/hns: Remove unused parameters in some functions
  IB/hns: Add node_guid definition to the bindings document
  ...
parents 689f891c 1bdab400
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ length of memory mapped region.
representing a ethernet device.
- dsaf-handle: phandle, specifies a reference to a node
representing a dsaf device.
- node_guid: a number that uniquely identifies a device or component
- #address-cells: must be 2
- #size-cells: must be 2
Optional properties:
@@ -32,6 +33,7 @@ Example:
			dma-coherent;
			eth-handle = <&eth2 &eth3 &eth4 &eth5 &eth6 &eth7>;
			dsaf-handle = <&soc0_dsa>;
			node-guid = [00 9A CD 00 00 01 02 03];
			#address-cells = <2>;
			#size-cells = <2>;
			interrupt-parent = <&mbigen_dsa>;
+15 −8
Original line number Diff line number Diff line
@@ -83,8 +83,7 @@ static int hns_roce_sw2hw_cq(struct hns_roce_dev *dev,
static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
			     struct hns_roce_mtt *hr_mtt,
			     struct hns_roce_uar *hr_uar,
			     struct hns_roce_cq *hr_cq, int vector,
			     int collapsed)
			     struct hns_roce_cq *hr_cq, int vector)
{
	struct hns_roce_cmd_mailbox *mailbox = NULL;
	struct hns_roce_cq_table *cq_table = NULL;
@@ -153,6 +152,9 @@ static int hns_roce_cq_alloc(struct hns_roce_dev *hr_dev, int nent,
	hr_cq->cons_index = 0;
	hr_cq->uar = hr_uar;

	atomic_set(&hr_cq->refcount, 1);
	init_completion(&hr_cq->free);

	return 0;

err_radix:
@@ -192,6 +194,11 @@ static void hns_roce_free_cq(struct hns_roce_dev *hr_dev,
	/* Waiting interrupt process procedure carried out */
	synchronize_irq(hr_dev->eq_table.eq[hr_cq->vector].irq);

	/* wait for all interrupt processed */
	if (atomic_dec_and_test(&hr_cq->refcount))
		complete(&hr_cq->free);
	wait_for_completion(&hr_cq->free);

	spin_lock_irq(&cq_table->lock);
	radix_tree_delete(&cq_table->tree, hr_cq->cqn);
	spin_unlock_irq(&cq_table->lock);
@@ -300,10 +307,7 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,

	cq_entries = roundup_pow_of_two((unsigned int)cq_entries);
	hr_cq->ib_cq.cqe = cq_entries - 1;
	mutex_init(&hr_cq->resize_mutex);
	spin_lock_init(&hr_cq->lock);
	hr_cq->hr_resize_buf = NULL;
	hr_cq->resize_umem = NULL;

	if (context) {
		if (ib_copy_from_udata(&ucmd, udata, sizeof(ucmd))) {
@@ -338,8 +342,8 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
	}

	/* Allocate cq index, fill cq_context */
	ret = hns_roce_cq_alloc(hr_dev, cq_entries, &hr_cq->hr_buf.hr_mtt,
				uar, hr_cq, vector, 0);
	ret = hns_roce_cq_alloc(hr_dev, cq_entries, &hr_cq->hr_buf.hr_mtt, uar,
				hr_cq, vector);
	if (ret) {
		dev_err(dev, "Creat CQ .Failed to cq_alloc.\n");
		goto err_mtt;
@@ -353,12 +357,15 @@ struct ib_cq *hns_roce_ib_create_cq(struct ib_device *ib_dev,
	if (context) {
		if (ib_copy_to_udata(udata, &hr_cq->cqn, sizeof(u64))) {
			ret = -EFAULT;
			goto err_mtt;
			goto err_cqc;
		}
	}

	return &hr_cq->ib_cq;

err_cqc:
	hns_roce_free_cq(hr_dev, hr_cq);

err_mtt:
	hns_roce_mtt_cleanup(hr_dev, &hr_cq->hr_buf.hr_mtt);
	if (context)
+6 −12
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@
#define HNS_ROCE_AEQE_OF_VEC_NUM		1

/* 4G/4K = 1M */
#define HNS_ROCE_SL_SHIFT			29
#define HNS_ROCE_SL_SHIFT			28
#define HNS_ROCE_TCLASS_SHIFT			20
#define HNS_ROCE_FLOW_LABLE_MASK		0xfffff

@@ -74,7 +74,9 @@
#define MR_TYPE_DMA				0x03

#define PKEY_ID					0xffff
#define GUID_LEN				8
#define NODE_DESC_SIZE				64
#define DB_REG_OFFSET				0x1000

#define SERV_TYPE_RC				0
#define SERV_TYPE_RD				1
@@ -282,20 +284,11 @@ struct hns_roce_cq_buf {
	struct hns_roce_mtt hr_mtt;
};

struct hns_roce_cq_resize {
	struct hns_roce_cq_buf	hr_buf;
	int			cqe;
};

struct hns_roce_cq {
	struct ib_cq			ib_cq;
	struct hns_roce_cq_buf		hr_buf;
	/* pointer to store information after resize*/
	struct hns_roce_cq_resize	*hr_resize_buf;
	spinlock_t			lock;
	struct mutex			resize_mutex;
	struct ib_umem			*umem;
	struct ib_umem			*resize_umem;
	void (*comp)(struct hns_roce_cq *);
	void (*event)(struct hns_roce_cq *, enum hns_roce_event);

@@ -408,6 +401,7 @@ struct hns_roce_qp {
	u32			buff_size;
	struct mutex		mutex;
	u8			port;
	u8			phy_port;
	u8			sl;
	u8			resp_depth;
	u8			state;
@@ -471,7 +465,6 @@ struct hns_roce_caps {
	u32		max_rq_desc_sz;	/* 64 */
	int		max_qp_init_rdma;
	int		max_qp_dest_rdma;
	int		sqp_start;
	int		num_cqs;
	int		max_cqes;
	int		reserved_cqs;
@@ -512,6 +505,8 @@ struct hns_roce_hw {
	void (*write_cqc)(struct hns_roce_dev *hr_dev,
			  struct hns_roce_cq *hr_cq, void *mb_buf, u64 *mtts,
			  dma_addr_t dma_handle, int nent, u32 vector);
	int (*clear_hem)(struct hns_roce_dev *hr_dev,
			 struct hns_roce_hem_table *table, int obj);
	int (*query_qp)(struct ib_qp *ibqp, struct ib_qp_attr *qp_attr,
			int qp_attr_mask, struct ib_qp_init_attr *qp_init_attr);
	int (*modify_qp)(struct ib_qp *ibqp, const struct ib_qp_attr *attr,
@@ -533,7 +528,6 @@ struct hns_roce_dev {
	struct hns_roce_uar     priv_uar;
	const char		*irq_names[HNS_ROCE_MAX_IRQ_NUM];
	spinlock_t		sm_lock;
	spinlock_t		cq_db_lock;
	spinlock_t		bt_cmd_lock;
	struct hns_roce_ib_iboe iboe;

+71 −75
Original line number Diff line number Diff line
@@ -66,9 +66,6 @@ static void hns_roce_wq_catas_err_handle(struct hns_roce_dev *hr_dev,
{
	struct device *dev = &hr_dev->pdev->dev;

	qpn = roce_get_field(aeqe->event.qp_event.qp,
			     HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M,
			     HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S);
	dev_warn(dev, "Local Work Queue Catastrophic Error.\n");
	switch (roce_get_field(aeqe->asyn, HNS_ROCE_AEQE_U32_4_EVENT_SUB_TYPE_M,
			       HNS_ROCE_AEQE_U32_4_EVENT_SUB_TYPE_S)) {
@@ -96,13 +93,6 @@ static void hns_roce_wq_catas_err_handle(struct hns_roce_dev *hr_dev,
	default:
		break;
	}

	hns_roce_qp_event(hr_dev, roce_get_field(aeqe->event.qp_event.qp,
					HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M,
					HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S),
			  roce_get_field(aeqe->asyn,
					HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
					HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S));
}

static void hns_roce_local_wq_access_err_handle(struct hns_roce_dev *hr_dev,
@@ -111,9 +101,6 @@ static void hns_roce_local_wq_access_err_handle(struct hns_roce_dev *hr_dev,
{
	struct device *dev = &hr_dev->pdev->dev;

	qpn = roce_get_field(aeqe->event.qp_event.qp,
			     HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M,
			     HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S);
	dev_warn(dev, "Local Access Violation Work Queue Error.\n");
	switch (roce_get_field(aeqe->asyn, HNS_ROCE_AEQE_U32_4_EVENT_SUB_TYPE_M,
			       HNS_ROCE_AEQE_U32_4_EVENT_SUB_TYPE_S)) {
@@ -141,13 +128,69 @@ static void hns_roce_local_wq_access_err_handle(struct hns_roce_dev *hr_dev,
	default:
		break;
	}
}

static void hns_roce_qp_err_handle(struct hns_roce_dev *hr_dev,
				   struct hns_roce_aeqe *aeqe,
				   int event_type)
{
	struct device *dev = &hr_dev->pdev->dev;
	int phy_port;
	int qpn;

	hns_roce_qp_event(hr_dev, roce_get_field(aeqe->event.qp_event.qp,
	qpn = roce_get_field(aeqe->event.qp_event.qp,
			     HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M,
					 HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S),
			  roce_get_field(aeqe->asyn,
					 HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
					 HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S));
			     HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S);
	phy_port = roce_get_field(aeqe->event.qp_event.qp,
			HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_M,
			HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_S);
	if (qpn <= 1)
		qpn = HNS_ROCE_MAX_PORTS * qpn + phy_port;

	switch (event_type) {
	case HNS_ROCE_EVENT_TYPE_INV_REQ_LOCAL_WQ_ERROR:
		dev_warn(dev, "Invalid Req Local Work Queue Error.\n"
			      "QP %d, phy_port %d.\n", qpn, phy_port);
		break;
	case HNS_ROCE_EVENT_TYPE_WQ_CATAS_ERROR:
		hns_roce_wq_catas_err_handle(hr_dev, aeqe, qpn);
		break;
	case HNS_ROCE_EVENT_TYPE_LOCAL_WQ_ACCESS_ERROR:
		hns_roce_local_wq_access_err_handle(hr_dev, aeqe, qpn);
		break;
	default:
		break;
	}

	hns_roce_qp_event(hr_dev, qpn, event_type);
}

static void hns_roce_cq_err_handle(struct hns_roce_dev *hr_dev,
				   struct hns_roce_aeqe *aeqe,
				   int event_type)
{
	struct device *dev = &hr_dev->pdev->dev;
	u32 cqn;

	cqn = le32_to_cpu(roce_get_field(aeqe->event.cq_event.cq,
		    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
		    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S));

	switch (event_type) {
	case HNS_ROCE_EVENT_TYPE_CQ_ACCESS_ERROR:
		dev_warn(dev, "CQ 0x%x access err.\n", cqn);
		break;
	case HNS_ROCE_EVENT_TYPE_CQ_OVERFLOW:
		dev_warn(dev, "CQ 0x%x overflow\n", cqn);
		break;
	case HNS_ROCE_EVENT_TYPE_CQ_ID_INVALID:
		dev_warn(dev, "CQ 0x%x ID invalid.\n", cqn);
		break;
	default:
		break;
	}

	hns_roce_cq_event(hr_dev, cqn, event_type);
}

static void hns_roce_db_overflow_handle(struct hns_roce_dev *hr_dev,
@@ -185,7 +228,7 @@ static int hns_roce_aeq_int(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
	struct device *dev = &hr_dev->pdev->dev;
	struct hns_roce_aeqe *aeqe;
	int aeqes_found = 0;
	int qpn = 0;
	int event_type;

	while ((aeqe = next_aeqe_sw(eq))) {
		dev_dbg(dev, "aeqe = %p, aeqe->asyn.event_type = 0x%lx\n", aeqe,
@@ -195,9 +238,10 @@ static int hns_roce_aeq_int(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
		/* Memory barrier */
		rmb();

		switch (roce_get_field(aeqe->asyn,
		event_type = roce_get_field(aeqe->asyn,
				HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
			HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S)) {
				HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S);
		switch (event_type) {
		case HNS_ROCE_EVENT_TYPE_PATH_MIG:
			dev_warn(dev, "PATH MIG not supported\n");
			break;
@@ -211,23 +255,9 @@ static int hns_roce_aeq_int(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
			dev_warn(dev, "PATH MIG failed\n");
			break;
		case HNS_ROCE_EVENT_TYPE_INV_REQ_LOCAL_WQ_ERROR:
			dev_warn(dev, "qpn = 0x%lx\n",
			roce_get_field(aeqe->event.qp_event.qp,
				       HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M,
				       HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S));
			hns_roce_qp_event(hr_dev,
				roce_get_field(aeqe->event.qp_event.qp,
					HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M,
					HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S),
				roce_get_field(aeqe->asyn,
					HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
					HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S));
			break;
		case HNS_ROCE_EVENT_TYPE_WQ_CATAS_ERROR:
			hns_roce_wq_catas_err_handle(hr_dev, aeqe, qpn);
			break;
		case HNS_ROCE_EVENT_TYPE_LOCAL_WQ_ACCESS_ERROR:
			hns_roce_local_wq_access_err_handle(hr_dev, aeqe, qpn);
			hns_roce_qp_err_handle(hr_dev, aeqe, event_type);
			break;
		case HNS_ROCE_EVENT_TYPE_SRQ_LIMIT_REACH:
		case HNS_ROCE_EVENT_TYPE_SRQ_CATAS_ERROR:
@@ -235,40 +265,9 @@ static int hns_roce_aeq_int(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
			dev_warn(dev, "SRQ not support!\n");
			break;
		case HNS_ROCE_EVENT_TYPE_CQ_ACCESS_ERROR:
			dev_warn(dev, "CQ 0x%lx access err.\n",
			roce_get_field(aeqe->event.cq_event.cq,
				       HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
				       HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S));
			hns_roce_cq_event(hr_dev,
			le32_to_cpu(roce_get_field(aeqe->event.cq_event.cq,
				    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
				    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S)),
			roce_get_field(aeqe->asyn,
				       HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
				       HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S));
			break;
		case HNS_ROCE_EVENT_TYPE_CQ_OVERFLOW:
			dev_warn(dev, "CQ 0x%lx overflow\n",
			roce_get_field(aeqe->event.cq_event.cq,
				       HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
				       HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S));
			hns_roce_cq_event(hr_dev,
			le32_to_cpu(roce_get_field(aeqe->event.cq_event.cq,
				    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
				    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S)),
			roce_get_field(aeqe->asyn,
				       HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
				       HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S));
			break;
		case HNS_ROCE_EVENT_TYPE_CQ_ID_INVALID:
			dev_warn(dev, "CQ ID invalid.\n");
			hns_roce_cq_event(hr_dev,
			le32_to_cpu(roce_get_field(aeqe->event.cq_event.cq,
				    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M,
				    HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S)),
			roce_get_field(aeqe->asyn,
				       HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
				       HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S));
			hns_roce_cq_err_handle(hr_dev, aeqe, event_type);
			break;
		case HNS_ROCE_EVENT_TYPE_PORT_CHANGE:
			dev_warn(dev, "port change.\n");
@@ -290,11 +289,8 @@ static int hns_roce_aeq_int(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq)
				     HNS_ROCE_AEQE_EVENT_CE_EVENT_CEQE_CEQN_S));
			break;
		default:
			dev_warn(dev, "Unhandled event 0x%lx on EQ %d at index %u\n",
				 roce_get_field(aeqe->asyn,
					      HNS_ROCE_AEQE_U32_4_EVENT_TYPE_M,
					      HNS_ROCE_AEQE_U32_4_EVENT_TYPE_S),
				 eq->eqn, eq->cons_index);
			dev_warn(dev, "Unhandled event %d on EQ %d at index %u\n",
				 event_type, eq->eqn, eq->cons_index);
			break;
		};

+4 −0
Original line number Diff line number Diff line
@@ -107,6 +107,10 @@ struct hns_roce_aeqe {
#define HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_M   \
	(((1UL << 24) - 1) << HNS_ROCE_AEQE_EVENT_QP_EVENT_QP_QPN_S)

#define HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_S 25
#define HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_M   \
	(((1UL << 3) - 1) << HNS_ROCE_AEQE_EVENT_QP_EVENT_PORT_NUM_S)

#define HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S 0
#define HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_M   \
	(((1UL << 16) - 1) << HNS_ROCE_AEQE_EVENT_CQ_EVENT_CQ_CQN_S)
Loading