From: Gal Pressman <galpress@amazon.com>
To: Michal Kalderon <mkalderon@marvell.com>
Cc: Ariel Elior <aelior@marvell.com>, "jgg@ziepe.ca" <jgg@ziepe.ca>,
"dledford@redhat.com" <dledford@redhat.com>,
"bmt@zurich.ibm.com" <bmt@zurich.ibm.com>,
"sleybo@amazon.com" <sleybo@amazon.com>,
"leon@kernel.org" <leon@kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>
Subject: Re: [PATCH v8 rdma-next 3/7] RDMA/efa: Use the common mmap_xa helpers
Date: Sun, 1 Sep 2019 09:56:58 +0300 [thread overview]
Message-ID: <61cf039c-793e-e9e6-60e0-cd93b6da4815@amazon.com> (raw)
In-Reply-To: <MN2PR18MB31820C96A5906F9054AE23D6A1BD0@MN2PR18MB3182.namprd18.prod.outlook.com>
On 30/08/2019 9:15, Michal Kalderon wrote:
>> From: Gal Pressman <galpress@amazon.com>
>> Sent: Thursday, August 29, 2019 5:21 PM
>>
>> On 27/08/2019 16:28, Michal Kalderon wrote:
>>> +static void efa_qp_user_mmap_entries_remove(struct efa_ucontext
>> *ucontext,
>>> + struct efa_qp *qp)
>>> +{
>>> + rdma_user_mmap_entry_remove(&ucontext->ibucontext, qp-
>>> sq_db_mmap_key);
>>> + rdma_user_mmap_entry_remove(&ucontext->ibucontext,
>>> + qp->llq_desc_mmap_key);
>>> + rdma_user_mmap_entry_remove(&ucontext->ibucontext, qp-
>>> rq_mmap_key);
>>> + rdma_user_mmap_entry_remove(&ucontext->ibucontext,
>>> +qp->rq_db_mmap_key);
>>
>> Please remove the entries in reverse insertion order.
> I don't mind fixing, but why ?
So the flows will be symmetric.
>>
>>> +}
>>> +
>>> @@ -767,15 +726,17 @@ struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
>>>
>>> return &qp->ibqp;
>>>
>>> +err_remove_mmap_entries:
>>> + efa_qp_user_mmap_entries_remove(ucontext, qp);
>>> err_destroy_qp:
>>> efa_destroy_qp_handle(dev, create_qp_resp.qp_handle);
>>> err_free_mapped:
>>> - if (qp->rq_size) {
>>> + if (qp->rq_dma_addr)
>>
>> What's the difference?
> Seemed a better query since it now only covers the rq_dma_addr unmapping.
>
>>
>>> dma_unmap_single(&dev->pdev->dev, qp->rq_dma_addr,
>> qp->rq_size,
>>> DMA_TO_DEVICE);
>>> - if (!rq_entry_inserted)
>>> - free_pages_exact(qp->rq_cpu_addr, qp->rq_size);
>>> - }
>>> +
>>> + if (qp->rq_mmap_key == RDMA_USER_MMAP_INVALID)
>>> + free_pages_exact(qp->rq_cpu_addr, qp->rq_size);
>>
>> This should be inside the previous if statement, otherwise it might try to free
>> pages that weren't allocated.
> If they weren't allocated the key will be INVALID and they won't be freed.
If the key is INVALID you call free_pages_exact, but rq_cpu_addr might have
never been allocated (if RQ is of size zero).
>
>>
>>> err_free_qp:
>>> kfree(qp);
>>> err_out:
>>> @@ -887,6 +848,7 @@ static int efa_destroy_cq_idx(struct efa_dev *dev,
>>> int cq_idx)
>>>
>>> void efa_destroy_cq(struct ib_cq *ibcq, struct ib_udata *udata) {
>>> + struct efa_ucontext *ucontext;
>>
>> Reverse xmas tree.
> ok
>>
>>> struct efa_dev *dev = to_edev(ibcq->device);
>>> struct efa_cq *cq = to_ecq(ibcq);
>>>
>>> @@ -894,20 +856,33 @@ void efa_destroy_cq(struct ib_cq *ibcq, struct
>> ib_udata *udata)
>>> "Destroy cq[%d] virt[0x%p] freed: size[%lu], dma[%pad]\n",
>>> cq->cq_idx, cq->cpu_addr, cq->size, &cq->dma_addr);
>>>
>>> + ucontext = rdma_udata_to_drv_context(udata, struct efa_ucontext,
>>> + ibucontext);
>>> efa_destroy_cq_idx(dev, cq->cq_idx);
>>> dma_unmap_single(&dev->pdev->dev, cq->dma_addr, cq->size,
>>> DMA_FROM_DEVICE);
>>> + rdma_user_mmap_entry_remove(&ucontext->ibucontext,
>>> + cq->mmap_key);
>>
>> Entry removal should be first.
> Why ? removing can lead to freeing, why would we want that before unmapping ?
Makes sense, thanks.
>>
>>> }
>>>
next prev parent reply other threads:[~2019-09-01 6:57 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 13:28 [PATCH v8 rdma-next 0/7] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Michal Kalderon
2019-08-27 13:28 ` [PATCH v8 rdma-next 1/7] RDMA/core: Move core content from ib_uverbs to ib_core Michal Kalderon
2019-08-27 13:28 ` [PATCH v8 rdma-next 2/7] RDMA/core: Create mmap database and cookie helper functions Michal Kalderon
2019-08-29 11:35 ` Gal Pressman
2019-08-29 12:40 ` Jason Gunthorpe
2019-08-30 6:10 ` [EXT] " Michal Kalderon
2019-08-27 13:28 ` [PATCH v8 rdma-next 3/7] RDMA/efa: Use the common mmap_xa helpers Michal Kalderon
2019-08-29 14:20 ` Gal Pressman
2019-08-30 6:15 ` Michal Kalderon
2019-09-01 6:56 ` Gal Pressman [this message]
2019-09-02 7:47 ` Michal Kalderon
2019-08-27 13:28 ` [PATCH v8 rdma-next 4/7] RDMA/siw: " Michal Kalderon
2019-08-27 13:28 ` [PATCH v8 rdma-next 5/7] RDMA/qedr: Use the common mmap API Michal Kalderon
2019-08-27 13:28 ` [PATCH v8 rdma-next 6/7] RDMA/qedr: Add doorbell overflow recovery support Michal Kalderon
2019-08-27 13:28 ` [PATCH v8 rdma-next 7/7] RDMA/qedr: Add iWARP doorbell " Michal Kalderon
2019-08-28 14:41 ` [PATCH v8 rdma-next 0/7] RDMA/qedr: Use the doorbell overflow recovery mechanism for RDMA Gal Pressman
2019-08-30 12:07 ` [PATCH v8 rdma-next 4/7] RDMA/siw: Use the common mmap_xa helpers Bernard Metzler
2019-08-30 12:42 ` [EXT] " Michal Kalderon
2019-08-30 13:19 ` Bernard Metzler
2019-09-02 8:00 ` Michal Kalderon
2019-09-02 10:55 ` Bernard Metzler
2019-09-02 11:21 ` Michal Kalderon
2019-09-02 11:18 ` Bernard Metzler
2019-09-02 13:16 ` Michal Kalderon
2019-09-02 14:17 ` Bernard Metzler
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=61cf039c-793e-e9e6-60e0-cd93b6da4815@amazon.com \
--to=galpress@amazon.com \
--cc=aelior@marvell.com \
--cc=bmt@zurich.ibm.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mkalderon@marvell.com \
--cc=sleybo@amazon.com \
/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;
as well as URLs for NNTP newsgroup(s).