How to get the physical address with Bus, Device, Function, and Offset










2















I want to make a kernel module that read the DRAM counters to get the number of data read from DRAM (https://software.intel.com/en-us/articles/monitoring-integrated-memory-controller-requests-in-the-2nd-3rd-and-4th-generation-intel).



In that page, they say




"The BAR is available (in PCI configuration space) at Bus 0; Device 0; Function 0; Offset 048H", and UNC_IMC_DRAM_DATA_READS, which I want to read, is on "BAR + 0x5050".




Does it mean that I can get the physical address of DRAM Counter by typing



 sudo setpci 00:00:0 48.L 


and then + 0x5050 to get the address where the UNC_IMC_DRAM_DATA_READS?



Actually,



 sudo setpci 00:00:0 48.L


outputs



 fed10001


, and I accessed 0xfed15051 with busybox.



 sudo busybox devmem 0xfed15051


However, the two leftmost bit, I mean "00" in 0x00123456, are always zero.



What was wrong, and how can I get the physical address correctly with Bus, Device, Function, and Offset.



Thank you :)










share|improve this question






















  • Bit 0 of the BAR is probably a flag, not part of the address. Try fed15050.

    – prl
    Nov 13 '18 at 14:52















2















I want to make a kernel module that read the DRAM counters to get the number of data read from DRAM (https://software.intel.com/en-us/articles/monitoring-integrated-memory-controller-requests-in-the-2nd-3rd-and-4th-generation-intel).



In that page, they say




"The BAR is available (in PCI configuration space) at Bus 0; Device 0; Function 0; Offset 048H", and UNC_IMC_DRAM_DATA_READS, which I want to read, is on "BAR + 0x5050".




Does it mean that I can get the physical address of DRAM Counter by typing



 sudo setpci 00:00:0 48.L 


and then + 0x5050 to get the address where the UNC_IMC_DRAM_DATA_READS?



Actually,



 sudo setpci 00:00:0 48.L


outputs



 fed10001


, and I accessed 0xfed15051 with busybox.



 sudo busybox devmem 0xfed15051


However, the two leftmost bit, I mean "00" in 0x00123456, are always zero.



What was wrong, and how can I get the physical address correctly with Bus, Device, Function, and Offset.



Thank you :)










share|improve this question






















  • Bit 0 of the BAR is probably a flag, not part of the address. Try fed15050.

    – prl
    Nov 13 '18 at 14:52













2












2








2


1






I want to make a kernel module that read the DRAM counters to get the number of data read from DRAM (https://software.intel.com/en-us/articles/monitoring-integrated-memory-controller-requests-in-the-2nd-3rd-and-4th-generation-intel).



In that page, they say




"The BAR is available (in PCI configuration space) at Bus 0; Device 0; Function 0; Offset 048H", and UNC_IMC_DRAM_DATA_READS, which I want to read, is on "BAR + 0x5050".




Does it mean that I can get the physical address of DRAM Counter by typing



 sudo setpci 00:00:0 48.L 


and then + 0x5050 to get the address where the UNC_IMC_DRAM_DATA_READS?



Actually,



 sudo setpci 00:00:0 48.L


outputs



 fed10001


, and I accessed 0xfed15051 with busybox.



 sudo busybox devmem 0xfed15051


However, the two leftmost bit, I mean "00" in 0x00123456, are always zero.



What was wrong, and how can I get the physical address correctly with Bus, Device, Function, and Offset.



Thank you :)










share|improve this question














I want to make a kernel module that read the DRAM counters to get the number of data read from DRAM (https://software.intel.com/en-us/articles/monitoring-integrated-memory-controller-requests-in-the-2nd-3rd-and-4th-generation-intel).



In that page, they say




"The BAR is available (in PCI configuration space) at Bus 0; Device 0; Function 0; Offset 048H", and UNC_IMC_DRAM_DATA_READS, which I want to read, is on "BAR + 0x5050".




Does it mean that I can get the physical address of DRAM Counter by typing



 sudo setpci 00:00:0 48.L 


and then + 0x5050 to get the address where the UNC_IMC_DRAM_DATA_READS?



Actually,



 sudo setpci 00:00:0 48.L


outputs



 fed10001


, and I accessed 0xfed15051 with busybox.



 sudo busybox devmem 0xfed15051


However, the two leftmost bit, I mean "00" in 0x00123456, are always zero.



What was wrong, and how can I get the physical address correctly with Bus, Device, Function, and Offset.



Thank you :)







linux linux-kernel pci






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 14:14









Taewoong KimTaewoong Kim

132




132












  • Bit 0 of the BAR is probably a flag, not part of the address. Try fed15050.

    – prl
    Nov 13 '18 at 14:52

















  • Bit 0 of the BAR is probably a flag, not part of the address. Try fed15050.

    – prl
    Nov 13 '18 at 14:52
















Bit 0 of the BAR is probably a flag, not part of the address. Try fed15050.

– prl
Nov 13 '18 at 14:52





Bit 0 of the BAR is probably a flag, not part of the address. Try fed15050.

– prl
Nov 13 '18 at 14:52












1 Answer
1






active

oldest

votes


















2














The low bit is an enable bit and should be excluded from the address you use. See for example https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/xeon-e3-1200v6-vol-2-datasheet.pdf (section 3.12 page # 57) -- where it's documented as the MCHBAREN flag.



This document also provides detailed register descriptions of the same registers mentioned in that tech note -- starting at section 7.43 page # 202.



In general, accesses to PCI registers are pretty much always done on 32-bit (DWORD) boundaries. You'll almost never find a counter that overlaps 32-bit words.






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282972%2fhow-to-get-the-physical-address-with-bus-device-function-and-offset%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    The low bit is an enable bit and should be excluded from the address you use. See for example https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/xeon-e3-1200v6-vol-2-datasheet.pdf (section 3.12 page # 57) -- where it's documented as the MCHBAREN flag.



    This document also provides detailed register descriptions of the same registers mentioned in that tech note -- starting at section 7.43 page # 202.



    In general, accesses to PCI registers are pretty much always done on 32-bit (DWORD) boundaries. You'll almost never find a counter that overlaps 32-bit words.






    share|improve this answer



























      2














      The low bit is an enable bit and should be excluded from the address you use. See for example https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/xeon-e3-1200v6-vol-2-datasheet.pdf (section 3.12 page # 57) -- where it's documented as the MCHBAREN flag.



      This document also provides detailed register descriptions of the same registers mentioned in that tech note -- starting at section 7.43 page # 202.



      In general, accesses to PCI registers are pretty much always done on 32-bit (DWORD) boundaries. You'll almost never find a counter that overlaps 32-bit words.






      share|improve this answer

























        2












        2








        2







        The low bit is an enable bit and should be excluded from the address you use. See for example https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/xeon-e3-1200v6-vol-2-datasheet.pdf (section 3.12 page # 57) -- where it's documented as the MCHBAREN flag.



        This document also provides detailed register descriptions of the same registers mentioned in that tech note -- starting at section 7.43 page # 202.



        In general, accesses to PCI registers are pretty much always done on 32-bit (DWORD) boundaries. You'll almost never find a counter that overlaps 32-bit words.






        share|improve this answer













        The low bit is an enable bit and should be excluded from the address you use. See for example https://www.intel.com/content/dam/www/public/us/en/documents/datasheets/xeon-e3-1200v6-vol-2-datasheet.pdf (section 3.12 page # 57) -- where it's documented as the MCHBAREN flag.



        This document also provides detailed register descriptions of the same registers mentioned in that tech note -- starting at section 7.43 page # 202.



        In general, accesses to PCI registers are pretty much always done on 32-bit (DWORD) boundaries. You'll almost never find a counter that overlaps 32-bit words.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 17:38









        Gil HamiltonGil Hamilton

        8,9341739




        8,9341739



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53282972%2fhow-to-get-the-physical-address-with-bus-device-function-and-offset%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

            Museum of Modern and Contemporary Art of Trento and Rovereto