drivers/bus: Freescale Management Complex bus driver patch series
cover drivers/bus: Freescale Management Complex bus driver patch series
This patch series introduces Linux support for the Freescale Management Complex (fsl-mc) hardware.
The fsl-mc is a hardware resource manager that manages specialized hardware objects used in network-oriented packet processing applications. After the fsl-mc block is enabled, pools of hardware resources are available, such as queues, buffer poools, I/O interfaces. These resources are building blocks that can be used to create functional hardware objects such as network interfaces, crypto accelerator instances, or L2 switches.
All the fsl-mc managed hardware resources/objects are represented in a physical grouping mechanism called a 'container' or DPRC (data path resource container).
Quoted 1 line
From the point of view of an OS, a DPRC functions similar to a plug
and play bus. Using fsl-mc commands software can enumerate the contents of the DPRC discovering the hardware objects present and binding them to drivers. Hardware objects can be created and removed dynamically, providing hot pluggability of the hardware objects.
Software contexts interact with the fsl-mc by sending commands through a memory mapped hardware interface called an "MC portal". Every fsl-mc object type has a command set to manage the objects. Key DPRC commands include:
-create/destroy a DPRC
-enumerate objects and resource pools in the DPRC, including
identifying mappable regions and the number of IRQs an object may have
-IRQ configuration
-move objects/resources between DPRCs
-connecting objects (e.g. connecting a network interface to
an L2 switch port)
-reset
Patch 1 contains a minimal set of low level functions to send an d receive commands to the fsl-mc. It includes support for basic management commands and commands to manipulate DPRC objects.
Patch 2 contains a platform device driver that sets up and registers the basic bus infrastructure including support for adding/removing devices, register/unregister of drivers, and bus match support to bind devices to drivers.
Patch 3 contains an driver that manages DPRC objects (the container that holds the hardware resources). This driver functions as a bus controller and handles enumeration of the objects in the container and hotplug events.
Patch 4 contains the update to the MAINTAINERS file.
CHANGE HISTORY
No changes since RFC v4
Changes in RFC v4:
- Fixed parameter mismatch for device_find_child() call in fsl_mc_dprc.c
- Added back the dma_mask field to struct fsl_mc_device as it is needed by some MC child device drivers. However, the default DMA mask now does not have the 32-bit limitation of the original patch series (v1).
Changes in RFC v3:
Rework to address comments from Arnd Bergmann:
- Removed per-bus list of children, and instead use device_for_each_child()
- Use the same structure (struct fsl_mc_device) to represent both bus devices and their children.
http://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg711301.html
Changes in RFC v2:
Rework to address comments from Arnd Bergmann:
- Removed fsl_mc_bus structure and global variable
- Removed the 'magic' fields from all structs
- Removed NULL initializers
- Replaced all occurrences of EXPORT_SYMBOL() with EXPORT_SYMBOL_GPL()
- Removed function dprc_parse_dt_node(), and replaced its call by a direct call to of_address_to_resource()
- Removed struct fsl_mc_device_region and use standard 'struct resource' instead.
- Removed dma_mask field from 'struct fsl_mc_device' as it is not currently being used.
- Removed redundant 'driver' field from struct fsl_mc_device
- Removed the container field. We can get the parent DPRC of a given dev, from its dev.parent field.
http://www.mail-archive.com/linux-kernel%40vger.kernel.org/msg708858.html
PATCH 1/4 drivers/bus: Added Freescale Management Complex APIs
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.c create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.h
drivers/bus/fsl-mc/dpmng.c new file +93 -0
@@ -0,0 +1,93 @@ +/* Copyright 2013-2014 Freescale Semiconductor Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Freescale Semiconductor nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* +* ALTERNATIVELY, this software may be distributed under the terms of the +* GNU General Public License ("GPL") as published by the Free Software +* Foundation, either version 2 of that License or (at your option) any +* later version. +* +* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <linux/fsl_mc_sys.h> +#include <linux/fsl_mc_cmd.h> +#include <linux/fsl_dpmng.h> +#include "fsl_dpmng_cmd.h" + +int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 }; +int err; + + cmd.header =mc_encode_cmd_header (DPMNG_CMDID_GET_VERSION , +DPMNG_CMDSZ_GET_VERSION , +MC_CMD_PRI_LOW ,0 ); + + err =mc_send_command (mc_io, &cmd); +if (!err) +DPMNG_RSP_GET_VERSION (cmd, mc_ver_info); + +return err; +} + +int dpmng_reset_aiop (struct fsl_mc_io *mc_io,int aiop_tile_id) +{ +struct mc_command cmd = {0 }; + + cmd.header =mc_encode_cmd_header (DPMNG_CMDID_RESET_AIOP , +DPMNG_CMDSZ_RESET_AIOP , +MC_CMD_PRI_LOW ,0 ); + +DPMNG_CMD_RESET_AIOP (cmd, aiop_tile_id); + +return mc_send_command (mc_io, &cmd); +} + +int dpmng_load_aiop (struct fsl_mc_io *mc_io, +int aiop_tile_id,uint8_t *img_addr,int img_size) +{ +struct mc_command cmd = {0 }; +uint64_t img_paddr =virt_to_phys (img_addr); + + cmd.header =mc_encode_cmd_header (DPMNG_CMDID_LOAD_AIOP , +DPMNG_CMDSZ_LOAD_AIOP , +MC_CMD_PRI_LOW ,0 ); + +DPMNG_CMD_LOAD_AIOP (cmd, aiop_tile_id, img_size, img_paddr); + +return mc_send_command (mc_io, &cmd); +} + +int dpmng_run_aiop (struct fsl_mc_io *mc_io, +int aiop_tile_id,uint32_t cores_mask,uint64_t options) +{ +struct mc_command cmd = {0 }; + + cmd.header =mc_encode_cmd_header (DPMNG_CMDID_RUN_AIOP , +DPMNG_CMDSZ_RUN_AIOP , +MC_CMD_PRI_LOW ,0 ); + +DPMNG_CMD_RUN_AIOP (cmd, aiop_tile_id, cores_mask, options); + +return mc_send_command (mc_io, &cmd); +}
drivers/bus/fsl-mc/dprc.c new file +504 -0
504 lines not on this page · raw message
drivers/bus/fsl-mc/fsl_dpmng_cmd.h new file +83 -0
83 lines not on this page · raw message
drivers/bus/fsl-mc/fsl_dprc_cmd.h new file +545 -0
545 lines not on this page · raw message
drivers/bus/fsl-mc/fsl_mc_sys.c new file +237 -0
237 lines not on this page · raw message
include/linux/fsl_dpmng.h new file +120 -0
120 lines not on this page · raw message
include/linux/fsl_dprc.h new file +790 -0
790 lines not on this page · raw message
include/linux/fsl_mc_cmd.h new file +182 -0
182 lines not on this page · raw message
include/linux/fsl_mc_sys.h new file +81 -0
81 lines not on this page · raw message
Signature · 1 line
1.7.9.7
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
drivers/bus/fsl-mc/dpmng.c
Quoted 6 lines · J. German Rivera
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
drivers/bus/fsl-mc/dpmng.c +0
-0
[]
Quoted 4 lines
drivers/bus/fsl-mc/dpmng.c +4
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 }; +int err;
drivers/bus/fsl-mc/dpmng.c line 50
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c +10
-0+ + cmd.header =mc_encode_cmd_header (DPMNG_CMDID_GET_VERSION , +DPMNG_CMDSZ_GET_VERSION , +MC_CMD_PRI_LOW ,0 ); + + err =mc_send_command (mc_io, &cmd); +if (!err) +DPMNG_RSP_GET_VERSION (cmd, mc_ver_info); + +return err;
I think it better style to read when the failure case is handled immediately by a return or a "goto out" and the successful case code is at the same indent level
err = mc_send_command_(etc...) if (err) return err; DPMNG_RSP_GET_VERSION(cmd, mc_ver_info); return 0; }
Quoted 7 lines
drivers/bus/fsl-mc/dprc.c +5
-0+int dprc_get_container_id (struct fsl_mc_io *mc_io,int *container_id) +{ +struct mc_command cmd = {0 }; +int err; +
drivers/bus/fsl-mc/dprc.c line 51
Quoted 10 lines
drivers/bus/fsl-mc/dprc.c +10
-0+ cmd.header =mc_encode_cmd_header (DPRC_CMDID_GET_CONT_ID , +DPRC_CMDSZ_GET_CONT_ID , +MC_CMD_PRI_LOW ,0 ); + + err =mc_send_command (mc_io, &cmd); +if (!err) +DPRC_RSP_GET_CONTAINER_ID (cmd, *container_id); + +return err; +}
Same sort of thing as above.
Actively fail on err and proceed at the same indent level on success.
Quoted 7 lines
drivers/bus/fsl-mc/dprc.c +7
-0+ +int dprc_open (struct fsl_mc_io *mc_io,int container_id,uint16_t *dprc_handle) +{ +int err; +struct mc_command cmd = {0 }; + + cmd.header = mc_encode_cmd_header(MC_DPRC_CMDID_OPEN,
drivers/bus/fsl-mc/dprc.c line 68
Quoted 10 lines
drivers/bus/fsl-mc/dprc.c +10
-0+ MC_CMD_OPEN_SIZE, MC_CMD_PRI_LOW, 0); + +DPRC_CMD_OPEN (cmd, container_id); + + err =mc_send_command (mc_io, &cmd); +if (!err) + *dprc_handle =MC_CMD_HDR_READ_AUTHID (cmd.header); + +return err; +}
etc.
I didn't read any more.
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 23 lines · Joe Perches
drivers/bus/fsl-mc/dpmng.c
Quoted 2 lines
drivers/bus/fsl-mc/dpmng.c +0
-0[]
Quoted 4 lines
drivers/bus/fsl-mc/dpmng.c +4
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 }; +int err;drivers/bus/fsl-mc/dpmng.c line 50
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c +10
-0+ + cmd.header =mc_encode_cmd_header (DPMNG_CMDID_GET_VERSION , +DPMNG_CMDSZ_GET_VERSION , +MC_CMD_PRI_LOW ,0 ); + + err =mc_send_command (mc_io, &cmd); +if (!err) +DPMNG_RSP_GET_VERSION (cmd, mc_ver_info); + +return err;I think it better style to read when the failure case is handled immediately by a return or a "goto out" and the successful case code is at the same indent level
Quoted 9 lines
err = mc_send_command_(etc...) if (err) return err; DPMNG_RSP_GET_VERSION(cmd, mc_ver_info); return 0; }
Ok, I'll change this as suggested in the next respin.
Quoted 13 lines
Quoted 13 lines
drivers/bus/fsl-mc/dprc.c +11
-0+int dprc_get_container_id (struct fsl_mc_io *mc_io,int *container_id) +{ +struct mc_command cmd = {0 }; +int err; + + cmd.header =mc_encode_cmd_header (DPRC_CMDID_GET_CONT_ID , +DPRC_CMDSZ_GET_CONT_ID , +MC_CMD_PRI_LOW ,0 ); + + err =mc_send_command (mc_io, &cmd); +if (!err)
Quoted 9 lines
drivers/bus/fsl-mc/dprc.c line 51
Quoted 4 lines
drivers/bus/fsl-mc/dprc.c +4
-0+DPRC_RSP_GET_CONTAINER_ID (cmd, *container_id); + +return err; +}Same sort of thing as above.
Actively fail on err and proceed at the same indent level on success.
Yes, I'll change all occurrences of this.
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to J. German RiveraQuoted 21 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.c
Quoted 8 lines
create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.h
the fsl prefix in the filename fsl_dpmng_cmd.h is redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?
Also, any reason why these and future include files aren't being put in include/linux/fsl/, so as to not pollute the top level include/linux/? That way, we can also remove the fsl- prefix from those filenames, too..
Quoted 16 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0@@ -0,0 +1,93 @@ +/* Copyright 2013-2014 Freescale Semiconductor Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Freescale Semiconductor nor the
drivers/bus/fsl-mc/dpmng.c line 20
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* +* ALTERNATIVELY, this software may be distributed under the terms of the +* GNU General Public License ("GPL") as published by the Free Software +* Foundation, either version 2 of that License or (at your option) any +* later version. +* +* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
interesting, normally this text reads:
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"
...does that mean we're excluding non-Freescale copyright holders and contributors from this warranty statement? That doesn't seem appropriate for an upstream kernel submission.
drivers/bus/fsl-mc/dpmng.c line 30
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/
This dual BSD-3-clause/GPL license doesn't match that of patch 2's drivers/bus/fsl-mc/fsl_mc_bus.c, GPLv2:
+/*
+ * Freescale Management Complex (MC) bus driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: German Rivera <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
any reason the licenses are different?
drivers/bus/fsl-mc/dpmng.c line 39
Quoted 3 lines
drivers/bus/fsl-mc/dpmng.c new file +3
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 };
we can save some cycles if this initialization is not absolutely
necessary: is it? i.e., does the h/w actually look at the params section when doing a get_version? not sure to what other commands this comment would apply to...at least get_container_id, but maybe more - all of them?
Quoted 33 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +31
-0+/** +* Map an MC portal in the kernel virtual address space +*/ +static int map_mc_portal (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +void __iomem **new_mc_portal_virt_addr) +{ +void __iomem *mc_portal_virt_addr =NULL ; +struct resource *res =NULL ; +int error = -EINVAL ; + + res = +request_mem_region (mc_portal_phys_addr, mc_portal_size, +"mc_portal" ); +if (res ==NULL ) { +pr_err ("request_mem_region() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EBUSY ; + goto error; + } + + mc_portal_virt_addr =ioremap_nocache (mc_portal_phys_addr, + mc_portal_size); +if (mc_portal_virt_addr ==NULL ) { +pr_err ("ioremap_nocache() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EFAULT ; + goto error; + } + + *new_mc_portal_virt_addr = mc_portal_virt_addr;
drivers/bus/fsl-mc/fsl_mc_sys.c line 88
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+return 0 ; +error: +if (mc_portal_virt_addr !=NULL ) +iounmap (mc_portal_virt_addr); + +if (res !=NULL ) +release_mem_region (mc_portal_phys_addr, mc_portal_size); + +return error; +}
unnecessary initializations, bad error codes (both should be -ENOMEM), unnecessarily complicated error path, plus a simpler implementation can be made if fn can return the mapped address, like so:
static void __iomem *map_mc_portal(phys_addr_t mc_portal_phys_addr,
uint32_t mc_portal_size)
{
struct resource *res;
void __iomem *mapped_addr;
res = request_mem_region(mc_portal_phys_addr, mc_portal_size,
"mc_portal");
if (!res)
return NULL;
mapped_addr = ioremap_nocache(mc_portal_phys_addr,
mc_portal_size);
if (!mapped_addr)
release_mem_region(mc_portal_phys_addr, mc_portal_size);
return mapped_addr;
}the callsite can return -ENOMEM to its caller if returned NULL. This can be improved even further if devm_ functions are used: this is just an example of how to simplify the code using early returns instead of goto error.
Quoted 16 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +16
-0+int __must_check fsl_create_mc_io (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +uint32_t flags,struct fsl_mc_io **new_mc_io) +{ +int error = -EINVAL ; +struct fsl_mc_io *mc_io =NULL ; + + mc_io =kzalloc (sizeof (*mc_io),GFP_KERNEL ); +if (mc_io ==NULL ) { + error = -ENOMEM ; +pr_err ("No memory to allocate mc_io\n" ); + goto error; + } + + mc_io->magic =FSL_MC_IO_MAGIC ; + mc_io->flags = flags;
drivers/bus/fsl-mc/fsl_mc_sys.c line 129
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+ mc_io->portal_phys_addr = mc_portal_phys_addr; + mc_io->portal_size = mc_portal_size; +spin_lock_init (&mc_io->spinlock); + error =map_mc_portal (mc_portal_phys_addr, + mc_portal_size, &mc_io->portal_virt_addr); +if (error <0 ) + goto error; + + *new_mc_io = mc_io; +return 0 ;
if a fn only returns an address or error, it can return ERR_PTR (e.g., -ENOMEM), and the callsite use IS_ERR() to determine whether there was an error or address returned. This makes code much simpler instead of passing address values back by reference.
drivers/bus/fsl-mc/fsl_mc_sys.c line 138
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +9
-0+error: +if (mc_io !=NULL ) { +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_portal_phys_addr, + mc_portal_size, + mc_io->portal_virt_addr); + } + +kfree (mc_io);
kfree can handle being passed NULL, but again, might want to consider using devm_ functions instead.
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +4
-0+ } + +return error; +}
drivers/bus/fsl-mc/fsl_mc_sys.c line 152
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+EXPORT_SYMBOL_GPL (fsl_create_mc_io); + +void fsl_destroy_mc_io (struct fsl_mc_io *mc_io) +{ +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC )) +return ; + +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_io->portal_phys_addr, + mc_io->portal_size, mc_io->portal_virt_addr);
unmap_mc_portal already checks for virt_addr, this is another example where the code goes too far checking for NULL.
Quoted 29 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +29
-0+ mc_io->portal_virt_addr =NULL ; + } + + mc_io->magic =0x0 ; +kfree (mc_io); +} +EXPORT_SYMBOL_GPL (fsl_destroy_mc_io); + +static int mc_status_to_error (enum mc_cmd_status status) +{ +switch (status) { +case MC_CMD_STATUS_OK : +return 0 ; +case MC_CMD_STATUS_AUTH_ERR : +return -EACCES ; +case MC_CMD_STATUS_NO_PRIVILEGE : +return -EPERM ; +case MC_CMD_STATUS_DMA_ERR : +return -EIO ; +case MC_CMD_STATUS_CONFIG_ERR : +return -EINVAL ; +case MC_CMD_STATUS_TIMEOUT : +return -ETIMEDOUT ; +case MC_CMD_STATUS_NO_RESOURCE : +return -ENAVAIL ; +case MC_CMD_STATUS_NO_MEMORY : +return -ENOMEM ; +case MC_CMD_STATUS_BUSY : +return -EBUSY ;
drivers/bus/fsl-mc/fsl_mc_sys.c line 192
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+case MC_CMD_STATUS_UNSUPPORTED_OP : +return -ENOTSUP ; +case MC_CMD_STATUS_INVALID_STATE : +return -ENODEV ; +default : +break ; + } + +/* Not expected to reach here */ +return -EINVAL ;
but if it does, callsite can't disambiguate between that and e.g., MC_CMD_STATUS_CONFIG_ERR. Also, this would be more readable as a static const lookup table.
drivers/bus/fsl-mc/fsl_mc_sys.c line 205
Quoted 13 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +13
-0+} + +int mc_send_command (struct fsl_mc_io *mc_io,struct mc_command *cmd) +{ +enum mc_cmd_status status; +unsigned long irqsave_flags =0 ; +int error = -EINVAL ; +bool lock_acquired = false; +unsigned long jiffies_until_timeout = + jiffies +MC_CMD_COMPLETION_TIMEOUT ; + +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC )) + goto out;
if the h/w signals an error on the bad magic condition, s/w doesn't need to check it in its fast path.
Quoted 17 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +17
-0+if (mc_io->flags &FSL_MC_IO_PORTAL_SHARED ) { +spin_lock_irqsave (&mc_io->spinlock, irqsave_flags); + lock_acquired = true; + } + +mc_write_command (mc_io->portal_virt_addr, cmd); + +for (;;) { + status =mc_read_response (mc_io->portal_virt_addr, cmd); +if (status !=MC_CMD_STATUS_READY ) +break ; + +/* +* TODO: When MC command completion interrupts are supported +* call wait function here instead of udelay() +*/ +udelay (MC_CMD_COMPLETION_POLLING_INTERVAL );
drivers/bus/fsl-mc/fsl_mc_sys.c line 233
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+if (time_after_eq (jiffies, jiffies_until_timeout)) { + error = -ETIMEDOUT ; + goto out; + } + } + + error =mc_status_to_error (status); +out: +if (lock_acquired) +spin_unlock_irqrestore (&mc_io->spinlock, irqsave_flags);
so if the portal is shared, we take a lock, disable interrupts, and then potentially udelay for a whopping 500usec, then check to see if _100_usec have passed, and thus _always_ issue a timeout error, even if the device took < 100usec to consume the command???
Not to mention this code will spin perpetually with IRQs disabled if the read_response never returns ready. I also don't see a reason why IRQs are being disabled in the first place - it's not being used in an IRQ handler...perhaps we need to wait until command completion IRQs are supported :)
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0
code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 13 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +13
-0+/** +* @brief Disconnects one endpoint to remove its network link +* +* @param[in] mc_io Pointer to opaque I/O object +* @param[in] dprc_handle Handle to the DPRC object +* @param[in] endpoint Endpoint configuration parameters. +* +* @returns '0' on Success; Error code otherwise. +* */ +int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */
this entire file is riddled with non-kernel-doc comment markers: see Documentation/kernel-doc-nano-HOWTO.txt on how to write function and other types of comments in a kernel-doc compliant format.
Quoted 14 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +14
-0+#ifdef FSL_MC_FIRMWARE +/* +* MC firmware decodes MC command parameters and encodes MC response parameters +*/ + +#define MC_CMD_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \ + ((_arg) = (_type)u64_dec((_cmd).params[_param], (_offset), (_width))) + +#define MC_RSP_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \ + ((_cmd).params[_param] |= u64_enc((_offset), (_width), (_type)(_arg))) + +#else +/* +* MC clients (GPP side) encode MC command parameters and decode MC response
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+* parameters +*/ + +#define MC_CMD_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \ + ((_cmd).params[_param] |= u64_enc((_offset), (_width), (_type)(_arg))) + +#define MC_RSP_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \ + ((_arg) = (_type)u64_dec((_cmd).params[_param], (_offset), (_width))) + +#endif /* FSL_MC_FIRMWARE */
FSL_MC_FIRMWARE isn't being defined anywhere; remove.
Quoted 1 line
include/linux/fsl_mc_sys.h +0
-0
...
include/linux/fsl_mc_sys.h line 42
Quoted 3 lines
include/linux/fsl_mc_sys.h +3
-0+#ifndef ENOTSUP +#define ENOTSUP 95 +#endif
This is already being defined as EOPNOTSUPP: either use that, ENOTSUPP, or, if you can justify it, patch a more generic errno.h as a separate patch, earlier in the patchseries.
include/linux/fsl_mc_sys.h line 45
Quoted 2 lines
include/linux/fsl_mc_sys.h +2
-0+#define ioread64 (_p) readq(_p) +#define iowrite64 (_v, _p) writeq(_v, _p)
these definitions have names that are too generic to belong in a FSL h/w header: conflicts will be introduced once the existing io{read,write}32 functions get promoted. Either use readq/writeq directly, or, if you can justify it, patch a more generic io.h.
Also, is there a reason the 'relaxed' versions of the i/o accessors aren't being used?
I'm stopping my review here, since I expect numerous changes in the subsequent patches as a result of changes to this one in the next version of the series.
Thanks,
Kim
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 12 lines · Kim Phillips
drivers/bus/fsl-mc/dpmng.c line 39
Quoted 3 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
drivers/bus/fsl-mc/dpmng.c new file +3
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 };we can save some cycles if this initialization is not absolutely
necessary: is it? i.e., does the h/w actually look at the params section when doing aget_version? not sure to what other commands this comment would apply to...at leastget_container_id, but maybe more - all of them?
Do you really want to open that can of worms, much less to speed up something that doesn't look performance critical? Have fun debugging it if it turns out the hardware does look at something you didn't initialize.
Quoted 38 lines
Quoted 38 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +36
-0+/** +* Map an MC portal in the kernel virtual address space +*/ +static int map_mc_portal (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +void __iomem **new_mc_portal_virt_addr) +{ +void __iomem *mc_portal_virt_addr =NULL ; +struct resource *res =NULL ; +int error = -EINVAL ; + + res = +request_mem_region (mc_portal_phys_addr, mc_portal_size, +"mc_portal" ); +if (res ==NULL ) { +pr_err ("request_mem_region() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EBUSY ; + goto error; + } + + mc_portal_virt_addr =ioremap_nocache (mc_portal_phys_addr, + mc_portal_size); +if (mc_portal_virt_addr ==NULL ) { +pr_err ("ioremap_nocache() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EFAULT ; + goto error; + } + + *new_mc_portal_virt_addr = mc_portal_virt_addr; +return 0 ; +error: +if (mc_portal_virt_addr !=NULL ) +iounmap (mc_portal_virt_addr); +
Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 88
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+if (res !=NULL ) +release_mem_region (mc_portal_phys_addr, mc_portal_size); + +return error; +}unnecessary initializations, bad error codes (both should be
-ENOMEM),
Why should the first one be -ENOMEM? It's not allocating memory, but rather reserving I/O space.
Quoted 23 lines
unnecessarily complicated error path, plus a simpler
implementation can be made if fn can return the mapped address, like so:static void
__iomem*map_mc_portal(phys_addr_tmc_portal_phys_addr,
uint32_tmc_portal_size){ struct resource *res; void __iomem *mapped_addr; res = request_mem_region(mc_portal_phys_addr, mc_portal_size, "mc_portal"); if (!res) return NULL; mapped_addr = ioremap_nocache(mc_portal_phys_addr, mc_portal_size); if (!mapped_addr) release_mem_region(mc_portal_phys_addr, mc_portal_size); return mapped_addr; }
Quoted 1 line
the callsite can return
-ENOMEMto its caller if returned NULL.
-ENOMEM would only be appropriate for one of these errors.
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 2 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +2
-0+#define ioread64 (_p) readq(_p) +#define iowrite64 (_v, _p) writeq(_v, _p)these definitions have names that are too generic to belong in a FSL h/w header: conflicts will be introduced once the existing io{read,write}32 functions get promoted. Either use readq/writeq directly, or, if you can justify it, patch a more generic
io.h.Also, is there a reason the 'relaxed' versions of the i/o accessors aren't being used?
Raw accessors should only be used in performance critical sections where it's worth the effort to implement and verify manual synchronization. My understanding is that the entire management complex is related to setup, not on the I/O fast path.
-Scott
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 14 lines · On Mon, 15 Sep 2014 23:31:21 -0500 Scott Wood <[email protected]> wrote:
Quoted 12 lines · Kim Phillips
drivers/bus/fsl-mc/dpmng.c line 39
Quoted 3 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
drivers/bus/fsl-mc/dpmng.c new file +3
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 };we can save some cycles if this initialization is not absolutely
necessary: is it? i.e., does the h/w actually look at the params section when doing aget_version? not sure to what other commands this comment would apply to...at leastget_container_id, but maybe more - all of them?
Quoted 4 lines
Do you really want to open that can of worms, much less to speed up something that doesn't look performance critical? Have fun debugging it if it turns out the hardware does look at something you didn't initialize.
point taken.
Quoted 47 lines
Quoted 38 lines
Quoted 38 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +36
-0+/** +* Map an MC portal in the kernel virtual address space +*/ +static int map_mc_portal (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +void __iomem **new_mc_portal_virt_addr) +{ +void __iomem *mc_portal_virt_addr =NULL ; +struct resource *res =NULL ; +int error = -EINVAL ; + + res = +request_mem_region (mc_portal_phys_addr, mc_portal_size, +"mc_portal" ); +if (res ==NULL ) { +pr_err ("request_mem_region() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EBUSY ; + goto error; + } + + mc_portal_virt_addr =ioremap_nocache (mc_portal_phys_addr, + mc_portal_size); +if (mc_portal_virt_addr ==NULL ) { +pr_err ("ioremap_nocache() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EFAULT ; + goto error; + } + + *new_mc_portal_virt_addr = mc_portal_virt_addr; +return 0 ; +error: +if (mc_portal_virt_addr !=NULL ) +iounmap (mc_portal_virt_addr); +Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 88
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+if (res !=NULL ) +release_mem_region (mc_portal_phys_addr, mc_portal_size); + +return error; +}unnecessary initializations, bad error codes (both should be
-ENOMEM),
Quoted 2 lines
Why should the first one be
-ENOMEM? It's not allocating memory, but rather reserving I/O space.
I was going with what most of the drivers are already doing, but I see EFAULT is 'Bad address', which, you're right, is probably more appropriate.
Quoted 20 lines
Quoted 20 lines
unnecessarily complicated error path, plus a simpler
implementation can be made if fn can return the mapped address, like so:static void
__iomem*map_mc_portal(phys_addr_tmc_portal_phys_addr,
uint32_tmc_portal_size){ struct resource *res; void __iomem *mapped_addr; res = request_mem_region(mc_portal_phys_addr, mc_portal_size, "mc_portal"); if (!res) return NULL; mapped_addr = ioremap_nocache(mc_portal_phys_addr, mc_portal_size); if (!mapped_addr) release_mem_region(mc_portal_phys_addr, mc_portal_size);
Quoted 6 lines
Quoted 4 lines
return mapped_addr; }the callsite can return
-ENOMEMto its caller if returned NULL.
-ENOMEMwould only be appropriate for one of these errors.
in that case, ERR_PTR() can be used to return the specific error.
Quoted 8 lines
Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 2 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +2
-0+#define ioread64 (_p) readq(_p) +#define iowrite64 (_v, _p) writeq(_v, _p)these definitions have names that are too generic to belong in a FSL h/w header: conflicts will be introduced once the existing io{read,write}32 functions get promoted. Either use readq/writeq directly, or, if you can justify it, patch a more generic
io.h.
Quoted 7 lines
Quoted 2 lines
Also, is there a reason the 'relaxed' versions of the i/o accessors aren't being used?
Raw accessors should only be used in performance critical sections where it's worth the effort to implement and verify manual synchronization. My understanding is that the entire management complex is related to setup, not on the I/O fast path.
ok.
Thanks,
Kim
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 54 lines · Kim Phillips
Quoted 51 lines · On Mon, 15 Sep 2014 23:31:21 -0500 Scott Wood <[email protected]> wrote:
Quoted 49 lines · Kim Phillips
Quoted 33 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
drivers/bus/fsl-mc/fsl_mc_sys.c +31
-0+/** +* Map an MC portal in the kernel virtual address space +*/ +static int map_mc_portal (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +void __iomem **new_mc_portal_virt_addr) +{ +void __iomem *mc_portal_virt_addr =NULL ; +struct resource *res =NULL ; +int error = -EINVAL ; + + res = +request_mem_region (mc_portal_phys_addr, mc_portal_size, +"mc_portal" ); +if (res ==NULL ) { +pr_err ("request_mem_region() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EBUSY ; + goto error; + } + + mc_portal_virt_addr =ioremap_nocache (mc_portal_phys_addr, + mc_portal_size); +if (mc_portal_virt_addr ==NULL ) { +pr_err ("ioremap_nocache() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EFAULT ; + goto error; + } + + *new_mc_portal_virt_addr = mc_portal_virt_addr;drivers/bus/fsl-mc/fsl_mc_sys.c line 88
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+return 0 ; +error: +if (mc_portal_virt_addr !=NULL ) +iounmap (mc_portal_virt_addr); + +if (res !=NULL ) +release_mem_region (mc_portal_phys_addr, mc_portal_size); + +return error; +}unnecessary initializations, bad error codes (both should be
-ENOMEM),
Quoted 6 lines
Quoted 2 lines
Why should the first one be
-ENOMEM? It's not allocating memory, but rather reserving I/O space.I was going with what most of the drivers are already doing, but I see EFAULT is 'Bad address', which, you're right, is probably more appropriate.
EFAULT is for userspace addresses that fault.
I don't see consistency on what other drivers use after request_mem_region() -- some use ENOMEM, some ENODEV, some EBUSY... and probably others.
I'd probably go with ENXIO or EBUSY.
-Scott
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Kim PhillipsQuoted 33 lines · Kim Phillips
Quoted 20 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+)Quoted 9 lines
create mode 100644
drivers/bus/fsl-mc/dpmng.ccreate mode 100644drivers/bus/fsl-mc/dprc.ccreate mode 100644drivers/bus/fsl-mc/fsl_dpmng_cmd.hcreate mode 100644drivers/bus/fsl-mc/fsl_dprc_cmd.hcreate mode 100644drivers/bus/fsl-mc/fsl_mc_sys.ccreate mode 100644include/linux/fsl_dpmng.hcreate mode 100644include/linux/fsl_dprc.hcreate mode 100644include/linux/fsl_mc_cmd.hcreate mode 100644include/linux/fsl_mc_sys.h
Quoted 5 lines
the fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?
This is a convention that we decided early on '-' for directory names and '_' for file names.
Quoted 5 lines
Also, any reason why these and future include files aren't being put in
include/linux/fsl/, so as to not pollute the top levelinclude/linux/? That way, we can also remove the fsl- prefix from those filenames, too..
I would like to receive opinions from others about this before making any change here.
Quoted 29 lines
Quoted 16 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0@@ -0,0 +1,93 @@ +/* Copyright 2013-2014 Freescale Semiconductor Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Freescale Semiconductor nor the drivers/bus/fsl-mc/dpmng.c line 20
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* +* ALTERNATIVELY, this software may be distributed under the terms of the +* GNU General Public License ("GPL") as published by the Free Software +* Foundation, either version 2 of that License or (at your option) any +* later version. +* +* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY interesting, normally this text reads:
Quoted 6 lines
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"
...does that mean we're excluding non-Freescale copyright holders and contributors from this warranty statement? That doesn't seem appropriate for an upstream kernel submission.
I would like to receive opinions from others about this before making any change here.
Quoted 11 lines
drivers/bus/fsl-mc/dpmng.c line 30
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/
Quoted 3 lines
This dual BSD-3-clause/GPL license doesn't match that of patch 2's
drivers/bus/fsl-mc/fsl_mc_bus.c, GPLv2:
This is because the MC flib files in patch 1 can also be used in user-space code not just in the kernel. I will not make any change to the licenses of the MC flib files included in patch 1.
Quoted 11 lines
+/*
+ * Freescale Management Complex (MC) bus driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: German Rivera <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
Quoted 2 lines
any reason the licenses are different?
Different teams wrote the files.
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c line 39
Quoted 3 lines
drivers/bus/fsl-mc/dpmng.c new file +3
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 };we can save some cycles if this initialization is not absolutely
necessary: is it? i.e., does the h/w actually look at the params section when doing aget_version? not sure to what other commands this comment would apply to...at leastget_container_id, but maybe more - all of them?
I agree with the response from Scott Wood. I will not change this.
Quoted 38 lines
Quoted 38 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +36
-0+/** +* Map an MC portal in the kernel virtual address space +*/ +static int map_mc_portal (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +void __iomem **new_mc_portal_virt_addr) +{ +void __iomem *mc_portal_virt_addr =NULL ; +struct resource *res =NULL ; +int error = -EINVAL ; + + res = +request_mem_region (mc_portal_phys_addr, mc_portal_size, +"mc_portal" ); +if (res ==NULL ) { +pr_err ("request_mem_region() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EBUSY ; + goto error; + } + + mc_portal_virt_addr =ioremap_nocache (mc_portal_phys_addr, + mc_portal_size); +if (mc_portal_virt_addr ==NULL ) { +pr_err ("ioremap_nocache() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EFAULT ; + goto error; + } + + *new_mc_portal_virt_addr = mc_portal_virt_addr; +return 0 ; +error: +if (mc_portal_virt_addr !=NULL ) +iounmap (mc_portal_virt_addr); +
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 88
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+if (res !=NULL ) +release_mem_region (mc_portal_phys_addr, mc_portal_size); + +return error; +}unnecessary initializations, bad error codes (both should be
-ENOMEM),
I disagree, the ioremap_nocache() failure should not be treated as ENOMEM. As Scott Wood suggested, I'll change the EFAULT error to ENXIO error.
unnecessarily complicated error path, plus a simpler
Quoted 22 lines
implementation can be made if fn can return the mapped address, like so:
static void
__iomem*map_mc_portal(phys_addr_tmc_portal_phys_addr,
uint32_tmc_portal_size){ struct resource *res; void __iomem *mapped_addr; res = request_mem_region(mc_portal_phys_addr, mc_portal_size, "mc_portal"); if (!res) return NULL; mapped_addr = ioremap_nocache(mc_portal_phys_addr, mc_portal_size); if (!mapped_addr) release_mem_region(mc_portal_phys_addr, mc_portal_size); return mapped_addr; }
Quoted 4 lines
the callsite can return
-ENOMEMto its caller if returned NULL. This can be improved even further ifdevm_functions are used: this is just an example of how to simplify the code using early returns instead of goto error.
I disagree. Having a common error return point is more maintainable than having multiple returns as having the clean-up logic in one place is more maintainable and makes the min path (non-error) more readable.
Quoted 24 lines
Quoted 24 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +23
-0+int __must_check fsl_create_mc_io (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +uint32_t flags,struct fsl_mc_io **new_mc_io) +{ +int error = -EINVAL ; +struct fsl_mc_io *mc_io =NULL ; + + mc_io =kzalloc (sizeof (*mc_io),GFP_KERNEL ); +if (mc_io ==NULL ) { + error = -ENOMEM ; +pr_err ("No memory to allocate mc_io\n" ); + goto error; + } + + mc_io->magic =FSL_MC_IO_MAGIC ; + mc_io->flags = flags; + mc_io->portal_phys_addr = mc_portal_phys_addr; + mc_io->portal_size = mc_portal_size; +spin_lock_init (&mc_io->spinlock); + error =map_mc_portal (mc_portal_phys_addr, + mc_portal_size, &mc_io->portal_virt_addr); +if (error <0 ) + goto error;
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 129
Quoted 3 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +3
-0+ + *new_mc_io = mc_io; +return 0 ;if a fn only returns an address or error, it can return
ERR_PTR(e.g.,-ENOMEM), and the callsite useIS_ERR()to determine whether there was an error or address returned. This makes code much simpler instead of passing address values back by reference.
I disagree. I don't see why the alternative you suggest makes the code "much simpler".
Quoted 4 lines
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +4
-0+error: +if (mc_io !=NULL ) { +if (mc_io->portal_virt_addr !=NULL ) { + unmap_mc_portal(mc_portal_phys_addr,
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 138
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+ mc_portal_size, + mc_io->portal_virt_addr); + } + +kfree (mc_io);kfree can handle being passed NULL, but again, might want to consider using
devm_functions instead.
No. We cannot use devm_ functions here as there is no device passed in.
Quoted 9 lines
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +9
-0+ } + +return error; +} +EXPORT_SYMBOL_GPL (fsl_create_mc_io); + +void fsl_destroy_mc_io (struct fsl_mc_io *mc_io) +{ +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC ))
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 152
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+return ; + +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_io->portal_phys_addr, + mc_io->portal_size, mc_io->portal_virt_addr);
unmap_mc_portalalready checks forvirt_addr, this is another example where the code goes too far checking for NULL.
I disagree. Having the extra check is harmless and more importantly makes the intent explicit that we should only call unmap_mc_portal if we called map_mc_portal earlier.
Quoted 35 lines
Quoted 35 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +35
-0+ mc_io->portal_virt_addr =NULL ; + } + + mc_io->magic =0x0 ; +kfree (mc_io); +} +EXPORT_SYMBOL_GPL (fsl_destroy_mc_io); + +static int mc_status_to_error (enum mc_cmd_status status) +{ +switch (status) { +case MC_CMD_STATUS_OK : +return 0 ; +case MC_CMD_STATUS_AUTH_ERR : +return -EACCES ; +case MC_CMD_STATUS_NO_PRIVILEGE : +return -EPERM ; +case MC_CMD_STATUS_DMA_ERR : +return -EIO ; +case MC_CMD_STATUS_CONFIG_ERR : +return -EINVAL ; +case MC_CMD_STATUS_TIMEOUT : +return -ETIMEDOUT ; +case MC_CMD_STATUS_NO_RESOURCE : +return -ENAVAIL ; +case MC_CMD_STATUS_NO_MEMORY : +return -ENOMEM ; +case MC_CMD_STATUS_BUSY : +return -EBUSY ; +case MC_CMD_STATUS_UNSUPPORTED_OP : +return -ENOTSUP ; +case MC_CMD_STATUS_INVALID_STATE : +return -ENODEV ; +default : +break ;
Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 192
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +4
-0+ } + +/* Not expected to reach here */ +return -EINVAL ;but if it does, callsite can't disambiguate between that and e.g.,
MC_CMD_STATUS_CONFIG_ERR. Also, this would be more readable as a static const lookup table.
I will change the switch to a lookup table and fix the -EINVAL ambiguity in the v2 respin.
Quoted 18 lines
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +3
-0+} + +int mc_send_command (struct fsl_mc_io *mc_io,struct mc_command *cmd)drivers/bus/fsl-mc/fsl_mc_sys.c line 205
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+{ +enum mc_cmd_status status; +unsigned long irqsave_flags =0 ; +int error = -EINVAL ; +bool lock_acquired = false; +unsigned long jiffies_until_timeout = + jiffies +MC_CMD_COMPLETION_TIMEOUT ; + +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC )) + goto out;if the h/w signals an error on the bad magic condition, s/w doesn't need to check it in its fast path.
As per comments from Arnd Bergmann on the RFC patch series, I removed the magic field from all structs. I just forgot to do it for this one. I will remove this magic field in the v2 respin.
Quoted 24 lines
Quoted 24 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +24
-0+if (mc_io->flags &FSL_MC_IO_PORTAL_SHARED ) { +spin_lock_irqsave (&mc_io->spinlock, irqsave_flags); + lock_acquired = true; + } + +mc_write_command (mc_io->portal_virt_addr, cmd); + +for (;;) { + status =mc_read_response (mc_io->portal_virt_addr, cmd); +if (status !=MC_CMD_STATUS_READY ) +break ; + +/* +* TODO: When MC command completion interrupts are supported +* call wait function here instead of udelay() +*/ +udelay (MC_CMD_COMPLETION_POLLING_INTERVAL ); +if (time_after_eq (jiffies, jiffies_until_timeout)) { + error = -ETIMEDOUT ; + goto out; + } + } + + error =mc_status_to_error (status);
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 233
Quoted 3 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +3
-0+out: +if (lock_acquired) +spin_unlock_irqrestore (&mc_io->spinlock, irqsave_flags);so if the portal is shared, we take a lock, disable interrupts, and then potentially udelay for a whopping 500usec, then check to see if
_100_usechave passed, and thus _always_ issue a timeout error, even if the device took < 100usec to consume the command???
That is not true. The 100 is in jiffies not in usec:
/**
* Timeout in jiffies to wait for the completion of an MC command */
#define MC_CMD_COMPLETION_TIMEOUT 100
/**
* Delay in microseconds between polling iterations while
* waiting for MC command completion
*/
#define MC_CMD_COMPLETION_POLLING_INTERVAL 500
Quoted 6 lines
Not to mention this code will spin perpetually with IRQs disabled if the
read_responsenever returns ready. I also don't see a reason why IRQs are being disabled in the first place - it's not being used in an IRQ handler...perhaps we need to wait until command completion IRQs are supported :)
I agree that disabling interrupts while doing polling is not efficient. I was assuming the worst case scenario of sharing the portal: both
threads and interrupt handlers accessing the same portal at the same time. If only threads access the same portal, we don't need to disable interrupts and even further we can use a mutex instead of a spinlock. If only interrupt handlers access a given portal (from multiple CPUs)
we have use a spinlock but we don't need to disabel interrupts.
If both threads and interrupt handlers access a given portal, then
we need to both use a spinlock and disable interrupts
I will change synchronization logic in the v2 respin to avoid disabling interrupts in the first two cases above.
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
This comment is not precise enough be actionable.
What exactly you want to be changed here?
Quoted 9 lines
Quoted 9 lines
+/**
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +4
-0+int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone and not make any change here.
Quoted 18 lines
Quoted 18 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +18
-0+#ifdef FSL_MC_FIRMWARE +/* +* MC firmware decodes MC command parameters and encodes MC response parameters +*/ + +#define MC_CMD_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \ + ((_arg) = (_type)u64_dec((_cmd).params[_param], (_offset), (_width))) + +#define MC_RSP_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \ + ((_cmd).params[_param] |= u64_enc((_offset), (_width), (_type)(_arg))) + +#else +/* +* MC clients (GPP side) encode MC command parameters and decode MC response +* parameters +*/ + +#define MC_CMD_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 6 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +6
-0+ ((_cmd).params[_param] |= u64_enc((_offset), (_width), (_type)(_arg))) + +#define MC_RSP_PARAM_OP (_cmd, _param, _offset, _width, _type, _arg) \ + ((_arg) = (_type)u64_dec((_cmd).params[_param], (_offset), (_width))) + +#endif /* FSL_MC_FIRMWARE */
FSL_MC_FIRMWAREisn't being defined anywhere; remove.
I will remove the FSL_MC_FIRMWARE #ifdef in the v2 respin.
Quoted 10 lines
Quoted 1 line
include/linux/fsl_mc_sys.h +0
-0...
include/linux/fsl_mc_sys.h line 42
Quoted 3 lines
include/linux/fsl_mc_sys.h +3
-0+#ifndef ENOTSUP +#define ENOTSUP 95 +#endif This is already being defined as EOPNOTSUPP: either use that, ENOTSUPP, or, if you can justify it, patch a more generic
errno.has a separate patch, earlier in the patchseries.
I will remove ENOTSUP and use ENOTSUPP instead.
Quoted 8 lines
include/linux/fsl_mc_sys.h line 45
Quoted 2 lines
include/linux/fsl_mc_sys.h +2
-0+#define ioread64 (_p) readq(_p) +#define iowrite64 (_v, _p) writeq(_v, _p)these definitions have names that are too generic to belong in a FSL h/w header: conflicts will be introduced once the existing io{read,write}32 functions get promoted. Either use readq/writeq directly, or, if you can justify it, patch a more generic
io.h.
I will remove ioread64() and iowrite64() and use readq() and writeq() directly instead.
Quoted 3 lines
Also, is there a reason the 'relaxed' versions of the i/o accessors aren't being used?
Scott Wood responded to this already.
Quoted 8 lines
I'm stopping my review here, since I expect numerous changes in the subsequent patches as a result of changes to this one in the next version of the series.
Thanks,
Kim
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 80 lines
Am 18.09.2014 um 06:17 schrieb German Rivera <[email protected]>:
Quoted 34 lines · Kim Phillips
Quoted 21 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.cQuoted 8 lines
create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.hQuoted 4 lines
the fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?This is a convention that we decided early on '-' for directory names and '_' for file names.
Quoted 4 lines
Also, any reason why these and future include files aren't being put in
include/linux/fsl/, so as to not pollute the top levelinclude/linux/? That way, we can also remove the fsl- prefix from those filenames, too..I would like to receive opinions from others about this before making any change here.
Quoted 29 lines
Quoted 16 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0@@ -0,0 +1,93 @@ +/* Copyright 2013-2014 Freescale Semiconductor Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Freescale Semiconductor nor the drivers/bus/fsl-mc/dpmng.c line 20
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* +* ALTERNATIVELY, this software may be distributed under the terms of the +* GNU General Public License ("GPL") as published by the Free Software +* Foundation, either version 2 of that License or (at your option) any +* later version. +* +* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY interesting, normally this text reads:
Quoted 6 lines
Quoted 5 lines
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"
...does that mean we're excluding non-Freescale copyright holders and contributors from this warranty statement? That doesn't seem appropriate for an upstream kernel submission.
I would like to receive opinions from others about this before making any change here.
IANAL, but I would prefer to have this identical to the rest of Linux to be on the safe side.
Quoted 168 lines
Quoted 12 lines
drivers/bus/fsl-mc/dpmng.c line 30
Quoted 11 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ Quoted 2 lines
This dual BSD-3-clause/GPL license doesn't match that of patch 2's
drivers/bus/fsl-mc/fsl_mc_bus.c, GPLv2:This is because the MC flib files in patch 1 can also be used in user-space code not just in the kernel. I will not make any change to the licenses of the MC flib files included in patch 1.
Quoted 11 lines
+/*
+ * Freescale Management Complex (MC) bus driver
+ *
+ * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Author: German Rivera <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */Quoted 1 line
any reason the licenses are different?
Different teams wrote the files.
Quoted 9 lines
drivers/bus/fsl-mc/dpmng.c line 39
Quoted 3 lines
drivers/bus/fsl-mc/dpmng.c new file +3
-0+int mc_get_version (struct fsl_mc_io *mc_io,struct mc_version *mc_ver_info) +{ +struct mc_command cmd = {0 };we can save some cycles if this initialization is not absolutely
necessary: is it? i.e., does the h/w actually look at the params section when doing aget_version? not sure to what other commands this comment would apply to...at leastget_container_id, but maybe more - all of them?I agree with the response from Scott Wood. I will not change this.
Quoted 38 lines
Quoted 38 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +36
-0+/** +* Map an MC portal in the kernel virtual address space +*/ +static int map_mc_portal (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +void __iomem **new_mc_portal_virt_addr) +{ +void __iomem *mc_portal_virt_addr =NULL ; +struct resource *res =NULL ; +int error = -EINVAL ; + + res = +request_mem_region (mc_portal_phys_addr, mc_portal_size, +"mc_portal" ); +if (res ==NULL ) { +pr_err ("request_mem_region() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EBUSY ; + goto error; + } + + mc_portal_virt_addr =ioremap_nocache (mc_portal_phys_addr, + mc_portal_size); +if (mc_portal_virt_addr ==NULL ) { +pr_err ("ioremap_nocache() failed for MC portal %#llx\n" , + mc_portal_phys_addr); + error = -EFAULT ; + goto error; + } + + *new_mc_portal_virt_addr = mc_portal_virt_addr; +return 0 ; +error: +if (mc_portal_virt_addr !=NULL ) +iounmap (mc_portal_virt_addr); +Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 88
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+if (res !=NULL ) +release_mem_region (mc_portal_phys_addr, mc_portal_size); + +return error; +}unnecessary initializations, bad error codes (both should be
-ENOMEM),I disagree, the
ioremap_nocache()failure should not be treated as ENOMEM. As Scott Wood suggested, I'll change the EFAULT error to ENXIO error.unnecessarily complicated error path, plus a simpler
Quoted 22 lines
implementation can be made if fn can return the mapped address, like so:
static void
__iomem*map_mc_portal(phys_addr_tmc_portal_phys_addr,
uint32_tmc_portal_size){ struct resource *res; void __iomem *mapped_addr; res = request_mem_region(mc_portal_phys_addr, mc_portal_size, "mc_portal"); if (!res) return NULL; mapped_addr = ioremap_nocache(mc_portal_phys_addr, mc_portal_size); if (!mapped_addr) release_mem_region(mc_portal_phys_addr, mc_portal_size); return mapped_addr; }Quoted 4 lines
the callsite can return
-ENOMEMto its caller if returned NULL. This can be improved even further ifdevm_functions are used: this is just an example of how to simplify the code using early returns instead of goto error.I disagree. Having a common error return point is more maintainable than having multiple returns as having the clean-up logic in one place is more maintainable and makes the min path (non-error) more readable.
Quoted 24 lines
Quoted 24 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +23
-0+int __must_check fsl_create_mc_io (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +uint32_t flags,struct fsl_mc_io **new_mc_io) +{ +int error = -EINVAL ; +struct fsl_mc_io *mc_io =NULL ; + + mc_io =kzalloc (sizeof (*mc_io),GFP_KERNEL ); +if (mc_io ==NULL ) { + error = -ENOMEM ; +pr_err ("No memory to allocate mc_io\n" ); + goto error; + } + + mc_io->magic =FSL_MC_IO_MAGIC ; + mc_io->flags = flags; + mc_io->portal_phys_addr = mc_portal_phys_addr; + mc_io->portal_size = mc_portal_size; +spin_lock_init (&mc_io->spinlock); + error =map_mc_portal (mc_portal_phys_addr, + mc_portal_size, &mc_io->portal_virt_addr); +if (error <0 ) + goto error;Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 129
Quoted 3 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +3
-0+ + *new_mc_io = mc_io; +return 0 ;if a fn only returns an address or error, it can return
ERR_PTR(e.g.,-ENOMEM), and the callsite useIS_ERR()to determine whether there was an error or address returned. This makes code much simpler instead of passing address values back by reference.I disagree. I don't see why the alternative you suggest makes the code "much simpler".
Quoted 4 lines
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +4
-0+error: +if (mc_io !=NULL ) { +if (mc_io->portal_virt_addr !=NULL ) { + unmap_mc_portal(mc_portal_phys_addr,Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 138
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+ mc_portal_size, + mc_io->portal_virt_addr); + } + +kfree (mc_io);kfree can handle being passed NULL, but again, might want to consider using
devm_functions instead.
Quoted 1 line
No. We cannot use
devm_functions here as there is no device passed in.
Is it a good idea to lose your device context in any function? Whenever I dropped contexts in helper I usually ended up regretting it later ;).
Quoted 118 lines
Quoted 10 lines
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +9
-0+ } + +return error; +} +EXPORT_SYMBOL_GPL (fsl_create_mc_io); + +void fsl_destroy_mc_io (struct fsl_mc_io *mc_io) +{ +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC ))Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 152
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+return ; + +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_io->portal_phys_addr, + mc_io->portal_size, mc_io->portal_virt_addr);
unmap_mc_portalalready checks forvirt_addr, this is another example where the code goes too far checking for NULL.I disagree. Having the extra check is harmless and more importantly makes the intent explicit that we should only call
unmap_mc_portalif we calledmap_mc_portalearlier.Quoted 35 lines
Quoted 35 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +35
-0+ mc_io->portal_virt_addr =NULL ; + } + + mc_io->magic =0x0 ; +kfree (mc_io); +} +EXPORT_SYMBOL_GPL (fsl_destroy_mc_io); + +static int mc_status_to_error (enum mc_cmd_status status) +{ +switch (status) { +case MC_CMD_STATUS_OK : +return 0 ; +case MC_CMD_STATUS_AUTH_ERR : +return -EACCES ; +case MC_CMD_STATUS_NO_PRIVILEGE : +return -EPERM ; +case MC_CMD_STATUS_DMA_ERR : +return -EIO ; +case MC_CMD_STATUS_CONFIG_ERR : +return -EINVAL ; +case MC_CMD_STATUS_TIMEOUT : +return -ETIMEDOUT ; +case MC_CMD_STATUS_NO_RESOURCE : +return -ENAVAIL ; +case MC_CMD_STATUS_NO_MEMORY : +return -ENOMEM ; +case MC_CMD_STATUS_BUSY : +return -EBUSY ; +case MC_CMD_STATUS_UNSUPPORTED_OP : +return -ENOTSUP ; +case MC_CMD_STATUS_INVALID_STATE : +return -ENODEV ; +default : +break ;Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 192
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +4
-0+ } + +/* Not expected to reach here */ +return -EINVAL ;but if it does, callsite can't disambiguate between that and e.g.,
MC_CMD_STATUS_CONFIG_ERR. Also, this would be more readable as a static const lookup table.I will change the switch to a lookup table and fix the
-EINVALambiguity in the v2 respin.Quoted 17 lines
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +3
-0+} + +int mc_send_command (struct fsl_mc_io *mc_io,struct mc_command *cmd)drivers/bus/fsl-mc/fsl_mc_sys.c line 205
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +10
-0+{ +enum mc_cmd_status status; +unsigned long irqsave_flags =0 ; +int error = -EINVAL ; +bool lock_acquired = false; +unsigned long jiffies_until_timeout = + jiffies +MC_CMD_COMPLETION_TIMEOUT ; + +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC )) + goto out;if the h/w signals an error on the bad magic condition, s/w doesn't need to check it in its fast path.
As per comments from Arnd Bergmann on the RFC patch series, I removed the magic field from all structs. I just forgot to do it for this one. I will remove this magic field in the v2 respin.
Quoted 24 lines
Quoted 24 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +24
-0+if (mc_io->flags &FSL_MC_IO_PORTAL_SHARED ) { +spin_lock_irqsave (&mc_io->spinlock, irqsave_flags); + lock_acquired = true; + } + +mc_write_command (mc_io->portal_virt_addr, cmd); + +for (;;) { + status =mc_read_response (mc_io->portal_virt_addr, cmd); +if (status !=MC_CMD_STATUS_READY ) +break ; + +/* +* TODO: When MC command completion interrupts are supported +* call wait function here instead of udelay() +*/ +udelay (MC_CMD_COMPLETION_POLLING_INTERVAL ); +if (time_after_eq (jiffies, jiffies_until_timeout)) { + error = -ETIMEDOUT ; + goto out; + } + } + + error =mc_status_to_error (status);Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 233
Quoted 3 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +3
-0+out: +if (lock_acquired) +spin_unlock_irqrestore (&mc_io->spinlock, irqsave_flags);so if the portal is shared, we take a lock, disable interrupts, and then potentially udelay for a whopping 500usec, then check to see if
_100_usechave passed, and thus _always_ issue a timeout error, even if the device took < 100usec to consume the command???
Quoted 1 line
That is not true. The 100 is in jiffies not in usec:
If you always wait for 100 jiffies, the timeout code suddenly depends on the HZ value which is kernel configuration, no? Wouldn't it be better to base the timeout on real wall time?
Quoted 36 lines
/**
* Timeout in jiffies to wait for the completion of an MC command */
#defineMC_CMD_COMPLETION_TIMEOUT100/**
* Delay in microseconds between polling iterations while
* waiting for MC command completion
*/
#defineMC_CMD_COMPLETION_POLLING_INTERVAL500Quoted 5 lines
Not to mention this code will spin perpetually with IRQs disabled if the
read_responsenever returns ready. I also don't see a reason why IRQs are being disabled in the first place - it's not being used in an IRQ handler...perhaps we need to wait until command completion IRQs are supported :)I agree that disabling interrupts while doing polling is not efficient. I was assuming the worst case scenario of sharing the portal: both
threads and interrupt handlers accessing the same portal at the same time. If only threads access the same portal, we don't need to disable interrupts and even further we can use a mutex instead of a spinlock. If only interrupt handlers access a given portal (from multiple CPUs)
we have use a spinlock but we don't need to disabel interrupts.
If both threads and interrupt handlers access a given portal, then
we need to both use a spinlock and disable interruptsI will change synchronization logic in the v2 respin to avoid disabling interrupts in the first two cases above.
Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 5 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?
I think the easy thing to do is to convert the exact version check into a ranged version check: have minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 18 lines
Quoted 10 lines
Quoted 10 lines
+/**
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_sys.c +4
-0+int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone and not make any change here.
Do you see any other source files in Linux using doxygen comments? Mixing different documentation styles can easily become a big mess, because you can't generate external documentation consistently for the whole tree.
Alex
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 36 lines · On Thu, 18 Sep 2014 15:14:03 +0200 Alexander Graf <[email protected]> wrote:
Quoted 36 lines
Am 18.09.2014 um 06:17 schrieb German Rivera <[email protected]>:
Quoted 34 lines · Kim Phillips
Quoted 29 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.c create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.h
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
the fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?This is a convention that we decided early on '-' for directory names and '_' for file names.
based on what?
Quoted 23 lines
Quoted 23 lines
unnecessarily complicated error path, plus a simpler
Quoted 22 lines
implementation can be made if fn can return the mapped address, like so:
static void
__iomem*map_mc_portal(phys_addr_tmc_portal_phys_addr,
uint32_tmc_portal_size){ struct resource *res; void __iomem *mapped_addr; res = request_mem_region(mc_portal_phys_addr, mc_portal_size, "mc_portal"); if (!res) return NULL; mapped_addr = ioremap_nocache(mc_portal_phys_addr, mc_portal_size); if (!mapped_addr) release_mem_region(mc_portal_phys_addr, mc_portal_size); return mapped_addr; }
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
the callsite can return
-ENOMEMto its caller if returned NULL. This can be improved even further ifdevm_functions are used: this is just an example of how to simplify the code using early returns instead of goto error.I disagree. Having a common error return point is more maintainable than having multiple returns as having the clean-up logic in one place is more maintainable and makes the min path (non-error) more readable.
my comment is not that much different from Joe's here:
https://lkml.org/lkml/2014/9/17/381
but hopefully all this will change with a devm_ based implementation.
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 16 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +16
-0+int __must_check fsl_create_mc_io (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +uint32_t flags,struct fsl_mc_io **new_mc_io) +{ +int error = -EINVAL ; +struct fsl_mc_io *mc_io =NULL ; + + mc_io =kzalloc (sizeof (*mc_io),GFP_KERNEL ); +if (mc_io ==NULL ) { + error = -ENOMEM ; +pr_err ("No memory to allocate mc_io\n" ); + goto error; + } + + mc_io->magic =FSL_MC_IO_MAGIC ; + mc_io->flags = flags;drivers/bus/fsl-mc/fsl_mc_sys.c line 129
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +10
-0+ mc_io->portal_phys_addr = mc_portal_phys_addr; + mc_io->portal_size = mc_portal_size; +spin_lock_init (&mc_io->spinlock); + error =map_mc_portal (mc_portal_phys_addr, + mc_portal_size, &mc_io->portal_virt_addr); +if (error <0 ) + goto error; + + *new_mc_io = mc_io; +return 0 ;if a fn only returns an address or error, it can return
ERR_PTR(e.g.,-ENOMEM), and the callsite useIS_ERR()to determine whether there was an error or address returned. This makes code much simpler instead of passing address values back by reference.
Quoted 1 line
Quoted 1 line
I disagree. I don't see why the alternative you suggest makes the code "much simpler".
because it eliminates the need for the extra pass-by-reference argument struct fsl_mc_io **new_mc_io.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 152
Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +8
-0+void fsl_destroy_mc_io (struct fsl_mc_io *mc_io) +{ +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC )) +return ; + +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_io->portal_phys_addr, + mc_io->portal_size, mc_io->portal_virt_addr);
unmap_mc_portalalready checks forvirt_addr, this is another example where the code goes too far checking for NULL.
Quoted 1 line
Quoted 1 line
I disagree. Having the extra check is harmless and more importantly makes the intent explicit that we should only call
unmap_mc_portalif we calledmap_mc_portalearlier.
the code is doing this:
if (mc_io->portal_virt_addr != NULL) {
if (WARN_ON(mc_portal_virt_addr == NULL))
return;which is redundant and therefore makes it unnecessarily complicated, after all, a stack trace will occur if mc_portal_virt_addr is referenced anyway, making the WARN_ON clause redundant, too.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 159
Quoted 6 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +6
-0+ mc_io->portal_virt_addr =NULL ; + } + + mc_io->magic =0x0 ; +kfree (mc_io); +}
btw, what's the point of zeroing out things that are being freed?
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/fsl_dpmng.h line 53
Quoted 5 lines
include/linux/fsl_dpmng.h new file +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
include/linux/fsl_dprc.h line 788
Quoted 13 lines
include/linux/fsl_dprc.h new file +13
-0+/** +* @brief Disconnects one endpoint to remove its network link +* +* @param[in] mc_io Pointer to opaque I/O object +* @param[in] dprc_handle Handle to the DPRC object +* @param[in] endpoint Endpoint configuration parameters. +* +* @returns '0' on Success; Error code otherwise. +* */ +int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.
Quoted 4 lines
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone and not make any change here.Do you see any other source files in Linux using doxygen comments? Mixing different documentation styles can easily become a big mess, because you can't generate external documentation consistently for the whole tree.
Thanks Alex,
Kim
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 39 lines · Kim Phillips
Quoted 36 lines · On Thu, 18 Sep 2014 15:14:03 +0200 Alexander Graf <[email protected]> wrote:
Quoted 36 lines
Am 18.09.2014 um 06:17 schrieb German Rivera <[email protected]>:
Quoted 34 lines · Kim Phillips
Quoted 29 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.c create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.h
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
the fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?This is a convention that we decided early on '-' for directory names and '_' for file names.
based on what?
I agree with Kim here.
Quoted 18 lines
Quoted 12 lines
Quoted 10 lines
Quoted 8 lines
include/linux/fsl_dpmng.h line 53
Quoted 5 lines
include/linux/fsl_dpmng.h new file +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
This comment is not precise enough be actionable.
What exactly you want to be changed here?Quoted 6 lines
I think the easy thing to do is to convert the exact version check into a ranged version check: have minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 3 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
Also keep in mind that in the future we may need to support multiple versions that behave differently.
-Scott
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Kim PhillipsQuoted 49 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Thursday, September 18, 2014 3:23 PM
To: Alexander Graf
Cc: Rivera Jose-B46482; <[email protected]>; <[email protected]>; <[email protected]>; Yoder Stuart-B08248; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 36 lines · On Thu, 18 Sep 2014 15:14:03 +0200 Alexander Graf <[email protected]> wrote:
Quoted 36 lines
Am 18.09.2014 um 06:17 schrieb German Rivera <[email protected]>:
Quoted 34 lines · Kim Phillips
Quoted 29 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.c create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.h
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
the fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?This is a convention that we decided early on '-' for directory names and '_' for file names.
based on what?
We looked at how generally files were named in kernel source.
For what it's worth in my 3.16 branch:
$ find drivers/ -type f | grep '-' | wc -l 4308 $ find drivers/ -type f | grep '_' | wc -l 6507
...it seems that there are far more files named with underscores. If Greg or Arnd wants the files renamed, fine, but other than that I see no reason to change this.
Stuart
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 61 lines · On Thu, 2014-09-18 at 18:13 -0500, Yoder Stuart-B08248 wrote:
Quoted 48 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Thursday, September 18, 2014 3:23 PM
To: Alexander Graf
Cc: Rivera Jose-B46482; <[email protected]>; <[email protected]>; <[email protected]>; Yoder Stuart-B08248; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 36 lines · On Thu, 18 Sep 2014 15:14:03 +0200 Alexander Graf <[email protected]> wrote:
Quoted 36 lines
Am 18.09.2014 um 06:17 schrieb German Rivera <[email protected]>:
Quoted 34 lines · Kim Phillips
Quoted 29 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.c create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.hQuoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
the fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?This is a convention that we decided early on '-' for directory names and '_' for file names.
based on what?
We looked at how generally files were named in kernel source.
For what it's worth in my 3.16 branch:
Quoted 8 lines
$ find drivers/ -type f | grep '-' | wc -l 4308 $ find drivers/ -type f | grep '_' | wc -l 6507...it seems that there are far more files named with underscores. If Greg or Arnd wants the files renamed, fine, but other than that I see no reason to change this.
60% isn't "far more". Regardless of whether we change this (dashes are easier to read, easier to type, and are what English normally uses -- underscores are for when you can't use a dash for technical reasons), let's not start making rules based on weak statistical inferences.
Plus, why limit the search to drivers? E.g. if you looked at arch/ you'd reach the opposite conclusion.
-Scott
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 82 lines
-----Original Message-----
From: Wood Scott-B07421
Sent: Thursday, September 18, 2014 6:29 PM
To: Yoder Stuart-B08248
Cc: Phillips Kim-R1AAHA; Alexander Graf; Rivera Jose-B46482; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 6 lines · On Thu, 2014-09-18 at 18:13 -0500, Yoder Stuart-B08248 wrote:
Quoted 6 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Thursday, September 18, 2014 3:23 PM
To: Alexander Graf
Cc: Rivera Jose-B46482; <[email protected]>; <[email protected]>; <[email protected]>;Yoder
Quoted 55 lines
Quoted 42 lines
Stuart-B08248; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 36 lines · On Thu, 18 Sep 2014 15:14:03 +0200 Alexander Graf <[email protected]> wrote:
Quoted 36 lines
Am 18.09.2014 um 06:17 schrieb German Rivera <[email protected]>:
Quoted 34 lines · Kim Phillips
Quoted 29 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.c create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.hQuoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
the fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?This is a convention that we decided early on '-' for directory names and '_' for file names.
based on what?
We looked at how generally files were named in kernel source.
For what it's worth in my 3.16 branch:
Quoted 8 lines
$ find drivers/ -type f | grep '-' | wc -l 4308 $ find drivers/ -type f | grep '_' | wc -l 6507...it seems that there are far more files named with underscores. If Greg or Arnd wants the files renamed, fine, but other than that I see no reason to change this.
Quoted 6 lines
60% isn't "far more". Regardless of whether we change this (dashes are easier to read, easier to type, and are what English normally uses -- underscores are for when you can't use a dash for technical reasons), let's not start making rules based on weak statistical inferences.
Plus, why limit the search to drivers?
It's a driver and we looked at the precedent/conventions used by other drivers.
Quoted 2 lines
E.g. if you looked at
arch/
you'd reach the opposite conclusion.
I guess if you look at the kernel as a whole it's almost exactly 50/50. So, don't understand how anyone can say it is _clear_ that underscores are better.
Stuart ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Kim PhillipsQuoted 30 lines · Kim Phillips
On Thu, 18 Sep 2014 15:14:03 +0200
Quoted 28 lines
Quoted 28 lines
unnecessarily complicated error path, plus a simpler
Quoted 26 lines
implementation can be made if fn can return the mapped address, like so:
static void
__iomem*map_mc_portal(phys_addr_tmc_portal_phys_addr,
uint32_tmc_portal_size){ struct resource *res; void __iomem *mapped_addr; res = request_mem_region(mc_portal_phys_addr, mc_portal_size, "mc_portal"); if (!res) return NULL; mapped_addr = ioremap_nocache(mc_portal_phys_addr, mc_portal_size); if (!mapped_addr) release_mem_region(mc_portal_phys_addr, mc_portal_size); return mapped_addr; }the callsite can return
-ENOMEMto its caller if returned NULL. This can be improved even further ifdevm_functions are used: this is just an example of how to simplify the code using early returns instead of goto error.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
I disagree. Having a common error return point is more maintainable than having multiple returns as having the clean-up logic in one place is more maintainable and makes the min path (non-error) more readable.
my comment is not that much different from Joe's here:
https://lkml.org/lkml/2014/9/17/381
but hopefully all this will change with a
devm_based implementation.
I will refactor this function to use devm_ functions, to simplify the error cleanup logic as you suggested, but still keep the current signature of the function, as I don't think it is a good practice
to just return NULL in case of error, hiding the actual cause of the error. Also, mixing returning a valid pointer and an error encoded as an invalid pointer is not clean and can be error-prone for callers, if some caller just checks for NULL instead of using IS_ERR() ir IS_ERR_OR_NULL().
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 16 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +16
-0+int __must_check fsl_create_mc_io (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +uint32_t flags,struct fsl_mc_io **new_mc_io) +{ +int error = -EINVAL ; +struct fsl_mc_io *mc_io =NULL ; + + mc_io =kzalloc (sizeof (*mc_io),GFP_KERNEL ); +if (mc_io ==NULL ) { + error = -ENOMEM ; +pr_err ("No memory to allocate mc_io\n" ); + goto error; + } + + mc_io->magic =FSL_MC_IO_MAGIC ; + mc_io->flags = flags;drivers/bus/fsl-mc/fsl_mc_sys.c line 129
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +10
-0+ mc_io->portal_phys_addr = mc_portal_phys_addr; + mc_io->portal_size = mc_portal_size; +spin_lock_init (&mc_io->spinlock); + error =map_mc_portal (mc_portal_phys_addr, + mc_portal_size, &mc_io->portal_virt_addr); +if (error <0 ) + goto error; + + *new_mc_io = mc_io; +return 0 ;if a fn only returns an address or error, it can return
ERR_PTR(e.g.,-ENOMEM), and the callsite useIS_ERR()to determine whether there was an error or address returned. This makes code much simpler instead of passing address values back by reference.
Quoted 5 lines
Quoted 1 line
Quoted 1 line
I disagree. I don't see why the alternative you suggest makes the code "much simpler".
because it eliminates the need for the extra pass-by-reference argument struct
fsl_mc_io**new_mc_io.
Having an extra pass-by-reference argument does not make the code that complicated. Bit more importantly the simplicity that you gain by not using the extra pass-by-reference pointer comes at the price of making the interface less safer to use (more error-prone for the caller as I mentioned above), which I think it is a bad trade off.
Quoted 15 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 152
Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +8
-0+void fsl_destroy_mc_io (struct fsl_mc_io *mc_io) +{ +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC )) +return ; + +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_io->portal_phys_addr, + mc_io->portal_size, mc_io->portal_virt_addr);
unmap_mc_portalalready checks forvirt_addr, this is another example where the code goes too far checking for NULL.Quoted 1 line
Quoted 1 line
I disagree. Having the extra check is harmless and more importantly makes the intent explicit that we should only call
unmap_mc_portalif we calledmap_mc_portalearlier.the code is doing this:
Quoted 8 lines
if (mc_io->portal_virt_addr != NULL) { if (WARN_ON(mc_portal_virt_addr == NULL)) return;which is redundant and therefore makes it unnecessarily complicated, after all, a stack trace will occur if
mc_portal_virt_addris referenced anyway, making theWARN_ONclause redundant, too.
All this will be gone with the refactoring to use devm_ APIs.
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 159
Quoted 6 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +6
-0+ mc_io->portal_virt_addr =NULL ; + } + + mc_io->magic =0x0 ; +kfree (mc_io); +}btw, what's the point of zeroing out things that are being freed?
In this particular case, this comment doe snot apply anymore, as the magic filed will be removed.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
include/linux/fsl_dpmng.h line 53
Quoted 5 lines
include/linux/fsl_dpmng.h new file +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 39 lines · On Thu, 18 Sep 2014 22:05:03 -0500 German Rivera <[email protected]>…
Quoted 30 lines · Kim Phillips
On Thu, 18 Sep 2014 15:14:03 +0200
Quoted 28 lines
Quoted 28 lines
unnecessarily complicated error path, plus a simpler
Quoted 26 lines
implementation can be made if fn can return the mapped address, like so:
static void
__iomem*map_mc_portal(phys_addr_tmc_portal_phys_addr,
uint32_tmc_portal_size){ struct resource *res; void __iomem *mapped_addr; res = request_mem_region(mc_portal_phys_addr, mc_portal_size, "mc_portal"); if (!res) return NULL; mapped_addr = ioremap_nocache(mc_portal_phys_addr, mc_portal_size); if (!mapped_addr) release_mem_region(mc_portal_phys_addr, mc_portal_size); return mapped_addr; }the callsite can return
-ENOMEMto its caller if returned NULL. This can be improved even further ifdevm_functions are used: this is just an example of how to simplify the code using early returns instead of goto error.Quoted 8 lines
Quoted 1 line
Quoted 1 line
I disagree. Having a common error return point is more maintainable than having multiple returns as having the clean-up logic in one place is more maintainable and makes the min path (non-error) more readable.
my comment is not that much different from Joe's here:
https://lkml.org/lkml/2014/9/17/381
but hopefully all this will change with a
devm_based implementation.
Quoted 8 lines
I will refactor this function to use
devm_functions, to simplify the error cleanup logic as you suggested, but still keep the current signature of the function, as I don't think it is a good practice to just return NULL in case of error, hiding the actual cause of the error. Also, mixing returning a valid pointer and an error encoded as an invalid pointer is not clean and can be error-prone for callers, if some caller just checks for NULL instead of usingIS_ERR()irIS_ERR_OR_NULL().
we'll make sure callers don't do that then :)
Quoted 19 lines
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 152
Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +8
-0+void fsl_destroy_mc_io (struct fsl_mc_io *mc_io) +{ +if (WARN_ON (mc_io->magic !=FSL_MC_IO_MAGIC )) +return ; + +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_io->portal_phys_addr, + mc_io->portal_size, mc_io->portal_virt_addr);
unmap_mc_portalalready checks forvirt_addr, this is another example where the code goes too far checking for NULL.Quoted 1 line
Quoted 1 line
I disagree. Having the extra check is harmless and more importantly makes the intent explicit that we should only call
unmap_mc_portalif we calledmap_mc_portalearlier.the code is doing this:
if (mc_io->portal_virt_addr != NULL) { if (WARN_ON(mc_portal_virt_addr == NULL)) return;
Quoted 5 lines
Quoted 4 lines
which is redundant and therefore makes it unnecessarily complicated, after all, a stack trace will occur if
mc_portal_virt_addris referenced anyway, making theWARN_ONclause redundant, too.All this will be gone with the refactoring to use
devm_APIs.
sounds good.
Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 159
Quoted 6 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +6
-0+ mc_io->portal_virt_addr =NULL ; + } + + mc_io->magic =0x0 ; +kfree (mc_io); +}btw, what's the point of zeroing out things that are being freed?
In this particular case, this comment doe snot apply anymore, as the magic filed will be removed.
it still applies for portal_virt_addr.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 8 lines
include/linux/fsl_dpmng.h line 53
Quoted 5 lines
include/linux/fsl_dpmng.h new file +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
This comment is not precise enough be actionable.
What exactly you want to be changed here?
Quoted 7 lines
Quoted 6 lines
Quoted 1 line
I think the easy thing to do is to convert the exact version check into a ranged version check: have minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
Kim
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * @brief Management Complex firmware version information + */ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have
minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
You're right, in the future if there are future major versions we would want this same driver to function on multiple versions of the hardware. But at this point in time we don't know what future evolutions there will be and we
need the check to error out for now. The driver will have to be changed
in the future to dynamically deal with different versions.
We could add a TODO in the driver to note that.
Stuart
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 22 lines · On Fri, 19 Sep 2014 14:06:32 -0500 Yoder Stuart-B08248…
Quoted 22 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * @brief Management Complex firmware version information + */ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have
minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 6 lines
Quoted 5 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
Quoted 7 lines
Quoted 2 lines
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
You're right, in the future if there are future major versions we would want this same driver to function on multiple versions of the hardware. But at this point in time we don't know what future evolutions there will be and we need the check to error out for now.
why? We have to make the standard assumption that newer versions will be backward compatible, in which case the driver should be left to run.
Quoted 4 lines
The driver will have to be changed
in the future to dynamically deal with different versions.We could add a TODO in the driver to note that.
"TODO: add support for new h/w versions" is almost universally true for all drivers, we don't need to write that down.
Support for new h/w versions with new features should be incrementally added once they're known.
Kim
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 28 lines · Kim Phillips
Quoted 25 lines · On Fri, 19 Sep 2014 14:06:32 -0500 Yoder Stuart-B08248…
Quoted 24 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * @brief Management Complex firmware version information + */ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have
minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 6 lines
Quoted 5 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
Quoted 8 lines
Quoted 4 lines
You're right, in the future if there are future major versions we would want this same driver to function on multiple versions of the hardware. But at this point in time we don't know what future evolutions there will be and we need the check to error out for now.
why? We have to make the standard assumption that newer versions will be backward compatible, in which case the driver should be left to run.
How much is the interface set in stone? Can we indicate to the MC that we want version x of the protocol? Then the MC can tell us whether it's compatible or not.
Quoted 11 lines
Quoted 5 lines
The driver will have to be changed
in the future to dynamically deal with different versions.We could add a TODO in the driver to note that.
"TODO: add support for new h/w versions" is almost universally true for all drivers, we don't need to write that down.
Support for new h/w versions with new features should be incrementally added once they're known.
The "version id" is basically the equivalent of the pci device id. We don't add wildcards there either for unknown pieces of hardware, so limiting to driver to "known good" devices is sane IMHO.
Alex
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 35 lines · Alexander Graf
Quoted 33 lines · Kim Phillips
Quoted 29 lines · On Fri, 19 Sep 2014 14:06:32 -0500 Yoder Stuart-B08248…
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * @brief Management Complex firmware version information + */ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have
minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
You're right, in the future if there are future major versions we would want this same driver to function on multiple versions of the hardware. But at this point in time we don't know what future evolutions there will be and we need the check to error out for now.
Quoted 7 lines
Quoted 3 lines
why? We have to make the standard assumption that newer versions will be backward compatible, in which case the driver should be left to run.
How much is the interface set in stone? Can we indicate to the MC that we want version x of the protocol? Then the MC can tell us whether it's compatible or not.
I don't trust that new versions will be 100% backwards compatible (though I hope they will be), but do we normally bother making a driver refuse to run on newer versions? Sure, if we need to explicitly match a comptible string or PCI ID, the match will be rejected if the driver doesn't know about it, but if it's a version in a register we usually only check for known issues with certain versions.
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
The driver will have to be changed
in the future to dynamically deal with different versions.We could add a TODO in the driver to note that.
"TODO: add support for new h/w versions" is almost universally true for all drivers, we don't need to write that down.
Quoted 6 lines
Quoted 2 lines
Support for new h/w versions with new features should be incrementally added once they're known.
The "version id" is basically the equivalent of the pci device id. We don't add wildcards there either for unknown pieces of hardware, so limiting to driver to "known good" devices is sane IMHO.
How would you go about adding a wildcard to a PCI ID even if you wanted to? Version information on PCI is not separate from device identification.
-Scott
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 44 lines · Scott Wood
Quoted 35 lines · Alexander Graf
Quoted 33 lines · Kim Phillips
Quoted 29 lines · On Fri, 19 Sep 2014 14:06:32 -0500 Yoder Stuart-B08248…
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * @brief Management Complex firmware version information + */ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have
minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
You're right, in the future if there are future major versions we would want this same driver to function on multiple versions of the hardware. But at this point in time we don't know what future evolutions there will be and we need the check to error out for now.
Quoted 7 lines
Quoted 3 lines
why? We have to make the standard assumption that newer versions will be backward compatible, in which case the driver should be left to run.
How much is the interface set in stone? Can we indicate to the MC that we want version x of the protocol? Then the MC can tell us whether it's compatible or not.
Quoted 6 lines
I don't trust that new versions will be 100% backwards compatible (though I hope they will be), but do we normally bother making a driver refuse to run on newer versions? Sure, if we need to explicitly match a comptible string or PCI ID, the match will be rejected if the driver doesn't know about it, but if it's a version in a register we usually only check for known issues with certain versions.
If the major number is defined as "this interface is incompatible", it really is on the same lines as a PCI ID or a new compatible string, no?
So IMHO having a version check on the major version is reasonable as a sanity check.
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
The driver will have to be changed
in the future to dynamically deal with different versions.We could add a TODO in the driver to note that.
"TODO: add support for new h/w versions" is almost universally true for all drivers, we don't need to write that down.
Support for new h/w versions with new features should be incrementally added once they're known.
Quoted 7 lines
Quoted 3 lines
The "version id" is basically the equivalent of the pci device id. We don't add wildcards there either for unknown pieces of hardware, so limiting to driver to "known good" devices is sane IMHO.
How would you go about adding a wildcard to a PCI ID even if you wanted to? Version information on PCI is not separate from device identification.
Yup. Hence you can't expect a new version of e1000 to work with an old driver for example - it will have a new PCI ID. So on most hardware, we do have major version checks through that interface. If you want, the "revision" config space field in PCI could be the equivalent of a minor version number here - drivers still match because the device ID itself still matches.
The alternative to the approach taken here would be to have an "mc bridge device" that gets proper device tree compatible versioning. Overall the matching and compatibility decision would then lie in the device tree.
Speaking of which, how does Linux find this new bus? I couldn't find anything that describes the device tree bindings, but maybe I just missed them.
Alex
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 3 lines
Speaking of which, how does Linux find this new bus? I couldn't find anything that describes the device tree bindings, but maybe I just missed them.
There is a separate thread on the ARM mailing list with the device tree and binding (device tree will be in arch/arm64):
http://www.spinics.net/lists/arm-kernel/msg354635.html
Stuart ���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Alexander GrafQuoted 46 lines
-----Original Message-----
From: Alexander Graf [mailto:[email protected]]
Sent: Friday, September 19, 2014 3:33 PM
To: Phillips Kim-R1AAHA; Yoder Stuart-B08248
Cc: Rivera Jose-B46482; <[email protected]>; <[email protected]>; <[email protected]>; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 33 lines · Kim Phillips
Quoted 29 lines · On Fri, 19 Sep 2014 14:06:32 -0500 Yoder Stuart-B08248…
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * @brief Management Complex firmware version information + */ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have
minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
You're right, in the future if there are future major versions we would want this same driver to function on multiple versions of the hardware. But at this point in time we don't know what future evolutions there will be and we need the check to error out for now.
Quoted 5 lines
Quoted 3 lines
why? We have to make the standard assumption that newer versions will be backward compatible, in which case the driver should be left to run.
How much is the interface set in stone?
It is set in stone, in that a particular version has an specific set of commands.
Quoted 3 lines
Can we indicate to the MC that
we want version x of the protocol? Then the MC can tell us whether it's compatible or not.
No, it's not that clever. For the DPRC object there is a set of commands with a binary interface. The major/minor version number tell us what version of the hw object we are dealing with...what commands are there, what version of the binary interface is there.
Stuart
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Kim PhillipsQuoted 38 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Friday, September 19, 2014 3:25 PM
To: Yoder Stuart-B08248
Cc: Rivera Jose-B46482; Alexander Graf; <[email protected]>; <[email protected]>; <linux- [email protected]>; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 25 lines · On Fri, 19 Sep 2014 14:06:32 -0500 Yoder Stuart-B08248…
Quoted 24 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+/** + * @brief Management Complex firmware version information + */ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have
minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
Quoted 6 lines
Quoted 5 lines
yes, this was my point: elsewhere I noticed the code denies to run iff those defines are not matched exactly: that code should change to run as Alex describes.
As I mentioned in the reply to Alex, I will remove the minor version check.
the code should be able to run on all subsequent versions of the h/w, even in the major version case.
Quoted 8 lines
Quoted 4 lines
You're right, in the future if there are future major versions we would want this same driver to function on multiple versions of the hardware. But at this point in time we don't know what future evolutions there will be and we need the check to error out for now.
why? We have to make the standard assumption that newer versions will be backward compatible, in which case the driver should be left to run.
If future changes are backward compatible then only the minor version changes. That is the explicit definition of the meaning of major/minor version for this device.
If the major number changes, then it is not backward compatible and will require driver changes. So this "error out" check is temporary until we reach that future point, where it can be removed and we can hopefully implement dynamic handling of the incompatibility.
Stuart
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Alexander Graf+/**
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
include/linux/fsl_dprc.h line 788
Quoted 12 lines
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */include/linux/fsl_dprc.h new file +4
-0+int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.
Quoted 5 lines
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone and not makeany change here.
Do you see any other source files in Linux using doxygen comments?
Yes. Grep around a bit and you'll see examples of it. I grep'ed for some doxygen tags and found close to 200 source files with them.
Quoted 2 lines
Mixing different documentation styles can
easily become a big mess, because you can't generate external documentation consistently for the whole tree.
As German mentioned elsewhere, this file is an interface to a hardware block, was written by another team targetting a wide variety of environments-- u-boot, Linux, user space, other OSes etc.
We left the doxygen stuff there because while admitedly not used much, there are other examples of it in the kernel and the documentation seems useful. If it can't go into the kernel as is, we can just delete it.
If doxygen is not allowed, it would be nice to see checkpatch updated to complain.
Thanks,
Stuart
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Alexander GrafQuoted 48 lines · Alexander Graf
Quoted 48 lines
Quoted 26 lines
Quoted 26 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +23
-0+int __must_check fsl_create_mc_io (phys_addr_t mc_portal_phys_addr, +uint32_t mc_portal_size, +uint32_t flags,struct fsl_mc_io **new_mc_io) +{ +int error = -EINVAL ; +struct fsl_mc_io *mc_io =NULL ; + + mc_io =kzalloc (sizeof (*mc_io),GFP_KERNEL ); +if (mc_io ==NULL ) { + error = -ENOMEM ; +pr_err ("No memory to allocate mc_io\n" ); + goto error; + } + + mc_io->magic =FSL_MC_IO_MAGIC ; + mc_io->flags = flags; + mc_io->portal_phys_addr = mc_portal_phys_addr; + mc_io->portal_size = mc_portal_size; +spin_lock_init (&mc_io->spinlock); + error =map_mc_portal (mc_portal_phys_addr, + mc_portal_size, &mc_io->portal_virt_addr); +if (error <0 ) + goto error;Quoted 8 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 129
Quoted 3 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +3
-0+ + *new_mc_io = mc_io; +return 0 ;if a fn only returns an address or error, it can return
ERR_PTR(e.g.,-ENOMEM), and the callsite useIS_ERR()to determine whether there was an error or address returned. This makes code much simpler instead of passing address values back by reference.I disagree. I don't see why the alternative you suggest makes the code "much simpler".
Quoted 12 lines
drivers/bus/fsl-mc/fsl_mc_sys.c line 138
Quoted 9 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +9
-0+error: +if (mc_io !=NULL ) { +if (mc_io->portal_virt_addr !=NULL ) { +unmap_mc_portal (mc_portal_phys_addr, + mc_portal_size, + mc_io->portal_virt_addr); + } + +kfree (mc_io);kfree can handle being passed NULL, but again, might want to consider using
devm_functions instead.
Quoted 4 lines
Quoted 1 line
No. We cannot use
devm_functions here as there is no device passed in.Is it a good idea to lose your device context in any function? Whenever I dropped contexts in helper I usually ended up regretting it later ;).
OK, I will add a dev param to this the fsl_mc_io_create() function, to enable the use of devm_ APIs.
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
Quoted 17 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +17
-0+if (mc_io->flags &FSL_MC_IO_PORTAL_SHARED ) { +spin_lock_irqsave (&mc_io->spinlock, irqsave_flags); + lock_acquired = true; + } + +mc_write_command (mc_io->portal_virt_addr, cmd); + +for (;;) { + status =mc_read_response (mc_io->portal_virt_addr, cmd); +if (status !=MC_CMD_STATUS_READY ) +break ; + +/* +* TODO: When MC command completion interrupts are supported +* call wait function here instead of udelay() +*/ +udelay (MC_CMD_COMPLETION_POLLING_INTERVAL );drivers/bus/fsl-mc/fsl_mc_sys.c line 233
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_sys.c new file +10
-0+if (time_after_eq (jiffies, jiffies_until_timeout)) { + error = -ETIMEDOUT ; + goto out; + } + } + + error =mc_status_to_error (status); +out: +if (lock_acquired) +spin_unlock_irqrestore (&mc_io->spinlock, irqsave_flags);so if the portal is shared, we take a lock, disable interrupts, and then potentially udelay for a whopping 500usec, then check to see if
_100_usechave passed, and thus _always_ issue a timeout error, even if the device took < 100usec to consume the command???
Quoted 4 lines
Quoted 1 line
That is not true. The 100 is in jiffies not in usec:
If you always wait for 100 jiffies, the timeout code suddenly depends on the HZ value which is kernel configuration, no? Wouldn't it be better to base the timeout on real wall time?
I will change the value of the timeout to be a function of HZ instead of a hard-coded jiffies value. Also, to avoid future confusion, I'll rename the timeout and delay macros to include their units:
/**
* Timeout in jiffies to wait for the completion of an MC command */
#define MC_CMD_COMPLETION_TIMEOUT_JIFFIES (HZ / 2) /* 500 ms */
/**
* Delay in microseconds between polling iterations while
* waiting for MC command completion
*/
#define MC_CMD_COMPLETION_POLLING_INTERVAL_USECS 500 /* 0.5 ms */
Quoted 36 lines
Quoted 36 lines
/**
* Timeout in jiffies to wait for the completion of an MC command */
#defineMC_CMD_COMPLETION_TIMEOUT100/**
* Delay in microseconds between polling iterations while
* waiting for MC command completion
*/
#defineMC_CMD_COMPLETION_POLLING_INTERVAL500Quoted 5 lines
Not to mention this code will spin perpetually with IRQs disabled if the
read_responsenever returns ready. I also don't see a reason why IRQs are being disabled in the first place - it's not being used in an IRQ handler...perhaps we need to wait until command completion IRQs are supported :)I agree that disabling interrupts while doing polling is not efficient. I was assuming the worst case scenario of sharing the portal: both
threads and interrupt handlers accessing the same portal at the same time. If only threads access the same portal, we don't need to disable interrupts and even further we can use a mutex instead of a spinlock. If only interrupt handlers access a given portal (from multiple CPUs)
we have use a spinlock but we don't need to disabel interrupts.
If both threads and interrupt handlers access a given portal, then
we need to both use a spinlock and disable interruptsI will change synchronization logic in the v2 respin to avoid disabling interrupts in the first two cases above.
Quoted 8 lines
include/linux/fsl_dpmng.h line 53
Quoted 5 lines
include/linux/fsl_dpmng.h new file +5
-0+/** +* @brief Management Complex firmware version information +*/ +#define MC_VER_MAJOR 2 +#define MC_VER_MINOR 0code should be adjusted to run on all *compatible* versions of h/w, not strictly the one set in these defines.
Quoted 5 lines
Quoted 2 lines
This comment is not precise enough be actionable.
What exactly you want to be changed here?I think the easy thing to do is to convert the exact version check into a ranged version check: have minimum and maximum versions you support. Or a list of exact versions you support. Or not check for the version at all - or only for the major version and guarantee that the major version indicates backwards compatibility.
I will keep only the major version check and remove the minor version check.
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines
include/linux/fsl_dprc.h new file +3
-0+/** +* @brief Disconnects one endpoint to remove its network link +* include/linux/fsl_dprc.h line 788
Quoted 10 lines
include/linux/fsl_dprc.h new file +10
-0+* @param[in] mc_io Pointer to opaque I/O object +* @param[in] dprc_handle Handle to the DPRC object +* @param[in] endpoint Endpoint configuration parameters. +* +* @returns '0' on Success; Error code otherwise. +* */ +int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.
Quoted 6 lines
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone and not make any change here.Do you see any other source files in Linux using doxygen comments? Mixing different documentation styles can easily become a big mess, because you can't generate external documentation consistently for the whole tree.
Stuart already answered this question.
Quoted 2 lines
Alex
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Alexander GrafQuoted 41 lines
-----Original Message-----
From: Yoder Stuart-B08248
Sent: Thursday, September 18, 2014 7:19 PM
To: 'Alexander Graf'; Rivera Jose-B46482
Cc: Phillips Kim-R1AAHA; <[email protected]>; <[email protected]>; <[email protected]>; Wood Scott-B07421; <[email protected]>
Subject: RE: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIs+/**
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
include/linux/fsl_dprc.h line 788
Quoted 12 lines
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */include/linux/fsl_dprc.h new file +4
-0+int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.Quoted 2 lines
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone and notmake
Quoted 3 lines
any change here.
Do you see any other source files in Linux using doxygen comments?
Yes. Grep around a bit and you'll see examples of it. I grep'ed for some doxygen tags and found close to 200 source files with them.
Quoted 2 lines
Mixing different documentation styles can
easily become a big mess, because you can't generate external documentation consistently for the wholetree.
Quoted 7 lines
As German mentioned elsewhere, this file is an interface to a hardware block, was written by another team targetting a wide variety of environments-- u-boot, Linux, user space, other OSes etc.
We left the doxygen stuff there because while admitedly not used much, there are other examples of it in the kernel and the documentation seems useful. If it can't go into the kernel as is, we can just delete it.
...to be clear, we could just delete the doyxen tags. There is no scenario where I would envision anyone generating documentation from these files in the kernel. The tags are there because of where we grabbed the source from. It certainly would benefit no one by conversion to kerneldoc.
However, just leaving the comments and doxygen tags alone as is would be nice.
Stuart
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 22 lines · On Fri, 19 Sep 2014 13:25:06 -0500 Yoder Stuart-B08248…
Quoted 22 lines
From: Yoder Stuart-B08248
Sent: Thursday, September 18, 2014 7:19 PM+/**
Quoted 18 lines
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */Quoted 8 lines
include/linux/fsl_dprc.h line 788
Quoted 4 lines
include/linux/fsl_dprc.h new file +4
-0+int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone and not
Quoted 7 lines
Quoted 7 lines
make
Quoted 3 lines
any change here.
Do you see any other source files in Linux using doxygen comments?
Yes. Grep around a bit and you'll see examples of it. I grep'ed for some doxygen tags and found close to 200 source files with them.
grepping for the one in this patch above - "! @}" - returns nothing.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Mixing different documentation styles can
easily become a big mess, because you can't generate external documentation consistently for the wholetree.
As German mentioned elsewhere, this file is an interface to a hardware block, was written by another team targetting a wide variety of environments-- u-boot, Linux, user space, other OSes etc.
Quoted 8 lines
Quoted 3 lines
We left the doxygen stuff there because while admitedly not used much, there are other examples of it in the kernel and the documentation seems useful. If it can't go into the kernel as is, we can just delete it.
...to be clear, we could just delete the doyxen tags. There is no scenario where I would envision anyone generating documentation from these files in the kernel. The tags are there because of where we grabbed the source from. It certainly would benefit no one by conversion to kerneldoc.
except kerneldoc users :)
Quoted 1 line
However, just leaving the comments and doxygen tags alone as is would be nice.
they are incompatible with kerneldoc.
Kim
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 63 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Friday, September 19, 2014 3:58 PM
To: Yoder Stuart-B08248
Cc: Alexander Graf; Rivera Jose-B46482; Phillips Kim-R1AAHA; <[email protected]>; <[email protected]>; <[email protected]>; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 20 lines · On Fri, 19 Sep 2014 13:25:06 -0500 Yoder Stuart-B08248…
Quoted 20 lines
From: Yoder Stuart-B08248
Sent: Thursday, September 18, 2014 7:19 PM+/**
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
include/linux/fsl_dprc.h line 788
Quoted 12 lines
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */include/linux/fsl_dprc.h new file +4
-0+int dprc_disconnect (struct fsl_mc_io *mc_io,uint16_t dprc_handle, +struct dprc_endpoint *endpoint); + +/*! @} */ this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone andnot
Quoted 7 lines
Quoted 7 lines
make
Quoted 3 lines
any change here.
Do you see any other source files in Linux using doxygen comments?
Yes. Grep around a bit and you'll see examples of it. I grep'ed for some doxygen tags and found close to 200 source files with them.
grepping for the one in this patch above - "! @}" - returns nothing.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Mixing different documentation styles can
easily become a big mess, because you can't generate external documentation consistently for the wholetree.
As German mentioned elsewhere, this file is an interface to a hardware block, was written by another team targetting a wide variety of environments-- u-boot, Linux, user space, other OSes etc.
Quoted 8 lines
Quoted 3 lines
We left the doxygen stuff there because while admitedly not used much, there are other examples of it in the kernel and the documentation seems useful. If it can't go into the kernel as is, we can just delete it.
...to be clear, we could just delete the doyxen tags. There is no scenario where I would envision anyone generating documentation from these files in the kernel. The tags are there because of where we grabbed the source from. It certainly would benefit no one by conversion to kerneldoc.
Quoted 5 lines
except kerneldoc users :)
Quoted 1 line
However, just leaving the comments and doxygen tags alone as is would be nice.
they are incompatible with kerneldoc.
Seriously, no one is going to ever generate docs from this obscure bit of code documenting an internal interface within this driver. Makes no sense to convert the comments to kerneldoc.
I completely get what you are saying with respect to comments actually documenting kernel interfaces used by different kernel components or uapi interfaces.
The doxygen tags are there because this code originated in a different project. That code was intended to be Linux-style compliant and complies with checkpatch --strict. However, we can sanitize the code and remove the tags if they are causing grief. It's too bad though, because we'll have to fork this interface code from its origin.
Stuart
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 73 lines · Stuart Yoder
Quoted 63 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Friday, September 19, 2014 3:58 PM
To: Yoder Stuart-B08248
Cc: Alexander Graf; Rivera Jose-B46482; Phillips Kim-R1AAHA; <[email protected]>; <[email protected]>; <[email protected]>; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 20 lines · On Fri, 19 Sep 2014 13:25:06 -0500 Yoder Stuart-B08248…
Quoted 20 lines
From: Yoder Stuart-B08248
Sent: Thursday, September 18, 2014 7:19 PM+/**
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Review
Quoted 12 lines
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */(quoted diff) +4
-0+int dprc_disconnect(struct fsl_mc_io *mc_io, uint16_t dprc_handle, + struct dprc_endpoint *endpoint); + +/*! @} */this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments alone andnot
Quoted 7 lines
Quoted 7 lines
make
Quoted 3 lines
any change here.
Do you see any other source files in Linux using doxygen comments?
Yes. Grep around a bit and you'll see examples of it. I grep'ed for some doxygen tags and found close to 200 source files with them.
grepping for the one in this patch above - "! @}" - returns nothing.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Mixing different documentation styles can
easily become a big mess, because you can't generate external documentation consistently for the wholetree.
As German mentioned elsewhere, this file is an interface to a hardware block, was written by another team targetting a wide variety of environments-- u-boot, Linux, user space, other OSes etc.
Quoted 8 lines
Quoted 3 lines
We left the doxygen stuff there because while admitedly not used much, there are other examples of it in the kernel and the documentation seems useful. If it can't go into the kernel as is, we can just delete it.
...to be clear, we could just delete the doyxen tags. There is no scenario where I would envision anyone generating documentation from these files in the kernel. The tags are there because of where we grabbed the source from. It certainly would benefit no one by conversion to kerneldoc.
Quoted 5 lines
except kerneldoc users :)
Quoted 1 line
However, just leaving the comments and doxygen tags alone as is would be nice.
they are incompatible with kerneldoc.
Seriously, no one is going to ever generate docs from this obscure bit of code documenting an internal interface within this driver. Makes no sense to convert the comments to kerneldoc.
Quoted 7 lines
I completely get what you are saying with respect to comments actually documenting kernel interfaces used by different kernel components or uapi interfaces.
The doxygen tags are there because this code originated in a different project. That code was intended to be Linux-style compliant and complies with checkpatch --strict. However, we can sanitize the code and remove the tags if they are causing grief. It's too bad though, because we'll have to fork this interface code from its origin.
You "forked" the code when you asked for it be merged into the kernel tree. You shouldn't ever have to rely on the "old" version again, so please, remove the doxygen mess.
greg k-h
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 90 lines
-----Original Message-----
From: <[email protected]> [mailto:[email protected]]
Sent: Monday, September 22, 2014 9:58 AM
To: Yoder Stuart-B08248
Cc: Phillips Kim-R1AAHA; Alexander Graf; Rivera Jose-B46482; <[email protected]>; <[email protected]>; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 7 lines · Stuart Yoder
Quoted 7 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Friday, September 19, 2014 3:58 PM
To: Yoder Stuart-B08248
Cc: Alexander Graf; Rivera Jose-B46482; Phillips Kim-R1AAHA; <[email protected]>;Quoted 26 lines
Quoted 26 lines
<[email protected]>; Wood Scott-B07421; <[email protected]>
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 20 lines · On Fri, 19 Sep 2014 13:25:06 -0500 Yoder Stuart-B08248…
Quoted 20 lines
From: Yoder Stuart-B08248
Sent: Thursday, September 18, 2014 7:19 PM+/**
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Review
Quoted 12 lines
+ * @brief Disconnects one endpoint to remove its network link
+ *
+ * @param[in]mc_ioPointer to opaque I/O object
+ * @param[in]dprc_handleHandle to the DPRC object
+ * @param[in] endpoint Endpoint configuration parameters.
+ *
+ * @returns '0' on Success; Error code otherwise.
+ * */(quoted diff) +4
-0+int dprc_disconnect(struct fsl_mc_io *mc_io, uint16_t dprc_handle, + struct dprc_endpoint *endpoint); + +/*! @} */this entire file is riddled with non-kernel-doc comment markers: see
Documentation/kernel-doc-nano-HOWTO.txton how to write function and other types of comments in a kernel-doc compliant format.Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
This is because this file is using doxygen comments, as it was developed
by another team. Unless someone else has an objection, I will leave the doxygen comments aloneand
Quoted 6 lines
Quoted 6 lines
not
Quoted 5 lines
Quoted 5 lines
make
Quoted 3 lines
any change here.
Do you see any other source files in Linux using doxygen comments?
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Yes. Grep around a bit and you'll see examples of it. I grep'ed for some doxygen tags and found close to 200 source files with them.
grepping for the one in this patch above - "! @}" - returns nothing.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Mixing different documentation styles can
easily become a big mess, because you can't generate external documentation consistently for thewhole
Quoted 28 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
tree.
As German mentioned elsewhere, this file is an interface to a hardware block, was written by another team targetting a wide variety of environments-- u-boot, Linux, user space, other OSes etc.
Quoted 8 lines
Quoted 3 lines
We left the doxygen stuff there because while admitedly not used much, there are other examples of it in the kernel and the documentation seems useful. If it can't go into the kernel as is, we can just delete it.
...to be clear, we could just delete the doyxen tags. There is no scenario where I would envision anyone generating documentation from these files in the kernel. The tags are there because of where we grabbed the source from. It certainly would benefit no one by conversion to kerneldoc.
Quoted 5 lines
except kerneldoc users :)
Quoted 1 line
However, just leaving the comments and doxygen tags alone as is would be nice.
they are incompatible with kerneldoc.
Seriously, no one is going to ever generate docs from this obscure bit of code documenting an internal interface within this driver. Makes no sense to convert the comments to kerneldoc.
I completely get what you are saying with respect to comments actually documenting kernel interfaces used by different kernel components or uapi interfaces.
Quoted 8 lines
Quoted 4 lines
The doxygen tags are there because this code originated in a different project. That code was intended to be Linux-style compliant and complies with checkpatch --strict. However, we can sanitize the code and remove the tags if they are causing grief. It's too bad though, because we'll have to fork this interface code from its origin.
You "forked" the code when you asked for it be merged into the kernel tree. You shouldn't ever have to rely on the "old" version again, so please, remove the doxygen mess.
Will do.
Stuart
RE: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
In reply to Kim PhillipsQuoted 48 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Monday, September 15, 2014 6:45 PM
To: Rivera Jose-B46482
Cc: [email protected]; [email protected]; [email protected]; Yoder Stuart-B08248; Phillips Kim-R1AAHA; Wood Scott-B07421; [email protected]; [email protected]
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 21 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.cQuoted 8 lines
create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.hthe fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?
Quoted 4 lines
Also, any reason why these and future include files aren't being put in
include/linux/fsl/, so as to not pollute the top levelinclude/linux/? That way, we can also remove the fsl- prefix from those filenames, too..
There is nothing in include/linux/fsl except 1 driver from 2 years ago. Why is that?
I'd also prefer to see these headers is include/linux/fsl, but given that the directory is essentially unused it seemed that include/linux was more conventional.
Quoted 29 lines
Quoted 16 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0@@ -0,0 +1,93 @@ +/* Copyright 2013-2014 Freescale Semiconductor Inc. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of Freescale Semiconductor nor the drivers/bus/fsl-mc/dpmng.c line 20
Quoted 10 lines
drivers/bus/fsl-mc/dpmng.c new file +10
-0+* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* +* ALTERNATIVELY, this software may be distributed under the terms of the +* GNU General Public License ("GPL") as published by the Free Software +* Foundation, either version 2 of that License or (at your option) any +* later version. +* +* THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY interesting, normally this text reads:
Quoted 5 lines
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS"
...does that mean we're excluding non-Freescale copyright holders and contributors from this warranty statement? That doesn't seem appropriate for an upstream kernel submission.
This is a standard license dual license used by Freescale, wording most likely set by the legal dept.
There are many instances of it in the kernel (mostly in device trees).
git grep 'THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor' | wc -l 180
Unless it is condition of being accepted into the kernel I want to leave it as is.
Stuart
Re: [PATCH 1/4] drivers/bus: Added Freescale Management Complex APIs
Quoted 52 lines · On Thu, 2014-09-18 at 18:39 -0500, Yoder Stuart-B08248 wrote:
Quoted 47 lines
-----Original Message-----
From: Kim Phillips [mailto:[email protected]]
Sent: Monday, September 15, 2014 6:45 PM
To: Rivera Jose-B46482
Cc: [email protected]; [email protected]; [email protected]; Yoder Stuart-B08248; Phillips Kim-R1AAHA; Wood Scott-B07421; [email protected]; [email protected]
Subject: Re: [PATCH 1/4]drivers/bus: Added Freescale Management Complex APIsQuoted 21 lines · On Thu, 11 Sep 2014 12:34:21 -0500 "J. German Rivera"…
From: "J. German Rivera" <[email protected]>
APIs to access the Management Complex (MC) hardware module of Freescale LS2 SoCs. This patch includes APIs to check the MC firmware version and to manipulate DPRC objects in the MC.
Signed-off-by J. German Rivera <[email protected]>Signed-off-by Stuart Yoder <[email protected]>--- drivers/bus/fsl-mc/dpmng.c | 93 +++++ drivers/bus/fsl-mc/dprc.c | 504 +++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_dpmng_cmd.h | 83 ++++ drivers/bus/fsl-mc/fsl_dprc_cmd.h | 545 +++++++++++++++++++++++++ drivers/bus/fsl-mc/fsl_mc_sys.c | 237 +++++++++++ include/linux/fsl_dpmng.h | 120 ++++++ include/linux/fsl_dprc.h | 790 ++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_cmd.h | 182 +++++++++ include/linux/fsl_mc_sys.h | 81 ++++ 9 files changed, 2635 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpmng.cQuoted 8 lines
create mode 100644 drivers/bus/fsl-mc/dprc.c create mode 100644 drivers/bus/fsl-mc/fsl_dpmng_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_dprc_cmd.h create mode 100644 drivers/bus/fsl-mc/fsl_mc_sys.c create mode 100644 include/linux/fsl_dpmng.h create mode 100644 include/linux/fsl_dprc.h create mode 100644 include/linux/fsl_mc_cmd.h create mode 100644 include/linux/fsl_mc_sys.hthe fsl prefix in the filename
fsl_dpmng_cmd.his redundant with its directory name fsl-mc/. Note that I find dashes ('-') in filenames make them easier to type: is there a reason we're using underscores here?Quoted 4 lines
Also, any reason why these and future include files aren't being put in
include/linux/fsl/, so as to not pollute the top levelinclude/linux/? That way, we can also remove the fsl- prefix from those filenames, too..
Quoted 6 lines
There is nothing in
include/linux/fslexcept 1 driver from 2 years ago. Why is that?I'd also prefer to see these headers is
include/linux/fsl, but given that the directory is essentially unused it seemed thatinclude/linuxwas more conventional.
I thought I saw some other patch dump some more things in there recently -- maybe LS1 stuff?
-Scott
PATCH 2/4 drivers/bus: Freescale Management Complex (fsl-mc) bus driver
In reply to J. German RiveraFrom: "J. German Rivera" <[email protected]>
Platform device driver that sets up the basic bus infrastructure for the fsl-mc bus type, including support for adding/removing fsl-mc devices, register/unregister of fsl-mc drivers, and bus match support to bind devices to drivers.
---
Changes in RFC v4:
- Added back the dma_mask field to struct fsl_mc_device as it is needed by some MC child device drivers. However, the default DMA mask now does not have the 32-bit limitation of the original patch series (v1).
Changes in RFC v3:
- Removed per-bus list of children, and instead use device_for_each_child()
- Use the same structure (struct fsl_mc_device) to represent both bus devices and their children.
Changes in RFC v2:
- Removed fsl_mc_bus structure and global variable
- Removed the 'magic' fields from all structs
- Removed NULL initializers
- Replaced all occurrences of EXPORT_SYMBOL() with EXPORT_SYMBOL_GPL()
- Removed function dprc_parse_dt_node(), and replaced its call by a direct call to of_address_to_resource()
- Removed struct fsl_mc_device_region and use standard 'struct resource' instead.
- Removed dma_mask field from 'struct fsl_mc_device' as it is not currently being used.
- Removed redundant 'driver' field from struct fsl_mc_device
- Removed the container field. We can get the parent DPRC of a given dev, from its dev.parent field.
drivers/bus/Kconfig | 3 + drivers/bus/Makefile | 3 + drivers/bus/fsl-mc/Kconfig | 13 + drivers/bus/fsl-mc/Makefile | 14 + drivers/bus/fsl-mc/fsl_mc_bus.c | 602 +++++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc.h | 137 +++++++++ include/linux/fsl_mc_private.h | 33 +++ 7 files changed, 805 insertions(+) create mode 100644 drivers/bus/fsl-mc/Kconfig create mode 100644 drivers/bus/fsl-mc/Makefile create mode 100644 drivers/bus/fsl-mc/fsl_mc_bus.c create mode 100644 include/linux/fsl_mc.h create mode 100644 include/linux/fsl_mc_private.h
drivers/bus/Kconfig +3 -0
@@ -67,4 +67,7 @@ config VEXPRESS_CONFIG help Platform configuration infrastructure for the ARM Ltd. Versatile Express. + +source "drivers/bus/fsl-mc/Kconfig" + endmenu
drivers/bus/Makefile +3 -0
@@ -15,3 +15,6 @@ obj-$(CONFIG_ARM_CCI) += arm-cci.o obj-$(CONFIG_ARM_CCN) += arm-ccn.o obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress-config.o + +# Freescale Management Complex (MC) bus drivers +obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
drivers/bus/fsl-mc/Kconfig new file +13 -0
@@ -0,0 +1,13 @@ +# +# Freescale Management Complex (MC) bus drivers +# +# Copyright (C) 2014 Freescale Semiconductor, Inc. +# +# This file is released under the GPLv2 +# + +config FSL_MC_BUS + tristate "Freescale Management Complex (MC) bus driver" + help + Driver to enable the bus infrastructure for the Freescale + QorIQ Management Complex.
drivers/bus/fsl-mc/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +# +# Freescale Management Complex (MC) bus drivers +# +# Copyright (C) 2014 Freescale Semiconductor, Inc. +# +# This file is released under the GPLv2 +# +obj-$(CONFIG_FSL_MC_BUS) += fsl_mc_bus_driver.o + +fsl_mc_bus_driver-objs := fsl_mc_bus.o \ + fsl_mc_sys.o \ + dprc.o \ + dpmng.o +
drivers/bus/fsl-mc/fsl_mc_bus.c new file +602 -0
602 lines not on this page · raw message
include/linux/fsl_mc.h new file +137 -0
137 lines not on this page · raw message
include/linux/fsl_mc_private.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Freescale Management Complex (MC) bus private declarations +* +* Copyright (C) 2014 Freescale Semiconductor, Inc. +* Author: German Rivera <[email protected]> +* +* This file is licensed under the terms of the GNU General Public +* License version 2. This program is licensed "as is" without any +* warranty of any kind, whether express or implied. +*/ +#ifndef _FSL_MC_PRIVATE_H_ +#define _FSL_MC_PRIVATE_H_ + +#include <linux/fsl_mc.h> +#include <linux/mutex.h> +#include <linux/stringify.h> + +#define FSL_MC_DEVICE_MATCH (_mc_dev, _obj_desc) \ + (strcmp((_mc_dev)->obj_desc.type, (_obj_desc)->type) == 0 && \ + (_mc_dev)->obj_desc.id == (_obj_desc)->id) + +#define FSL_MC_IS_ALLOCATABLE (_obj_type) \ + (strcmp(_obj_type, "dpbp") == 0 || \ + strcmp(_obj_type, "dpcon") == 0) + +int __must_check fsl_mc_device_add (struct dprc_obj_desc *obj_desc, +struct fsl_mc_io *mc_io, +struct device *parent_dev, +struct fsl_mc_device **new_mc_dev); + +void fsl_mc_device_remove (struct fsl_mc_device *mc_dev); + +#endif /* _FSL_MC_PRIVATE_H_ */
--
1.7.9.7
Re: [PATCH 2/4] drivers/bus: Freescale Management Complex (fsl-mc) bus driver
Quoted 6 lines · J. German Rivera
From: "J. German Rivera" <[email protected]>
Platform device driver that sets up the basic bus infrastructure for the fsl-mc bus type, including support for adding/removing fsl-mc devices, register/unregister of fsl-mc drivers, and bus match support to bind devices to drivers.
[]
drivers/bus/fsl-mc/fsl_mc_bus.c
Quoted 1 line
drivers/bus/fsl-mc/fsl_mc_bus.c +0
-0
[]
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_bus.c +4
-0+/** +* fsl_mc_bus_match - device to driver matching callback +* @dev: the MC object device structure to match against +* @drv: the device driver to search for matching MC object device id
drivers/bus/fsl-mc/fsl_mc_bus.c line 38
Quoted 10 lines
drivers/bus/fsl-mc/fsl_mc_bus.c +10
-0+* structures +* +* Returns 1 on success, 0 otherwise. +*/ +static int fsl_mc_bus_match (struct device *dev,struct device_driver *drv) +{ +const struct fsl_mc_device_match_id *id; +struct fsl_mc_device *mc_dev =to_fsl_mc_device (dev); +struct fsl_mc_driver *mc_drv =to_fsl_mc_driver (drv); +bool found = false;
[]
drivers/bus/fsl-mc/fsl_mc_bus.c line 67
Quoted 3 lines
drivers/bus/fsl-mc/fsl_mc_bus.c +3
-0+out: +pr_debug ("%s: %s %s\n" , __func__,dev_name (dev), + found ?"matched" :"not matched" );
Thia should probably use dev_dbg
dev_dbg(dev, "%smatched\n", found ? "" : "not ");
and let the dynamic debug mechanism emit the
function name if desired.
Re: [PATCH 2/4] drivers/bus: Freescale Management Complex (fsl-mc) bus driver
Quoted 7 lines · Joe Perches
drivers/bus/fsl-mc/fsl_mc_bus.c line 67
Quoted 4 lines
drivers/bus/fsl-mc/fsl_mc_bus.c new file +3
-0+out: +pr_debug ("%s: %s %s\n" , __func__,dev_name (dev), + found ?"matched" :"not matched" );Thia should probably use
dev_dbg
Quoted 6 lines
dev_dbg(dev, "%smatched\n", found ? "" : "not ");and let the dynamic debug mechanism emit the
function name if desired.
Ok, I'll make this change in the v2 respin
PATCH 3/4 drivers/bus: Device driver for FSL-MC DPRC devices
In reply to J. German RiveraFrom: "J. German Rivera" <[email protected]>
A DPRC (Data Path Resource Container) is an isolation device that contains a set of DPAA networking devices to be assigned to an isolation domain (e.g., a virtual machine).
---
Changes in RFC v4:
- Fixed parameter mismatch for device_find_child() call in fsl_mc_dprc.c
Changes in RFC v3:
- Removed per-bus list of children, and instead use device_for_each_child()
- Use the same structure (struct fsl_mc_device) to represent both bus devices and their children.
Changes in RFC v2:
- Removed the 'magic' fields from all structs
drivers/bus/fsl-mc/Makefile | 3 +- drivers/bus/fsl-mc/fsl_mc_dprc.c | 396 ++++++++++++++++++++++++++++++++++++++ include/linux/fsl_mc_private.h | 6 + 3 files changed, 404 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/fsl-mc/fsl_mc_dprc.c
drivers/bus/fsl-mc/Makefile +2 -1
@@ -5,7 +5,8 @@ # # This file is released under the GPLv2 # -obj-$(CONFIG_FSL_MC_BUS) += fsl_mc_bus_driver.o +obj-$(CONFIG_FSL_MC_BUS) += fsl_mc_bus_driver.o \ + fsl_mc_dprc.o fsl_mc_bus_driver-objs := fsl_mc_bus.o \ fsl_mc_sys.o \
drivers/bus/fsl-mc/fsl_mc_dprc.c new file +396 -0
396 lines not on this page · raw message
include/linux/fsl_mc_private.h +6 -0
@@ -15,6 +15,8 @@#include <linux/mutex.h> #include <linux/stringify.h> +#define FSL_MC_DPRC_DRIVER_NAME "fsl_mc_dprc" +#define FSL_MC_DEVICE_MATCH (_mc_dev, _obj_desc) \ (strcmp((_mc_dev)->obj_desc.type, (_obj_desc)->type) == 0 && \ (_mc_dev)->obj_desc.id == (_obj_desc)->id)
@@ -30,4 +32,8 @@ int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc,void fsl_mc_device_remove (struct fsl_mc_device *mc_dev); +int __must_check dprc_scan_container (struct fsl_mc_device *mc_bus_dev); + +int __must_check dprc_scan_objects (struct fsl_mc_device *mc_bus_dev); +#endif /* _FSL_MC_PRIVATE_H_ */
--
1.7.9.7
PATCH 4/4 Update MAINTAINERS file
In reply to J. German RiveraFrom: "J. German Rivera" <[email protected]>
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -3841,6 +3841,14 @@ S: Maintained F: sound/soc/fsl/fsl* F: sound/soc/fsl/mpc8610_hpcd.c +FREESCALE QORIQ MANAGEMENT COMPLEX DRIVER +M: J. German Rivera <[email protected]> +L: [email protected] +S: Maintained +F: include/linux/fsl_mc* +F: include/linux/fsl_dp* +F: drivers/bus/fsl-mc/* + FREEVXFS FILESYSTEM M: Christoph Hellwig <[email protected]> W: ftp://ftp.openlinux.org/pub/people/hch/vxfs
Signature · 1 line
1.7.9.7
Quoted 2 lines · On Thu, 11 Sep 2014 12:34:20 -0500 "J. German Rivera"…
This patch series introduces Linux support for the Freescale Management Complex (fsl-mc) hardware.
here are the results of using some tools to check this patchseries:
make C=1 CF="-D__CHECK_ENDIAN__":
drivers/bus/fsl-mc/fsl_mc_sys.c:235:9: warning: context imbalance in 'mc_send_command' - different lock contexts for basic block drivers/bus/fsl-mc/fsl_mc_dprc.c: In function 'dprc_add_new_devices':drivers/bus/fsl-mc/fsl_mc_dprc.c:173:6: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint32_t' [-Wformat=]
region_desc.size);
^When built as a module (CONFIG_FSL_MC_BUS=m):
ERROR: ".dprc_get_obj" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_get_obj_count" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_close" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_open" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_get_obj_region" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined! make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
checkpatch:
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
WARNING: DT compatible string "fsl,qoriq-mc" appears un-documented -- check ./Documentation/devicetree/bindings/ #690: FILE: drivers/bus/fsl-mc/fsl_mc_bus.c:528:
+ {.compatible = "fsl,qoriq-mc",},
For the former warning, I'd suggest moving patch 4/4's contents up in the series.
For the latter warning, googling for the property shows an upstream effort, so it might be ok, but it'd be nice to provide a cross-reference to the status of the latest post, to make it easier for reviewer consumption.
Also, I think you'd get more recipient coverage by using scripts/get_maintainer.pl.
Thanks,
Kim
Quoted 8 lines · Kim Phillips
Quoted 2 lines · On Thu, 11 Sep 2014 12:34:20 -0500 "J. German Rivera"…
This patch series introduces Linux support for the Freescale Management Complex (fsl-mc) hardware.
here are the results of using some tools to check this patchseries:
Quoted 8 lines
make C=1 CF="-D__CHECK_ENDIAN__":
drivers/bus/fsl-mc/fsl_mc_sys.c:235:9: warning: context imbalance in 'mc_send_command' - different lock contexts for basic blockdrivers/bus/fsl-mc/fsl_mc_dprc.c: In function 'dprc_add_new_devices':drivers/bus/fsl-mc/fsl_mc_dprc.c:173:6: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint32_t' [-Wformat=]region_desc.size); ^
I'll fix this in v2 respin.
Quoted 10 lines
When built as a module (
CONFIG_FSL_MC_BUS=m):ERROR: ".dprc_get_obj" [
drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_get_obj_count" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_close" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_open" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_get_obj_region" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined! make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2
I'll fix this in v2 respin.
Quoted 11 lines
checkpatch:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?WARNING: DT compatible string "fsl,qoriq-mc" appears un-documented -- check
./Documentation/devicetree/bindings/#690: FILE:drivers/bus/fsl-mc/fsl_mc_bus.c:528:(quoted diff) +1
-0+ {.compatible = "fsl,qoriq-mc",},For the former warning, I'd suggest moving patch 4/4's contents up in the series.
I tried moving 4/4 to be 1/4 but still get the the same warning from checkpatch. So, this suggestion does not work. Besides, I took a look at other commits that update the MAINTAINERS such as563da3a90364fc29cd09bed034162592e591747a, and that commit comes after the commits that added the new files.
Quoted 12 lines
For the latter warning, googling for the property shows an upstream effort, so it might be ok, but it'd be nice to provide a cross-reference to the status of the latest post, to make it easier for reviewer consumption.
Also, I think you'd get more recipient coverage by using
scripts/get_maintainer.pl.Thanks,
Kim
Quoted 41 lines
Am 18.09.2014 um 02:20 schrieb German Rivera <[email protected]>:
Quoted 9 lines · Kim Phillips
Quoted 2 lines · On Thu, 11 Sep 2014 12:34:20 -0500 "J. German Rivera"…
This patch series introduces Linux support for the Freescale Management Complex (fsl-mc) hardware.
here are the results of using some tools to check this patchseries:
Quoted 7 lines
make C=1 CF="-D__CHECK_ENDIAN__":
drivers/bus/fsl-mc/fsl_mc_sys.c:235:9: warning: context imbalance in 'mc_send_command' - different lock contexts for basic blockdrivers/bus/fsl-mc/fsl_mc_dprc.c: In function 'dprc_add_new_devices':drivers/bus/fsl-mc/fsl_mc_dprc.c:173:6: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'uint32_t' [-Wformat=]region_desc.size); ^I'll fix this in v2 respin.
Quoted 9 lines
When built as a module (
CONFIG_FSL_MC_BUS=m):ERROR: ".dprc_get_obj" [
drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_get_obj_count" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_close" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_open" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined!
ERROR: ".dprc_get_obj_region" [drivers/bus/fsl-mc/fsl_mc_dprc.ko] undefined! make[1]: *** [__modpost] Error 1
make: *** [modules] Error 2I'll fix this in v2 respin.
Quoted 8 lines
checkpatch:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?WARNING: DT compatible string "fsl,qoriq-mc" appears un-documented -- check
./Documentation/devicetree/bindings/#690: FILE:drivers/bus/fsl-mc/fsl_mc_bus.c:528:
+ {.compatible = "fsl,qoriq-mc",},
Quoted 5 lines
Quoted 2 lines
For the former warning, I'd suggest moving patch 4/4's contents up in the series.
I tried moving 4/4 to be 1/4 but still get the the same warning from checkpatch. So, this suggestion does not work. Besides, I took a look at other commits that update the
MAINTAINERSsuch as563da3a90364fc29cd09bed034162592e591747a, and that commit comes after the commits that added the new files.
The alternative would be to add MAINTAINERS entries for the files you add in the patch that adds the files.
Alex
Quoted 9 lines · Alexander Graf
Quoted 9 lines
Quoted 9 lines
checkpatch:
WARNING: added, moved or deleted file(s), does
MAINTAINERSneed updating?WARNING: DT compatible string "fsl,qoriq-mc" appears un-documented -- check
./Documentation/devicetree/bindings/#690: FILE:drivers/bus/fsl-mc/fsl_mc_bus.c:528:
+ {.compatible = "fsl,qoriq-mc",},
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
For the former warning, I'd suggest moving patch 4/4's contents up in the series.
I tried moving 4/4 to be 1/4 but still get the the same warning from checkpatch. So, this suggestion does not work. Besides, I took a look at other commits that update the
MAINTAINERSsuch as563da3a90364fc29cd09bed034162592e591747a, and that commit comes after the commits that added the new files.The alternative would be to add
MAINTAINERSentries for the files you add in the patch that adds the files.
I tried this but still get the checpatch warning:
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
Still, I will add MAINTAINERS entries in each patch that adds files, instead of having a separate patch just for that.
Quoted 3 lines
Alex