Linux PCI subsystem development
 help / color / mirror / Atom feed
From: "Krzysztof Wilczyński" <kw@linux.com>
To: kelvin.cao@microchip.com
Cc: kurt.schwemmer@microsemi.com, logang@deltatee.com,
	bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, kelvincao@outlook.com
Subject: Re: [PATCH v2 1/5] PCI/switchtec: Error out MRPC execution when MMIO reads fail
Date: Fri, 15 Oct 2021 03:21:47 +0200	[thread overview]
Message-ID: <YWjXq/NL6zex4oeR@rocinante> (raw)
In-Reply-To: <20211014141859.11444-2-kelvin.cao@microchip.com>

Hi Kelvin,

Thank you for sending the series over!

I am terribly sorry for a very late comment, especially since Bjorn already
accepted this series to be included, but allow me for a small question
below.

[...]
> @@ -113,6 +127,7 @@ static void stuser_set_state(struct switchtec_user *stuser,
>  		[MRPC_QUEUED] = "QUEUED",
>  		[MRPC_RUNNING] = "RUNNING",
>  		[MRPC_DONE] = "DONE",
> +		[MRPC_IO_ERROR] = "IO_ERROR",

Looking at the above, and then looking at stuser_set_state(), which
contains the following local array definition:

	const char * const state_names[] = {
		[MRPC_IDLE] = "IDLE",
		[MRPC_QUEUED] = "QUEUED",
		[MRPC_RUNNING] = "RUNNING",
		[MRPC_DONE] = "DONE",
	};

I was wondering if there might be a small benefit of declaring this array
state_names[], or list of states if you wish, as static so that we avoid
having to allocate space and fill it in with values every time this
functions runs?

The function itself if referenced in few places as per:

  Index File                           Line Content
      1 drivers/pci/switch/switchtec.c  159 stuser_set_state(stuser, MRPC_RUNNING);
      2 drivers/pci/switch/switchtec.c  178 stuser_set_state(stuser, MRPC_QUEUED);
      3 drivers/pci/switch/switchtec.c  206 stuser_set_state(stuser, MRPC_DONE);
      4 drivers/pci/switch/switchtec.c  567 stuser_set_state(stuser, MRPC_IDLE);

Even though the string representation of the state is ever only printed if
a debug logging is requested, we would allocate and popular this array
every time anyway, regardless of whether we print any debug information or
not.

What do you think?

	Krzysztof

  reply	other threads:[~2021-10-15  1:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 14:18 [PATCH v2 0/5] Switchtec Fixes and Improvements kelvin.cao
2021-10-14 14:18 ` [PATCH v2 1/5] PCI/switchtec: Error out MRPC execution when MMIO reads fail kelvin.cao
2021-10-15  1:21   ` Krzysztof Wilczyński [this message]
2021-10-15 22:13     ` Kelvin.Cao
2021-10-14 14:18 ` [PATCH v2 2/5] PCI/switchtec: Fix a MRPC error status handling issue kelvin.cao
2021-10-14 14:18 ` [PATCH v2 3/5] PCI/switchtec: Update the way of getting management VEP instance ID kelvin.cao
2021-10-14 14:18 ` [PATCH v2 4/5] PCI/switchtec: Replace ENOTSUPP with EOPNOTSUPP kelvin.cao
2021-10-15  1:55   ` Krzysztof Wilczyński
2021-10-14 14:18 ` [PATCH v2 5/5] PCI/switchtec: Add check of event support kelvin.cao
2021-10-14 14:47 ` [PATCH v2 0/5] Switchtec Fixes and Improvements Bjorn Helgaas
2021-10-14 21:19   ` Kelvin.Cao

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=YWjXq/NL6zex4oeR@rocinante \
    --to=kw@linux.com \
    --cc=bhelgaas@google.com \
    --cc=kelvin.cao@microchip.com \
    --cc=kelvincao@outlook.com \
    --cc=kurt.schwemmer@microsemi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.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