From: "Franklin S Cooper Jr." <fcooper-l0cyMroinI0@public.gmane.org>
To: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>,
<david.s.gordon-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
<axboe-b10kYP2dOMg@public.gmane.org>,
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
<ming.l-Vzezgt5dB6uUEJcrhfAQsw@public.gmane.org>,
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
<peter.ujfalusi-l0cyMroinI0@public.gmane.org>
Subject: Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist
Date: Wed, 6 Jul 2016 12:20:54 -0500 [thread overview]
Message-ID: <577D3DF6.6000406@ti.com> (raw)
In-Reply-To: <577CDA45.80408-l0cyMroinI0@public.gmane.org>
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
>
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: "Franklin S Cooper Jr." <fcooper@ti.com>
To: Sekhar Nori <nsekhar@ti.com>, <david.s.gordon@intel.com>,
<axboe@fb.com>, <akpm@linux-foundation.org>,
<ming.l@ssi.samsung.com>, <linux-kernel@vger.kernel.org>,
<broonie@kernel.org>, <linux-spi@vger.kernel.org>,
<peter.ujfalusi@ti.com>
Subject: Re: [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist
Date: Wed, 6 Jul 2016 12:20:54 -0500 [thread overview]
Message-ID: <577D3DF6.6000406@ti.com> (raw)
In-Reply-To: <577CDA45.80408@ti.com>
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
>
next prev parent reply other threads:[~2016-07-06 17:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-27 14:54 [RFC] [PATCH v2 0/3] scatterlist: Add support to clone sg_table Franklin S Cooper Jr
[not found] ` <1467039249-7816-1-git-send-email-fcooper-l0cyMroinI0@public.gmane.org>
2016-06-27 14:54 ` [RFC] [PATCH v2 1/3] scatterlist: Add support to clone scatterlist Franklin S Cooper Jr
2016-06-27 14:54 ` Franklin S Cooper Jr
[not found] ` <1467039249-7816-2-git-send-email-fcooper-l0cyMroinI0@public.gmane.org>
2016-07-05 14:49 ` Mark Brown
2016-07-05 14:49 ` Mark Brown
2016-07-05 16:47 ` Andy Shevchenko
2016-07-05 17:10 ` Andy Shevchenko
2016-07-05 17:10 ` Andy Shevchenko
[not found] ` <CAHp75VfR=TKfVN=03jvGy5oZRA_-ASb8Vb_A4+x3OrkpZT6PoQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-06 17:09 ` Franklin S Cooper Jr.
2016-07-06 17:09 ` Franklin S Cooper Jr.
2016-07-06 17:46 ` Andy Shevchenko
[not found] ` <CAHp75VcPLV-483ihn_RmHnDOc0iFMSdYj5_SrNevyqrrpeWatQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-07-06 19:39 ` Franklin S Cooper Jr.
2016-07-06 19:39 ` Franklin S Cooper Jr.
2016-07-06 22:04 ` Robert Jarzmik
[not found] ` <871t368lu6.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org>
2016-07-07 8:02 ` Mark Brown
2016-07-07 8:02 ` Mark Brown
[not found] ` <20160707080241.GE6247-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-07-07 17:43 ` Robert Jarzmik
2016-07-07 17:43 ` Robert Jarzmik
[not found] ` <87twg1739e.fsf-4ty26DBLk+jEm7gnYqmdkQ@public.gmane.org>
2016-07-08 8:18 ` Mark Brown
2016-07-08 8:18 ` Mark Brown
2016-07-12 17:14 ` Robert Jarzmik
2016-07-07 15:58 ` Franklin S Cooper Jr.
2016-07-07 15:58 ` Franklin S Cooper Jr.
2016-07-06 10:15 ` Sekhar Nori
2016-07-06 10:15 ` Sekhar Nori
[not found] ` <577CDA45.80408-l0cyMroinI0@public.gmane.org>
2016-07-06 17:20 ` Franklin S Cooper Jr. [this message]
2016-07-06 17:20 ` Franklin S Cooper Jr.
2016-06-27 14:54 ` [RFC] [PATCH v2 2/3] spi: omap2-mcspi: Add comments for RX only DMA buffer workaround Franklin S Cooper Jr
2016-06-27 14:54 ` Franklin S Cooper Jr
2016-06-27 14:54 ` [RFC] [PATCH v2 3/3] spi: omap2-mcspi: Use the SPI framework to handle DMA mapping Franklin S Cooper Jr
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=577D3DF6.6000406@ti.com \
--to=fcooper-l0cymroini0@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=axboe-b10kYP2dOMg@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=david.s.gordon-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ming.l-Vzezgt5dB6uUEJcrhfAQsw@public.gmane.org \
--cc=nsekhar-l0cyMroinI0@public.gmane.org \
--cc=peter.ujfalusi-l0cyMroinI0@public.gmane.org \
/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.