RE: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER Allocator

2010-07-27 Thread Hiremath, Vaibhav
> -Original Message-
> From: Sin, David
> Sent: Saturday, July 24, 2010 4:52 AM
> To: linux-arm-ker...@lists.arm.linux.org.uk; linux-omap@vger.kernel.org;
> Tony Lindgren; Russell King
> Cc: Kanigeri, Hari; Ohad Ben-Cohen; Hiremath, Vaibhav; Shilimkar, Santosh;
> Ramachandra, Ravikiran; Molnar, Lajos; Sin, David
> Subject: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER
> Allocator
>
> From: Ravi Ramachandra 
>
> This patch implements a simple TILER Container Manager.
>
> Signed-off-by: Ravi Ramachandra 
> Signed-off-by: Lajos Molnar 
> Signed-off-by: David Sin 
> ---
>  drivers/media/video/tiler/tcm/Makefile|1 +
>  drivers/media/video/tiler/tcm/_tcm-sita.h |   64 
>  drivers/media/video/tiler/tcm/tcm-sita.c  |  459
> +
>  drivers/media/video/tiler/tcm/tcm-sita.h  |   37 +++
>  4 files changed, 561 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/tiler/tcm/Makefile
>  create mode 100644 drivers/media/video/tiler/tcm/_tcm-sita.h
>  create mode 100644 drivers/media/video/tiler/tcm/tcm-sita.c
>  create mode 100644 drivers/media/video/tiler/tcm/tcm-sita.h
>
> diff --git a/drivers/media/video/tiler/tcm/Makefile
> b/drivers/media/video/tiler/tcm/Makefile
> new file mode 100644
> index 000..8434607
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_TI_TILER) += tcm-sita.o
> diff --git a/drivers/media/video/tiler/tcm/_tcm-sita.h
> b/drivers/media/video/tiler/tcm/_tcm-sita.h
> new file mode 100644
> index 000..4ede1ab
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/_tcm-sita.h
> @@ -0,0 +1,64 @@
> +/*
> + * _tcm_sita.h
> + *
> + * SImple Tiler Allocator (SiTA) private structures.
> + *
> + * Author: Ravi Ramachandra 
> + *
> + * Copyright (C) 2009-2010 Texas Instruments, Inc.
> + *
> + * This package is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
> + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
> + */
> +
> +#ifndef _TCM_SITA_H
> +#define _TCM_SITA_H
> +
> +#include "../tcm.h"
> +
> +/* length between two coordinates */
> +#define LEN(a, b) ((a) > (b) ? (a) - (b) + 1 : (b) - (a) + 1)
> +
> +enum criteria {
> + CR_MAX_NEIGHS   = 0x01,
> + CR_FIRST_FOUND  = 0x10,
> + CR_BIAS_HORIZONTAL  = 0x20,
> + CR_BIAS_VERTICAL= 0x40,
> + CR_DIAGONAL_BALANCE = 0x80
> +};
> +
> +/* nearness to the beginning of the search field from 0 to 1000 */
> +struct nearness_factor {
> + s32 x;
> + s32 y;
> +};
> +
> +/*
> + * Statistics on immediately neighboring slots.  Edge is the number of
> + * border segments that are also border segments of the scan field.  Busy
> + * refers to the number of neighbors that are occupied.
> + */
> +struct neighbor_stats {
> + u16 edge;
> + u16 busy;
> +};
> +
> +/* structure to keep the score of a potential allocation */
> +struct score {
> + struct nearness_factor  f;
> + struct neighbor_stats   n;
> + struct tcm_area a;
> + u16neighs;  /* number of busy neighbors */
> +};
> +
> +struct sita_pvt {
> + struct mutex mtx;
> + struct tcm_area ***map; /* pointers to the parent area for each slot
> */
> +};
> +
> +#endif
> diff --git a/drivers/media/video/tiler/tcm/tcm-sita.c
> b/drivers/media/video/tiler/tcm/tcm-sita.c
> new file mode 100644
> index 000..93be3e6
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/tcm-sita.c
> @@ -0,0 +1,459 @@
> +/*
> + * tcm-sita.c
> + *
> + * SImple Tiler Allocator (SiTA): 2D and 1D allocation(reservation)
> algorithm
> + *
> + * Authors: Ravi Ramachandra ,
> + *  Lajos Molnar 
> + *
> + * Copyright (C) 2009-2010 Texas Instruments, Inc.
> + *
> + * This package is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
> + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
> + *
> + */
> +#include 
> +
> +#include "_tcm-sita.h"
> +#include "tcm-sita.h"
> +
> +#define TCM_ALG_NAME "tcm_sita"
[Hiremath, Vaibhav] Move this after include statement.

> +#include "tcm-utils.h"
> +
> +#define ALIGN_DOWN(value, align) ((value) & ~((align) - 1))
> +
> +/* Individual selection criteria for different scan areas */
> +static s32 CR_L2R_T2B = CR_BIAS_HORIZONTAL;
> +
[Hiremath, Vaibhav] Not good practice to define variable in caps.
Also why do we need this variable which is not getting modified and used as 
constant only?

> +/**

RE: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER Allocator

2010-07-26 Thread Sin, David
Comments acknowledged.  Adding in media lists also.

-David

-Original Message-
From: Shilimkar, Santosh
Sent: Saturday, July 24, 2010 2:13 AM
To: Sin, David; linux-arm-ker...@lists.arm.linux.org.uk; 
linux-omap@vger.kernel.org; Tony Lindgren; Russell King
Cc: Kanigeri, Hari; Ohad Ben-Cohen; Hiremath, Vaibhav; Ramachandra, Ravikiran; 
Molnar, Lajos
Subject: RE: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER 
Allocator

> -Original Message-
> From: Sin, David
> Sent: Saturday, July 24, 2010 4:52 AM
> To: linux-arm-ker...@lists.arm.linux.org.uk; linux-omap@vger.kernel.org;
> Tony Lindgren; Russell King
> Cc: Kanigeri, Hari; Ohad Ben-Cohen; Hiremath, Vaibhav; Shilimkar, Santosh;
> Ramachandra, Ravikiran; Molnar, Lajos; Sin, David
> Subject: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER
> Allocator
>
> From: Ravi Ramachandra 
>
> This patch implements a simple TILER Container Manager.
>
> Signed-off-by: Ravi Ramachandra 
> Signed-off-by: Lajos Molnar 
> Signed-off-by: David Sin 
> ---
>  drivers/media/video/tiler/tcm/Makefile|1 +
>  drivers/media/video/tiler/tcm/_tcm-sita.h |   64 
Why is such a header file name. Can't you club
>  drivers/media/video/tiler/tcm/tcm-sita.c  |  459
> +
>  drivers/media/video/tiler/tcm/tcm-sita.h  |   37 +++
You should club _tcm-sita.h and tcm-sita.h together
>  4 files changed, 561 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/tiler/tcm/Makefile
>  create mode 100644 drivers/media/video/tiler/tcm/_tcm-sita.h
>  create mode 100644 drivers/media/video/tiler/tcm/tcm-sita.c
>  create mode 100644 drivers/media/video/tiler/tcm/tcm-sita.h
>
> diff --git a/drivers/media/video/tiler/tcm/Makefile
> b/drivers/media/video/tiler/tcm/Makefile
> new file mode 100644
> index 000..8434607
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_TI_TILER) += tcm-sita.o
> diff --git a/drivers/media/video/tiler/tcm/_tcm-sita.h
> b/drivers/media/video/tiler/tcm/_tcm-sita.h
> new file mode 100644
> index 000..4ede1ab
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/_tcm-sita.h
> @@ -0,0 +1,64 @@
> +/*
> + * _tcm_sita.h
> + *
> + * SImple Tiler Allocator (SiTA) private structures.
> + *
> + * Author: Ravi Ramachandra 
> + *
> + * Copyright (C) 2009-2010 Texas Instruments, Inc.
> + *
> + * This package is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
> + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
> + */
> +
> +#ifndef _TCM_SITA_H
> +#define _TCM_SITA_H
> +
> +#include "../tcm.h"
Header inclusion
> +
> +/* length between two coordinates */
> +#define LEN(a, b) ((a) > (b) ? (a) - (b) + 1 : (b) - (a) + 1)
> +
> +enum criteria {
> + CR_MAX_NEIGHS   = 0x01,
> + CR_FIRST_FOUND  = 0x10,
> + CR_BIAS_HORIZONTAL  = 0x20,
> + CR_BIAS_VERTICAL= 0x40,
> + CR_DIAGONAL_BALANCE = 0x80
> +};
> +
> +/* nearness to the beginning of the search field from 0 to 1000 */
> +struct nearness_factor {
> + s32 x;
> + s32 y;
> +};
> +
> +/*
> + * Statistics on immediately neighboring slots.  Edge is the number of
> + * border segments that are also border segments of the scan field.  Busy
> + * refers to the number of neighbors that are occupied.
> + */
> +struct neighbor_stats {
> + u16 edge;
> + u16 busy;
> +};
> +
> +/* structure to keep the score of a potential allocation */
> +struct score {
> + struct nearness_factor  f;
> + struct neighbor_stats   n;
> + struct tcm_area a;
> + u16neighs;  /* number of busy neighbors */
> +};
> +
> +struct sita_pvt {
> + struct mutex mtx;
> + struct tcm_area ***map; /* pointers to the parent area for each slot
> */
> +};
> +
> +#endif
> diff --git a/drivers/media/video/tiler/tcm/tcm-sita.c
> b/drivers/media/video/tiler/tcm/tcm-sita.c
> new file mode 100644
> index 000..93be3e6
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/tcm-sita.c
> @@ -0,0 +1,459 @@
> +/*
> + * tcm-sita.c
> + *
> + * SImple Tiler Allocator (SiTA): 2D and 1D allocation(reservation)
> algorithm
> + *
> + * Authors: Ravi Ramachandra ,
> + *  Lajos Molnar 
> + *
> + * Copyright (C) 2009-2010 Texas Instruments, Inc.
> + *
&g

RE: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER Allocator

2010-07-25 Thread Molnar, Lajos


> -Original Message-
> From: Shilimkar, Santosh
> Sent: Saturday, July 24, 2010 2:13 AM
> > +   kfree(tcm);
> > +   kfree(pvt);
> If only one of the allocation was successful, then you
> are freeing a NULL pointer.
> May be have something like this
> 
>   tcm = kzalloc(sizeof(*tcm), GFP_KERNEL);
>   if (!tcm)
>   goto error1;
>   pvt = kzalloc(sizeof(*pvt), GFP_KERNEL);
>   if (!pvt)
>   goto error2;
>   .
>   .
>   .
> error1:
>   kfree(tcm);
> error2:
>   kfree(pvt);

Freeing a NULL pointer is always valid, and simply returns.  This is a C 
specification.

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER Allocator

2010-07-24 Thread Shilimkar, Santosh
> -Original Message-
> From: Sin, David
> Sent: Saturday, July 24, 2010 4:52 AM
> To: linux-arm-ker...@lists.arm.linux.org.uk; linux-omap@vger.kernel.org;
> Tony Lindgren; Russell King
> Cc: Kanigeri, Hari; Ohad Ben-Cohen; Hiremath, Vaibhav; Shilimkar, Santosh;
> Ramachandra, Ravikiran; Molnar, Lajos; Sin, David
> Subject: [RFC 3/8] TILER-DMM: Sample TCM implementation: Simple TILER
> Allocator
>
> From: Ravi Ramachandra 
>
> This patch implements a simple TILER Container Manager.
>
> Signed-off-by: Ravi Ramachandra 
> Signed-off-by: Lajos Molnar 
> Signed-off-by: David Sin 
> ---
>  drivers/media/video/tiler/tcm/Makefile|1 +
>  drivers/media/video/tiler/tcm/_tcm-sita.h |   64 
Why is such a header file name. Can't you club
>  drivers/media/video/tiler/tcm/tcm-sita.c  |  459
> +
>  drivers/media/video/tiler/tcm/tcm-sita.h  |   37 +++
You should club _tcm-sita.h and tcm-sita.h together
>  4 files changed, 561 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/media/video/tiler/tcm/Makefile
>  create mode 100644 drivers/media/video/tiler/tcm/_tcm-sita.h
>  create mode 100644 drivers/media/video/tiler/tcm/tcm-sita.c
>  create mode 100644 drivers/media/video/tiler/tcm/tcm-sita.h
>
> diff --git a/drivers/media/video/tiler/tcm/Makefile
> b/drivers/media/video/tiler/tcm/Makefile
> new file mode 100644
> index 000..8434607
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_TI_TILER) += tcm-sita.o
> diff --git a/drivers/media/video/tiler/tcm/_tcm-sita.h
> b/drivers/media/video/tiler/tcm/_tcm-sita.h
> new file mode 100644
> index 000..4ede1ab
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/_tcm-sita.h
> @@ -0,0 +1,64 @@
> +/*
> + * _tcm_sita.h
> + *
> + * SImple Tiler Allocator (SiTA) private structures.
> + *
> + * Author: Ravi Ramachandra 
> + *
> + * Copyright (C) 2009-2010 Texas Instruments, Inc.
> + *
> + * This package is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
> + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
> + */
> +
> +#ifndef _TCM_SITA_H
> +#define _TCM_SITA_H
> +
> +#include "../tcm.h"
Header inclusion
> +
> +/* length between two coordinates */
> +#define LEN(a, b) ((a) > (b) ? (a) - (b) + 1 : (b) - (a) + 1)
> +
> +enum criteria {
> + CR_MAX_NEIGHS   = 0x01,
> + CR_FIRST_FOUND  = 0x10,
> + CR_BIAS_HORIZONTAL  = 0x20,
> + CR_BIAS_VERTICAL= 0x40,
> + CR_DIAGONAL_BALANCE = 0x80
> +};
> +
> +/* nearness to the beginning of the search field from 0 to 1000 */
> +struct nearness_factor {
> + s32 x;
> + s32 y;
> +};
> +
> +/*
> + * Statistics on immediately neighboring slots.  Edge is the number of
> + * border segments that are also border segments of the scan field.  Busy
> + * refers to the number of neighbors that are occupied.
> + */
> +struct neighbor_stats {
> + u16 edge;
> + u16 busy;
> +};
> +
> +/* structure to keep the score of a potential allocation */
> +struct score {
> + struct nearness_factor  f;
> + struct neighbor_stats   n;
> + struct tcm_area a;
> + u16neighs;  /* number of busy neighbors */
> +};
> +
> +struct sita_pvt {
> + struct mutex mtx;
> + struct tcm_area ***map; /* pointers to the parent area for each slot
> */
> +};
> +
> +#endif
> diff --git a/drivers/media/video/tiler/tcm/tcm-sita.c
> b/drivers/media/video/tiler/tcm/tcm-sita.c
> new file mode 100644
> index 000..93be3e6
> --- /dev/null
> +++ b/drivers/media/video/tiler/tcm/tcm-sita.c
> @@ -0,0 +1,459 @@
> +/*
> + * tcm-sita.c
> + *
> + * SImple Tiler Allocator (SiTA): 2D and 1D allocation(reservation)
> algorithm
> + *
> + * Authors: Ravi Ramachandra ,
> + *  Lajos Molnar 
> + *
> + * Copyright (C) 2009-2010 Texas Instruments, Inc.
> + *
> + * This package is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
> + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
> + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
> + *
> + */
> +#include 
> +
> +#include "_tcm-sita.h"
> +#include "tcm-sita.h"
> +
> +#define TCM_ALG_NAME "tcm_sita"
> +#include "tcm-utils.h"
> +
> +#define ALIGN_DOWN(value, align) ((value) & ~((align) - 1))
> +
> +/* Individual selection criteria for different scan areas */
> +static s32 CR_L2R_T2B = CR_BIAS_HORIZONTAL;
> +
> +/*
> + *   TCM API - Sita Implementation
> + *