All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: Rob Herring <robh@kernel.org>, Qiang Yu <yuq825@gmail.com>
Cc: "Marek Vasut" <marex@denx.de>,
	"Simon Shields" <simon@lineageos.org>,
	lima@lists.freedesktop.org,
	"Andreas Baierl" <ichgeh@imkreisrum.de>,
	"Maxime Ripard" <maxime.ripard@bootlin.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"Neil Armstrong" <narmstrong@baylibre.com>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	"Vasily Khoruzhick" <anarsoul@gmail.com>,
	"David Airlie" <airlied@linux.ie>, "Sean Paul" <sean@poorly.run>,
	"Erico Nunes" <nunes.erico@gmail.com>
Subject: Re: [PATCH v3 2/2] drm/lima: driver for ARM Mali4xx GPUs
Date: Tue, 05 Mar 2019 12:18:47 -0800	[thread overview]
Message-ID: <87imwx5b2w.fsf@anholt.net> (raw)
In-Reply-To: <CAL_Jsq+bMhBtVr7aHGO8HeULQHg6=KJZYsgUCQY8MzJMTCnHrA@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 3237 bytes --]

Rob Herring <robh@kernel.org> writes:

> On Fri, Mar 1, 2019 at 11:23 PM Qiang Yu <yuq825@gmail.com> wrote:
>>
>> > > +static struct lima_fence *lima_fence_create(struct lima_sched_pipe *pipe)
>> > > +{
>> > > +       struct lima_fence *fence;
>> > > +
>> > > +       fence = kmem_cache_zalloc(lima_fence_slab, GFP_KERNEL);
>> >
>> > Out of curiosity, what is the benefit of using a separate slab here?
>> > If this is beneficial, then other drivers should do this too and it
>> > should be common. Otherwise, it adds some complexity.
>>
>> fence is pretty frequently alloc free struct, so make it a slab. And it's used
>> in get/put pattern, so may live longer than embedded struct. This is referenced
>> from amdgpu driver.
>>
>> >
>> > And maybe the slab should be initialzed in probe rather than module_init.
>> >
>> Either way is OK. But live in module init is easier not to init twice
>> for two devices.
>
> True, but I was thinking more about initializing it for 0 devices
> which can be common if built-in on a multi-platform kernel.
>
>> > > +int lima_vm_bo_add(struct lima_vm *vm, struct lima_bo *bo, bool create)
>> > > +{
>> > > +       struct lima_bo_va *bo_va;
>> > > +       int err;
>> > > +
>> > > +       mutex_lock(&bo->lock);
>> > > +
>> > > +       bo_va = lima_vm_bo_find(vm, bo);
>> > > +       if (bo_va) {
>> > > +               bo_va->ref_count++;
>> > > +               mutex_unlock(&bo->lock);
>> > > +               return 0;
>> > > +       }
>> > > +
>> > > +       /* should not create new bo_va if not asked by caller */
>> > > +       if (!create) {
>> > > +               mutex_unlock(&bo->lock);
>> > > +               return -ENOENT;
>> > > +       }
>> > > +
>> > > +       bo_va = kzalloc(sizeof(*bo_va), GFP_KERNEL);
>> > > +       if (!bo_va) {
>> > > +               err = -ENOMEM;
>> > > +               goto err_out0;
>> > > +       }
>> > > +
>> > > +       bo_va->vm = vm;
>> > > +       bo_va->ref_count = 1;
>> > > +
>> > > +       mutex_lock(&vm->lock);
>> > > +
>> > > +       err = drm_mm_insert_node(&vm->mm, &bo_va->node, bo->gem.size);
>> > > +       if (err)
>> > > +               goto err_out1;
>> > > +
>> > > +       err = lima_vm_map_page_table(vm, bo->pages_dma_addr, bo_va->node.start,
>> > > +                                    bo_va->node.start + bo_va->node.size - 1);
>> > > +       if (err)
>> > > +               goto err_out2;
>> > > +
>> > > +       mutex_unlock(&vm->lock);
>> > > +
>> > > +       list_add_tail(&bo_va->list, &bo->va);
>> >
>> > So you can have 1 BO at multiple VAs? Is that really needed?
>> >
>> Actually 1 BO can't have multi VA in single VM, but one VA in each VM.
>> When a BO is exported/imported between two process, i.e. xserver and client,
>> two processes have different VM, so can't make sure it can be mapped at the same
>> place.
>
> Right, but when you import a BO, a new BO struct is created and
> therefore a new list. If there's only 1 VA, then you don't need a
> list. Just move 'node' into lima_bo. (It is possible I missed some
> detail though.)

You only make a new GEM BO struct on importing a new dmabuf into the
driver -- export/imports between process share the same GEM BO struct
(unless I've misread what you're saying).

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2019-03-05 20:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27 13:41 [PATCH v3 2/2] drm/lima: driver for ARM Mali4xx GPUs Qiang Yu
2019-02-27 20:29 ` Sam Ravnborg
2019-02-27 21:41 ` Rob Herring
2019-03-02  2:32   ` Qiang Yu
2019-03-02 18:23     ` Rob Clark
2019-03-04 17:20       ` Rob Herring
2019-03-05  1:36         ` Qiang Yu
2019-03-02  5:22   ` Qiang Yu
2019-03-05 15:31     ` Rob Herring
2019-03-05 20:18       ` Eric Anholt [this message]
2019-03-06  2:01         ` Qiang Yu

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=87imwx5b2w.fsf@anholt.net \
    --to=eric@anholt.net \
    --cc=airlied@linux.ie \
    --cc=anarsoul@gmail.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ichgeh@imkreisrum.de \
    --cc=lima@lists.freedesktop.org \
    --cc=marex@denx.de \
    --cc=maxime.ripard@bootlin.com \
    --cc=narmstrong@baylibre.com \
    --cc=nunes.erico@gmail.com \
    --cc=robh@kernel.org \
    --cc=sean@poorly.run \
    --cc=simon@lineageos.org \
    --cc=yuq825@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.