From: Leon Romanovsky <leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Yixian Liu <liuyixian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Cc: jgg-uk2M96/98Pc@public.gmane.org,
dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH for-next 2/2] RDMA/hns: Fix alignment problem of the doorbell
Date: Tue, 26 Dec 2017 10:15:26 +0200 [thread overview]
Message-ID: <20171226081526.GB10734@mtr-leonro.local> (raw)
In-Reply-To: <1514209039-9388-3-git-send-email-liuyixian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 3148 bytes --]
On Mon, Dec 25, 2017 at 09:37:19PM +0800, Yixian Liu wrote:
> 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.
Are you sure that it gives you alignment?
The macros ALIGN/PTR_ALIGN are usually used for that.
Thanks
>
> Signed-off-by: Yixian Liu <liuyixian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Lijun Ou <oulijun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
> 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..defc4ee 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_db {
> + u64 doorbell64;
> + u32 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 7f393f6..ee26bbd 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_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);
>
> /* Make sure we update the consumer index of EQ before
> * accessing it later
> --
> 1.9.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-12-26 8:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-25 13:37 [PATCH for-next 0/2] Bugfixes for eq support in hns Yixian Liu
[not found] ` <1514209039-9388-1-git-send-email-liuyixian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-12-25 13:37 ` [PATCH for-next 1/2] RDMA/hns: Add detailed comments for mb() call Yixian Liu
[not found] ` <1514209039-9388-2-git-send-email-liuyixian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-12-26 7:37 ` Leon Romanovsky
2017-12-25 13:37 ` [PATCH for-next 2/2] RDMA/hns: Fix alignment problem of the doorbell Yixian Liu
[not found] ` <1514209039-9388-3-git-send-email-liuyixian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-12-26 8:15 ` Leon Romanovsky [this message]
[not found] ` <20171226081526.GB10734-U/DQcQFIOTAAJjI8aNfphQ@public.gmane.org>
2017-12-27 10:01 ` Liuyixian (Eason)
[not found] ` <6f657295-ab91-a940-c1d8-8d85dcedb4ea-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-12-27 16:44 ` Jason Gunthorpe
[not found] ` <20171227164407.GB25436-uk2M96/98Pc@public.gmane.org>
2017-12-28 6:48 ` Liuyixian (Eason)
[not found] ` <2a0a56fb-1ec8-dfc9-3c29-c9bae7bd9bae-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2017-12-28 8:31 ` Liuyixian (Eason)
2017-12-28 16:00 ` Jason Gunthorpe
2017-12-27 17:40 ` Ruhl, Michael J
[not found] ` <14063C7AD467DE4B82DEDB5C278E86639F0E6137-AtyAts71sc88Ug9VwtkbtrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-12-28 6:51 ` Liuyixian (Eason)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171226081526.GB10734@mtr-leonro.local \
--to=leon-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jgg-uk2M96/98Pc@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=liuyixian-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox