Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1437861
| From | "Franklin S Cooper Jr." <fcooper@ti.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist |
| Date | 2016-07-06 19:30 +0200 |
| Message-ID | <rRYO5-3Ee-3@gated-at.bofh.it> (permalink) |
| References | <rOGaZ-1Du-1@gated-at.bofh.it> <rOGb0-1Du-23@gated-at.bofh.it> <rRS5X-7V0-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 07/06/2016 05:15 AM, Sekhar Nori wrote:
> On Monday 27 June 2016 08:24 PM, Franklin S Cooper Jr wrote:
>
>> +/*
>> + * sg_table_clone - Duplicate an existing sg_table including chained sgl
>
> This function should probably be called sg_clone_table() to be
> consistent with sg_alloc_table(), sg_free_table() etc.
Will fix.
>
>> + * @orig_table: Original sg_table to be duplicated
>> + * @len: Total length of sg while taking chaining into account
>> + * @gfp_mask: GFP allocation mask
>> + *
>> + * Description:
>> + * Clone a sg_table along with chained sgl. This cloned copy may be
>> + * modified in some ways while keeping the original table and sgl in tact.
>> + * Also allow the cloned sgl copy to have a smaller length than the original
>> + * which may reduce the sgl total sg entries.
>> + *
>> + * Returns:
>> + * Pointer to new kmalloced sg_table, ERR_PTR() on error
>> + *
>> + */
>> +struct sg_table *sg_table_clone(struct sg_table *orig_table, u64 len,
>> + gfp_t gfp_mask)
>> +{
>> + struct sg_table *table;
>> +
>> + table = kmalloc(sizeof(struct sg_table), gfp_mask);
>
> Can you use sg_alloc_table() to allocate the new table? The way you have
> it now, it looks like users will need to use kfree() to free a cloned
> table and use sg_free_table() otherwise. It will be nice if
> sg_free_table() can be used consistently.
Sg_alloc_table doesn't actually allocate a struct sg_table. It allocates
a single sgl or chained sgl. Drivers that use sg_table manually allocate
it via kmalloc. One change that might make sense is to not kmalloc
sg_table but instead have a user pass a pointer to a preallocated
instance of it. This way it will mimic how sg_table is typically handled.
>
> Regards,
> Sekhar
>
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[RFC] [PATCH v2 0/3] scatterlist: Add support to clone sg_table Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
[RFC] [PATCH v2 3/3] spi: omap2-mcspi: Use the SPI framework to handle DMA mapping Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
[RFC] [PATCH v2 2/3] spi: omap2-mcspi: Add comments for RX only DMA buffer workaround Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
[RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Franklin S Cooper Jr <fcooper@ti.com> - 2016-06-27 17:00 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Mark Brown <broonie@kernel.org> - 2016-07-05 17:00 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-07-05 18:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-07-05 19:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-06 19:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-07-06 19:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-06 21:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Robert Jarzmik <robert.jarzmik@free.fr> - 2016-07-07 00:10 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Mark Brown <broonie@kernel.org> - 2016-07-07 10:40 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Robert Jarzmik <robert.jarzmik@free.fr> - 2016-07-07 19:50 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Mark Brown <broonie@kernel.org> - 2016-07-08 10:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-07 18:00 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Sekhar Nori <nsekhar@ti.com> - 2016-07-06 12:20 +0200
Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist "Franklin S Cooper Jr." <fcooper@ti.com> - 2016-07-06 19:30 +0200
csiph-web