[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ImageBuilder 2/2] Add support for lopper to generate partial dts


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Tue, 13 Sep 2022 12:26:53 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VKIF4aseAT4bj9zk56AyTjkrKzQ/p+1kM91bR5dP4NU=; b=CqMeIRo3/YW6k+LiGPrw8uWnQejhiQ+0LCsRIkHbA8naj6d58JwW3keAE0yXbOa1Oz7f6GisIpj/rwF1+HrgONTTGAaF58LNFGS1HRJLtLZoqGRm1oI5K38UAomdHvQC74oYJUoKcDRY1IiMIB/LhD5FlpG5kxKDF0B12Un34YMJeafAmwQtEdb1RQgRWr2knEdO0OQ1NxYRApiVI6/41MVSSQd4Dx2S2Prlm1mXL9qsrehWnHtLELIVF7P7uvjyXAlsqhrD4P6P7q0x0G5pDFBVvSGosdW3lEGTlV1o6fzcDhr/G70omVL7CxRIK3arG6wRC/cHxZp5o3JggqX79g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KcPSFlomQaKnAr/cgy9Y0a7Ta5RKcPf8LteiaaCJv55iFIEnmxov1vdjcW6cAq5AvF49M035S9n7MDGn0obMP4xlf2NT/ZCggVdZKb++XjzsHkbp5kMxRwiBk4fVtgG9sKDoxMFSYxz3Oq4CvdHbqlLid0hgGroW1jWFOppZ0FWlFRUJoPM9KJik3/DjfQYGSLy6uDdPs7EWkQQe1sN6LeXXDaQwMZY1qPagqC01Pu22gzLO71b87pCZJ/Xg/og1Q4YSvmWRYemotffSFgfGieK8TS3bzlHdWLI4ZK0h7t7jCe0xVBIqR2ZWXTL+62Zzy0b3IL9TmRLeR4Bp9cptmA==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 13 Sep 2022 10:27:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 13/09/2022 09:54, Michal Orzel wrote:
> 
> Hi Stefano,
> 
> On 13/09/2022 03:13, Stefano Stabellini wrote:
>>
>> On Mon, 12 Sep 2022, Michal Orzel wrote:
>>> Currently ImageBuilder can compile and merge partial dts obtained from
>>> a repository specified using PASSTHROUGH_DTS_REPO. With the recent
>>> changes done in the lopper, we can use it to generate partial dts
>>> automatically (to some extent as this is still an early support).
>>>
>>> Introduce LOPPER_PATH option to specify a path to a lopper.py script,
>>> that if set, will invoke lopper to generate partial dts for the
>>> passthrough devices specified in DOMU_PASSTHROUGH_PATHS.
>>>
>>> Introduce LOPPER_CMD option to specify custom command line arguments
>>> (if needed) for lopper's extract assist.
>>>
>>> Example usage:
>>> LOPPER_PATH="/home/user/lopper/lopper.py"
>>> DOMU_PASSTHROUGH_PATHS[0]="/axi/spi@ff0f0000 /axi/serial@ff010000"
>>
>> Is lopper.py this file?
>>
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevicetree-org%2Flopper%2Fblob%2Fmaster%2Flopper.py&amp;data=05%7C01%7Cmichal.orzel%40amd.com%7Ca7d4f0cc1c07424da8ba08da955d2fcc%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637986524721374780%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=oz5an1eISNbs6LoX3lE90RR%2FnYTX7ikZXw%2Fl57HlHV8%3D&amp;reserved=0
>>
>> If so, it would be good to specify in the README that this is not just
>> an arbitrary lopper.py script, but the main entry point of Lopper as a
>> project. For instance:
>>
>> ---
>> Introduce LOPPER_PATH option to specify a path to a lopper.py script,
>> the main script in the Lopper repository
>> (https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdevicetree-org%2Flopper&amp;data=05%7C01%7Cmichal.orzel%40amd.com%7Ca7d4f0cc1c07424da8ba08da955d2fcc%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637986524721374780%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=6ScZeGSMsX4MGgbOEi6I%2FDvkGNPlbVvBeSKQwexTHGA%3D&amp;reserved=0).
>>  If set, ....
>> ---
>>
> Sounds good. I will add this explanation.
> 
>>
>>> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
>>> ---
>>>  README.md                | 22 ++++++++++++--
>>>  scripts/common           | 64 ++++++++++++++++++++++++++++++----------
>>>  scripts/uboot-script-gen | 17 +++++++++--
>>>  3 files changed, 83 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/README.md b/README.md
>>> index da9ba788a3bf..aaee0939b589 100644
>>> --- a/README.md
>>> +++ b/README.md
>>> @@ -128,6 +128,19 @@ Where:
>>>  - DT_OVERLAY[number] specifies the path to the hosts device tree overlays
>>>    to be added at boot time in u-boot
>>>
>>> +- LOPPER_PATH specifies the path to lopper.py script. This is optional.
>>> +  However, if this is specified, then DOMU_PASSTHROUGH_PATHS[number] need
>>> +  to be specified. uboot-script-gen will invoke lopper to generate the 
>>> partial
>>> +  device trees which have been specified in DOMU_PASSTHROUGH_PATHS[number].
>>> +  This option is currently in experimental state as the corresponding 
>>> lopper
>>> +  changes are still in an early support state.
>>> +
>>> +- LOPPER_CMD specifies the command line arguments for lopper's extract 
>>> assist.
>>> +  This is optional and only applicable when LOPPER_PATH is specified. Only 
>>> to be
>>> +  used to specify which nodes to include (using -i <node_name>) and which
>>> +  nodes/properties to exclude (using -x <regex>). If not set at all, the 
>>> default
>>> +  one is used applicable for ZynqMP MPSoC boards.
>>> +
>>>  - NUM_DOMUS specifies how many Dom0-less DomUs to load
>>>
>>>  - DOMU_KERNEL[number] specifies the DomU kernel to use.
>>> @@ -140,7 +153,7 @@ Where:
>>>  - DOMU_PASSTHROUGH_PATHS[number] specifies the passthrough devices (
>>>    separated by spaces). It adds "xen,passthrough" to the corresponding
>>>    dtb nodes in xen device tree blob.
>>> -  This option is valid in the following two cases:
>>> +  This option is valid in the following cases:
>>>
>>>    1. When PASSTHROUGH_DTS_REPO is provided.
>>>    With this option, the partial device trees (corresponding to the
>>> @@ -149,7 +162,12 @@ Where:
>>>    Note it assumes that the names of the partial device trees will match
>>>    to the names of the devices specified here.
>>>
>>> -  2. When DOMU_NOBOOT[number] is provided. In this case, it will only
>>> +  2. When LOPPER_PATH is provided.
>>> +  With this option, the partial device trees (corresponding to the
>>> +  passthrough devices) are generated by the lopper and then compiled and 
>>> merged
>>> +  by ImageBuilder to be used as DOMU[number] device tree blob.
>>> +
>>> +  3. When DOMU_NOBOOT[number] is provided. In this case, it will only
>>>    add "xen,passthrough" as mentioned before.
>>>
>>>  - DOMU_PASSTHROUGH_DTB[number] specifies the passthrough device trees
>>> diff --git a/scripts/common b/scripts/common
>>> index ccad03d82b30..680c5090cd07 100644
>>> --- a/scripts/common
>>> +++ b/scripts/common
>>> @@ -9,6 +9,9 @@
>>>  # - NUM_DOMUS
>>>  # - DOMU_PASSTHROUGH_PATHS
>>>  # - DOMU_PASSTHROUGH_DTB
>>> +# - LOPPER_PATH
>>> +# - LOPPER_CMD
>>> +# - DEVICE_TREE
>>>
>>>  tmp_files=()
>>>  tmp_dirs=()
>>> @@ -99,31 +102,41 @@ function compile_merge_partial_dts()
>>>      local tmp
>>>      local tmpdts
>>>      local file
>>> +    local node
>>>      local i
>>>      local j
>>>
>>> -    if [[ "$repo" =~ .*@.*:.* ]]
>>> +    if test "$repo"
>>>      then
>>> -        tmp=`mktemp -d`
>>> -        tmp_dirs+=($tmp)
>>> -
>>> -        echo "Cloning git repo \"$git_repo\""
>>> -        git clone "$repo" $tmp
>>> -        if test $? -ne 0
>>> +        # Partial dts will be obtained from PASSTHROUGH_DTS_REPO
>>> +        if [[ "$repo" =~ .*@.*:.* ]]
>>>          then
>>> -            echo "Error occurred while cloning \"$git_repo\""
>>> -            return 1
>>> -        fi
>>> +            tmp=`mktemp -d`
>>> +            tmp_dirs+=($tmp)
>>>
>>> -        repo=$tmp
>>> -    fi
>>> +            echo "Cloning git repo \"$git_repo\""
>>> +            git clone "$repo" $tmp
>>> +            if test $? -ne 0
>>> +            then
>>> +                echo "Error occurred while cloning \"$git_repo\""
>>> +                return 1
>>> +            fi
>>>
>>> -    if test -z "$dir"
>>> -    then
>>> -        dir="."
>>> +            repo=$tmp
>>> +        fi
>>> +
>>> +        if test -z "$dir"
>>> +        then
>>> +            dir="."
>>> +        fi
>>> +        partial_dts_dir="$repo"/"$dir"
>>> +    else
>>> +        # Partial dts will be generated by the lopper
>>> +        tmp=`mktemp -d`
>>> +        tmp_dirs+=($tmp)
>>
>> setting tmp and tmp_dirs can be moved outside of the if
>>
> Ok.
> 
Actually, these cannot be moved outside of the if because we have
3 possibilities and we need to create tmp dir only in 2 of them.
1) partial dts stored in repository - tmp needed
2) partial dts stored in a local dir - tmp not needed
3) partial dts will be generated by lopper - tmp needed

Moving the tmp creation at the top of if would result in creating redundant tmp
for second case. So it should stay as it is.

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.