All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andy Falanga (afalanga)" <afalanga@micron.com>
To: "linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>
Subject: pointer arithmetic on void *
Date: Fri, 11 Dec 2015 00:42:09 +0000	[thread overview]
Message-ID: <566A1B99.6040200@micron.com> (raw)

I'm working on understanding the final result of this code from ahci.c 
(it's libahci.c in newer kernels):

struct ata_queued_cmd {
     ...
     unsigned int tag;
     ...
};

struct ahci_port_priv {
     ...
     void *cmd_tbl;
     dma_addr_t cmd_tbl_dma;
     ...
};

static void  ahci_qc_prep( struct ata_queued_cmd *qc)
{
     ...
     cmd_tbl = pp->cmd_tbl + qc->tag * AHCI_CMD_TBL_SZ;
     ...
}

qc is a struct ata_queued_cmd object.  I'm assuming qc->tag is the PxCI 
slot number which was found to be free for this command. Please correct 
me if I'm wrong.  Furthermore, AHCI_CMD_TBL_SZ is defined as

enum {
     ...
     AHCI_MAX_SG        = 168, /* hardware max is 64K */
     ...
     AHCI_CMD_TBL_HDR_SZ    = 0x80,
     AHCI_CMD_TBL_SZ        = AHCI_CMD_TBL_HDR_SZ + (AHCI_MAX_SG * 16),
     ...
}

The first question is, given the above definition for AHCI_MAX_SG, is 
this a limitation from within the Linux kernel?  The comment alludes to 
this and the spec says 64k are allowed.

Next, is qc->tag the PxCI slot (open command slot)?  Second, is this 
arithmetic supposed to get me to the start of a new command?

Andy

                 reply	other threads:[~2015-12-11  0:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=566A1B99.6040200@micron.com \
    --to=afalanga@micron.com \
    --cc=linux-ide@vger.kernel.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.