public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "Sjur Brændeland" <sjur.brandeland@stericsson.com>
Cc: linux-kernel@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Paul Bolle <pebolle@tiscali.nl>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCHv2 07/10] xshm: XSHM Configuration data handling
Date: Fri, 9 Dec 2011 15:09:40 +0000	[thread overview]
Message-ID: <201112091509.41123.arnd@arndb.de> (raw)
In-Reply-To: <1323439648-22697-8-git-send-email-sjur.brandeland@stericsson.com>

On Friday 09 December 2011, Sjur Brændeland wrote:
> This patch implements the configuration handling:
> - reception of gen-netlink requests from user-space.
> - calculating address of where to put information in shared memory, i.e
>   the offset of: IPC-TOC, channel-descriptors, read/write indexes for each
>   directional channel, and data area of each channel.
> - formatting of the shared memory area, so modem can read out configuration
>   data.
> - Creation of configuration data given to the XSHM drivers: xshm_chr and
>   caif_xshm.

Hmm, from what I read here, you rely on the user to create the channels
that correspond to the ones that the modem side has configured.

Why is that? Can't you query from the modem what channels it needs and
then automatically create those?

> +static bool config_error;
> +static bool commited;
> +static bool registered;
> +static bool addr_set;
> +static u32 modem_bootimg_size;
> +static void *shm_start;
> +static u32 xshm_channels;
> +static struct xshm_dev *xshmdevs[XSHM_MAX_CHANNELS + 1];
> +static struct xshm_ipctoc *ipctoc;

Global variables like this are a bit problematic. What would happen if
you ever get a system that has access to two devices? I think you
can remove most of these easily. Anything that is specific to the xshm
modem should just go into the device private data of the modem.

Do not hold your own list of devices, that's what the generic device
handling is for. You can e.g. use device_for_each_child on the
modem device to iterate the channels.

> +static unsigned long xshm_start;
> +module_param(xshm_start, ulong, S_IRUGO | S_IWUSR);
> +MODULE_PARM_DESC(xshm_start, "Address for memory shared by host/modem.");
> +
> +static unsigned long xshm_c2c_bootaddr;
> +module_param(xshm_c2c_bootaddr, ulong, S_IRUGO | S_IWUSR);
> +MODULE_PARM_DESC(xshm_c2c_bootaddr, "Address given to modem (through GENI register)");
> +
> +static long xshm_size;
> +module_param(xshm_size, long, S_IRUGO | S_IWUSR);
> +MODULE_PARM_DESC(xshm_size, "Size of SHM area");

That looks fragile, you should never have addresses as module arguments.
Either the kernel should be free to pick a reasonable address and tell
it to the modem, or the modem should pick an address and then the kernel
needs a reliable way to find out what it is.

> +/* sysfs: Write the modem firmware including TOC */
> +static ssize_t modemfw_write(struct file *f, struct kobject *kobj,
> +			struct bin_attribute *attr,
> +			char *buf, loff_t off, size_t count)
> +{
> +	if (commited)
> +		return -EBUSY;
> +
> +	if (off + count > xshm_size)
> +		return -ENOSPC;
> +	memcpy(shm_start + off, buf, count);
> +	modem_bootimg_size = off + count;
> +	return count;
> +}
> +
> +/* sysfs: Modem firmware attribute */
> +static struct bin_attribute modemfw_attr = {
> +	.attr = {
> +		 .name = "bootimg",
> +		 .mode = S_IRUGO | S_IWUSR,
> +		 },
> +	.size = IMG_MAX_SZ,
> +	.read = modemfw_read,
> +	.write = modemfw_write
> +};

Why don't you use the regular request_firmware() function here?

	Arnd

  reply	other threads:[~2011-12-09 15:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 14:07 [PATCHv2 00/10] XSHM: Shared Memory Driver for ST-E Thor M7400 LTE modem Sjur Brændeland
2011-12-09 14:07 ` [PATCHv2 01/10] xshm: Shared Memory layout for ST-E M7400 driver Sjur Brændeland
2011-12-09 14:45   ` Arnd Bergmann
2011-12-12  9:09     ` Sjur BRENDELAND
2011-12-09 14:07 ` [PATCHv2 02/10] xshm: Channel config definitions " Sjur Brændeland
2011-12-09 14:07 ` [PATCHv2 03/10] xshm: Configuration for XSHM Channel an devices Sjur Brændeland
2011-12-09 14:07 ` [PATCHv2 04/10] xshm: geni/geno driver interface Sjur Brændeland
2011-12-09 14:07 ` [PATCHv2 05/10] xshm: genio dummy driver Sjur Brændeland
2011-12-09 14:07 ` [PATCHv2 06/10] xshm: Add xshm device implementation Sjur Brændeland
2011-12-10 14:05   ` Michal Marek
2011-12-12  7:54     ` Sjur BRENDELAND
2011-12-09 14:07 ` [PATCHv2 07/10] xshm: XSHM Configuration data handling Sjur Brændeland
2011-12-09 15:09   ` Arnd Bergmann [this message]
2011-12-12 10:46     ` Sjur BRENDELAND
2011-12-15 10:18     ` Sjur BRENDELAND
2011-12-09 14:07 ` [PATCHv2 08/10] xshm: Character device for XSHM channel access Sjur Brændeland
2011-12-09 14:07 ` [PATCHv2 09/10] xshm: Makefile and Kconfig for M7400 Shared Memory Drivers Sjur Brændeland
2011-12-09 14:07 ` [PATCHv2 10/10] caif-xshm: Add CAIF driver for Shared memory for M7400 Sjur Brændeland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201112091509.41123.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=dan.carpenter@oracle.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pebolle@tiscali.nl \
    --cc=sjur.brandeland@stericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox