All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pandy Gao <pandy.gao-3arQi8VN3Tc@public.gmane.org>
To: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: "robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
	<robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Frank Li <frank.li-3arQi8VN3Tc@public.gmane.org>,
	Andy Duan <fugang.duan-3arQi8VN3Tc@public.gmane.org>
Subject: RE: [Patch V2 1/2] spi: imx: add lpspi bus driver
Date: Thu, 17 Nov 2016 09:55:41 +0000	[thread overview]
Message-ID: <AM4PR0401MB1780CDE562EEA1CE202E9572F6B10@AM4PR0401MB1780.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20161116173228.cqtt5j5eczgg26gn-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>

From: Mark Brown <mailto:broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Sent: Thursday, November 17, 2016 1:32 AM
> To: Pandy Gao <pandy.gao-3arQi8VN3Tc@public.gmane.org>
> Cc: robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org; linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Frank Li <frank.li-vgrsnd+bvIE@public.gmane.orgm>;
> Andy Duan <fugang.duan-3arQi8VN3Tc@public.gmane.org>
> Subject: Re: [Patch V2 1/2] spi: imx: add lpspi bus driver
> 
> On Tue, Nov 15, 2016 at 09:33:50PM +0800, Gao Pan wrote:
> 
> > +static int
> > +fsl_lpspi_prepare_message(struct spi_master *master, struct
> > +spi_message *msg) {
> > +	struct fsl_lpspi_data *fsl_lpspi = spi_master_get_devdata(master);
> > +
> > +	return clk_enable(fsl_lpspi->clk);
> > +}
> 
> Why are we not also unpreparing the clock when the driver is idle?
 
I use clk_enable()  rather than  clk_prepare_enable() here to avoid potential sleeping in runtime cause by clk_prepare().  clk is prepare in fsl_lpspi_probe() and unprepared in fsl_lpspi_remove().

> > +static void fsl_lpspi_copy_to_buf(struct spi_message *m,
> > +					struct fsl_lpspi_data *fsl_lpspi) {
> > +	struct spi_transfer *t;
> > +	u8 *buf = fsl_lpspi->local_buf;
> > +
> > +	list_for_each_entry(t, &m->transfers, transfer_list) {
> > +		if (t->tx_buf)
> > +			memcpy(buf, t->tx_buf, t->len);
> > +		else
> > +			memset(buf, 0, t->len);
> > +		buf += t->len;
> > +	}
> > +}
> 
> Why are we doing this linearization into a single buffer?
 
For a spi  transfer transmitted by lpspi,  the clk for the last bit is incomplete.  The last rising edge never comes unless  we manually de-assert SS.  
In case that a spi message contains multiple transfers, SS should be de-asserted for each transfer.

However, for spi device such as m25p80, SS should keep asserted during a whole message.  So we need do this linearization here.

Thanks!

> > +static int fsl_lpspi_check_message(struct spi_message *m) {
> 
> If there's any checks in here that aren't done by the core then extend the core
> to support them (or drop them).

Due to the limitation of lpspi IP,  all transfers in a message should have same " speed_hz" & " bits_per_word". 
fsl_lpspi_check_message() is used to check the coherence of separate transfers.

This  limitation may not be applicable for other spi.  Do you still think the check should be extend to core?

> > +static int fsl_lpspi_transfer_one_msg(struct spi_master *master,
> > +					struct spi_message *m)
> > +{
> 
> Why are we doing transfer_one_msg() and not transfer_one()?

transfer_one() is used for separate spi transfer, which is not applicable to lpspi. 
Because lpspi need to intergrate all message transfers  into one  transfer. 
 
> 
> > +	m->actual_length = ret ? 0 : trans.len;
> 
> Please write normal if statements, people should be able to read the code.

Thanks, will change it in next version.   

> > +out:
> > +	if (m->status == -EINPROGRESS)
> > +		m->status = ret;
> 
> Why not for other errors?

Should be "m->status = ret" regardless of errors types. Thanks, will change it in next version.

Best  Regards
Gao Pan
--
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

  parent reply	other threads:[~2016-11-17  9:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 13:33 [Patch V2 1/2] spi: imx: add lpspi bus driver Gao Pan
     [not found] ` <1479216831-8709-1-git-send-email-pandy.gao-3arQi8VN3Tc@public.gmane.org>
2016-11-15 13:33   ` [Patch V2 2/2] spi: imx: add devicetree binding for lpspi Gao Pan
2016-11-16 17:32   ` [Patch V2 1/2] spi: imx: add lpspi bus driver Mark Brown
     [not found]     ` <20161116173228.cqtt5j5eczgg26gn-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-11-17  9:55       ` Pandy Gao [this message]
     [not found]         ` <AM4PR0401MB1780CDE562EEA1CE202E9572F6B10-4rsfagO7TJzc3fSXliz02I3W/0Ik+aLCnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2016-11-21 17:24           ` Mark Brown
     [not found]             ` <20161121172415.vtx7gahbzfgxconf-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-11-22 13:39               ` Pandy Gao

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=AM4PR0401MB1780CDE562EEA1CE202E9572F6B10@AM4PR0401MB1780.eurprd04.prod.outlook.com \
    --to=pandy.gao-3arqi8vn3tc@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=frank.li-3arQi8VN3Tc@public.gmane.org \
    --cc=fugang.duan-3arQi8VN3Tc@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@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.