From: Sameer Goel <sameer.goel@linaro.org>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
mjaggi@caviumnetworks.com, george.dunlap@eu.citrix.com,
Andrew.Cooper3@citrix.com, andre.przywara@linaro.org,
julien.grall@arm.com, jbeulich@suse.com,
xen-devel@lists.xenproject.org, Ian.Jackson@citrix.com,
nd@arm.com, shankerd@codeaurora.org
Subject: Re: [RFC v4 3/8] xen/linux_compat: Add a Linux compat header
Date: Fri, 9 Feb 2018 10:54:38 -0700 [thread overview]
Message-ID: <d0c9f8f7-b8c3-b3b8-a28e-d7cc2ac25c8c@linaro.org> (raw)
In-Reply-To: <20180123165143.zr6tsg6tfgg566vi@MacBook-Pro-de-Roger.local>
On 1/23/2018 9:51 AM, Roger Pau Monné wrote:
> On Mon, Dec 18, 2017 at 08:16:58PM -0700, Sameer Goel wrote:
>> For porting files directly from Linux it is useful to have a function mapping
>> definitions from Linux to Xen. This file adds common API functions and
>> other defines that are needed for porting arm SMMU drivers.
> It would be good that you add things to linux_compat.h in the same
> patch that you import the code, or else reviewing whether this is
> needed or not is impossible.
I'll do that.
>
>> Signed-off-by: Sameer Goel <sameer.goel@linaro.org>
>> ---
>> xen/include/xen/linux_compat.h | 81 ++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 81 insertions(+)
>> create mode 100644 xen/include/xen/linux_compat.h
>>
>> diff --git a/xen/include/xen/linux_compat.h b/xen/include/xen/linux_compat.h
>> new file mode 100644
>> index 0000000000..174d0390e5
>> --- /dev/null
>> +++ b/xen/include/xen/linux_compat.h
>> @@ -0,0 +1,81 @@
>> +/******************************************************************************
>> + * include/xen/linux_compat.h
>> + *
>> + * Compatibility defines for porting code from Linux to Xen
>> + *
>> + * Copyright (c) 2017 Linaro Limited
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; If not, see <http://www.gnu.org/licenses/>.
>> + */
>> +
>> +#ifndef __XEN_LINUX_COMPAT_H__
>> +#define __XEN_LINUX_COMPAT_H__
>> +
>> +#include <asm/types.h>
>> +
>> +typedef paddr_t phys_addr_t;
>> +typedef paddr_t dma_addr_t;
>> +
>> +typedef unsigned int gfp_t;
>> +#define GFP_KERNEL 0
>> +#define __GFP_ZERO 0
>> +
>> +/* Alias to Xen device tree helpers */
>> +#define device_node dt_device_node
>> +#define of_phandle_args dt_phandle_args
>> +#define of_device_id dt_device_match
>> +#define of_match_node dt_match_node
>> +#define of_property_read_u32(np, pname, out) (!dt_property_read_u32(np, pname, out))
>> +#define of_property_read_bool dt_property_read_bool
>> +#define of_parse_phandle_with_args dt_parse_phandle_with_args
> The above looks pretty much ARM specific. I wonder whether it would
> make sense to also introduce an asm/linux_compat.h to place such
> things.
Yes at this point this is arm specific. Since, this is only being used for smmu specific code I'll move this out to the smmu specific header.
>> +/* Helpers for IRQ functions */
>> +#define free_irq release_irq
>> +
>> +enum irqreturn {
>> + IRQ_NONE = (0 << 0),
>> + IRQ_HANDLED = (1 << 0),
>> + IRQ_WAKE_THREAD = (2 << 0),
> You don't need to set the explicit values, just using:
Ok.
>
> enum irqreturn {
> IRQ_NONE,
> IRQ_HANDLED,
> IRQ_WAKE_THREAD,
> };
>
> Will achieve exactly the same.
>
>> +};
>> +
>> +typedef enum irqreturn irqreturn_t;
>> +
>> +/* Device logger functions */
>> +#define dev_print(dev, lvl, fmt, ...) \
>> + printk(lvl fmt, ## __VA_ARGS__)
> You don't need to pass dev here (it's not used AFAICT).
>
>> +
>> +#define dev_dbg(dev, fmt, ...) dev_print(dev, XENLOG_DEBUG, fmt, ## __VA_ARGS__)
>> +#define dev_notice(dev, fmt, ...) dev_print(dev, XENLOG_INFO, fmt, ## __VA_ARGS__)
>> +#define dev_warn(dev, fmt, ...) dev_print(dev, XENLOG_WARNING, fmt, ## __VA_ARGS__)
>> +#define dev_err(dev, fmt, ...) dev_print(dev, XENLOG_ERR, fmt, ## __VA_ARGS__)
>> +#define dev_info(dev, fmt, ...) dev_print(dev, XENLOG_INFO, fmt, ## __VA_ARGS__)
> Neither here. In which case you can get rid of dev_print and simply
> use printk the in the above macros. Also you should make sure they are
> no longer than 80 cols.
Ok.
>
>> +
>> +#define dev_err_ratelimited(dev, fmt, ...) \
>> + dev_print(dev, XENLOG_ERR, fmt, ## __VA_ARGS__)
>> +
>> +#define dev_name(dev) dt_node_full_name(dev_to_dt(dev))
>> +
>> +/* Alias to Xen allocation helpers */
>> +#define kfree xfree
>> +#define kmalloc(size, flags) _xmalloc(size, sizeof(void *))
>> +#define kzalloc(size, flags) _xzalloc(size, sizeof(void *))
>> +#define devm_kzalloc(dev, size, flags) _xzalloc(size, sizeof(void *))
>> +#define kmalloc_array(size, n, flags) _xmalloc_array(size, sizeof(void *), n)
> Why use the '_' versions of malloc/zalloc? Do you really intend to
> force the alignment?
No, it just that xmalloc and xzalloc don't take in a size. I can use xmalloc_bytes and xzalloc_bytes but the above defines worked fine in the upstreamed smmu driver and I just copied them over.
>
>> +
>> +/* Alias to Xen time functions */
>> +#define ktime_t s_time_t
>> +#define ktime_add_us(t,i) (NOW() + MICROSECS(i))
>> +#define ktime_compare(t,i) (NOW() > (i))
> Er, the above is wrong, ktime_add_us adds 'i' to 't', not to NOW.
>
> Roger.
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-02-09 17:54 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-19 3:16 [RFC v4 0/8] SMMUv3 driver Sameer Goel
2017-12-19 3:16 ` [RFC v4 1/8] Port WARN_ON_ONCE() from Linux Sameer Goel
2018-01-23 11:33 ` Julien Grall
2018-01-23 16:13 ` Wei Liu
2018-01-26 1:45 ` Sameer Goel
2017-12-19 3:16 ` [RFC v4 2/8] xen/bitops: Rename LOG_2 to ilog2 Sameer Goel
2018-01-23 11:36 ` Julien Grall
2018-01-23 11:39 ` Roger Pau Monné
2018-01-23 11:44 ` Julien Grall
2018-01-23 12:10 ` Roger Pau Monné
2018-01-23 12:17 ` Julien Grall
2017-12-19 3:16 ` [RFC v4 3/8] xen/linux_compat: Add a Linux compat header Sameer Goel
2018-01-23 16:28 ` Wei Liu
2018-01-23 16:51 ` Roger Pau Monné
2018-02-09 17:54 ` Sameer Goel [this message]
2017-12-19 3:16 ` [RFC v4 4/8] passthrough/arm: Modify SMMU driver to use generic device definition Sameer Goel
2018-01-23 11:41 ` Julien Grall
2017-12-19 3:17 ` [RFC v4 5/8] Add verbatim copy of arm-smmu-v3.c from Linux Sameer Goel
2017-12-19 3:17 ` [RFC v4 6/8] xen/iommu: smmu-v3: Add Xen specific code to enable the ported driver Sameer Goel
2018-01-03 5:47 ` Manish Jaggi
2018-01-15 20:34 ` Julien Grall
2018-01-16 12:37 ` Manish Jaggi
2018-01-16 13:13 ` Julien Grall
2018-01-23 15:18 ` Julien Grall
2018-02-09 17:56 ` Sameer Goel
2018-02-09 18:11 ` Julien Grall
2017-12-19 3:17 ` [RFC v4 7/8] xen/smmu: Add a new config define for legacy SMMU Sameer Goel
2018-01-23 15:26 ` Julien Grall
2017-12-19 3:17 ` [RFC v4 8/8] drivers/passthrough/arm: Refactor code for arm smmu drivers Sameer Goel
2018-01-03 5:34 ` Manish Jaggi
2018-01-15 20:41 ` Julien Grall
2018-01-16 12:40 ` Manish Jaggi
2018-01-16 13:14 ` Julien Grall
2018-01-16 13:27 ` Manish Jaggi
2018-01-16 13:40 ` Julien Grall
2018-01-17 6:37 ` Manish Jaggi
2018-01-23 15:38 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d0c9f8f7-b8c3-b3b8-a28e-d7cc2ac25c8c@linaro.org \
--to=sameer.goel@linaro.org \
--cc=Andrew.Cooper3@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=andre.przywara@linaro.org \
--cc=george.dunlap@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=mjaggi@caviumnetworks.com \
--cc=nd@arm.com \
--cc=roger.pau@citrix.com \
--cc=shankerd@codeaurora.org \
--cc=sstabellini@kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).