From nobody Mon Apr 29 02:49:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1556806551; cv=none; d=zoho.com; s=zohoarc; b=JMOtNHwVE5dZgj8U1lysa2pNZ5rWQqZwaVwnEGKr4p50cXw/jBl78lKHtiqCflmhLoUBN13SwUPA+bdNtZ10ETYj2NdVGJWRhM5HY4yWxLiNFNJovtngi+tnj0oW7fRKDYutxMYLp/pRIQMq9yB3ZJxiZIfaxRqSrt6DsEMHP9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556806551; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mCdeZod9i4Vocxw7e+zhLodPj+vACfnzUz0D8xuvHMg=; b=IRpifdwEmLMySDoFDr8JvXcXxN40hrKvk+HNeSqGdStui+r+fkfhhBYbtbGbvVpz6OnodXRJmwwwj8yVSA+2cjqwGnbTWn91CDtQupCTZ3jhnW+rddzKf+ToIlO/l8HN9FF1W7q3tLqtCmhTSZiFXOYXyH7hxYtSMaKdpeQLwE8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556806551204872.3215904403227; Thu, 2 May 2019 07:15:51 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMCTx-0001VN-EZ; Thu, 02 May 2019 14:14:41 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMCTv-0001V5-J6 for xen-devel@lists.xenproject.org; Thu, 02 May 2019 14:14:39 +0000 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 9e8fce8e-6ce4-11e9-843c-bc764e045a96; Thu, 02 May 2019 14:14:38 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id h21so2291458ljk.13 for ; Thu, 02 May 2019 07:14:38 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id v11sm9447761lfb.68.2019.05.02.07.14.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 May 2019 07:14:36 -0700 (PDT) X-Inumbo-ID: 9e8fce8e-6ce4-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=czcrQJ4ZOkigVhUXJ1PqpCqEbSt+PWnfNBwK7rAOIVo=; b=HggtKAWincswp8O2AwNnv0IVbVU+lVSKShIk/+ZJ2A0UTcX0jEe6Vhm0LjSN+pLA+6 fIaiIsxyTfR3npN1xPsqALFShEJkMz0KnlsF7rPVPspQ5rMrScdnmB/Dchi1Vh7pFRTU R1et7HwuOCihJm9kH60eAHq3H9/n00o6bb04GmwMAw7ECj4Sx2EC5JxJ3UbmVKPQSWaH 9ucgdRQ0wsANIQDArMgdZNxFk5YuOod015U5nJEQyxkIK/yb0VdVkmivFgpxyDeke/3j d82w55+qdb2KejIfP/SEOc0P8wwVrFnZf9pmOsGqjjNBlXtmMSqRzOBny1oROHqXHwj2 rphA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=czcrQJ4ZOkigVhUXJ1PqpCqEbSt+PWnfNBwK7rAOIVo=; b=DLptbDWtA79EExGtI6XH2PFzDntwMY1Gfe9TZ41E45PK3DM8O7SsOf83e9jDYZkqOq lNRL15mce7U2dTkJWgsxahVf78KEPAaCxwj7H9XBLjsM9V4xVSyFZS8aUHmWxDIWqEo/ pKkW6gdrAPOvAvZXgnKCa7096hWVPq0n7osJarHURlQXB0b4H4zAvNRug9Ayh3riL4Z0 rmSWicQkWEkhJkR89JIcfNqIB4bBDwn1kYSOLqsjv+ZUljSzgTE+eDsAgTT9u2IdUmK/ X5caeiTIseDW7ucTvazMyRKnK+KN8kmMOA/rlmmEj5NvfioInMm/j/7cZ9X32uHrGX6P AYTg== X-Gm-Message-State: APjAAAU/56npV+qTGLAFgT7csiNefy0/AxbBSTog7N8+6EuUVbU+WL4R UYdHg+lapkYcp9onoPP1jlSFKq21DqA= X-Google-Smtp-Source: APXvYqxwvUq+coxxlISjHlNCZ3dkTi2eTt9o3LlhLai1hthYE5COmHJ43XZFMVCDMJTuwrIKKi55Yg== X-Received: by 2002:a2e:5c49:: with SMTP id q70mr2092746ljb.16.1556806477373; Thu, 02 May 2019 07:14:37 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Thu, 2 May 2019 17:13:55 +0300 Message-Id: <1556806436-26283-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556806436-26283-1-git-send-email-olekstysh@gmail.com> References: <1556806436-26283-1-git-send-email-olekstysh@gmail.com> Subject: [Xen-devel] [RFC PATCH 1/2] xen/device-tree: Add dt_count_phandle_with_args helper X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Oleksandr Tyshchenko Port Linux helper of_count_phandle_with_args for counting number of phandles in a property. Signed-off-by: Oleksandr Tyshchenko --- xen/common/device_tree.c | 7 +++++++ xen/include/xen/device_tree.h | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 8fc401d..65862b5 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -1663,6 +1663,13 @@ int dt_parse_phandle_with_args(const struct dt_devic= e_node *np, index, out_args); } =20 +int dt_count_phandle_with_args(const struct dt_device_node *np, + const char *list_name, + const char *cells_name) +{ + return __dt_parse_phandle_with_args(np, list_name, cells_name, 0, -1, = NULL); +} + /** * unflatten_dt_node - Alloc and populate a device_node from the flat tree * @fdt: The parent device tree blob diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h index 7408a6c..8315629 100644 --- a/xen/include/xen/device_tree.h +++ b/xen/include/xen/device_tree.h @@ -738,6 +738,25 @@ int dt_parse_phandle_with_args(const struct dt_device_= node *np, const char *cells_name, int index, struct dt_phandle_args *out_args); =20 +/** + * dt_count_phandle_with_args() - Find the number of phandles references i= n a property + * @np: pointer to a device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * + * Returns the number of phandle + argument tuples within a property. It + * is a typical pattern to encode a list of phandle and variable + * arguments into a single property. The number of arguments is encoded + * by a property in the phandle-target node. For example, a gpios + * property would contain a list of GPIO specifies consisting of a + * phandle and 1 or more arguments. The number of arguments are + * determined by the #gpio-cells property in the node pointed to by the + * phandle. + */ +int dt_count_phandle_with_args(const struct dt_device_node *np, + const char *list_name, + const char *cells_name); + #ifdef CONFIG_DEVICE_TREE_DEBUG #define dt_dprintk(fmt, args...) \ printk(XENLOG_DEBUG fmt, ## args) --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Apr 29 02:49:44 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1556806554; cv=none; d=zoho.com; s=zohoarc; b=OVz6d2+d2IuPrW7KjJVRXYeKgNkDnXtWp/1Gnq54shYzqwWtz+8KKkcvbF6u4b04UljzoCH1RdQbQ+ChAwvDxR2BCgmglOJWzy4oa1YsCJhjPbtw/cs+lzMB8xDeGAjYCan6sm+ukX6GS0xuH0Nbg5+Jpe1hLGL161p7mnctC1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556806554; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5xNSGLceIQvFZPUzpxr7N4rvGOoKW33TTLkH0aVOaCY=; b=dqpHl8Vm+L30rYDHyeXg+XaQu3fHNZ3m5Os0l9QEH47vPYYUzl+WYTyXBosb1lJafMZjEgPir047lUOT6Gt5FjTVv1uc/RaSIKkbQKjfLWy8wI6okaFM6odWTusCr/gOI2gkp3+vJrOttWF9vCg2zzYf83wSdRf1lsiZPhpOLeE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1556806554593354.31248968718955; Thu, 2 May 2019 07:15:54 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMCTy-0001Vd-Na; Thu, 02 May 2019 14:14:42 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hMCTw-0001VI-QA for xen-devel@lists.xenproject.org; Thu, 02 May 2019 14:14:40 +0000 Received: from mail-lj1-x243.google.com (unknown [2a00:1450:4864:20::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 9f4075ee-6ce4-11e9-843c-bc764e045a96; Thu, 02 May 2019 14:14:40 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id s7so2354647ljh.1 for ; Thu, 02 May 2019 07:14:39 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id v11sm9447761lfb.68.2019.05.02.07.14.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 May 2019 07:14:37 -0700 (PDT) X-Inumbo-ID: 9f4075ee-6ce4-11e9-843c-bc764e045a96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Bhy8ERTYdfSjiRGGOCL7/5SLLcwd2wNxUdxXkfyMshc=; b=oL7gET7CqS0nwJMPi9sVDkudmZ6vHVbWK4OxvW9b1QuKabOXthovk/BTUqFv1zIgL9 jCiDBY6pQfRVE2ZhC05l/kLlug3xDaor35IPKkfSmfpClpPxr4uOaUNDIFq05MR7LCHi TF6wGnnacoc0KbXs88InyJtXhpaKirStL53ZDW3DVk4MzKBKacGVD8xZDPXLHhsuAe48 lluUKExaXou/9mRZSRPR8lIsU7hFbz12uuH/hDy5AWmIhfoanSm2AGSYRDi3posP8o63 N+kBWh9IXVqZHb8COgB3DIypyOtKyox19W3qvdr4B0+jBcbYqfIscqdlmY/ILX7ggTZF vfpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bhy8ERTYdfSjiRGGOCL7/5SLLcwd2wNxUdxXkfyMshc=; b=mnm6eF72kODH3Mv2dj2zbxHo64qsK8vSWKNW93hpo46+x9nn3sEcVUP5XjF0Kc6bIN cQ079WIquTxo+9y2YLNrAAC24Ytlgy+Bi0cMxK2Ps3LNHoY+1U2Y7Q7O6YvTyRPiwhza LpI+1uacNsnHoFG+BdWpdK0AbNYdqyTqzuESsnq89AQ5A6Iu5NUC32h5st+bnvU4RDF5 FP1xe6J4QURin739Kig/P5FpvFD7ot87jcuFVqMoPKVfm5CaIrDhPEh/uUR3TCCMVU/G rYSm3rYfaML/DmZ9NBeicPu+rw4Rwp6FhX37XguZSUGX9SL1bpnGcuQgPUgCSmJoXq3z 9ZwQ== X-Gm-Message-State: APjAAAXsJmy2CLtgzEsD7jm3vt5BvAMlCm/VxfEeKRQjEH6uo+xNGgcu oqaviR9Qu78OW4jaCOdXiP73BOofRo0= X-Google-Smtp-Source: APXvYqzkfAPQBzM3yV+K++/uKYeax21hyP5PpNdsLi4HIMAENkQK/EK2uervWNIe2rf6A8k1HGYaLg== X-Received: by 2002:a2e:428c:: with SMTP id h12mr2047959ljf.26.1556806478511; Thu, 02 May 2019 07:14:38 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Thu, 2 May 2019 17:13:56 +0300 Message-Id: <1556806436-26283-3-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556806436-26283-1-git-send-email-olekstysh@gmail.com> References: <1556806436-26283-1-git-send-email-olekstysh@gmail.com> Subject: [Xen-devel] [RFC PATCH 2/2] xen/device-tree: Add ability to handle nodes with interrupts-extended prop X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Oleksandr Tyshchenko Xen expects to see "interrupts" property when parsing host device-tree. But, there are cases when some device nodes contain "interrupts-extended" property instead. The good example here is arch timer node for R-Car Gen3/Gen2 family, which is mandatory device for Xen usage on ARM. And without ability to handle such nodes, Xen fails to operate: (XEN) **************************************** (XEN) Panic on CPU 0: (XEN) Timer: Unable to retrieve IRQ 0 from the device tree (XEN) **************************************** Signed-off-by: Oleksandr Tyshchenko --- xen/common/device_tree.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c index 65862b5..00ada6e 100644 --- a/xen/common/device_tree.c +++ b/xen/common/device_tree.c @@ -987,9 +987,19 @@ unsigned int dt_number_of_irq(const struct dt_device_n= ode *device) const struct dt_device_node *p; const __be32 *intspec, *tmp; u32 intsize, intlen; + int intnum; =20 dt_dprintk("dt_irq_number: dev=3D%s\n", device->full_name); =20 + /* Try the new-style interrupts-extended first */ + intnum =3D dt_count_phandle_with_args(device, "interrupts-extended", + "#interrupt-cells"); + if ( intnum > 0 ) + { + dt_dprintk(" intnum=3D%d\n", intnum); + return intnum; + } + /* Get the interrupts property */ intspec =3D dt_get_property(device, "interrupts", &intlen); if ( intspec =3D=3D NULL ) @@ -1420,10 +1430,29 @@ int dt_device_get_raw_irq(const struct dt_device_no= de *device, const __be32 *intspec, *tmp, *addr; u32 intsize, intlen; int res =3D -EINVAL; + struct dt_phandle_args args; + int i; =20 dt_dprintk("dt_device_get_raw_irq: dev=3D%s, index=3D%u\n", device->full_name, index); =20 + /* Get the reg property (if any) */ + addr =3D dt_get_property(device, "reg", NULL); + + /* Try the new-style interrupts-extended first */ + res =3D dt_parse_phandle_with_args(device, "interrupts-extended", + "#interrupt-cells", index, &args); + if ( !res ) + { + dt_dprintk(" intspec=3D%d intsize=3D%d\n", args.args[0], args.args= _count); + + for ( i =3D 0; i < args.args_count; i++ ) + args.args[i] =3D cpu_to_be32(args.args[i]); + + return dt_irq_map_raw(args.np, args.args, args.args_count, + addr, out_irq); + } + /* Get the interrupts property */ intspec =3D dt_get_property(device, "interrupts", &intlen); if ( intspec =3D=3D NULL ) @@ -1432,9 +1461,6 @@ int dt_device_get_raw_irq(const struct dt_device_node= *device, =20 dt_dprintk(" intspec=3D%d intlen=3D%d\n", be32_to_cpup(intspec), intle= n); =20 - /* Get the reg property (if any) */ - addr =3D dt_get_property(device, "reg", NULL); - /* Look for the interrupt parent. */ p =3D dt_irq_find_parent(device); if ( p =3D=3D NULL ) --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel