Linux.com

joetech20

joetech20

  • Linux.com Member
  • Posts: 5
  • Member Since: 02 Jul 09
  • Last Logged In: 07 Oct 09

Latest Posts

Posted by
Topic
Post Preview
Posted
  • joetech20
    DMA from Local memory to PCI device - DMA Address
    I am working on a driver that uses PCI DMA transfers from processor local memory (slave memory) to the PCI device. The board that is use is MIPS based & the kernel version is linux 2.6.18.8. For some reason, i am not able to achieve this. Instead, if i use __get_free_pages which allocates pages from main memory, the dma transfer happens. Given below are the steps i followed for each case Case 1 : (using get_free_pages) a. allocate memory __get_free_pages() ---> returns virtual address b. assign the physical address to dma_handle *dma_handle = __pa(ret) c. Return the uncach address to the callee return UNCAC_ADDR(ret); With the above steps dma happen and the system works as expected. Now, in the next case, i replace step a with my custom function which allocates memory from the system local memory (slave memory). All other steps are kept as is. Case 2 : a. allocate memory from slave memory custom_allocate_memory () ---> returns physical address of the slave memory __va( custom_allocate_memory () ) ---> this will convert the physical address to virtual memory. This is done so as to keep the step b & step c of Case 1 as it is. b. assign the physical address to dma_handle *dma_handle = __pa(ret) c. Return the uncached address to the callee return UNCAC_ADDR(ret); In Case2, the DMA doesn't work and returns an error which indicates that the address provided to the DMA is wrong? What could be the probable mistake i am doing here? Is there anything else to be considered while replacing the __get_free_pages() with my custom function? Can someone give me a pointer of how Case 2 can be acheived? -Joe
    Link to this post 07 Oct 09

    I am working on a driver that uses PCI DMA transfers from processor local memory (slave memory) to the PCI device. The board that is use is MIPS based & the kernel version is linux 2.6.18.8. For some reason, i am not able to achieve this. Instead, if i use __get_free_pages which allocates pages from main memory, the dma transfer happens. Given below are the steps i followed for each case

    Case 1 : (using get_free_pages)
    a. allocate memory
    __get_free_pages() ---> returns virtual address
    b. assign the physical address to dma_handle
    *dma_handle = __pa(ret)
    c. Return the uncach address to the callee
    return UNCAC_ADDR(ret);

    With the above steps dma happen and the system works as expected.

    Now, in the next case, i replace step a with my custom function which allocates memory from the system local memory (slave memory). All other steps are kept as is.
    Case 2 :
    a. allocate memory from slave memory
    custom_allocate_memory () ---> returns physical address of the slave memory
    __va( custom_allocate_memory () ) ---> this will convert the physical address to virtual memory. This is done so as to keep the step b & step c of Case 1 as it is.
    b. assign the physical address to dma_handle
    *dma_handle = __pa(ret)
    c. Return the uncached address to the callee
    return UNCAC_ADDR(ret);
    In Case2, the DMA doesn't work and returns an error which indicates that the address provided to the DMA is wrong? What could be the probable mistake i am doing here? Is there anything else to be considered while replacing the __get_free_pages() with my custom function?

    Can someone give me a pointer of how Case 2 can be acheived?

    -Joe

  • joetech20
    RE: Kernel Routing Table - Interface specific routes
    The situation which you have explained is the difference between default route (route to 0.0.0.0 destination) and the interface specifc route (destination 192.168.1.0). My question is different. Probably, i did not explain it clearly enough. Let me try to explain the situation with an example. Consider the scenario where you have eth1 interface with IP address as 192.168.1.1. In such a case when the interface comes up (assuming that there is no other route configured) , the following is the entry in the kernel route table [b] [b]Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1[/b][/b] Now, if i try to add the same entry again into the kernel routing table using the following command, the entry gets added and route entry shows two similar entries route add -net 192.168.1.0 dev eth1 [b]Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1[/b][b][/b] I understand that there will not be any problem because of this duplicate rule. But, Can someone clarify the following questions based on the scenario which i explained above? 1. Are these two entries (the entry which got added by default and the entry which i added manually) different by any means?? 2. why should there be two similar routes in the kernel routing table? 3. Is there a patch available to solve this? 4. In general, there should not be identical entries in the kernel routing table. 5. Is this not applicable to all routing entries (be it host specific, default route or interface specific route)? Regards Joe
    Link to this post 08 Jul 09

    The situation which you have explained is the difference between default route (route to 0.0.0.0 destination) and the interface specifc route (destination 192.168.1.0).
    My question is different. Probably, i did not explain it clearly enough. Let me try to explain the situation with an example.

    Consider the scenario where you have eth1 interface with IP address as 192.168.1.1. In such a case when the interface comes up (assuming that there is no other route configured) , the following is the entry in the kernel route table

    Destination Gateway Genmask Flags Metric Ref Use Iface
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1

    Now, if i try to add the same entry again into the kernel routing table using the following command, the entry gets added and route entry shows two similar entries
    route add -net 192.168.1.0 dev eth1
    Destination Gateway Genmask Flags Metric Ref Use Iface
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1

    I understand that there will not be any problem because of this duplicate rule. But, Can someone clarify the following questions based on the scenario which i explained above?

    1. Are these two entries (the entry which got added by default and the entry which i added manually) different by any means??
    2. why should there be two similar routes in the kernel routing table?
    3. Is there a patch available to solve this?
    4. In general, there should not be identical entries in the kernel routing table. 5. Is this not applicable to all routing entries (be it host specific, default route or interface specific route)?

    Regards
    Joe

  • joetech20
    RE: Kernel Routing Table - Interface specific routes
    In the case of network specifc routes, gateway address will be 0.0.0.0. try route -n on any linux Box/PC and verify. My question is how can there be two identical routes in the routing table at a point of time. -Joe
    Link to this post 08 Jul 09

    In the case of network specifc routes, gateway address will be 0.0.0.0. try route -n on any linux Box/PC and verify.

    My question is how can there be two identical routes in the routing table at a point of time.

    -Joe

  • joetech20
    Kernel Routing Table - Interface specific routes
    I have a question on kernel routing table. It will be great if any of you can throw some light on this topic In general, whenever an inteface is brought to 'up' state, an interface route comes up. for ex. If eth0 with Ip address 192.168.10.0 is brought up, the following route is created by default "192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0" After this route is created, if i try to add the same route manually, with the following command, the same route gets added again. "route add -net 192.168.10.0 netmask 255.255.255.0 dev eth0" I do not see any difference in both of these routes when i verified with 'route -n' or 'netstat -r' or 'cat /proc/net/route'. How is this possible? In general, at any point of time, you cannot have two same entries in the kernel routing table. Can any of the linux expert help me with this question?? Regards, Joe
    Link to this post 07 Jul 09

    I have a question on kernel routing table. It will be great if any of you can throw some light on this topic

    In general, whenever an inteface is brought to 'up' state, an interface route comes up. for ex. If eth0 with Ip address 192.168.10.0 is brought up, the following route is created by default
    "192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0"
    After this route is created, if i try to add the same route manually, with the following command, the same route gets added again.
    "route add -net 192.168.10.0 netmask 255.255.255.0 dev eth0"
    I do not see any difference in both of these routes when i verified with 'route -n' or 'netstat -r' or 'cat /proc/net/route'. How is this possible?
    In general, at any point of time, you cannot have two same entries in the kernel routing table. Can any of the linux expert help me with this question??

    Regards,
    Joe

  • joetech20
    Single Binary with linux Kernel & filesystem
    Hi guys, I would like to get suggestions on how to create a single binary with linux kernel & filesystem. Currently i have linux kernel & filesystem as two separate binaries running on mips platform. I intend to have a single binary which should contain both kernel & filesystem. Can somebody guide me on this? Is there a tool available to combine both kernel & filesystem in to one? This is my first post in this forum. I hope to get valuable suggestions from experts. Regards, Joe
    Link to this post 02 Jul 09

    Hi guys,

    I would like to get suggestions on how to create a single binary with linux kernel & filesystem.
    Currently i have linux kernel & filesystem as two separate binaries running on mips platform. I intend to have a single binary which should contain both kernel & filesystem. Can somebody guide me on this? Is there a tool available to combine both kernel & filesystem in to one?

    This is my first post in this forum. I hope to get valuable suggestions from experts.

    Regards,
    Joe

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board