Linux Hotplug development
 help / color / mirror / Atom feed
* Re: [PATCH] Create symlinks and static/module nodes before /dev/null check
From: Kay Sievers @ 2010-11-22 13:01 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20101119164446.GA5399@mott.hasevolq.tld>

On Fri, Nov 19, 2010 at 17:44, Michal Soltys <soltys@ziu.info> wrote:
> static_dev_create() and static_dev_create_from_modules() are called much later,
> after udevd checks for /dev/null existence (and in case of failure it exits).
> Although not really important with devtmpfs - if someone uses standard tmpfs,
> one will have to copy static nodes manually (or at least create /dev/null) - even
> though udevd does that itself.
>
> As both of the functions don't seem to depend on things after /dev/null check, they
> probably could be moved up a bit, right after setting umask.

Applied.

Thanks,
Kay

^ permalink raw reply

* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based
From: Dan Nicholson @ 2010-11-24 14:46 UTC (permalink / raw)
  To: linux-hotplug

On Wed, Nov 24, 2010 at 2:14 AM, Linus Walleij
<linus.ml.walleij@gmail.com> wrote:
> 2010/11/3  <lan.liu@nokia.com>:
>
>> 45-libmtp8.rules
>> PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp"
>> SYMLINK+="libmtp-%k", MODE="666", GROUP="plugdev"
>
> This file - 45-libmtp8.rules is some distro file, what libmtp generates
> is libmtp.rules, which is autogenerated from a device database by the
> program found in examples/hotplug.c.
>
> Can you provide a patch to hotplug.c that adds this line to libmtp.rules?
>
> If you do that you will get this change into every distribution.

Every distribution does not have the plugdev group, though.
Furthermore, I don't see the point of making the mode 666 while also
setting the group to narrow the scope.

Might I suggest instead that the program be used not to set the
permissions, but to set the attributes consistently. E.g.,

PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp", ENV{ID_MTP_DEVICE}="1"

If we know that all mtp devices have the environment variable
ID_MTP_DEVICE, then it's very easy to add a rule controlling the
permissions.

ENV{ID_MTP_DEVICE}="?*", MODE="666"

Even better, if we let the udev people know that there is some
attribute like ID_MTP_DEVICE that's set for all mtp devices, they can
add a rule for udev-acl, which dynamically updates the ACLs on all
distros. See how the gphoto2 devices are handled here:

http://git.kernel.org/?p=linux/hotplug/udev.git;a=blob;f=extras/udev-acl/70-acl.rules;hãff31c22e5c96af6478a715aa39928f7ba025bd;hb=HEAD

In fact, it seems they already have a rule to manage the ACLs on
PTP/MTP devices. What do you think?

--
Dan

^ permalink raw reply

* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device
From: Marcus Meissner @ 2010-11-24 15:05 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <AANLkTimamoY-ui9bSB8ThKGw8=r4x5NDokugnCZ=uERe@mail.gmail.com>

On Wed, Nov 24, 2010 at 06:46:28AM -0800, Dan Nicholson wrote:
> On Wed, Nov 24, 2010 at 2:14 AM, Linus Walleij
> <linus.ml.walleij@gmail.com> wrote:
> > 2010/11/3  <lan.liu@nokia.com>:
> >
> >> 45-libmtp8.rules
> >> PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp"
> >> SYMLINK+="libmtp-%k", MODE="666", GROUP="plugdev"
> >
> > This file - 45-libmtp8.rules is some distro file, what libmtp generates
> > is libmtp.rules, which is autogenerated from a device database by the
> > program found in examples/hotplug.c.
> >
> > Can you provide a patch to hotplug.c that adds this line to libmtp.rules?
> >
> > If you do that you will get this change into every distribution.
> 
> Every distribution does not have the plugdev group, though.
> Furthermore, I don't see the point of making the mode 666 while also
> setting the group to narrow the scope.
> 
> Might I suggest instead that the program be used not to set the
> permissions, but to set the attributes consistently. E.g.,
> 
> PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp", ENV{ID_MTP_DEVICE}="1"
> 
> If we know that all mtp devices have the environment variable
> ID_MTP_DEVICE, then it's very easy to add a rule controlling the
> permissions.
> 
> ENV{ID_MTP_DEVICE}="?*", MODE="666"
> 
> Even better, if we let the udev people know that there is some
> attribute like ID_MTP_DEVICE that's set for all mtp devices, they can
> add a rule for udev-acl, which dynamically updates the ACLs on all
> distros. See how the gphoto2 devices are handled here:
> 
> http://git.kernel.org/?p=linux/hotplug/udev.git;a=blob;f=extras/udev-acl/70-acl.rules;hãff31c22e5c96af6478a715aa39928f7ba025bd;hb=HEAD
> 
> In fact, it seems they already have a rule to manage the ACLs on
> PTP/MTP devices. What do you think?

Errm, folks.

The upstream people have decided on the tag and the handling already, 
and I have implemented it in libgphoto2 udev rule generator already
(you benefit from it already this way btw ;)

A line in the "new style" udev from libgphoto2:

ATTRS{idVendor}="04a9", ATTRS{idProduct}="30f2", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="proprietary", ENV{ID_MEDIA_PLAYER}="1"

For libmtp this would probably be e.g.:
ATTRS{idVendor}="04a9", ATTRS{idProduct}="30f2", ENV{ID_MEDIA_PLAYER}="1"

Thats it, the rest handling will be done using ACLs from the regular udev code.

Ciao, Marcus

^ permalink raw reply

* RE: [PATCH 1/1] UDEV - Add 'udevlom' command line param to start_udev
From: Loke, Chetan @ 2010-11-24 20:57 UTC (permalink / raw)
  To: Rick Jones, Ben Hutchings
  Cc: Matt Domsch, Greg KH, K, Narendra, linux-hotplug, netdev,
	Hargrave, Jordan, Rose, Charles
In-Reply-To: <4CE18ACC.3020508@hp.com>

> 
> > - "mbe" = MotherBoard Ethernet. Looks a bit like "GbE" as some OEMs
put
> > on the port labels.
> 
> Collides with Multi-Bit Error.
> 
> > - "eom" = Ethernet On Motherboard
> 
> Collides with End of Message.
> 

On board ethernet(obe)?
On board nic(obn)?




^ permalink raw reply

* RE: [PATCH 1/1] UDEV - Add 'udevlom' command line param to start_udev
From: Loke, Chetan @ 2010-11-24 21:13 UTC (permalink / raw)
  To: Rick Jones, Ben Hutchings
  Cc: Matt Domsch, Greg KH, K, Narendra, linux-hotplug, netdev,
	Hargrave, Jordan, Rose, Charles
In-Reply-To: <4CE18ACC.3020508@hp.com>


> 
> Are folks sufficently confident that using anything other than "eth"
> won't cause some unpleasant "our app always ass-u-me-d interfaces
started with
> 'eth'" situations?
> 

Good point. I'm sure folks use 'eth' in their regex filters. Please
ignore my obe/obn email.



> rick jones

Chetan Loke


^ permalink raw reply

* Re: [PATCH 1/1] UDEV - Add 'udevlom' command line param to
From: Bill Fink @ 2010-11-25  2:56 UTC (permalink / raw)
  To: Loke, Chetan
  Cc: Rick Jones, Ben Hutchings, Matt Domsch, Greg KH, K, Narendra,
	linux-hotplug, netdev, Hargrave, Jordan, Rose, Charles
In-Reply-To: <D3F292ADF945FB49B35E96C94C2061B90E4E367E@nsmail.netscout.com>

On Wed, 24 Nov 2010, Loke, Chetan wrote:

> > Are folks sufficently confident that using anything other than "eth"
> > won't cause some unpleasant "our app always ass-u-me-d interfaces
> started with
> > 'eth'" situations?
> 
> Good point. I'm sure folks use 'eth' in their regex filters. Please
> ignore my obe/obn email.

If the 2 or 3 character name isn't a hard requirement, then
ethm for eth(ernet on )m(otherboard) would seem a natural
possibility.

					-Bill

^ permalink raw reply

* Re: [PATCH 1/1] UDEV - Add 'udevlom' command line param to start_udev
From: Matt Domsch @ 2010-11-26  2:09 UTC (permalink / raw)
  To: Bill Fink
  Cc: Loke, Chetan, Rick Jones, Ben Hutchings, Greg KH, K, Narendra,
	linux-hotplug, netdev, Hargrave, Jordan, Rose, Charles
In-Reply-To: <20101124215608.6b0371b8.billfink@mindspring.com>

On Wed, Nov 24, 2010 at 09:56:08PM -0500, Bill Fink wrote:
> On Wed, 24 Nov 2010, Loke, Chetan wrote:
> 
> > > Are folks sufficently confident that using anything other than "eth"
> > > won't cause some unpleasant "our app always ass-u-me-d interfaces
> > started with
> > > 'eth'" situations?
> > 
> > Good point. I'm sure folks use 'eth' in their regex filters. Please
> > ignore my obe/obn email.
> 
> If the 2 or 3 character name isn't a hard requirement, then
> ethm for eth(ernet on )m(otherboard) would seem a natural
> possibility.

I went with 'em' (embedded or ethernet-on-motherboard) in
biosdevname.  Git tree at:

http://linux.dell.com/cgi-bin/gitweb/gitweb.cgi?p=biosdevname.git;a=summary

Now I'm just trying to figure out why it seems pciutils libpci is
unhappy when the device tree is constantly changing underneath it,
such as when loading ixgbe max_vfsc - each new SR-IOV device created
launches a new udev instance as expected, but the device tree as seen
from any one of them may not be quite right as it's changing...

Thanks,
Matt

-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

^ permalink raw reply

* something about udev
From: shaoning @ 2010-11-27 10:23 UTC (permalink / raw)
  To: linux-hotplug

hi all

there is a simple question about udev, does anybody can help me ?

I wan to auto mount ntfs partition , and using nautilus auto open the
url when it mounted.
But why the nautilus can not show to me , the ntfs partition auto
mount to the /media dirctory?
it seems that  only the last RUN+ part can not work . It confused me.
So, does anyone know the reason ? Thanks!

Below is my test rules :


KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
# Import FS infos
IMPORT{program}="/sbin/blkid -o udev -p %N"
# # Get a label if present, otherwise specify one
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}="", ENV{dir_name}="usbhd-%k"
# # Global mount options
ACTION="add", ENV{mount_options}="relatime"
# # Filesystem-specific mount options
ACTION="add", ENV{ID_FS_TYPE}="ntfs",
ENV{mount_options}="$env{mount_options},utf8,gid\x100,umask\02",
RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -t ntfs-3g
-o $env{mount_options} /dev/%k
/media/%E{dir_name}",RUN+="/usr/bin/nautilus media/%E{dir_name}"
# # Clean up after removal
ACTION="remove", ENV{dir_name}!="", RUN+="/bin/umount -l
/media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
# # Exit
LABEL="media_by_label_auto_mount_end"

^ permalink raw reply

* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based
From: Linus Walleij @ 2010-11-28 21:12 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <AANLkTimamoY-ui9bSB8ThKGw8=r4x5NDokugnCZ=uERe@mail.gmail.com>

2010/11/24 Marcus Meissner <marcus@jet.franken.de>:

> A line in the "new style" udev from libgphoto2:
>
> ATTRS{idVendor}="04a9", ATTRS{idProduct}="30f2", ENV{ID_GPHOTO2}="1", ENV{GPHOTO2_DRIVER}="proprietary", ENV{ID_MEDIA_PLAYER}="1"
>
> For libmtp this would probably be e.g.:
> ATTRS{idVendor}="04a9", ATTRS{idProduct}="30f2", ENV{ID_MEDIA_PLAYER}="1"
>
> Thats it, the rest handling will be done using ACLs from the regular udev code.

I've fixed this in the examples/hotplug.c file last week, so yes this
should be enough for now atleast.

Linus

^ permalink raw reply

* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based
From: Linus Walleij @ 2010-11-28 21:25 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <AANLkTimamoY-ui9bSB8ThKGw8=r4x5NDokugnCZ=uERe@mail.gmail.com>

2010/11/26  <lan.liu@nokia.com>:

> change on 'example/hotplug.c' on release 1.0.1 (the most recent release I
> get from “http://libmtp.sourceforge.net/download.php”),

1.0.3 is the latest, sorry that page isn't working, I will hack it to redirect
to the SF download page unless Sean has some time to fix it like soon-ish...

> to generate
> following rule for mtp device:
> #For Nokia-based devices,their interface string descriptor contains 'mtp'
> pattern,consider it to be a mtp device
> ATTR{idVendor}="0421", PROGRAM="/usr/local/bin/check_mtp_device.sh
> /sys$env{DEVPATH} mtp",

Aha clever!

> SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1",
> ENV{ID_MEDIA_PLAYER}="1"

Hm I only added ID_MEDIA_PLAYER, I guess ID_MTP_DEVICE wouldn't
hurt so I have added that too.

> ENV{ID_MTP_DEVICE}="?*", MODE="666"

Aha yeah that solves an immediate problem for many people I guess.

> 1. Makefile need to be updated so that 'check_mtp_device.sh' could be
> installed , since I am new with this, could anybody give me a help?
> Currently, I hardcode the install path as '/usr/local/bin/' in rule file.

This is not the hard thing. The hard thing is that scripts like
"check_mtp_device.sh" take a long time to invoke, and I would
prefer to have it rewritten in plain C.

That would make it simpler to add OS descriptor probing too,
if desired.

examples/devicecheck.c

Installs as <prefix>/bin/mtp-devicecheck

And is used from the udev script.

Can it be done?

> 2. Currently, after you run 'make install', the generated 'libmtp.rules'
> will NOT be automatically copied to '/etc/udev/rules.d' or
> '/lib/udev/rules.d'(the directory where udev rules files located on Ubuntu
> system), user has to copy it manually. Thus we still could not provide an
> out-of-box experience for these devices.

Such is life, copying it into Ubuntu/Debian/Fedora/whatever locations
is a task for the packager.

If libmtp can help with any of this, the packagers (which are on this
list) should voice their needs...

Linus Walleij

^ permalink raw reply

* Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based
From: Linus Walleij @ 2010-11-28 22:12 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <AANLkTimamoY-ui9bSB8ThKGw8=r4x5NDokugnCZ=uERe@mail.gmail.com>

2010/11/24 Dan Nicholson <dbn.lists@gmail.com>:

> Every distribution does not have the plugdev group, though.

Yeah that shouldn't be hardcoded. The hotplug.c program already
supports supplying a custom actions string for those who need
it, like distro packagers.

> If we know that all mtp devices have the environment variable
> ID_MTP_DEVICE, then it's very easy to add a rule controlling the
> permissions.
>
> ENV{ID_MTP_DEVICE}="?*", MODE="666"

Yep that's how to do it.

> Even better, if we let the udev people know that there is some
> attribute like ID_MTP_DEVICE that's set for all mtp devices, they can
> add a rule for udev-acl, which dynamically updates the ACLs on all
> distros. See how the gphoto2 devices are handled here:
>
> http://git.kernel.org/?p=linux/hotplug/udev.git;a=blob;f=extras/udev-acl/70-acl.rules;hãff31c22e5c96af6478a715aa39928f7ba025bd;hb=HEAD
> In fact, it seems they already have a rule to manage the ACLs on
> PTP/MTP devices. What do you think?

Yes! It already recognize ID_MEDIA_PLAYER it seems? And I
added that to all of them...

Linus

^ permalink raw reply

* net device renaming 2-step, IFNAMSIZ limit
From: Matt Domsch @ 2010-11-29  3:29 UTC (permalink / raw)
  To: linux-hotplug

Once again, IFNAMSIZ bites me.

I see this in the udev debug logs when using biosdevname (which I
finally got working with SR-IOV devices tonight):

renamed network interface eth60 to eth60-pci2#0_60
renamed network interface eth60-pci2#0_60 to pci2#0_60

So, it worked, however, note that the rename happens in 2 steps, the
middle step of which uses a name that's dangerously close to
IFNAMSIZ, in fact it is 15 chars there.

In my testing, I'm doing:
 modprobe ixgbe max_vfsc

which generates ethN..(N+127) interfaces (yes, 128 new interfaces) on
this dual-port card.  Combine that with the longer names that
biosdevname is suggesting:

 pciNN#PP_VVV

which is itself already 12 chars if all the fields are used to their
maximum length, and the concatenation of <oldname>-<newname> is way
past IFNAMSIZ.

I need a solution in which the intermediate name doesn't exceed 15
characters, and is guaranteed to be unique, as there may be lots of
udev instances running in parallel trying to do the same thing.

Ideas?

(note, vconfig can create VLANs for interfaces, which needs another 5
characters appended on the end, but that's for another day).

Thanks,
Matt

-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

^ permalink raw reply

* biosdevname v0.3.1
From: Matt Domsch @ 2010-11-29  4:48 UTC (permalink / raw)
  To: linux-hotplug, netdev, K, Narendra, Hargrave, Jordan,
	Rose, Charles, Co

I've published biosdevname v0.3.1.  This has quite a few changes since
the 0.2.4 version published over 3 years ago.  Grab it here:

http://linux.dell.com/files/biosdevname/permalink/biosdevname-0.3.1.tar.gz
http://linux.dell.com/files/biosdevname/permalink/biosdevname-0.3.1.tar.gz.sign
GIT: http://linux.dell.com/cgi-bin/gitweb/gitweb.cgi?p=biosdevname.git;a=summary

Highlights:
- uses sysfs index and SMBIOS information if available.
- The only policies that remain are the new default 'physical' policy
  that uses sysfs index (SMBIOS), and the historic all_ethN policy
  that is only usable in non-hotplug environments.
- works on SR-IOV devices as well as traditional NICs

The naming policy it suggests are as follows:

Embedded devices: em<port>
Add-in PCI cards: pci<slot>#<port>_<virtual function instance>

My goal is to get this into Fedora 15, RHEL 6.x (x TBD), Debian, Ubuntu Natty,
openSUSE, and any other distribution that will have it.



git shortlog:

Gabriel C (1):
      add make uninstall target

Jordan Hargrave (2):
      fix mmap() return check
      bump version

Matt Domsch (72):
      Fix 'make deb' so it works.
      add 'make sdeb' for source debian packages for review
      include pkg/debian/ in tarball
      rpm specs: manpages are sometimes automatically compressed
      rpm spec: fix manpage in %files, add udev version requirement for Fedora
      update Makefile.in
      add chassis_label field
      add smbios_names naming policy
      ensure display buffer is long enough and zeroed before use
      bug fix: s/sprintf/snprintf/ leading to SEGV
      dmidecode: get proper chassis label string
      naming_policy: fix smbios_names reporting
      exit with error code if --policy=smbios_names but BIOS doesn't have the info
      make dev->bios_name[] a pointer
      udev rules: don't rename, create symlinks in net/by-slot-name and net/by-chassis-label instead
      strip trailing whitespace from SMBIOS strings
      remove extra spaces in udev rules, to work around udev bug
      add intermediary program /lib/udev/netdevice to cycle through biosdevname policies
      finish fixing up configure/Makefiles
      start netdevnames at 71; make netdevice exectuable
      s/chassis_label/smbios_label/
      move sysfs reading function from pcmcia to its own file
      read sysfs label and index files for PCI devices
      minor cleanups; dead code removal
      remove generated files from source control
      configure: note requires pciutils-devel
      read label and index from sysfs if present
      add policy=loms, make it default
      add .gitignore
      silently handle running in virtualization, bug fix storing sysfs label
      better configure messages on missing zlib-devel and pciutils-devel
      fix buglet in add_interface, with thanks to gcc 4.4.5 -Wall
      don't use perror() to print meaningless warnings to users
      don't print error opening /dev/mem, as fails on KVM guests
      bugfixes in reading sysfs files
      invoke biosdevname directly from udev rule, --policy=loms
      remove the netdevice script from install
      add policy=loms to manpage
      fix Makefile uninstall-local failure
      fix udev rules typo
      finish removing netdevice script
      update changelogs, bump version
      rename policy=loms to =embedded, use enX instead of lomX
      make embedded NIC name configurable, default ='en'
      add --prefix to manpage
      Use sysfs to find parent devices and slot
      add --policy=pony (to be renamed later) naming of PCI devices
      attach VFs to PFs, unparse the lists when debugging
      assign names to PCI VFs as pci1#0_2 for slot 1, port 0, VF 2
      change default embedded prefix to "em"
      allow all combinations of embedded/add-in, PF or VF, in naming
      don't use #port nomenclature for embedded devices
      mark HP embedded NICs as being embedded
      remove unused function
      s/pony/physical/
      fix udev rule policy name
      change udev rule to set NAME=, so stateful names persistent names aren't written to 70-persistent-net.rules
      add additional checks and define _GNU_SOURCE in configure.ac
      get VF index from sysfs
      fix getting VF indices from sysfs
      more fixes for SRIOV detection
      move setting slot_index into pci.c, fixes failures with SR-IOV devices; other cleanups.
      don't print to stderr on SIOCGIFHWADDR failure
      note that index_in_slot is only valid for physical slot PF devices
      POLICY DELETIONS: delete all policies but all_ethN and physical (default)
      only print Index in slot where it's valid
      fix manpage for policy deletions
      clean up manpage and help text
      fix use of uses_smbios
      update manpage with the naming policies in use now
      document return codes in manpage
      bump version string to 0.3.1


Thanks,
Matt

-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

^ permalink raw reply

* [PATCH][ ARM cpu hotplug 1/2 ] extract common code for arm cpu hotplug
From: Vincent Guittot @ 2010-11-29  9:48 UTC (permalink / raw)
  To: linux-hotplug

This patch extracts the common code of the cpu hotplug feature across
arm platforms. The goal is to only keep the specific stuff of the
platform in the sub-architecture. I have created a hotplug.c file in
the  arm/common directory after studying the cpu hotplug code of
omap2, realview, s5pv310, ux500 and tegra. I have extracted 3 main
platform dependent functions:
  -platform_enter_lowpower which prepares the platform for low power.
  -platform_do_lowpower on which the cpu will loop until it becomes
really plugged (spurious wake up). This function must returned the cpu
Id in order to leave the unplug state.
  -platform_leave_lowpower which restore the platform context.

 An ux500 patch is available which uses the common/hotplug.c code.
This patch is quite short because the idle / power down functions are
not yet upstreamed


Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
 arch/arm/common/Kconfig        |    4 ++
 arch/arm/common/Makefile       |    1 +
 arch/arm/common/hotplug.c      |   85 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/hotplug.h |    8 ++++
 4 files changed, 98 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/common/hotplug.c
 create mode 100644 arch/arm/include/asm/hotplug.h

diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 0a34c81..b1c5f6b 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -41,3 +41,7 @@ config SHARP_SCOOP
 config COMMON_CLKDEV
 	bool
 	select HAVE_CLK
+
+config USE_COMMON_ARM_HOTPLUG
+	bool
+	depends on HOTPLUG_CPU
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index e6e8664..d8a66d7 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
 obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
+obj-$(CONFIG_USE_COMMON_ARM_HOTPLUG)		+= hotplug.o
diff --git a/arch/arm/common/hotplug.c b/arch/arm/common/hotplug.c
new file mode 100644
index 0000000..05f39f9
--- /dev/null
+++ b/arch/arm/common/hotplug.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) STMicroelectronics 2009
+ * Copyright (C) ST-Ericsson SA 2010
+ *
+ * License Terms: GNU General Public License v2
+ *	Based on ARM realview platform
+ *
+ * Author: Sundar Iyer <sundar.iyer@stericsson.com>
+ * Author: Vincent Guittot <vincent.guittot@stericsson.com>
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/smp.h>
+#include <linux/completion.h>
+
+#include <asm/cacheflush.h>
+#include <asm/hotplug.h>
+
+static DECLARE_COMPLETION(cpu_killed);
+
+int platform_cpu_kill(unsigned int cpu)
+{
+	int err;
+	err = wait_for_completion_timeout(&cpu_killed, 5000);
+#ifdef DEBUG
+	printk(KERN_INFO "platform_cpu_kill %d err %d\n", cpu, err);
+#endif
+	return err;
+}
+
+/*
+ * architecture-specific code to shutdown a CPU
+ *
+ * Called with IRQs disabled
+ */
+void platform_cpu_die(unsigned int cpu)
+{
+	unsigned long spurious = 0;
+#ifdef DEBUG
+	unsigned int this_cpu = hard_smp_processor_id();
+
+	if (cpu != this_cpu) {
+		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
+			   this_cpu, cpu);
+		BUG();
+	}
+
+	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
+#endif
+	complete(&cpu_killed);
+
+	flush_cache_all();
+	wmb();
+
+	platform_enter_lowpower(cpu);
+
+	for (;;) {
+
+		if (platform_do_lowpower(cpu) = cpu) {
+			/*
+			 * OK, proper wakeup, we're done
+			 */
+			break;
+		}
+		spurious++;
+	}
+
+	platform_leave_lowpower(cpu);
+
+#ifdef DEBUG
+	printk(KERN_NOTICE "CPU%u: wake up (%lu spurious wake up)\n",
+			cpu, spurious);
+#endif
+
+}
+
+int platform_cpu_disable(unsigned int cpu)
+{
+	/*
+	 * we don't allow CPU 0 to be shutdown (it is still too special
+	 * e.g. clock tick interrupts)
+	 */
+	return cpu = 0 ? -EPERM : 0;
+}
diff --git a/arch/arm/include/asm/hotplug.h b/arch/arm/include/asm/hotplug.h
new file mode 100644
index 0000000..b38e737
--- /dev/null
+++ b/arch/arm/include/asm/hotplug.h
@@ -0,0 +1,8 @@
+#ifndef __ASM_MACH_HOTPLUG_H
+#define __ASM_MACH_HOTPLUG_H
+
+extern void platform_enter_lowpower(unsigned int cpu);
+extern int platform_do_lowpower(unsigned int cpu);
+extern void platform_leave_lowpower(unsigned int cpu);
+
+#endif
-- 
1.7.0.4

^ permalink raw reply related

* [PATCH][ ARM cpu hotplug 2/2 ] Use common cpu hotplug code for UX500
From: Vincent Guittot @ 2010-11-29  9:49 UTC (permalink / raw)
  To: linux-hotplug

This patch extracts the common code of the cpu hotplug feature across
arm platforms. The goal is to only keep the specific stuff of the
platform in the sub-architecture. I have created a hotplug.c file in
the  arm/common directory after studying the cpu hotplug code of
omap2, realview, s5pv310, ux500 and tegra. I have extracted 3 main
platform dependent functions:
  -platform_enter_lowpower which prepares the platform for low power.
  -platform_do_lowpower on which the cpu will loop until it becomes
really plugged (spurious wake up). This function must returned the cpu
Id in order to leave the unplug state.
  -platform_leave_lowpower which restore the platform context.

 An ux500 patch is available which uses the common/hotplug.c code.
This patch is quite short because the idle / power down functions are
not yet upstreamed

Signed-off-by: Vincent Guittot <vincent.guittot@stericsson.com>
---
 arch/arm/Kconfig              |    1 +
 arch/arm/mach-ux500/Makefile  |    2 +-
 arch/arm/mach-ux500/hotplug.c |   68 +++++++++-------------------------------
 arch/arm/mach-ux500/platsmp.c |    2 +
 4 files changed, 20 insertions(+), 53 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index ca96a44..ee74cf9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -797,6 +797,7 @@ config ARCH_U8500
 	select GENERIC_CLOCKEVENTS
 	select COMMON_CLKDEV
 	select ARCH_REQUIRE_GPIOLIB
+	select USE_COMMON_ARM_HOTPLUG if HOTPLUG_CPU
 	help
 	  Support for ST-Ericsson's Ux500 architecture

diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
index 0612013..cb86197 100644
--- a/arch/arm/mach-ux500/Makefile
+++ b/arch/arm/mach-ux500/Makefile
@@ -8,7 +8,7 @@ obj-$(CONFIG_UX500_SOC_DB8500)	+= cpu-db8500.o
devices-db8500.o prcmu.o
 obj-$(CONFIG_MACH_U8500_MOP)	+= board-mop500.o board-mop500-sdi.o
 obj-$(CONFIG_MACH_U5500)	+= board-u5500.o
 obj-$(CONFIG_SMP)		+= platsmp.o headsmp.o
-obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
+obj-$(CONFIG_USE_COMMON_ARM_HOTPLUG)	+= hotplug.o
 obj-$(CONFIG_LOCAL_TIMERS)	+= localtimer.o
 obj-$(CONFIG_REGULATOR_AB8500)	+= board-mop500-regulators.o
 obj-$(CONFIG_U5500_MODEM_IRQ)	+= modem_irq.o
diff --git a/arch/arm/mach-ux500/hotplug.c b/arch/arm/mach-ux500/hotplug.c
index b782a03..14a614f 100644
--- a/arch/arm/mach-ux500/hotplug.c
+++ b/arch/arm/mach-ux500/hotplug.c
@@ -6,70 +6,34 @@
  *	Based on ARM realview platform
  *
  * Author: Sundar Iyer <sundar.iyer@stericsson.com>
+ * Author: Vincent Guittot <vincent.guittot@stericsson.com>
  *
+ * We only keep platform related code in the subarchitecture directory.
+ * The common code across platform has been moved into kernel/common directory
  */
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/smp.h>
-#include <linux/completion.h>

-#include <asm/cacheflush.h>
+#include <asm/hotplug.h>

 extern volatile int pen_release;

-static DECLARE_COMPLETION(cpu_killed);
-
-static inline void platform_do_lowpower(unsigned int cpu)
-{
-	flush_cache_all();
-
-	/* we put the platform to just WFI */
-	for (;;) {
-		__asm__ __volatile__("dsb\n\t" "wfi\n\t"
-				: : : "memory");
-		if (pen_release = cpu) {
-			/*
-			 * OK, proper wakeup, we're done
-			 */
-			break;
-		}
-	}
-}
-
-int platform_cpu_kill(unsigned int cpu)
+/* Default implementation that will be used if not override
+ * by power specific implementation
+ */
+void __attribute__((weak)) platform_enter_lowpower(unsigned int cpu)
 {
-	return wait_for_completion_timeout(&cpu_killed, 5000);
+	return;
 }

-/*
- * platform-specific code to shutdown a CPU
- *
- * Called with IRQs disabled
- */
-void platform_cpu_die(unsigned int cpu)
+int __attribute__((weak)) platform_do_lowpower(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
+	__asm__ __volatile__("dsb\n\t" "wfi\n\t"
+				: : : "memory");

-	/* directly enter low power state, skipping secure registers */
-	platform_do_lowpower(cpu);
+	return pen_release;
 }

-int platform_cpu_disable(unsigned int cpu)
+void __attribute__((weak)) platform_leave_lowpower(unsigned int cpu)
 {
-	/*
-	 * we don't allow CPU 0 to be shutdown (it is still too special
-	 * e.g. clock tick interrupts)
-	 */
-	return cpu = 0 ? -EPERM : 0;
+	return;
 }
+
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index 9e4c678..3074260 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -51,6 +51,7 @@ void __cpuinit platform_secondary_init(unsigned int cpu)
 	 * pen, then head off into the C entry point
 	 */
 	pen_release = -1;
+	smp_wmb();

 	/*
 	 * Synchronise with the boot thread.
@@ -82,6 +83,7 @@ int __cpuinit boot_secondary(unsigned int cpu,
struct task_struct *idle)

 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
+		smp_rmb();
 		if (pen_release = -1)
 			break;
 	}
-- 
1.7.0.4

^ permalink raw reply related

* Re: [PATCH][ ARM cpu hotplug 2/2 ] Use common cpu hotplug code for UX500
From: Sundar @ 2010-11-29 14:13 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <AANLkTinmnN+Ta3LCpmL6kfjYLyY8eA8GspEmqEaaS8-p@mail.gmail.com>

Hi Vincent,

> On Mon, Nov 29, 2010 at 3:19 PM, Vincent Guittot <vincent.guittot@linaro.org> wrote:
>>
>> This patch extracts the common code of the cpu hotplug feature across
>> arm platforms. The goal is to only keep the specific stuff of the
>> platform in the sub-architecture. I have created a hotplug.c file in
>> the  arm/common directory after studying the cpu hotplug code of
>> omap2, realview, s5pv310, ux500 and tegra. I have extracted 3 main
>> platform dependent functions:
>>  -platform_enter_lowpower which prepares the platform for low power.
>>  -platform_do_lowpower on which the cpu will loop until it becomes
>> really plugged (spurious wake up). This function must returned the cpu
>> Id in order to leave the unplug state.
>>  -platform_leave_lowpower which restore the platform context.
>>  An ux500 patch is available which uses the common/hotplug.c code.
>> This patch is quite short because the idle / power down functions are
>> not yet upstreamed
>>
>

I had posted a patch which does exactly the same thing sometime ago,
but it got dropped
off from the radar. The patch set can be referenced
@ http://www.spinics.net/lists/arm-kernel/msg97600.html
I remember getting it Acked by most of the platform maintainers, but
Russell had some
reservations on that.

Cheers!

--
---------
The views expressed in this email are my personal ones and do not
necessarily echo my employers.

^ permalink raw reply

* Re: [PATCH][ ARM cpu hotplug 1/2 ] extract common code for arm cpu hotplug
From: Vincent Guittot @ 2010-11-29 17:27 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <20101129104149.GA10703@n2100.arm.linux.org.uk>

The goal of this patch is to remove as much duplicated code as
possible in each platform hotplug file. I have also tried to keep in
mind that current platform upstreamed code make nearly no power
management in their current implementation. I have added a new
interface and a new file in order to
 -Keep the current interface as it is. So each platform could move to
common code when they want
 -Have a dedicated file for arm hotplug function in which we can add
all code that must be executed on an arm core whatever the platform
(flushing cache, SCU disabling and handling spurious wake up as a
staring  point). I agree that the current code is quite small for now
and we can wonder if a dedicated file is useful, code might be put in
kernel/smp.c file.
The next step is also to add some hotplug tracepoints and I would
prefer to add the tracepoints only in a platform independent code.

With the common code, a new arm platform can have the hotplug feature
with less than 20 lines (power management not included) and can be
sure that minimal actions will be handled by the common Arm code.

We can also keep the platform_cpu_die has the platform entry point and
move the common part into kernel/smp.c file. We still have few
duplicated code (spurious wake-up) but this seems to be acceptable.

I have taken your example into account and have updated the patch accordingly

Vincent

On 29 November 2010 11:41, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Mon, Nov 29, 2010 at 10:54:35AM +0100, Vincent Guittot wrote:
>> This patch extracts the common code of the cpu hotplug feature across
>> arm platforms. The goal is to only keep the specific stuff of the
>> platform in the sub-architecture. I have created a hotplug.c file in
>> the  arm/common directory after studying the cpu hotplug code of
>> omap2, realview, s5pv310, ux500 and tegra. I have extracted 3 main
>> platform dependent functions:
>>  -platform_enter_lowpower which prepares the platform for low power.
>>  -platform_do_lowpower on which the cpu will loop until it becomes
>> really plugged (spurious wake up). This function must returned the cpu
>> Id in order to leave the unplug state.
>>  -platform_leave_lowpower which restore the platform context.
>
> I still do not like this patch.  The only thing that is worth doing is
> this.  This leaves less than 256 bytes of object code in the Realview
> hotplug.c, most of which is the stuff to handle the low power mode
> which you haven't dealt with in your patch either.
>
> I see no point in adding another API on top of the already existing
> and simple API.
>

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
 arch/arm/kernel/smp.c              |   35 ++++++++++++++++++++----
 arch/arm/mach-omap2/omap-hotplug.c |   28 -------------------
 arch/arm/mach-realview/hotplug.c   |   29 --------------------
 arch/arm/mach-s5pv310/hotplug.c    |   29 --------------------
 arch/arm/mach-tegra/hotplug.c      |   30 ---------------------
 arch/arm/mach-ux500/hotplug.c      |   51 +++++-------------------------------
 6 files changed, 36 insertions(+), 166 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 8c19595..03042db 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -24,6 +24,7 @@
 #include <linux/irq.h>
 #include <linux/percpu.h>
 #include <linux/clockchips.h>
+#include <linux/completion.h>

 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
@@ -213,11 +214,13 @@ int __cpu_disable(void)
 {
 	unsigned int cpu = smp_processor_id();
 	struct task_struct *p;
-	int ret;

-	ret = platform_cpu_disable(cpu);
-	if (ret)
-		return ret;
+	/*
+	 * we don't allow CPU 0 to be shutdown (it is still too special
+	 * e.g. clock tick interrupts)
+	 */
+	if (cpu = 0)
+		return -EPERM;

 	/*
 	 * Take this CPU offline.  Once we clear this, we can't return,
@@ -252,14 +255,16 @@ int __cpu_disable(void)
 	return 0;
 }

+static DECLARE_COMPLETION(cpu_killed);
+
 /*
  * called on the thread which is asking for a CPU to be shutdown -
  * waits until shutdown has completed, or it is timed out.
  */
 void __cpu_die(unsigned int cpu)
 {
-	if (!platform_cpu_kill(cpu))
-		printk("CPU%u: unable to kill\n", cpu);
+	if (!wait_for_completion_timeout(&cpu_killed, 5000))
+		printk(KERN_NOTICE "CPU%u: cpu didn't die\n", cpu);
 }

 /*
@@ -273,14 +278,32 @@ void __cpu_die(unsigned int cpu)
 void __ref cpu_die(void)
 {
 	unsigned int cpu = smp_processor_id();
+#ifdef DEBUG
+	unsigned int this_cpu = hard_smp_processor_id();
+#endif

 	local_irq_disable();
 	idle_task_exit();

+	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
+	complete(&cpu_killed);
+
+#ifdef DEBUG
+	if (cpu != this_cpu) {
+		printk(KERN_CRIT "Eek! platform_cpu_die is going to run on %u,
should be %u\n",
+			   this_cpu, cpu);
+		BUG();
+	}
+#endif
+
+	flush_cache_all();
+	wmb();
+
 	/*
 	 * actual CPU shutdown procedure is at least platform (if not
 	 * CPU) specific
 	 */
+
 	platform_cpu_die(cpu);

 	/*
diff --git a/arch/arm/mach-omap2/omap-hotplug.c
b/arch/arm/mach-omap2/omap-hotplug.c
index 6cee456..00f4190 100644
--- a/arch/arm/mach-omap2/omap-hotplug.c
+++ b/arch/arm/mach-omap2/omap-hotplug.c
@@ -17,35 +17,15 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>

-#include <asm/cacheflush.h>
 #include <mach/omap4-common.h>

-static DECLARE_COMPLETION(cpu_killed);
-
-int platform_cpu_kill(unsigned int cpu)
-{
-	return wait_for_completion_timeout(&cpu_killed, 5000);
-}
-
 /*
  * platform-specific code to shutdown a CPU
  * Called with IRQs disabled
  */
 void platform_cpu_die(unsigned int cpu)
 {
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		pr_crit("platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-	pr_notice("CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-	flush_cache_all();
-	dsb();

 	/*
 	 * we're ready for shutdown now, so do it
@@ -69,11 +49,3 @@ void platform_cpu_die(unsigned int cpu)
 	}
 }

-int platform_cpu_disable(unsigned int cpu)
-{
-	/*
-	 * we don't allow CPU 0 to be shutdown (it is still too special
-	 * e.g. clock tick interrupts)
-	 */
-	return cpu = 0 ? -EPERM : 0;
-}
diff --git a/arch/arm/mach-realview/hotplug.c b/arch/arm/mach-realview/hotplug.c
index f95521a..580cf7c 100644
--- a/arch/arm/mach-realview/hotplug.c
+++ b/arch/arm/mach-realview/hotplug.c
@@ -11,19 +11,16 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>

 #include <asm/cacheflush.h>

 extern volatile int pen_release;

-static DECLARE_COMPLETION(cpu_killed);

 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;

-	flush_cache_all();
 	asm volatile(
 	"	mcr	p15, 0, %1, c7, c5, 0\n"
 	"	mcr	p15, 0, %1, c7, c10, 4\n"
@@ -93,11 +90,6 @@ static inline void platform_do_lowpower(unsigned int cpu)
 	}
 }

-int platform_cpu_kill(unsigned int cpu)
-{
-	return wait_for_completion_timeout(&cpu_killed, 5000);
-}
-
 /*
  * platform-specific code to shutdown a CPU
  *
@@ -105,18 +97,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);

 	/*
 	 * we're ready for shutdown now, so do it
@@ -130,12 +110,3 @@ void platform_cpu_die(unsigned int cpu)
 	 */
 	cpu_leave_lowpower();
 }
-
-int platform_cpu_disable(unsigned int cpu)
-{
-	/*
-	 * we don't allow CPU 0 to be shutdown (it is still too special
-	 * e.g. clock tick interrupts)
-	 */
-	return cpu = 0 ? -EPERM : 0;
-}
diff --git a/arch/arm/mach-s5pv310/hotplug.c b/arch/arm/mach-s5pv310/hotplug.c
index 03652c3..59eafad 100644
--- a/arch/arm/mach-s5pv310/hotplug.c
+++ b/arch/arm/mach-s5pv310/hotplug.c
@@ -13,19 +13,16 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>

 #include <asm/cacheflush.h>

 extern volatile int pen_release;

-static DECLARE_COMPLETION(cpu_killed);

 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;

-	flush_cache_all();
 	asm volatile(
 	"	mcr	p15, 0, %1, c7, c5, 0\n"
 	"	mcr	p15, 0, %1, c7, c10, 4\n"
@@ -96,11 +93,6 @@ static inline void platform_do_lowpower(unsigned int cpu)
 	}
 }

-int platform_cpu_kill(unsigned int cpu)
-{
-	return wait_for_completion_timeout(&cpu_killed, 5000);
-}
-
 /*
  * platform-specific code to shutdown a CPU
  *
@@ -108,19 +100,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
@@ -134,11 +113,3 @@ void platform_cpu_die(unsigned int cpu)
 	cpu_leave_lowpower();
 }

-int platform_cpu_disable(unsigned int cpu)
-{
-	/*
-	 * we don't allow CPU 0 to be shutdown (it is still too special
-	 * e.g. clock tick interrupts)
-	 */
-	return cpu = 0 ? -EPERM : 0;
-}
diff --git a/arch/arm/mach-tegra/hotplug.c b/arch/arm/mach-tegra/hotplug.c
index 8e7f115..7e5eb3d 100644
--- a/arch/arm/mach-tegra/hotplug.c
+++ b/arch/arm/mach-tegra/hotplug.c
@@ -11,17 +11,14 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>

 #include <asm/cacheflush.h>

-static DECLARE_COMPLETION(cpu_killed);

 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;

-	flush_cache_all();
 	asm volatile(
 	"	mcr	p15, 0, %1, c7, c5, 0\n"
 	"	mcr	p15, 0, %1, c7, c10, 4\n"
@@ -92,11 +89,6 @@ static inline void platform_do_lowpower(unsigned int cpu)
 	}
 }

-int platform_cpu_kill(unsigned int cpu)
-{
-	return wait_for_completion_timeout(&cpu_killed, 5000);
-}
-
 /*
  * platform-specific code to shutdown a CPU
  *
@@ -104,19 +96,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
@@ -129,12 +108,3 @@ void platform_cpu_die(unsigned int cpu)
 	 */
 	cpu_leave_lowpower();
 }
-
-int platform_cpu_disable(unsigned int cpu)
-{
-	/*
-	 * we don't allow CPU 0 to be shutdown (it is still too special
-	 * e.g. clock tick interrupts)
-	 */
-	return cpu = 0 ? -EPERM : 0;
-}
diff --git a/arch/arm/mach-ux500/hotplug.c b/arch/arm/mach-ux500/hotplug.c
index b782a03..37b443b 100644
--- a/arch/arm/mach-ux500/hotplug.c
+++ b/arch/arm/mach-ux500/hotplug.c
@@ -6,23 +6,22 @@
  *	Based on ARM realview platform
  *
  * Author: Sundar Iyer <sundar.iyer@stericsson.com>
+ * Author: vincent.guittot <vincent.guittot@stericsson.com>
  *
  */
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>
-
-#include <asm/cacheflush.h>

 extern volatile int pen_release;

-static DECLARE_COMPLETION(cpu_killed);
-
-static inline void platform_do_lowpower(unsigned int cpu)
+/*
+ * platform-specific code to shutdown a CPU
+ *
+ * Called with IRQs disabled
+ */
+void platform_cpu_die(unsigned int cpu)
 {
-	flush_cache_all();
-
 	/* we put the platform to just WFI */
 	for (;;) {
 		__asm__ __volatile__("dsb\n\t" "wfi\n\t"
@@ -36,40 +35,4 @@ static inline void platform_do_lowpower(unsigned int cpu)
 	}
 }

-int platform_cpu_kill(unsigned int cpu)
-{
-	return wait_for_completion_timeout(&cpu_killed, 5000);
-}
-
-/*
- * platform-specific code to shutdown a CPU
- *
- * Called with IRQs disabled
- */
-void platform_cpu_die(unsigned int cpu)
-{
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-
-	/* directly enter low power state, skipping secure registers */
-	platform_do_lowpower(cpu);
-}

-int platform_cpu_disable(unsigned int cpu)
-{
-	/*
-	 * we don't allow CPU 0 to be shutdown (it is still too special
-	 * e.g. clock tick interrupts)
-	 */
-	return cpu = 0 ? -EPERM : 0;
-}
-- 
1.7.0.4

^ permalink raw reply related

* Re: [PATCH][ ARM cpu hotplug 1/2 ] extract common code for arm cpu
From: Russell King - ARM Linux @ 2010-11-29 19:24 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <AANLkTikHv+Rz7+bZY8Qo2drUQO4fjhJgqORcGFB7B6s7@mail.gmail.com>

On Mon, Nov 29, 2010 at 06:27:02PM +0100, Vincent Guittot wrote:
> The goal of this patch is to remove as much duplicated code as
> possible in each platform hotplug file. I have also tried to keep in
> mind that current platform upstreamed code make nearly no power
> management in their current implementation. I have added a new
> interface and a new file in order to
>  -Keep the current interface as it is. So each platform could move to
> common code when they want
>  -Have a dedicated file for arm hotplug function in which we can add
> all code that must be executed on an arm core whatever the platform
> (flushing cache, SCU disabling and handling spurious wake up as a
> staring  point). I agree that the current code is quite small for now
> and we can wonder if a dedicated file is useful, code might be put in
> kernel/smp.c file.
> The next step is also to add some hotplug tracepoints and I would
> prefer to add the tracepoints only in a platform independent code.
> 
> With the common code, a new arm platform can have the hotplug feature
> with less than 20 lines (power management not included) and can be
> sure that minimal actions will be handled by the common Arm code.
> 
> We can also keep the platform_cpu_die has the platform entry point and
> move the common part into kernel/smp.c file. We still have few
> duplicated code (spurious wake-up) but this seems to be acceptable.
> 
> I have taken your example into account and have updated the patch accordingly

No you haven't because you don't understand the point of keeping the
existing interfaces.  I'm not going to cripple the flexibility of the
current interface just in the name of merging them all together.

^ permalink raw reply

* make check error
From: robert @ 2010-11-30 21:30 UTC (permalink / raw)
  To: linux-hotplug

TEST 142: magic [subsys/sysname] attribute substitution
device 
'/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda' 
expecting node/link 'sda-8741C4G-end'
permissions: ok
add:         ok
remove:      ok

1 errors occured

FAIL: test/udev-test.pl
=======================
1 of 1 test failed
Please report to linux-hotplug@vger.kernel.org
=======================
make[3]: *** [check-TESTS] Error 1
make[2]: *** [check-am] Error 2
make[1]: *** [check-recursive] Error 1
make: *** [check] Error 2
root:/sources/udev-161# make check

^ permalink raw reply

* Re: make check error
From: Kay Sievers @ 2010-11-30 22:18 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <4CF56CDA.20308@gmail.com>

On Tue, Nov 30, 2010 at 22:30, robert <mullinrobert@gmail.com> wrote:
> TEST 142: magic [subsys/sysname] attribute substitution
> device
> '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda'
> expecting node/link 'sda-8741C4G-end'
> permissions: ok
> add:         ok
> remove:      ok
>
> 1 errors occured
>
> FAIL: test/udev-test.pl
> =======================
> 1 of 1 test failed
> Please report to linux-hotplug@vger.kernel.org
> =======================
> make[3]: *** [check-TESTS] Error 1
> make[2]: *** [check-am] Error 2
> make[1]: *** [check-recursive] Error 1
> make: *** [check] Error 2
> root:/sources/udev-161# make check

Hmm, I can't reproduce that in current code.

Kay

^ permalink raw reply

* udisks 1.0.2 released
From: Martin Pitt @ 2010-12-02  9:07 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 2356 bytes --]

Hello all,

here's a long overdue new udisks release, with support for two more
file systems (basic btrfs, and nilfs2), and a whole bunch of bug
fixes.

  http://hal.freedesktop.org/releases/udisks-1.0.2.tar.gz

  SHA1: a8307d726b7f1255e7008ff708c793a1301d1309
   MD5: f630eefa51b95d6485eb3246bc1bea9a

Thanks,

Martin

Changes from udisks 1.0.1:

David Zeuthen (5):
      Post-release version bump to 1.0.2
      Update to latest LVM2 API
      Don't probe non-data discs for partition tables
      Avoid using entities in introspection XML
      Also export UDISKS_DM_TARGET_PARAMS for 'multipath' target

Jiro SEKIBA (4):
      Add nilfs2 file system support
      Add nilfs2 label rename
      udisks: fix a bug of unquoted/unescaped label string
      udisks: escape backslash for label string

Marti Raudsepp (1):
      udisks: Avoid deprecated polkit_authority_get() function

Martin Pitt (24):
      testsuite: Check file permissions
      Bug 28075 — Do not have all files executable on vfat
      testsuite: mkfs() code cleanup
      Fix long hangs on probing nonexistant floppy drives
      Bug 28075 — Do not have files executable on NTFS
      Bug 26258 — initial btrfs support
      Fix btrfs properties
      profile.h: Add missing include
      testsuite: fix race with SMART data
      testsuite: Fix SMART test for SSDs
      testsuite: LVM: fix naming assumptions
      Fix mkfs.ext* arguments
      Fix creating NTFS on raw devices
      testsuite: Move to scsi_debug
      partutil: Explicitly use PART_TYPE_UNKNOWN
      Fix uninitialized variable in part-id
      testsuite: Check forced removal of LUKS encrypted device
      testsuite: Test forced removal of standard devices
      Fix building with Linux 2.6.37
      testsuite: Check correct handling of labels with funny characters
      testsuite: use shorter label for renaming
      Escape NTFS labels properly
      simplify validate_and_escape_label()
      Fix hang on setting invalid VFAT labels

Mathieu Trudel-Lapierre (1):
      Bug 30332 — udisks does not tear down LUKS devices when the slave is forci

Matt Zimmerman (1):
      Add udisks --eject option

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* udev_device_get_sysattr_value upon device remove
From: Stefan Harjes @ 2010-12-03 19:19 UTC (permalink / raw)
  To: linux-hotplug

Hi folks,

when I get an udev_device from the udev_monitor, because the device has been 
unplugged, the 'udev_device_get_sysattr_value()' call returns 'null' (in my 
case I was looking for the "serial" of an usb_device). From my understanding 
this value should still be cached, even if the device is already removed?

Is there any other way to get this value?

Best

Stefan

^ permalink raw reply

* Re: udev_device_get_sysattr_value upon device remove
From: Kay Sievers @ 2010-12-03 23:12 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <201012031319.54921.stefan.harjes@gmx.net>

On Fri, Dec 3, 2010 at 20:19, Stefan Harjes <stefan.harjes@gmx.net> wrote:
> when I get an udev_device from the udev_monitor, because the device has been
> unplugged, the 'udev_device_get_sysattr_value()' call returns 'null' (in my
> case I was looking for the "serial" of an usb_device). From my understanding
> this value should still be cached, even if the device is already removed?

Devices which are removed have no attributes, not in sysfs, not
anywhere else. They are just gone.

> Is there any other way to get this value?

You have to store stuff you want to remember in the udev database,
which is available during remove, everything else is not.

Kay

^ permalink raw reply

* biosdevname v0.3.2
From: Matt Domsch @ 2010-12-06 14:06 UTC (permalink / raw)
  To: linux-hotplug, netdev, K, Narendra, Hargrave, Jordan,
	Rose, Charles, Co

Bugfix update to biosdevname, now version 0.3.2.

The legacy code for reading the PCI IRQ Routing Table ($PIR) and the
PCMCIA information has been removed.  This means biosdevname will only
report BIOS-provided names if your system has SMBIOS 2.6 or higher and
has the information in Type 9 or Type 41.  This is in preparation for
widespread use, and will keep biosdevname from suggesting names on
systems that are well into or beyond their useful lifetime and
introducing an unexpected change of behavior on them.  Dell PowerEdge
10G and newer, HP ProLiant G6 and newer are known to have SMBIOS 2.6,
as do a number of desktop, laptop, and netbook-class systems as
reported on the fedora-devel mailing list.

This release also provides correct names for Intel and Broadcom
quad-port GigE cards that I've tried.  Format is pci<slot>#<port>.

Grab it here:
http://linux.dell.com/files/biosdevname/permalink/biosdevname-0.3.2.tar.gz
http://linux.dell.com/files/biosdevname/permalink/biosdevname-0.3.2.tar.gz.sign
git://linux.dell.com/biosdevname.git

This is already built in Fedora rawhide (will be 15), and I encourage
other distributions to pick it up as well.

On a related note, I've submitted a patch to dracut upstream to
include calls to biosdevname via udev.  This will let us use
BIOS-suggested names for network functionality during initramfs time,
such as finding your root file system on NFS or iSCSI.


Shortlog:

Matt Domsch (7):
      only match on smbios_type Ethernet, ignore sysfs index file for now
      PIRQ-ectomy, add pci_access pointer to state, pci_dev pointer instead of struct in pci_device
      PCMCIA-ectomy
      copy SMBIOS slot info to all matching domain/bus/device/functions
      skip bridges when setting index_in_slot
      fix RPM spec URL
      bump version


Thanks,
Matt

-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

^ permalink raw reply

* Re: net device renaming 2-step, IFNAMSIZ limit
From: Piter PUNK @ 2010-12-07  2:45 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20101129032908.GA29904@auslistsprd01.us.dell.com>

Matt Domsch wrote:
> I see this in the udev debug logs when using biosdevname (which I
> finally got working with SR-IOV devices tonight):
>
> renamed network interface eth60 to eth60-pci2#0_60
> renamed network interface eth60-pci2#0_60 to pci2#0_60
>
> So, it worked, however, note that the rename happens in 2 steps, the
> middle step of which uses a name that's dangerously close to
> IFNAMSIZ, in fact it is 15 chars there.
>
> <...>
>
> I need a solution in which the intermediate name doesn't exceed 15
> characters, and is guaranteed to be unique, as there may be lots of
> udev instances running in parallel trying to do the same thing.
>
> Ideas?

As we talk on #udev, there is a patch that uses hash32 function inside 
libudev to create
the intermediate name. We use the "oldname-newname" to create the hash. 
With that,
exceeding IFNAMSIZ isn't a problem:

-------cut here--------

diff --git a/udev/udev-event.c b/udev/udev-event.c
index 0648735..fc4aae0 100644
--- a/udev/udev-event.c
+++ b/udev/udev-event.c
@@ -462,6 +462,7 @@ static void rename_netif_kernel_log(struct ifreq ifr)
  static int rename_netif(struct udev_event *event)
  {
         struct udev_device *dev = event->dev;
+       char iftmp[IFNAMSIZ*2+1];
         int sk;
         struct ifreq ifr;
         int loop;
@@ -492,7 +493,8 @@ static int rename_netif(struct udev_event *event)
                 goto out;

         /* free our own name, another process may wait for us */
-       util_strscpyl(ifr.ifr_newname, IFNAMSIZ, 
udev_device_get_sysname(dev), "-", event->name, NULL);
+       util_strscpyl(iftmp, IFNAMSIZ*2+1, udev_device_get_sysname(dev), 
"-", event->name, NULL);
+       util_strscpyl(ifr.ifr_newname, IFNAMSIZ, "eth_%X", 
util_string_hash32(iftmp), NULL);
         err = ioctl(sk, SIOCSIFNAME, &ifr);
         if (err < 0) {
                 err = -errno;

-------cut here--------

Ideas and fixes are welcome,

Piter PUNK

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox