2011年4月15日 星期五

[筆記] Device and Bus Power Management

[http://www.lesswatts.org/projects/devices-power-management/usb.php]

Device and Bus Power Management

line

USB selective suspend

This is a project in progress for the USB subsystem. USB selective suspend allows you to suspend a USB device on demand. If one device doesn't support selective suspend, then the entire bus must remain active. This not only consumes USB bus power unnecessarily, but also prevents the CPU from entering lower power states.
A white paper describing USB selective suspend can be found here.

Autosuspend on Linux

For a device to be autosuspended in Linux, it must have in-kernel driver support. Currently there are several types of USB devices that have autosuspend support:

  • printers
  • hubs
  • some USB Ethernet devices
  • USB LCDs

Although kernel drivers may support autosuspend, some USB devices may not properly implement autosuspend. These devices may behave in unexpected ways, or simply not work after the kernel attempts to suspend them. Often a physical disconnection from the bus will fix the problem, but only until the kernel attempts to suspend the device again.

If you see these types of problems, please send mail to linux-usb-users@lists.sourceforge.net. Include output from `lsusb -v`, dmesg output with CONFIG_USB_DEBUG turned on, and a description of the symptoms. We would also appreciate a note that your USB device actually works with autosuspend.

Enabling Autosuspend

To enable autosuspend, you must recompile your kernel with CONFIG_USB_SUSPEND. (As of 2.6.23-rc6, this feature is marked "experimental".) You may also want to enable CONFIG_USB_DEBUG so you can see suspend and resume messages via dmesg.

Autosuspending USB devices

To attempt to autosuspend your USB device, first use lsusb as root to find out the bus number and device number of your usb device:
# lsusb Bus 005 Device 014: ID 04b3:4485 IBM Corp. Bus 005 Device 001: ID 0000:0000 Bus 004 Device 009: ID 0483:2016 SGS Thomson Microelectronics Fingerprint Reader Bus 004 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 Bus 003 Device 001: ID 0000:0000 Bus 001 Device 008: ID 04b3:310c IBM Corp. Bus 001 Device 007: ID 050d:0121 Belkin Components F5D5050 100Mbps Ethernet Bus 001 Device 001: ID 0000:0000 
Then find your device's directory in /sys/bus/usb/devices/. Look in directories that are named with two numbers separated with a dash:
/sys/bus/usb/devices# ls 1-0:1.0  1-1  1-1:1.0  1-2  1-2:1.0  2-0:1.0  3-0:1.0  4-0:1.0  4-2 4-2:1.0  5-0:1.0  5-6  5-6:1.0  usb1  usb2  usb3  usb4  usb5 /sys/bus/usb/devices# cat 1-1/busnum 1 /sys/bus/usb/devices# cat 1-1/devnum 8 /sys/bus/usb/devices# cat 1-2/busnum 1 /sys/bus/usb/devices# cat 1-2/devnum  7 
We know the USB to ethernet device's directory is 1-2 because the device and bus numbers match the lsusb output. Now we can tell the kernel that it should suspend this device automatically if it is not being used. First we set the idle timeout to 2 seconds:
/sys/bus/usb/devices# echo 2 > 1-2/power/autosuspend
The timeout can be set to any integer number of seconds. If set to -1, the device will not autosuspend. Then we make sure the kernel will automatically suspend the device, and resume the device if data needs to be transferred:
/sys/bus/usb/devices# echo auto > 1-2/power/level

Other options to echo to this file are "on" and "suspend":

  • "on" will force the device to be on all the time.
  • "suspend" will permanently suspend the device until the user echoes "on" or "auto" to this file.
    (Note that this is a simplification, since the value of the power/wakeup file may allow the device to signal a remote wakeup.)

For a more complete description of USB power management, see the file Documentation/usb/power-management.txt, which is in kernel sources 2.6.24-rc2 and later.

2011年1月30日 星期日

[心情] 2011/01/27ㄧ出生就不孤單...

兩隻小老虎在大家期待了9個月後終於來報到了,
目前一切健康, 體重也還算足夠 (男生: 2460, 女生: 2680),
雖然跟其他的小朋友動則 2800~3400比起來相對輕了一點
不過畢竟是一次兩個, 如果身體健健康康, 其他出來再養應該也是可以

希望以後你們可以像媽媽每天跟你們說的
相親相愛, 天天笑嘻嘻... 乖乖吃飯 乖乖睡覺, 開開心心的長大.....

2011年1月25日 星期二

[轉貼] 中階主管必備4技能,收服部屬的心

原文 -

http://www.managertoday.com.tw/index.php?mod=locality&func=view&id=2396


本文取材自《寫給經理的教科書》,先覺出版。整理 / 陳立唐

當上主管是一件讓人開心的事,卻也是操心的開始,不但要達成上級交付的任務,還要帶領部屬有效率地工作。這種情形,最常發生在中階主管身上。


中階主管必須具備的能力很多,像專業能力、溝通能力等等,但更重要的是必須體認和熟悉自己應該扮演的角色:連結高層和基層彼此不同的想法,化解價值觀差異,並創造溝通機會。由於公司經營者和第一線人員負責的任務大不相同,所以中階管理者須設法將領導者的願景,轉化成可實行的計畫,再交由部屬付諸行動。


這個「承上啟下」的角色,正是中階主管最大的考驗,因為中階主管的績效優劣,除了自身的專業能力之外,最主要是取決於旗下部屬的工作成效,而管理高層也會以此做為評斷中階主管管理能力的標準。為了贏得部屬的心,帶領他們合力達成公司的目標,主管不妨培養以下4項技巧:


1.營造坦誠文化,讓部屬敢說真話:組織很常發生報喜不報憂的情形,許多像是應收帳款還未收回或客戶跑單之類的壞消息,部屬有時會選擇隱匿不報,這對公司絕對有害無益。


為營造坦誠的企業文化,主管在碰到問題時,應和部屬一起面對,而非一味怪罪,如此才能取得員工的信任,也才能在碰到壞消息時,及早被告知,即時採取適當的解決方式。


2.部屬表現好壞,都要給予評價:對於績效良好的員工,應公開給予讚美,一方面表達謝意,另一方面也要讓員工了解目前的努力方向是正確的。對待表現欠佳的員工,則應在確實了解問題之後,於私下場合責備並提供指導。


主管若是對於員工的表現漠不關心,部屬不但無法了解主管的想法,也可能會在工作上草率應付。


3.「重視」、而非「監視」部屬:所謂「走動式管理」,是為了讓主管可以從現場工作中,掌握及了解第一手資訊。然而,許多主管接觸基層職員的目的,卻是為了監控部屬的工作進度,連瑣碎的雜事也不放過,結果只會適得其反。


主管一旦將任務交派給部屬,就應該信任員工的能力,放手讓他們盡情發揮,才能創造最大的功效。


4.引導部屬自己找答案:部屬遇到問題時,在條件許可下,主管未必要馬上提供協助,反倒可以透過提問,試著讓對方自行找尋解決方案,如此將有助於激發員工潛能,提升員工的信心。在這種時候,主管應以聆聽取代表達,以提問取代建議,創造一個互相的學習成長空間。

2011年1月11日 星期二

[筆記] uboot kernel command - root=

uboot中的kernel command會帶著資訊通知kernel想要怎麼boot
其中指定著rootfs的段落 可以寫成

root=/dev/had0
root=/dev/nfs
root=/dev/ram
root=/dev/mtd/0
root=31:01 ??

關於數字這部份 我ㄧ直指大概知道01是後面接著command的mtdparts=xxx的第一個block
但是卻都沒有考究過原因, 今天無聊找一下則確定...
31基本上是linux對於mtd device所給予的device major number
01則是代表block #1, device minor number

以上 筆記一下...

p.s 這個linux有不少uboot/linux的紀錄...


2010年12月30日 星期四

[工作] vmware tools+ubuntu10.10

我的ubuntu是安裝在vmware下, 而share folder的功能需要先裝vmware tools,
但是在安裝vmware tools的過程 應該是因為vmware版本太舊, ubuntu版本太新
造成build vmhgfs.ko的時候很多linux header file有些資料結構不match, 所以一堆erros就此產生...
(google一下似乎一堆人遇到類似的問題... )

ㄧ個比較麻煩但是可以解決的方法是, 續open-vm-tool抓最新版的source,
然後把vm-tool的header跟著跟新, 這樣應該可以解決問題

或是ubuntu也有跟著maintain vm-tool, 可以透過apt-get來更新
sudo apt-get install open-vm-tools open-vm-toolbox open-vm-dkms
這個方式可以確保你的ubuntu版本跟vm-tool的版本可以心靈相契合, 而不至於有問題,

安裝完畢後 重開系統, 然後應該就可以在lsmod | grep vm 看到vmhgfs的kernel module掛載著

接下來只要 ...

1. vmware-hgfsclient <-- 來顯示所有的windows share folder
2. mkdir /mnt/hgfs <-- 建立mount point
3. mount -t vmhgfs .host:/${share_folder} /mnt/hgfs

接下來就可以讓windows跟vmware/ubuntu ㄧ起共享folder了!!





2010年12月29日 星期三

[轉錄] initcall


弄了kgdb之後發現怎麼kgdbwait都無法啟動,
回頭看了System.map發現原來init_kgdb居然比tty driver早呼叫了,
以至於在init_kgdb中要find_polled_tty_driver的時候當然找不到

這邊文章介紹了 initcall 的機制, 雖然沒解決我的問題 不過卻是個還不錯的起頭...

回歸我的問題.... 仔細看一下polled_tty_driver之後發現是因為

我的serial driver沒有poll_put_char 跟poll_get_char, 所以補上這兩個之後
kgdbwait就會在等待host端來connect, 不過目前可能是因為get/put沒有做好
所以似乎 無法連上.... /_\


2010年12月28日 星期二

[科技] Wine installed

之前一直知道Linux上面現在可以安裝windows的軟體來跑...
這兩天看到後面同事用了很久, 趁工作比較不忙的時候想來安裝一下試試看

Wine是在1993在由Bob Amstadt及Eric Youngdale所發起的, 最初的目
的是希望在Windows上跑Linux的程式, 現在則相反的在Linux上可以跑Windows
的軟體, 更詳細的故事可以google一下 :-)

而實在懶的查到底最小安裝需要些什麼東西, 所以就大雜燴跟wine有關
的packge全拉下來... 可以先透過 yum來install所有相關wine的package
e.g yum install wine*

接著就是等待安裝的過程了~~ 自動下載安裝完畢之後只要透過wine來
執行想安裝的軟體就可以了
e.g wine xxx.exe

看來現在目前最想在linux上使用的大概就是source insight或是ultraedit了
XD... vim用了一陣子, 但是可能不夠認真, 很多command背了就用, 忘了再查
查了又忘 哈~~