The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Re: [PATCH 11/23] dmaengine: sdxi: Add client context alloc and release APIs
       [not found]   ` <aeXhkIZgwGttlJB0@lizhi-Precision-Tower-5810>
@ 2026-05-11 17:55     ` Lynch, Nathan
  0 siblings, 0 replies; only message in thread
From: Lynch, Nathan @ 2026-05-11 17:55 UTC (permalink / raw)
  To: Frank Li
  Cc: Vinod Koul, Wei Huang, Mario Limonciello, Bjorn Helgaas,
	Jonathan Cameron, Stephen Bates, PradeepVineshReddy.Kodamati,
	John.Kariuki, linux-pci, linux-kernel, dmaengine

Hi Frank,

Just following up on one thing as I prepare to post v2.

On 4/20/2026 3:19 AM, Frank Li wrote:
>> +/*
>> + * Allocate the context ID; link the context back to the device;
>> + * perform some final initialization of the context based on the ID
>> + * allocated; update the context tables.
>> + */
>> +static int register_cxt(struct sdxi_dev *sdxi, struct sdxi_cxt *cxt)
>> +{
>> +     int err;
>> +
>> +     CLASS(sdxi_alloc_cxt_id, slot)(sdxi, cxt);
>> +     if (slot.id < 0)
>> +             return slot.id;
> 
> I like use cleanup to do this. define error macro, like cleanup.h
> 
>  *      ACQUIRE(pci_dev_try, lock)(dev);
>  *      rc = ACQUIRE_ERR(pci_dev_try, &lock);
> 
> so hidden detail "id" in sdxi_alloc_cxt_id.
> 
> Or you can refer runtime pm method, save necceary information to "cxt"
> 
> DEFINE_GUARD_COND(pm_runtime_active, _try,
>                   pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> 
>> +
>> +     cxt->sdxi = sdxi;
>> +     cxt->id = slot.id;
>> +     cxt->db = sdxi->dbs + slot.id * sdxi->db_stride;
>> +
>> +     err = sdxi_publish_cxt(cxt);
>> +     if (err)
>> +             return err;
>> +
>> +     take_sdxi_cxt_id(slot);
> 
> I undestand try to keep id to avoid call xa_erase. but it hidden too much
> detail.
> 
> If only one error branch, using cleanup here have not bring too much beneafit.
> 
> 
> Idealy logic
> 
>         id = __free(your_xa_erase) your_xa_alloc()
>         ...
>         ctx->id = no_free_ptr(id).

Non-pointer types tend to require a class for automatic cleanup AFAICT
but I think I get pretty close to this in v2. I also reworked the
context allocation logic to reserve IDs earlier.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-11 17:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260410-sdxi-base-v1-0-1d184cb5c60a@amd.com>
     [not found] ` <20260410-sdxi-base-v1-11-1d184cb5c60a@amd.com>
     [not found]   ` <aeXhkIZgwGttlJB0@lizhi-Precision-Tower-5810>
2026-05-11 17:55     ` [PATCH 11/23] dmaengine: sdxi: Add client context alloc and release APIs Lynch, Nathan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox