From patchwork Tue Jul 8 02:58:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hao X-Patchwork-Id: 367787 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 75FD61400E9 for ; Tue, 8 Jul 2014 12:58:29 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751566AbaGHC62 (ORCPT ); Mon, 7 Jul 2014 22:58:28 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:55812 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307AbaGHC61 (ORCPT ); Mon, 7 Jul 2014 22:58:27 -0400 Received: by mail-pa0-f53.google.com with SMTP id ey11so6508355pad.12 for ; Mon, 07 Jul 2014 19:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=p7n2BGzruf8J8ykqUnidUOjMTlxqPrxjf2oiTRIoS6I=; b=NKdFbdPfj8Eccdpe77prG70Q0tCb3f493NmzH09SfA9GlXh0pSLujKQL/Q6Ro4MzvO 6weSx7IdfuGzrnJMjp8d7WQ9qo9Ays6Y663qKHFwbRDhq33W1ieKmIsXPNm3V3DpZPP8 YZ1BTMP0p6BceWjVW33stsLA9EcmMvmLx/odq9h+N/jGcifAFZoKblGOP2X1XyJfzmW4 gU9qBKaOJuFRqmsqPqRmZkiDyT6eCgixXrFOlnqV8ELsYUYmWBtdMllKD8sGlQsSITgI DXFDTkzcVr6z1udaNj15aRbHvZ8skLUxptvfaV4wwMTJfmhCHF8hXQX/0qp93mkUEeYo avGQ== X-Received: by 10.68.125.135 with SMTP id mq7mr12734312pbb.103.1404788307259; Mon, 07 Jul 2014 19:58:27 -0700 (PDT) Received: from pek-khao-d1.corp.ad.wrs.com ([1.202.252.122]) by mx.google.com with ESMTPSA id c6sm22734782pbu.12.2014.07.07.19.58.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Jul 2014 19:58:26 -0700 (PDT) Date: Tue, 8 Jul 2014 10:58:20 +0800 From: Kevin Hao To: Tejun Heo Cc: linux-ide@vger.kernel.org, Dan Williams Subject: Re: [PATCH v2 1/2] libata: introduce ata_host_set_queue_depth() Message-ID: <20140708025820.GB29746@pek-khao-d1.corp.ad.wrs.com> References: <1404628121-8158-1-git-send-email-haokexin@gmail.com> <1404628121-8158-2-git-send-email-haokexin@gmail.com> <20140707134945.GA18550@htj.dyndns.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20140707134945.GA18550@htj.dyndns.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org On Mon, Jul 07, 2014 at 09:49:45AM -0400, Tejun Heo wrote: > Hello, > > On Sun, Jul 06, 2014 at 02:28:40PM +0800, Kevin Hao wrote: > > +int ata_host_set_queue_depth(struct ata_host *host, unsigned int queue_depth) > > Hmmm... is there a reason we're doing this separately when the same > information is available from scsi_host_template->can_queue from > ata_host_register()? This was my first thought. But given that scsi_host_template are the parameters passed to the scsi layer, it seems a bit weird to set the ata_host based a value in that. Anyway if we decide to use can_queue, how about directly use it in ata_qc_new(), just like the following codes? Thanks, Kevin diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 8f3043165048..4792fea79acf 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4728,14 +4728,17 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) { struct ata_queued_cmd *qc = NULL; - unsigned int i, tag; + unsigned int i, tag, max_queue; + + max_queue = ap->scsi_host->can_queue; + WARN_ON_ONCE(max_queue > ATA_MAX_QUEUE); /* no command while frozen */ if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) return NULL; - for (i = 0; i < ATA_MAX_QUEUE; i++) { - tag = (i + ap->last_tag + 1) % ATA_MAX_QUEUE; + for (i = 0, tag = ap->last_tag + 1; i < max_queue; i++, tag++) { + tag = tag < max_queue ? tag : 0; /* the last tag is reserved for internal command. */ if (tag == ATA_TAG_INTERNAL)