mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: Jeff Hugo <jeff.hugo@oss.qualcomm.com>, <ogabbay@kernel.org>,
	<jacek.lawrynowicz@linux.intel.com>, <mario.limonciello@amd.com>,
	<dri-devel@lists.freedesktop.org>
Cc: <linux-kernel@vger.kernel.org>, <min.ma@amd.com>,
	<max.zhen@amd.com>, <sonal.santan@amd.com>, <king.tam@amd.com>
Subject: Re: [PATCH V1] accel/amdxdna: Add BO import and export
Date: Fri, 21 Mar 2025 12:52:35 -0700	[thread overview]
Message-ID: <e7358027-6a8b-85b0-3ccd-cb09b3a9ce7d@amd.com> (raw)
In-Reply-To: <d2d6b84b-7463-483a-a634-396b5099ef56@oss.qualcomm.com>


On 3/21/25 08:15, Jeff Hugo wrote:
> On 3/6/2025 11:03 AM, Lizhi Hou wrote:
>> +struct drm_gem_object *
>> +amdxdna_gem_prime_import(struct drm_device *dev, struct dma_buf 
>> *dma_buf)
>> +{
>> +    struct dma_buf_attachment *attach;
>> +    struct drm_gem_object *gobj;
>> +    struct sg_table *sgt;
>> +    int ret;
>> +
>> +    attach = dma_buf_attach(dma_buf, dev->dev);
>> +    if (IS_ERR(attach))
>> +        return ERR_CAST(attach);
>> +
>> +    get_dma_buf(dma_buf);
>> +
>> +    sgt = dma_buf_map_attachment_unlocked(attach, DMA_BIDIRECTIONAL);
>> +    if (IS_ERR(sgt)) {
>> +        ret = PTR_ERR(sgt);
>> +        goto fail_detach;
>> +    }
>> +
>> +    gobj = drm_gem_shmem_prime_import_sg_table(dev, attach, sgt);
>> +    if (IS_ERR(gobj)) {
>> +        ret = PTR_ERR(gobj);
>> +        goto fail_unmap;
>> +    }
>> +
>> +    gobj->import_attach = attach;
>> +    gobj->resv = dma_buf->resv;
>> +
>> +    return gobj;
>> +
>> +fail_unmap:
>> +    dma_buf_unmap_attachment_unlocked(attach, sgt, DMA_BIDIRECTIONAL);
>> +fail_detach:
>> +    dma_buf_detach(dma_buf, attach);
>> +    dma_buf_put(dma_buf);
>
> You attach() and then get(), so normal "reverse order" cleanup would 
> be put(), then detach(). That is not what you do here. Should this be 
> reordered, or should you get() then attach() first?

I referred drm_gem_prime_import_dev(). And I agree with you. It looks 
better to get() before attach(). I will respin V2 which will also 
contain another small update for this patch.


Thanks,

Lizhi

>
>

  reply	other threads:[~2025-03-21 19:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-06 18:03 Lizhi Hou
2025-03-21 15:15 ` Jeff Hugo
2025-03-21 19:52   ` Lizhi Hou [this message]
2025-03-25 18:14     ` Lizhi Hou

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=e7358027-6a8b-85b0-3ccd-cb09b3a9ce7d@amd.com \
    --to=lizhi.hou@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jacek.lawrynowicz@linux.intel.com \
    --cc=jeff.hugo@oss.qualcomm.com \
    --cc=king.tam@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=max.zhen@amd.com \
    --cc=min.ma@amd.com \
    --cc=ogabbay@kernel.org \
    --cc=sonal.santan@amd.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

all inboxes | Powered by JetHome®