From patchwork Fri Dec 29 11:26:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yixian Liu X-Patchwork-Id: 10136975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DDD3960318 for ; Fri, 29 Dec 2017 10:39:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D70082DEEE for ; Fri, 29 Dec 2017 10:39:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9CC72DF07; Fri, 29 Dec 2017 10:39:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E5A92DEEE for ; Fri, 29 Dec 2017 10:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754417AbdL2Kj0 (ORCPT ); Fri, 29 Dec 2017 05:39:26 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:39740 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751759AbdL2Kj0 (ORCPT ); Fri, 29 Dec 2017 05:39:26 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1D6ACBE0AA5E5; Fri, 29 Dec 2017 18:39:23 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.361.1; Fri, 29 Dec 2017 18:39:19 +0800 From: Yixian Liu To: , CC: , Subject: [PATCH v4 for-next 2/2] RDMA/hns: Fix alignment problem of the doorbell Date: Fri, 29 Dec 2017 19:26:19 +0800 Message-ID: <1514546779-206832-3-git-send-email-liuyixian@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1514546779-206832-1-git-send-email-liuyixian@huawei.com> References: <1514546779-206832-1-git-send-email-liuyixian@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The array defined for doorbell is not guaranteed to be 64 bit aligned while we write it to the hardware with 64 bit alignment required. This patch fixes this problem by defining a union for doorbell to make sure it 64 bit alignment. Signed-off-by: Yixian Liu Signed-off-by: Lijun Ou Signed-off-by: Wei Hu (Xavier) --- v2 -> v3: 1. delete the unnecessary assignment for doorbell64. --- drivers/infiniband/hw/hns/hns_roce_device.h | 5 +++++ drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index dde5178..4c08b00 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h @@ -569,6 +569,11 @@ struct hns_roce_eq_table { void __iomem **eqc_base; /* only for hw v1 */ }; +union hns_roce_eq_db { + __le64 doorbell64; + __le32 doorbell[2]; +}; + struct hns_roce_caps { u8 num_ports; int gid_table_len[HNS_ROCE_MAX_PORTS]; diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 68dc718..9c5b3ed 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -3172,33 +3172,33 @@ static int hns_roce_v2_modify_cq(struct ib_cq *cq, u16 cq_count, u16 cq_period) static void set_eq_cons_index_v2(struct hns_roce_eq *eq) { - u32 doorbell[2]; + union hns_roce_eq_db db; - doorbell[0] = 0; - doorbell[1] = 0; + db.doorbell[0] = 0; + db.doorbell[1] = 0; if (eq->type_flag == HNS_ROCE_AEQ) { - roce_set_field(doorbell[0], HNS_ROCE_V2_EQ_DB_CMD_M, + roce_set_field(db.doorbell[0], HNS_ROCE_V2_EQ_DB_CMD_M, HNS_ROCE_V2_EQ_DB_CMD_S, eq->arm_st == HNS_ROCE_V2_EQ_ALWAYS_ARMED ? HNS_ROCE_EQ_DB_CMD_AEQ : HNS_ROCE_EQ_DB_CMD_AEQ_ARMED); } else { - roce_set_field(doorbell[0], HNS_ROCE_V2_EQ_DB_TAG_M, + roce_set_field(db.doorbell[0], HNS_ROCE_V2_EQ_DB_TAG_M, HNS_ROCE_V2_EQ_DB_TAG_S, eq->eqn); - roce_set_field(doorbell[0], HNS_ROCE_V2_EQ_DB_CMD_M, + roce_set_field(db.doorbell[0], HNS_ROCE_V2_EQ_DB_CMD_M, HNS_ROCE_V2_EQ_DB_CMD_S, eq->arm_st == HNS_ROCE_V2_EQ_ALWAYS_ARMED ? HNS_ROCE_EQ_DB_CMD_CEQ : HNS_ROCE_EQ_DB_CMD_CEQ_ARMED); } - roce_set_field(doorbell[1], HNS_ROCE_V2_EQ_DB_PARA_M, + roce_set_field(db.doorbell[1], HNS_ROCE_V2_EQ_DB_PARA_M, HNS_ROCE_V2_EQ_DB_PARA_S, (eq->cons_index & HNS_ROCE_V2_CONS_IDX_M)); - hns_roce_write64_k(doorbell, eq->doorbell); + hns_roce_write64_k(db.doorbell, eq->doorbell); } static void hns_roce_v2_wq_catas_err_handle(struct hns_roce_dev *hr_dev,