<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PCI &#8211; richliu&#039;s blog</title>
	<atom:link href="https://richliu.com/tag/pci/feed/" rel="self" type="application/rss+xml" />
	<link>https://richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Wed, 16 Dec 2009 16:14:46 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Linux kernel PCI Domains Support for ARM</title>
		<link>https://richliu.com/2009/12/17/831/linux-kernel-pci-domains-support-for-arm/</link>
					<comments>https://richliu.com/2009/12/17/831/linux-kernel-pci-domains-support-for-arm/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 16 Dec 2009 16:11:15 +0000</pubDate>
				<category><![CDATA[隨手札記]]></category>
		<category><![CDATA[arm]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PCI]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=831</guid>

					<description><![CDATA[<p>Linux kernel 支援不同 domain 的 PCI, 看起來是 ACPI 的功能之一. 其他平台看起 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2009/12/17/831/linux-kernel-pci-domains-support-for-arm/">Linux kernel PCI Domains Support for ARM</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Linux kernel 支援不同 domain 的 PCI, 看起來是 ACPI 的功能之一.<br />
其他平台看起來也有支援, 像是 sparc or mips 都有.</p>
<p>但是在 ARM 上並沒有這樣的支援</p>
<p>我的平台有 2 個 PCIe Host Controller , 而且都要設定在 PCIe bus 0 上面.<br />
這時就拿 PCI domain 的 code 來用最快,<br />
以下就是 Sample Code 和 ARM 部份的 Patch Code (不含我目前使用平台的 Patch)</p>
<p><span id="more-831"></span><br />
  Seems ARM don&#8217;s support PCI Domains function now.<br />
Here is a tiny patch for PCI Domains support</p>
<p>   It&#8217;s work on my platform,<br />
There are two PCIe host controller on my platform, and both bus number<br />
should be 0<br />
So, use PCI Domain to control both PCIe host controller is better choice.</p>
<p>Here is platform PCIe sample code,<br />
static struct hw_pci cxxxxxx_pcie0 __initdata = {<br />
       .swizzle = pci_std_swizzle,<br />
       .map_irq = cxxxxxx_pcie0_map_irq,<br />
       .nr_controllers = 1,<br />
       .nr_domains = 0,<br />
       .setup = cxxxxxx_pci_setup,<br />
       .scan = cxxxxxx_pci_scan_bus,<br />
       .preinit = cxxxxxx_pci_preinit,<br />
       .postinit = cxxxxxx_pcie0_postinit,<br />
};<br />
static struct hw_pci cxxxxxx_pcie1 __initdata = {<br />
       .swizzle = pci_std_swizzle,<br />
       .map_irq = cxxxxxx_pcie1_map_irq,<br />
       .nr_controllers = 1,<br />
       .nr_domains = 1,<br />
       .setup = cxxxxxx_pci_setup,<br />
       .scan = cxxxxxx_pci_scan_bus,<br />
       .postinit = cxxxxxx_pcie1_postinit,<br />
};</p>
<p>static int __init cxxxxxx_pci_init(void)<br />
{<br />
       pci_common_init(&#038;cxxxxxx_pcie0);<br />
       pci_common_init(&#038;cxxxxxx_pcie1);<br />
       return 0;<br />
}</p>
<p>&#8212;<br />
diff &#8211;git a/arch/arm/Kconfig b/arch/arm/Kconfig<br />
index 79a3074..33a49ba 100644<br />
&#8212; a/arch/arm/Kconfig<br />
+++ b/arch/arm/Kconfig<br />
@@ -865,6 +865,10 @@ config PCI<br />
      your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or<br />
      VESA. If you have PCI, say Y, otherwise N.</p>
<p>+config PCI_DOMAINS<br />
+        def_bool y<br />
+        depends on PCI<br />
+<br />
 config PCI_SYSCALL<br />
    def_bool PCI</p>
<p>diff &#8211;git a/arch/arm/include/asm/mach/pci.h<br />
b/arch/arm/include/asm/mach/pci.h<br />
index a38bdc7..f099067 100644<br />
&#8212; a/arch/arm/include/asm/mach/pci.h<br />
+++ b/arch/arm/include/asm/mach/pci.h<br />
@@ -20,6 +20,9 @@ struct hw_pci {<br />
    void        (*postinit)(void);<br />
    u8        (*swizzle)(struct pci_dev *dev, u8 *pin);<br />
    int        (*map_irq)(struct pci_dev *dev, u8 slot, u8 pin);<br />
+#ifdef CONFIG_PCI_DOMAINS<br />
+    int        nr_domains;<br />
+#endif<br />
 };</p>
<p> /*<br />
@@ -37,8 +40,12 @@ struct pci_sys_data {<br />
                    /* IRQ mapping                */<br />
    int        (*map_irq)(struct pci_dev *, u8, u8);<br />
    struct hw_pci    *hw;<br />
+#ifdef CONFIG_PCI_DOMAINS<br />
+    int        domain;<br />
+#endif<br />
 };</p>
<p>+<br />
 /*<br />
 * This is the standard PCI-PCI bridge swizzling algorithm.<br />
 */<br />
diff &#8211;git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h<br />
index 0abf386..57ce5bd 100644<br />
&#8212; a/arch/arm/include/asm/pci.h<br />
+++ b/arch/arm/include/asm/pci.h<br />
@@ -25,6 +25,11 @@ static inline void pcibios_penalize_isa_irq(int irq,<br />
int active)<br />
    /* We don&#8217;t do dynamic PCI IRQ allocation */<br />
 }</p>
<p>+#ifdef CONFIG_PCI_DOMAINS<br />
+int pci_domain_nr(struct pci_bus *bus);<br />
+int pci_proc_domain(struct pci_bus *bus);<br />
+#endif<br />
+<br />
 /*<br />
 * The PCI address space does equal the physical memory address space.<br />
 * The networking and block device layers use this boolean for bounce<br />
diff &#8211;git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c<br />
index 8096819..b364ca8 100644<br />
&#8212; a/arch/arm/kernel/bios32.c<br />
+++ b/arch/arm/kernel/bios32.c<br />
@@ -531,6 +531,7 @@ static void __init pcibios_init_hw(struct hw_pci *hw)<br />
        sys->busnr   = busnr;<br />
        sys->swizzle = hw->swizzle;<br />
        sys->map_irq = hw->map_irq;<br />
+        sys->domain  = hw->nr_domains;<br />
        sys->resource[0] = &#038;ioport_resource;<br />
        sys->resource[1] = &#038;iomem_resource;</p>
<p>@@ -694,3 +695,20 @@ int pci_mmap_page_range(struct pci_dev *dev, struct<br />
vm_area_struct *vma,</p>
<p>    return 0;<br />
 }<br />
+#ifdef CONFIG_PCI_DOMAINS<br />
+int pci_domain_nr(struct pci_bus *bus)<br />
+{<br />
+<br />
+        //struct pci_sysdata *sd = bus->sysdata;<br />
+        struct pci_sys_data *sd = bus->sysdata;<br />
+        return sd->domain;<br />
+<br />
+}<br />
+EXPORT_SYMBOL(pci_domain_nr);<br />
+<br />
+int pci_proc_domain(struct pci_bus *bus)<br />
+{<br />
+        return pci_domain_nr(bus);<br />
+}<br />
+EXPORT_SYMBOL(pci_proc_domain);<br />
+#endif</p>
<p>Ref<br />
<a href="http://lwn.net/Articles/247773/" target="_blank" rel="noopener">x86/x86-64 PCI domain support</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2009/12/17/831/linux-kernel-pci-domains-support-for-arm/">Linux kernel PCI Domains Support for ARM</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2009/12/17/831/linux-kernel-pci-domains-support-for-arm/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux kernel 2.6.24 Porting 雜記.</title>
		<link>https://richliu.com/2008/05/15/593/linux-kernel-2624-porting-%e9%9b%9c%e8%a8%98/</link>
					<comments>https://richliu.com/2008/05/15/593/linux-kernel-2624-porting-%e9%9b%9c%e8%a8%98/#comments</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Thu, 15 May 2008 05:51:05 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[2.6.24]]></category>
		<category><![CDATA[napi]]></category>
		<category><![CDATA[network driver]]></category>
		<category><![CDATA[PCI]]></category>
		<guid isPermaLink="false">https://richliu.com/2008/05/15/593/</guid>

					<description><![CDATA[<p>最近將某個 Device Porting 從 2.6.16 Porting 上 2.6.24, 記錄一下碰到的 [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2008/05/15/593/linux-kernel-2624-porting-%e9%9b%9c%e8%a8%98/">Linux kernel 2.6.24 Porting 雜記.</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>最近將某個 Device Porting 從 2.6.16 Porting 上 2.6.24, 記錄一下碰到的問題.</p>
<p>1. Network Driver</p>
<p>當有這樣的訊息時<br />
# ifconfig eth0 up<br />
SIOCSIFFLAGS : invalid agument</p>
<p>我碰到的狀況是, MAC Address 必需要在 probe 時先行 initial 完成.<br />
若是沒有完成, ifconfig 就會出現這樣的錯誤訊息, 原因仍然不明.<br />
我的做法就是加一行<br />
memcpy(dev-&gt;dev_addr , addr, 6); 這樣就可以了.</p>
<p>2.6.24 的 NAPI Interface 改過了, 上比對一下 2.6.23 和 2.6.24 的 Code 就可以知道改了什麼地方.<br />
netif_poll_* 的 interface 改名了以外, NAPI hook 的 _poll function 在傳入參數和結構上有小小的修正</p>
<p>2.6.24 修改了 NAPI 的呼叫法, 對我這邊比較複雜的 Switch Driver 也應該修正一下.</p>
<p>2. PCI<br />
pci_find_device 要改用 pci_get_device. 這個 function 還很早就改名了,<br />
只是在 porting 這一版的時候, 多了一個選項<br />
[ ] Enable deprecated pci_find_* API.<br />
如果不想開就不用改了.</p>
<p>3. CPU<br />
2.6.24 CPU proc.info 結構和2.6.16 有一點點不一樣, 如果直接放上 2.6.24 則 CPU Info 會錯誤,<br />
這時要修改 mm/CPU-proc.S , 附上部份的 patch, 增加一個 word 大小, 這樣就可以顯示正常了.</p>
<blockquote><p> 		PMD_BIT4 | \<br />
PMD_SECT_AP_WRITE | \<br />
PMD_SECT_AP_READ<br />
+	.long   PMD_TYPE_SECT | \<br />
+		PMD_SECT_AP_WRITE | \<br />
+		PMD_SECT_AP_READ</p></blockquote>
<p>4. Interrupt.<br />
原來 SA_INTERRUPT/SA_SHIRQ 都改叫 IRQF_SHARED, 事實上, 這一組定義己經完全換掉了<br />
詳情請見 include\linux\Interrupt.h</p>
<p>5. DMA<br />
pci_free_consistent 被 dma_free_coherent 取代<br />
pci_alloc_consistent(..); 被 dma_alloc_coherent(.., GFP_KERNEL); 取代,  後面要多加一個參數.<br />
consistent_sync 被 dma_cache_maint 取代.<br />
算是小改&#8230;.</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2008/05/15/593/linux-kernel-2624-porting-%e9%9b%9c%e8%a8%98/">Linux kernel 2.6.24 Porting 雜記.</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2008/05/15/593/linux-kernel-2624-porting-%e9%9b%9c%e8%a8%98/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
