public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: zhaoshenglong@huawei•com (Shannon Zhao)
To: linux-arm-kernel@lists•infradead.org
Subject: [Xen-devel] [PATCH 05/13] Xen: ARM: Add support for mapping platform device mmio
Date: Wed, 18 Nov 2015 13:48:06 +0800	[thread overview]
Message-ID: <564C1116.8000603@huawei.com> (raw)
In-Reply-To: <20151117143822.GH3003@char.us.oracle.com>

On 2015/11/17 22:38, Konrad Rzeszutek Wilk wrote:
> On Tue, Nov 17, 2015 at 05:57:03PM +0800, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro•org>
>>
>> Add a bus_notifier for platform bus device in order to map the device
>> mmio regions when DOM0 booting with ACPI.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro•org>
>> ---
>>  drivers/xen/Makefile   |   1 +
>>  drivers/xen/platform.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 105 insertions(+)
>>  create mode 100644 drivers/xen/platform.c
>>
>> diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
>> index e293bc5..2f867e7 100644
>> --- a/drivers/xen/Makefile
>> +++ b/drivers/xen/Makefile
>> @@ -11,6 +11,7 @@ CFLAGS_features.o			:= $(nostackp)
>>  
>>  CFLAGS_efi.o				+= -fshort-wchar
>>  
>> +dom0-$(CONFIG_ARM64) += platform.o
>>  dom0-$(CONFIG_PCI) += pci.o
>>  dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
>>  dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
>> diff --git a/drivers/xen/platform.c b/drivers/xen/platform.c
>> new file mode 100644
>> index 0000000..0f95e7f
>> --- /dev/null
>> +++ b/drivers/xen/platform.c
>> @@ -0,0 +1,104 @@
>> +/*
>> + * Copyright (c) 2015, Linaro Limited.
>> + *
>> + * This program is free software; you can redistribute it and/or modify it
>> + * under the terms and conditions of the GNU General Public License,
>> + * version 2, as published by the Free Software Foundation.
>> + *
>> + * This program is distributed in the hope 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, write to the Free Software Foundation, Inc., 59 Temple
>> + * Place - Suite 330, Boston, MA 02111-1307 USA.
>> + *
>> + * Author: Shannon Zhao <shannon.zhao@linaro•org>
>> + */
>> +
>> +#include <linux/platform_device.h>
>> +#include <linux/acpi.h>
>> +#include <xen/xen.h>
>> +#include <xen/interface/memory.h>
>> +#include <asm/xen/hypervisor.h>
>> +#include <asm/xen/hypercall.h>
>> +
>> +static int xen_map_platform_device_mmio(struct platform_device *pdev)
>> +{
>> +	int i, rc = 0;
> 
> unsigned int i;
>> +
>> +	for (i = 0; i < pdev->num_resources; i++)
>> +	{
>> +		struct resource *r = &pdev->resource[i];
>> +
>> +		if (resource_type(r) == IORESOURCE_MEM)
> 
> Make this:
> 
> 	if (resource_type(r) != IORESOURCE_MEM)
> 		continue;
> 
>> +		{
> 
> And then you don't have to move all of this code to the right.
> 
>> +			int j;
> unsigned int
>> +			int nr = DIV_ROUND_UP(resource_size(r), PAGE_SIZE);
> 
> unsigned int
>> +			xen_pfn_t *gpfns = kmalloc(sizeof(xen_pfn_t) * nr,
>> +						   GFP_KERNEL);
>> +			xen_ulong_t *idxs = kmalloc(sizeof(xen_ulong_t) * nr,
>> +						    GFP_KERNEL);
>> +			int *errs = kmalloc(sizeof(int) * nr, GFP_KERNEL);
> 
> You can use kzalloc.
>> +			struct xen_add_to_physmap_range xatp;
> 
> This declaration of variables and then setting does not look like that
> pretty to my mind. (And it is a headache to debug if for example 'nr' ends up
> being zero for example). Or worst -1U since you had it as 'int'.
> 
Yes, a little. Maybe I can add a check for nr. Would that be fine?

Thanks,
-- 
Shannon

  parent reply	other threads:[~2015-11-18  5:48 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17  9:56 [PATCH 00/13] Add ACPI support for Xen Dom0 on ARM64 shannon.zhao at linaro.org
2015-11-17  9:56 ` [PATCH 01/13] Xen : Hide UART used by Xen shannon.zhao at linaro.org
2015-11-20 16:07   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 02/13] xen/grant-table: Move xlated_setup_gnttab_pages to common place shannon.zhao at linaro.org
2015-11-17 16:02   ` [Xen-devel] " David Vrabel
2015-11-18  4:32     ` Shannon Zhao
2015-11-18 10:38       ` David Vrabel
2015-11-18 12:25   ` Julien Grall
2015-11-18 13:34     ` Shannon Zhao
2015-11-17  9:57 ` [PATCH 03/13] arm/xen: Use xlated_setup_gnttab_pages to setup grant table shannon.zhao at linaro.org
2015-11-20 16:19   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 04/13] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio shannon.zhao at linaro.org
2015-11-17 11:16   ` Ard Biesheuvel
2015-11-17  9:57 ` [PATCH 05/13] Xen: ARM: Add support for mapping platform device mmio shannon.zhao at linaro.org
2015-11-17 16:32   ` [Xen-devel] " David Vrabel
2015-11-18  6:11     ` Shannon Zhao
     [not found]   ` <20151117143822.GH3003@char.us.oracle.com>
2015-11-18  5:48     ` Shannon Zhao [this message]
2015-11-20 16:30   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 06/13] Xen: ARM: Add support for mapping amba " shannon.zhao at linaro.org
2015-11-17 16:36   ` [Xen-devel] " David Vrabel
     [not found]   ` <20151117144040.GI3003@char.us.oracle.com>
2015-11-18  6:03     ` Shannon Zhao
2015-11-18 12:27       ` Julien Grall
2015-11-18 13:15         ` Shannon Zhao
2015-11-20 16:39   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 07/13] ARM: Xen: Document UEFI support on Xen ARM virtual platforms shannon.zhao at linaro.org
2015-11-17 16:46   ` [Xen-devel] " David Vrabel
2015-11-18  6:33     ` Shannon Zhao
2015-11-20 16:42     ` Stefano Stabellini
2015-11-17 20:44   ` Rob Herring
2015-11-18  6:24     ` Shannon Zhao
2015-11-17  9:57 ` [PATCH 08/13] Xen: EFI: Parse DT parameters for Xen specific UEFI shannon.zhao at linaro.org
2015-11-17 11:25   ` Ard Biesheuvel
2015-11-17 11:37     ` Mark Rutland
2015-11-17 12:17       ` Ard Biesheuvel
2015-11-18  6:26         ` Shannon Zhao
2015-11-20 17:04   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 09/13] ARM: Xen: Initialize Xen specific UEFI runtime services shannon.zhao at linaro.org
2015-11-17 11:28   ` Ard Biesheuvel
2015-11-17 12:17     ` Shannon Zhao
2015-11-20 16:57   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 10/13] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI shannon.zhao at linaro.org
2015-11-20 17:20   ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 11/13] xen/hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ shannon.zhao at linaro.org
2015-11-20 17:07   ` Stefano Stabellini
2015-11-20 17:22     ` [Xen-devel] " Andrew Cooper
2015-11-20 17:32       ` Stefano Stabellini
2015-11-17  9:57 ` [PATCH 12/13] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI shannon.zhao at linaro.org
2015-11-20 17:11   ` Stefano Stabellini
2015-11-24  3:49     ` Shannon Zhao
2015-11-17  9:57 ` [PATCH 13/13] ARM: XEN: Move xen_early_init() before efi_init() shannon.zhao at linaro.org
2015-11-20 17:30   ` Stefano Stabellini
2015-11-24  3:50     ` Shannon Zhao

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=564C1116.8000603@huawei.com \
    --to=zhaoshenglong@huawei$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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