From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Hurley Subject: Re: [PATCH] of/fdt: fix error checking for earlycon address Date: Wed, 28 Oct 2015 10:56:22 -0400 Message-ID: <5630E216.908@hurleysoftware.com> References: <1445600840-26749-1-git-send-email-yamada.masahiro@socionext.com> <562A32EA.20808@hurleysoftware.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Rob Herring Cc: Masahiro Yamada , "devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "linux-serial-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Frank Rowand , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Grant Likely , Ley Foon Tan List-Id: linux-serial@vger.kernel.org On 10/27/2015 04:46 PM, Rob Herring wrote: > On Fri, Oct 23, 2015 at 8:15 AM, Peter Hurley wrote: >> Hi Masahiro, >> >> On 10/23/2015 07:47 AM, Masahiro Yamada wrote: >>> fdt_translate_address() returns OF_BAD_ADDR on error. It is defined as >>> a u64 value, so the variable "addr" should be defined as u64 as well. >> >> Good catch. >> >> I would prefer if fdt_translate_address() returned resource_size_t (which >> is the proper type for handling addresses as integers) and that type >> was propagated through early_init_dt_scan_chosen_serial => of_setup_earlycon. > > That can be problematic in the DT code. The size of resource_size_t > can vary on 32-bit as it is based on phys_addr_t which in turn is > based on CONFIG_LPAE setting. However, the address sizes in DT are > fixed and may be 64-bit. So we stick with u64 in the DT code. I think I see your point about fdt_translate_address(); you want it to mirror of_translate_address(), yes? If so, then I have no objection to this patch and will mark it reviewed. But the u64 value from fdt_translate_address() should be preserved at least to the ioremap()/set_fixmap() in earlycon_map() . I could roll that change into my earlycon series that moves fdt_translate_address() into of_setup_earlycon(), thus preserving the u64 value until it's assigned to a phys_addr_t. Regards, Peter Hurley -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755985AbbJ1O4a (ORCPT ); Wed, 28 Oct 2015 10:56:30 -0400 Received: from mail-qg0-f51.google.com ([209.85.192.51]:35175 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754713AbbJ1O42 (ORCPT ); Wed, 28 Oct 2015 10:56:28 -0400 Subject: Re: [PATCH] of/fdt: fix error checking for earlycon address To: Rob Herring References: <1445600840-26749-1-git-send-email-yamada.masahiro@socionext.com> <562A32EA.20808@hurleysoftware.com> Cc: Masahiro Yamada , "devicetree@vger.kernel.org" , "linux-serial@vger.kernel.org" , Frank Rowand , "linux-kernel@vger.kernel.org" , Grant Likely , Ley Foon Tan From: Peter Hurley Message-ID: <5630E216.908@hurleysoftware.com> Date: Wed, 28 Oct 2015 10:56:22 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/27/2015 04:46 PM, Rob Herring wrote: > On Fri, Oct 23, 2015 at 8:15 AM, Peter Hurley wrote: >> Hi Masahiro, >> >> On 10/23/2015 07:47 AM, Masahiro Yamada wrote: >>> fdt_translate_address() returns OF_BAD_ADDR on error. It is defined as >>> a u64 value, so the variable "addr" should be defined as u64 as well. >> >> Good catch. >> >> I would prefer if fdt_translate_address() returned resource_size_t (which >> is the proper type for handling addresses as integers) and that type >> was propagated through early_init_dt_scan_chosen_serial => of_setup_earlycon. > > That can be problematic in the DT code. The size of resource_size_t > can vary on 32-bit as it is based on phys_addr_t which in turn is > based on CONFIG_LPAE setting. However, the address sizes in DT are > fixed and may be 64-bit. So we stick with u64 in the DT code. I think I see your point about fdt_translate_address(); you want it to mirror of_translate_address(), yes? If so, then I have no objection to this patch and will mark it reviewed. But the u64 value from fdt_translate_address() should be preserved at least to the ioremap()/set_fixmap() in earlycon_map() . I could roll that change into my earlycon series that moves fdt_translate_address() into of_setup_earlycon(), thus preserving the u64 value until it's assigned to a phys_addr_t. Regards, Peter Hurley