public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
To: Alex Chiang <achiang@hp.com>,
	Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>,
	Matthew Wilcox <matthew@wil.cx>,
	Pierre Ossman <drzeus-list@drzeus.cx>,
	Jesse Barnes <jbarnes@virtuousgeek.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH 2/2] shpchp: Rename duplicate slot name N as N-1, N-2, N-M...
Date: Thu, 31 Jul 2008 19:32:43 +0900	[thread overview]
Message-ID: <489194CB.2000008@jp.fujitsu.com> (raw)
In-Reply-To: <20080730024450.GC4269@ldl.fc.hp.com>

Tested-by & Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>

Thnaks,
Kenji Kaneshige


Alex Chiang wrote:
> Commit ef0ff95f136f0f2d035667af5d18b824609de320 introduces the
> shpchp_slot_with_bus module parameter, which was intended to help
> work around broken firmware that assigns the same name to multiple
> slots.
> 
> Commit b3bd307c628af2f0a581c42d5d7e4bcdbbf64b6a tells the user to
> use the above parameter in the event of a name collision.
> 
> This approach is sub-optimal because it requires too much work from
> the user.
> 
> Instead, let's rename the slot on behalf of the user. If firmware
> assigns the name N to multiple slots, then:
> 
>         The first registered slot is assigned N
>         The second registered slot is assigned N-1
>         The third registered slot is assigned N-2
>         The Mth registered slot becomes N-M
> 
> In the event we overflow the slot->name parameter, we report an
> error to the user.
> 
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---
>  drivers/pci/hotplug/shpchp_core.c |   34 +++++++++++++++-------------------
>  1 files changed, 15 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
> index a8cbd03..cc38615 100644
> --- a/drivers/pci/hotplug/shpchp_core.c
> +++ b/drivers/pci/hotplug/shpchp_core.c
> @@ -39,7 +39,6 @@
>  int shpchp_debug;
>  int shpchp_poll_mode;
>  int shpchp_poll_time;
> -static int shpchp_slot_with_bus;
>  struct workqueue_struct *shpchp_wq;
>  
>  #define DRIVER_VERSION	"0.4"
> @@ -53,11 +52,9 @@ MODULE_LICENSE("GPL");
>  module_param(shpchp_debug, bool, 0644);
>  module_param(shpchp_poll_mode, bool, 0644);
>  module_param(shpchp_poll_time, int, 0644);
> -module_param(shpchp_slot_with_bus, bool, 0644);
>  MODULE_PARM_DESC(shpchp_debug, "Debugging mode enabled or not");
>  MODULE_PARM_DESC(shpchp_poll_mode, "Using polling mechanism for hot-plug events or not");
>  MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds");
> -MODULE_PARM_DESC(shpchp_slot_with_bus, "Use bus number in the slot name");
>  
>  #define SHPC_MODULE_NAME "shpchp"
>  
> @@ -99,23 +96,13 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
>  	kfree(slot);
>  }
>  
> -static void make_slot_name(struct slot *slot)
> -{
> -	if (shpchp_slot_with_bus)
> -		snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d",
> -			 slot->bus, slot->number);
> -	else
> -		snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d",
> -			 slot->number);
> -}
> -
>  static int init_slots(struct controller *ctrl)
>  {
>  	struct slot *slot;
>  	struct hotplug_slot *hotplug_slot;
>  	struct hotplug_slot_info *info;
>  	int retval = -ENOMEM;
> -	int i;
> +	int i, len, dup = 1;
>  
>  	for (i = 0; i < ctrl->num_slots; i++) {
>  		slot = kzalloc(sizeof(*slot), GFP_KERNEL);
> @@ -146,7 +133,7 @@ static int init_slots(struct controller *ctrl)
>  		/* register this slot with the hotplug pci core */
>  		hotplug_slot->private = slot;
>  		hotplug_slot->release = &release_slot;
> -		make_slot_name(slot);
> +		snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
>  		hotplug_slot->ops = &shpchp_hotplug_slot_ops;
>  
>  		get_power_status(hotplug_slot, &info->power_status);
> @@ -157,14 +144,23 @@ static int init_slots(struct controller *ctrl)
>  		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
>  		    "slot_device_offset=%x\n", slot->bus, slot->device,
>  		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
> +duplicate_name:
>  		retval = pci_hp_register(slot->hotplug_slot,
>  				ctrl->pci_dev->subordinate, slot->device);
>  		if (retval) {
> +			/*
> +			 * If slot N already exists, we'll try to create
> +			 * slot N-1, N-2 ... N-M, until we overflow.
> +			 */
> +			if (retval == -EEXIST) {
> +				len = snprintf(slot->name, SLOT_NAME_SIZE,
> +					       "%d-%d", slot->number, dup++);
> +				if (len < SLOT_NAME_SIZE)
> +					goto duplicate_name;
> +				else
> +					err("duplicate slot name overflow\n");
> +			}
>  			err("pci_hp_register failed with error %d\n", retval);
> -			if (retval == -EEXIST)
> -				err("Failed to register slot because of name "
> -                                    "collision. Try \'shpchp_slot_with_bus\' "
> -				    "module option.\n");
>  			goto error_info;
>  		}
>  



  reply	other threads:[~2008-07-31 10:34 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-24 11:47 post 2.6.26 requires pciehp_slot_with_bus Pierre Ossman
2008-07-24 12:38 ` Kenji Kaneshige
2008-07-24 20:39   ` Pierre Ossman
2008-07-24 21:07     ` Jesse Barnes
2008-07-24 21:51       ` Pierre Ossman
2008-07-24 22:06         ` Jesse Barnes
2008-07-24 22:29           ` Alex Chiang
2008-07-24 22:49             ` Pierre Ossman
2008-07-24 23:08               ` Alex Chiang
2008-07-24 23:29                 ` Pierre Ossman
2008-07-25  3:29                   ` Matthew Wilcox
2008-07-25  4:42                     ` Alex Chiang
2008-07-25  5:38                       ` Kenji Kaneshige
2008-07-25 11:18                         ` Matthew Wilcox
2008-07-28 18:05                       ` Greg KH
2008-07-25  4:57                     ` Kenji Kaneshige
2008-07-30  2:38                       ` Alex Chiang
2008-07-30  2:42                         ` [PATCH 1/2] pciehp: Rename duplicate slot name N as N-1, N-2, N-M Alex Chiang
2008-07-31 10:32                           ` Kenji Kaneshige
2008-07-30  2:44                         ` [PATCH 2/2] shpchp: " Alex Chiang
2008-07-31 10:32                           ` Kenji Kaneshige [this message]
2008-07-31 10:31                         ` post 2.6.26 requires pciehp_slot_with_bus Kenji Kaneshige
2008-07-31 15:47                           ` Alex Chiang
2008-08-01  8:43                             ` Kenji Kaneshige
2008-07-25  8:53                     ` Kenji Kaneshige
2008-07-25 11:40                       ` Matthew Wilcox
2008-07-28  7:21                         ` Kenji Kaneshige
2008-07-25  4:50                   ` Kenji Kaneshige
2008-07-25 22:18                     ` Jesse Barnes
2008-07-26  1:16                       ` Matthew Wilcox
2008-07-28  8:58                         ` Kenji Kaneshige
2008-07-28  8:44                       ` Kenji Kaneshige
2008-07-28 16:16                         ` Jesse Barnes
2008-07-29  2:43                           ` Kenji Kaneshige
2008-07-29 15:14                             ` Jesse Barnes
2008-07-30  2:44                               ` Kenji Kaneshige
2008-07-28 16:57                         ` Matthew Wilcox
  -- strict thread matches above, loose matches on Subject: below --
2008-08-21 21:11 [PATCH 0/2] pciehp/shpchp prevent duplicate slot names Alex Chiang
2008-08-21 21:13 ` [PATCH 2/2] shpchp: Rename duplicate slot name N as N-1, N-2, N-M Alex Chiang

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=489194CB.2000008@jp.fujitsu.com \
    --to=kaneshige.kenji@jp.fujitsu.com \
    --cc=achiang@hp.com \
    --cc=drzeus-list@drzeus.cx \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=matthew@wil.cx \
    /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