Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751286AbbD3Its (ORCPT ); Thu, 30 Apr 2015 04:49:48 -0400 Received: from smarthost01a.mail.zen.net.uk ([212.23.1.1]:60455 "EHLO smarthost01a.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750758AbbD3Ito (ORCPT ); Thu, 30 Apr 2015 04:49:44 -0400 X-Greylist: delayed 73444 seconds by postgrey-1.27 at vger.kernel.org; Thu, 30 Apr 2015 04:49:44 EDT Message-ID: <1430383781.2868.9.camel@linaro.org> Subject: Re: [PATCH 1/4] mailbox: add support for System Control and Power Interface(SCPI) protocol From: "Jon Medhurst (Tixy)" To: Sudeep Holla Cc: "linux-kernel@vger.kernel.org" , Liviu Dudau , Lorenzo Pieralisi , Rob Herring , Mark Rutland , Jassi Brar , "devicetree@vger.kernel.org" Date: Thu, 30 Apr 2015 09:49:41 +0100 In-Reply-To: <1430310338.27241.45.camel@linaro.org> References: <1430134846-24320-1-git-send-email-sudeep.holla@arm.com> <1430134846-24320-2-git-send-email-sudeep.holla@arm.com> <1430229283.3321.40.camel@linaro.org> <5540B840.1030900@arm.com> <1430307828.27241.32.camel@linaro.org> <1430310338.27241.45.camel@linaro.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-smarthost01a-IP: [82.69.122.217] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1837 Lines: 48 On Wed, 2015-04-29 at 13:25 +0100, Jon Medhurst (Tixy) wrote: > diff --git a/drivers/mailbox/scpi_protocol.c > b/drivers/mailbox/scpi_protocol.c > index c74575b..5818d9b 100644 > --- a/drivers/mailbox/scpi_protocol.c > +++ b/drivers/mailbox/scpi_protocol.c > @@ -286,14 +286,23 @@ static void scpi_tx_prepare(struct mbox_client > *c, void *msg) > struct scpi_chan *ch = container_of(c, struct scpi_chan, cl); > struct scpi_shared_mem *mem = (struct scpi_shared_mem > *)ch->tx_payload; > > - mem->command = cpu_to_le32(t->cmd); > if (t->tx_buf) > memcpy_toio(mem->payload, t->tx_buf, t->tx_len); > if (t->rx_buf) { > + int token; > spin_lock_irqsave(&ch->rx_lock, flags); > + /* > + * Presumably we can do this token setting outside > + * spinlock and still be safe from concurrency? > + */ To answer my own question, yes, the four lines below can be moved up above the spin_lock_irqsave. Because we had better be safe from concurrency here as we are also writing to the channel's shared memory area. > + do > + token = (++ch->token) & CMD_TOKEN_ID_MASK; > + while(!token); > + t->cmd |= token << CMD_TOKEN_ID_SHIFT; > list_add_tail(&t->node, &ch->rx_pending); > spin_unlock_irqrestore(&ch->rx_lock, flags); > } > + mem->command = cpu_to_le32(t->cmd); > } > > static struct scpi_xfer *get_scpi_xfer(struct scpi_chan *ch) -- Tixy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/