<div dir="auto">It would be better to keep the headers as-is, because changing them wouldn't fix anybody's problems, but it would take time from us that we don't have.<div dir="auto"><br></div><div dir="auto">Marek</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mar 21, 2017 9:46 AM, "Edward O'Callaghan" <<a href="mailto:funfunctor@folklore1984.net">funfunctor@folklore1984.net</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 03/21/2017 05:36 PM, Christian König wrote:<br>
> Am 21.03.2017 um 00:38 schrieb Tom St Denis:<br>
>> On 03/20/2017 06:34 PM, Jan Ziak wrote:<br>
>>> On Mon, Mar 20, 2017 at 10:41 PM, Alex Deucher <<a href="mailto:alexdeucher@gmail.com">alexdeucher@gmail.com</a><br>
>>> <mailto:<a href="mailto:alexdeucher@gmail.com">alexdeucher@gmail.com</a>><wbr>> wrote:<br>
>>><br>
>>>     On Mon, Mar 20, 2017 at 5:36 PM, Jan Ziak <<a href="mailto:0xe2.0x9a.0x9b@gmail.com">0xe2.0x9a.0x9b@gmail.com</a><br>
>>>     <mailto:<a href="mailto:0xe2.0x9a.0x9b@gmail.com">0xe2.0x9a.0x9b@gmail.<wbr>com</a>>> wrote:<br>
>>>     > Hi<br>
>>>     ><br>
>>>     ><br>
>>> <a href="https://cgit.freedesktop.org/~agd5f/linux/plain/drivers/gpu/drm/amd/include/asic_reg/vega10/NBIO/nbio_6_1_sh_mask.h?h=amd-staging-4.9&id=9555ef0ba926df25d9a637d0ea21bc0d231c21d2" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/~<wbr>agd5f/linux/plain/drivers/gpu/<wbr>drm/amd/include/asic_reg/<wbr>vega10/NBIO/nbio_6_1_sh_mask.<wbr>h?h=amd-staging-4.9&id=<wbr>9555ef0ba926df25d9a637d0ea21bc<wbr>0d231c21d2</a><br>
>>><br>
>>> <<a href="https://cgit.freedesktop.org/~agd5f/linux/plain/drivers/gpu/drm/amd/include/asic_reg/vega10/NBIO/nbio_6_1_sh_mask.h?h=amd-staging-4.9&id=9555ef0ba926df25d9a637d0ea21bc0d231c21d2" rel="noreferrer" target="_blank">https://cgit.freedesktop.org/<wbr>~agd5f/linux/plain/drivers/<wbr>gpu/drm/amd/include/asic_reg/<wbr>vega10/NBIO/nbio_6_1_sh_mask.<wbr>h?h=amd-staging-4.9&id=<wbr>9555ef0ba926df25d9a637d0ea21bc<wbr>0d231c21d2</a>><br>
>>><br>
>>>     ><br>
>>>     > The file nbio_6_1_sh_mask.h is uncompressed. It consists from<br>
>>> 133884 lines.<br>
>>>     > Only generated C/C++ code will be able to utilize the content<br>
>>> of such a file<br>
>>>     > efficiently. All hand-written codes combined will be able to<br>
>>> utilize about<br>
>>>     > 1% of the file.<br>
>>>     ><br>
>>>     > Is there a reason why nbio_6_1_sh_mask.h is huge?<br>
>>><br>
>>>     That IP block contains a lot of registers.  The idea is to open<br>
>>> source<br>
>>>     as much IP as possible to facilitate debugging, new features, etc.<br>
>>><br>
>>>     Alex<br>
>>><br>
>>><br>
>>> [This email contains long/wide lines and should be viewed on a<br>
>>> sufficiently wide screen]<br>
>>><br>
>>> For example if I open the file in vim and go to line 66952:<br>
>>><br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_1_<wbr>LANE1_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>> 0x9<br>
>>><br>
>>> Then abstracting away some of the digits used in the defined identifier<br>
>>> and using egrep:<br>
>>><br>
>>> $ egrep<br>
>>> "\<DWC_E12MP_PHY_X._NS_X._._<wbr>LANE._DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_.__DTB_SEL__SHIFT\>"<br>
>>><br>
>>> nbio_6_1_sh_mask.h<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_0_<wbr>LANE0_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_0_<wbr>LANE1_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_0_<wbr>LANE2_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_0_<wbr>LANE3_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_0_<wbr>LANEX_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_1_<wbr>LANE0_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_1_<wbr>LANE1_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_1_<wbr>LANE2_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_1_<wbr>LANE3_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_1_<wbr>LANEX_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_2_<wbr>LANE0_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_2_<wbr>LANE1_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_2_<wbr>LANE2_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_2_<wbr>LANE3_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_2_<wbr>LANEX_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_3_<wbr>LANE0_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_3_<wbr>LANE1_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_3_<wbr>LANE2_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_3_<wbr>LANE3_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>> #define<br>
>>> DWC_E12MP_PHY_X4_NS_X4_3_<wbr>LANEX_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_1__DTB_SEL__SHIFT<br>
>>><br>
>>>                        0x9<br>
>>><br>
>>> The egrep command produced 20 lines.<br>
>>><br>
>>> Instead of the many #define directives, it is a possibility to define<br>
>>> functions such as:<br>
>>><br>
>>> int<br>
>>> DWC_E12MP_PHY_Xa_NS_Xb_c_<wbr>LANEd_DIG_RX_VCOCAL_RX_VCO_<wbr>CAL_CTRL_e__DTB_SEL__SHIFT(int<br>
>>><br>
>>> a, int b, int c, int d, int e) __attribute__((pure));<br>
>>><br>
>>> I suppose the file nbio_6_1_sh_mask.h is the output of a tool (it is a<br>
>>> generated file). It is an option to modify the tool to output C<br>
>>> functions with proper input guards instead of #define directives.<br>
>><br>
>> The registers are generated by the HW team and then filtered down to<br>
>> become what we release publicly.  It is machine generated very likely<br>
>> from the RTL that specifies the hardware itself.<br>
><br>
> Yes, exactly that. And it was actually quite some work to get to this<br>
> point.<br>
><br>
>> Generally speaking if a class of registers share masks/offsets the<br>
>> lowest (zero'th) is used in programming and offsets are used when<br>
>> selecting the correct MMIO address to use specific instances.<br>
><br>
> The problem is that the files we get from the HW team describe the<br>
> register block already broken down to the memory mappings. E.g. when an<br>
> RTL block is instantiated N times you get N times the same definition.<br>
><br>
>><br>
>> Having these enumerated though is handy for tools like UMR which would<br>
>> decode to the correct instance of the register (you could even see<br>
>> that by watching the logscan via umr).  So we make use of them fairly<br>
>> efficiently.  UMR reads the headers to create the arrays of<br>
>> registers/bitfields which if they were computed at runtime (via helper<br>
>> functions) would be harder to parse (and could amount to the halting<br>
>> problem...).<br>
>><br>
>> What is in the NBIO header today is what was IP cleared but in theory<br>
>> it could be filtered down more simply to reduce the unused LOCs in<br>
>> future kernels.<br>
>><br>
>> They don't make for good bedtime reading but imho you'd rather have<br>
>> more headers not less :-)<br>
><br>
> Manually merging that back into single definitions is not really an<br>
> option, but what we could do is releasing the full blown headers<br>
> somewhere and only limit what we push into the linux kernel to actually<br>
> used ones.<br>
<br>
Hi Christian,<br>
<br>
I have to say I prefer your idea here and perhaps they could even become<br>
part of the UMR repo, not sure? May I suggest the reduction to some like<br>
a `kernel-native-dialect` could be automated with a clang plugin. It<br>
seems like heaps of work however maybe not really, clang provides a API<br>
to grammatically do some AST transformers and auto-rewrite large chunks<br>
of code given some rules.<br>
<br>
I also agree with Tom, its certainly nice to have them regardless, just<br>
perhaps the kernel mainline repo is the wrong place for the kitchen sink.<br>
<br>
Just my thoughts,<br>
Kind Regards,<br>
Edward.<br>
<br>
><br>
> Christian.<br>
><br>
><br>
>><br>
>> Tom<br>
>> ______________________________<wbr>_________________<br>
>> amd-gfx mailing list<br>
>> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
>> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/amd-gfx</a><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> amd-gfx mailing list<br>
> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/amd-gfx</a><br>
<br>
<br>______________________________<wbr>_________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/amd-gfx</a><br>
<br></blockquote></div></div>