From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Vinod Koul <vinod.koul@intel.com>
Cc: gregkh@linuxfoundation.org, broonie@kernel.org,
alsa-devel@alsa-project.org, mark.rutland@arm.com,
michael.opdenacker@free-electrons.com, poeschel@lemonage.de,
andreas.noever@gmail.com, gong.chen@linux.intel.com,
arnd@arndb.de, kheitke@audience.com, bp@suse.de,
devicetree@vger.kernel.org, james.hogan@imgtec.com,
pawel.moll@arm.com, linux-arm-msm@vger.kernel.org,
sharon.dvir1@mail.huji.ac.il, robh+dt@kernel.org,
sdharia@codeaurora.org, alan@linux.intel.com, treding@nvidia.com,
mathieu.poirier@linaro.org, jkosina@suse.cz,
linux-kernel@vger.kernel.org, daniel@ffwll.ch, joe@perches.com,
davem@davemloft.net
Subject: Re: [alsa-devel] [Patch v6 2/7] slimbus: Add messaging APIs to slimbus framework
Date: Wed, 11 Oct 2017 10:42:28 +0100 [thread overview]
Message-ID: <aa117cb8-ba59-894c-5a82-1b38facfa841@linaro.org> (raw)
In-Reply-To: <20171011043814.GF30097@localhost>
On 11/10/17 05:38, Vinod Koul wrote:
> On Fri, Oct 06, 2017 at 05:51:31PM +0200, srinivas.kandagatla@linaro.org wrote:
>
>> mutex_init(&ctrl->m_ctrl);
>> + spin_lock_init(&ctrl->tx.lock);
>> + spin_lock_init(&ctrl->rx.lock);
>
> locks galore :) My assumption is that you want to optimize these? But given
> that audio user is going to be serialized do we practically need two locks?
>
If we remove the locking, It will be issue if we have multiple devices
in a component, which is common atleast with the codec which am looking at.
>> +
>> + ctrl->pending_wr = kcalloc((ctrl->tx.n - 1),
>> + sizeof(struct slim_pending),
>> + GFP_KERNEL);
>> + if (!ctrl->pending_wr) {
>> + ret = -ENOMEM;
>> + goto wr_alloc_failed;
>> + }
>> +
>> + sema_init(&ctrl->tx_sem, (ctrl->tx.n - 1));
>
> i though v5 comment from Arnd was not to use semaphores..
I will revisit this area once again and get rid of this semaphore all
together in next version.
>
>> +/* Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
>
> 2017?
Yep.
>
>> +int slim_processtxn(struct slim_controller *ctrl,
>
> slim_process_txn seems more readable to me
>
I can change it in next version.
>> + struct slim_msg_txn *txn)
>> +{
>> + int ret, i = 0;
>> + unsigned long flags;
>> + u8 *buf;
>> + bool async = false;
>> + struct slim_cb_data cbd;
>> + DECLARE_COMPLETION_ONSTACK(done);
>> + bool need_tid = slim_tid_txn(txn->mt, txn->mc);
>> +
>> + if (!txn->msg->comp_cb) {
>> + txn->msg->comp_cb = slim_sync_default_cb;
>> + cbd.comp = &done;
>> + txn->msg->ctx = &cbd;
>> + } else {
>> + async = true;
>> + }
>> +
>> + buf = slim_get_tx(ctrl, txn, need_tid);
>> + if (!buf)
>> + return -ENOMEM;
>> +
>> + if (need_tid) {
>> + spin_lock_irqsave(&ctrl->txn_lock, flags);
>> + for (i = 0; i < ctrl->last_tid; i++) {
>> + if (ctrl->tid_tbl[i] == NULL)
>> + break;
>> + }
>> + if (i >= ctrl->last_tid) {
>> + if (ctrl->last_tid == (SLIM_MAX_TIDS - 1)) {
>> + spin_unlock_irqrestore(&ctrl->txn_lock, flags);
>> + slim_return_tx(ctrl, -ENOMEM);
>> + return -ENOMEM;
>> + }
>> + ctrl->last_tid++;
>> + }
>> + ctrl->tid_tbl[i] = txn->msg;
>> + txn->tid = i;
>> + spin_unlock_irqrestore(&ctrl->txn_lock, flags);
>> + }
>> +
>> + ret = ctrl->xfer_msg(ctrl, txn, buf);
>> +
>> + if (!ret && !async) { /* sync transaction */
>> + /* Fine-tune calculation after bandwidth management */
>> + unsigned long ms = txn->rl + 100;
>> +
>> + ret = wait_for_completion_timeout(&done,
>> + msecs_to_jiffies(ms));
>> + if (!ret)
>> + slim_return_tx(ctrl, -ETIMEDOUT);
>> +
>> + ret = cbd.ret;
>> + }
>> +
>> + if (ret && need_tid) {
>> + spin_lock_irqsave(&ctrl->txn_lock, flags);
>> + /* Invalidate the transaction */
>> + ctrl->tid_tbl[txn->tid] = NULL;
>> + spin_unlock_irqrestore(&ctrl->txn_lock, flags);
>> + }
>> + if (ret)
>> + dev_err(&ctrl->dev, "Tx:MT:0x%x, MC:0x%x, LA:0x%x failed:%d\n",
>> + txn->mt, txn->mc, txn->la, ret);
>> + if (!async) {
>> + txn->msg->comp_cb = NULL;
>> + txn->msg->ctx = NULL;
>> + }
>> + return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(slim_processtxn);
>
> that is interesting, I was expecting this to be internal API. So users are
> expected to use this which is not very convenient IMO. Can we hide the gory
> details and give users simple tx/rx or read/write APIs. FWIW most of the
> usage would be thru regmap where people would call regmap_read/write()
>
Currently the only user of the api is qcom slim controller. May be the
reason for it to use this api is to fit in with all the locking and
sequencing mechanism with in the core.
I will be revisiting the semaphore thingy before I send next version,
hopefully I can to align with your above comments.
>> +
>> +static int slim_val_inf_sanity(struct slim_controller *ctrl,
>> + struct slim_val_inf *msg, u8 mc)
>> +{
>> + if (!msg || msg->num_bytes > 16 ||
>> + (msg->start_offset + msg->num_bytes) > 0xC00)
>> + goto reterr;
>
> line break here
I agree.
>
>> + switch (mc) {
>> + case SLIM_MSG_MC_REQUEST_VALUE:
>> + case SLIM_MSG_MC_REQUEST_INFORMATION:
>
> what does MC refer to?
Message Code.
>
>> + if (msg->rbuf != NULL)
>> + return 0;
>> + break;
>
> after each break too
>
Sure, will fix it in next version.
>> +static u16 slim_slicecodefromsize(u16 req)
>
> hmmm Linux code doesnt prefernamesnames like this :)
Yep, this function is unused, am going to delete this in next version.
>
>> +EXPORT_SYMBOL_GPL(slim_request_inf_element);
>> +
>> +
>
> unnecessary double space
>
>> +struct slim_val_inf {
>> + u16 start_offset;
>> + u8 num_bytes;
>> + u8 *rbuf;
>> + const u8 *wbuf;
>
> can we do read and write, if not it can be a buf which maybe rbuf or wbug
> based on type
With REQUEST_CHANGE_VALUE single command we can read old value at the
same time we can write new value.
>
next prev parent reply other threads:[~2017-10-11 9:43 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 15:51 [Patch v6 0/7] Introduce framework for SLIMbus device drivers srinivas.kandagatla
2017-10-06 15:51 ` [Patch v6 1/7] slimbus: Device management on SLIMbus srinivas.kandagatla
2017-10-07 4:14 ` Jonathan Neuschäfer
2017-10-07 10:24 ` Srinivas Kandagatla
2017-10-10 10:05 ` [alsa-devel] " Charles Keepax
2017-10-10 12:34 ` Srinivas Kandagatla
2017-10-10 12:56 ` Charles Keepax
2017-10-11 10:23 ` Mark Brown
2017-10-10 10:45 ` Vinod Koul
2017-10-10 12:34 ` Srinivas Kandagatla
2017-10-10 16:49 ` Vinod Koul
2017-10-10 17:21 ` Srinivas Kandagatla
2017-10-11 4:07 ` Vinod Koul
2017-10-11 9:42 ` Srinivas Kandagatla
2017-10-11 10:21 ` Vinod Koul
2017-10-11 11:23 ` Srinivas Kandagatla
2017-10-12 11:01 ` Sanyog Kale
2017-10-12 13:26 ` Srinivas Kandagatla
2017-10-13 19:26 ` Rob Herring
2017-10-16 9:28 ` Srinivas Kandagatla
2017-10-17 6:23 ` Bjorn Andersson
2017-10-18 16:38 ` Srinivas Kandagatla
2017-11-01 23:08 ` Bjorn Andersson
2017-10-23 9:06 ` Mark Brown
2017-10-25 0:16 ` Stephen Boyd
2017-10-06 15:51 ` [Patch v6 2/7] slimbus: Add messaging APIs to slimbus framework srinivas.kandagatla
2017-10-07 6:42 ` Jonathan Neuschäfer
2017-10-07 10:24 ` Srinivas Kandagatla
2017-10-07 12:29 ` Jonathan Neuschäfer
2017-10-10 12:19 ` [alsa-devel] " Charles Keepax
2017-10-10 13:01 ` Srinivas Kandagatla
2017-10-11 4:38 ` Vinod Koul
2017-10-11 7:53 ` Arnd Bergmann
2017-10-11 9:42 ` Srinivas Kandagatla [this message]
2017-10-11 10:24 ` Vinod Koul
2017-10-11 11:12 ` Srinivas Kandagatla
2017-10-18 6:15 ` Bjorn Andersson
2017-10-18 16:39 ` Srinivas Kandagatla
2017-10-20 5:00 ` Bjorn Andersson
2017-10-06 15:51 ` [Patch v6 3/7] slimbus: qcom: Add Qualcomm Slimbus controller driver srinivas.kandagatla
2017-10-07 7:45 ` Jonathan Neuschäfer
2017-10-07 10:24 ` Srinivas Kandagatla
2017-10-13 19:17 ` Rob Herring
2017-10-16 9:28 ` Srinivas Kandagatla
2017-10-18 7:27 ` Bjorn Andersson
2017-10-18 16:39 ` Srinivas Kandagatla
2017-10-06 15:51 ` [Patch v6 4/7] slimbus: Add support for 'clock-pause' feature srinivas.kandagatla
2017-10-07 8:06 ` Jonathan Neuschäfer
2017-10-07 10:24 ` Srinivas Kandagatla
2017-10-06 15:51 ` [Patch v6 5/7] slimbus: qcom: Add runtime-pm support using clock-pause feature srinivas.kandagatla
2017-10-07 8:22 ` Jonathan Neuschäfer
2017-10-07 10:25 ` Srinivas Kandagatla
2017-10-06 15:51 ` [Patch v6 6/7] regmap: add SLIMBUS support srinivas.kandagatla
2017-10-07 5:02 ` Jonathan Neuschäfer
2017-10-07 10:25 ` Srinivas Kandagatla
2017-10-20 5:00 ` Bjorn Andersson
2017-10-06 15:51 ` [Patch v6 7/7] MAINTAINERS: Add SLIMbus maintainer srinivas.kandagatla
2017-10-20 5:00 ` Bjorn Andersson
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=aa117cb8-ba59-894c-5a82-1b38facfa841@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=alan@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=andreas.noever@gmail.com \
--cc=arnd@arndb.de \
--cc=bp@suse.de \
--cc=broonie@kernel.org \
--cc=daniel@ffwll.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=gong.chen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.hogan@imgtec.com \
--cc=jkosina@suse.cz \
--cc=joe@perches.com \
--cc=kheitke@audience.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mathieu.poirier@linaro.org \
--cc=michael.opdenacker@free-electrons.com \
--cc=pawel.moll@arm.com \
--cc=poeschel@lemonage.de \
--cc=robh+dt@kernel.org \
--cc=sdharia@codeaurora.org \
--cc=sharon.dvir1@mail.huji.ac.il \
--cc=treding@nvidia.com \
--cc=vinod.koul@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®