linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Asai Thambi S P <asamymuthupa@micron.com>
To: Jens Axboe <jaxboe@fusionio.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Jeff Moyer <jmoyer@redhat.com>,
	"linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jeff Garzik <jgarzik@pobox.com>,
	Christoph Hellwig <hch@infradead.org>,
	"Sam Bradshaw (sbradshaw)" <sbradshaw@micron.com>
Subject: Re: [PATCH v3 2/3] drivers/block/mtip32xx: Adding source for hardware related operations
Date: Wed, 17 Aug 2011 18:18:39 -0600	[thread overview]
Message-ID: <4E4C5A5F.2090709@micron.com> (raw)
In-Reply-To: <4E44E782.7090309@fusionio.com>

On 8/12/2011 2:42 AM, Jens Axboe wrote:
>> +/*
>> + * Obtain an empty command slot.
>> + *
>> + * This function needs to be reentrant since it could be called
>> + * at the same time on multiple CPUs. The allocation of the
>> + * command slot must be atomic.
>> + *
>> + * @port Pointer to the port data structure.
>> + *
>> + * return value
>> + *     >= 0    Index of command slot obtained.
>> + *     -1      No command slots available.
>> + */
>> +static int get_slot(struct mtip_port *port)
>> +{
>> +       int slot, i;
>> +       unsigned int num_command_slots = port->dd->slot_groups * 32;
>> +
>> +       /*
>> +        * Try 10 times, because there is a small race here.
>> +        *  that's ok, because it's still cheaper than a lock.
>> +        */
> 
> Might want to expand on what that race is.

find_next_zero_bit and test_and_set, in order, could be executed in
different process contexts in different processor. So both(2 or more)
contexts could land in choosing the same bit, but test_and_set will
succeed only for one. The failing contexts will try to get the next bit
in subsequent retries. This operation is cheaper than a lock.

This procedure is protected under the counting semaphore, so there is a
slot request for every context that calls this routine.

Is there an equivalent of doing find_next_zero_bit and test_and_set_bit
atomically?


>> +static irqreturn_t mtip_irq_handler(int irq, void *instance)
>> +{
>> +       struct driver_data *dd = instance;
>> +#ifdef MTIP_USE_TASKLET
>> +       tasklet_schedule(&dd->tasklet);
>> +       return IRQ_HANDLED;
>> +#else
>> +       return mtip_handle_irq(dd);
>> +#endif
>> +}
> 
> Have you experimented with blk-iopoll?

Working on this. Believe this experiment could go in parallel to
submission. Let us know.

>> +/*
>> + * Byte-swap ATA ID strings.
>> + *
>> + * ATA identify data contains strings in byte-swapped 16-bit words.
>> + * They must be swapped (on all architectures) to be usable as C
>> strings.
>> + * This function swaps bytes in-place.
>> + *
>> + * @buf The buffer location of the string
>> + * @len The number of bytes to swap
>> + *
>> + * return value
>> + *     None
>> + */
>> +static inline void ata_swap_string(u16 *buf, unsigned int len)
>> +{
>> +       int i;
>> +       for (i = 0; i < (len/2); i++)
>> +               be16_to_cpus(&buf[i]);
>> +}
> 
> I'm pretty sure we have the exact same thing in IDE and libata, so lets
> put this somewhere we they can all use it.

Is ata.h an appropriate location? Would it be better to make this change
after inclusion of this driver?

> 
> Overall looks very clean. If you take care of the little things
> mentioned by me and Christoph, I don't see anything stopping this from
> being merged for 3.2.

Appreciate your valuable feedback.

-- 
Regards,
Asai Thambi

  reply	other threads:[~2011-08-18  0:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-11 18:52 [PATCH v3 2/3] drivers/block/mtip32xx: Adding source for hardware related operations Asai Thambi Samymuthu Pattrayasamy (asamymuthupa) [CONTRACTOR]
2011-08-12  8:42 ` Jens Axboe
2011-08-18  0:18   ` Asai Thambi S P [this message]
2011-08-22 21:28   ` [PATCH v4] drivers/block/mtip32xx: Adding new driver mtip32xx Sam Bradshaw (sbradshaw)
2011-09-01 19:43     ` Jeff Moyer
2011-09-01 19:46       ` Jens Axboe
2011-09-09  8:54     ` Christoph Hellwig
2011-09-09  8:58       ` Jens Axboe
2011-09-09  9:02         ` Christoph Hellwig
2011-09-09 15:10         ` Sam Bradshaw (sbradshaw)
2011-09-12 15:02         ` Christoph Hellwig
2011-09-12 18:25           ` Jens Axboe
2011-09-30 13:33         ` Christoph Hellwig
2011-09-30 19:45           ` Asai Thambi S P
2011-09-30 21:20           ` Jens Axboe
2011-09-30 19:49         ` Asai Thambi S P
2011-09-13 12:49       ` Christoph Hellwig
2011-09-13 16:46         ` Eric Seppanen
2011-09-13 21:03           ` Jens Axboe

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=4E4C5A5F.2090709@micron.com \
    --to=asamymuthupa@micron.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=hch@infradead.org \
    --cc=jaxboe@fusionio.com \
    --cc=jgarzik@pobox.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sbradshaw@micron.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;
as well as URLs for NNTP newsgroup(s).