Received: by 10.223.164.202 with SMTP id h10csp2238127wrb; Sun, 12 Nov 2017 04:54:43 -0800 (PST) X-Google-Smtp-Source: AGs4zMZnOEcjALvuS38s9UEBiSJKtXXKb8N/m3E9GmYMUGWY1RkTgu4g2X2HBVOlhvfPHWACBQRW X-Received: by 10.84.138.131 with SMTP id 3mr5962758plp.238.1510491283443; Sun, 12 Nov 2017 04:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510491283; cv=none; d=google.com; s=arc-20160816; b=Uda+H7CQEJRICWvbLa7wUbrCgPuKmQ745p6HJ988DVxugQWoCJjX7012irbC0sWN+s zB+DxxK+PhnIxzfJ4cYceWUwbh03WGG+bK3BT2Mu7AYJSEoIem0n7X0/VrMtr4c5CN+H IvhTuXZJoxVRTTbYO5WaPJhxS+3AaKRSsB/awkMSAY1G/tDoXP1qk2hYAlXroawPWeoI frw7QNi+bvxKesoqkd3Kkdqxo5MNS+rl4foLjPuobnKjJZ2Y6ZGMILu/fTiZdSuobJa9 aBMwC44YgDNBq2uqhoa7bLRIy78tdngxhRX86UnOxDmewyiQQvOC/FugSuVU/qeyvd9k NSOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :message-id:subject:cc:to:from:date:arc-authentication-results; bh=SpjjC5atD0HdeHAR3Ji/7ybbYcwyGRvuS3hB6Y7r5K0=; b=xG0j1HEvkQx3Nv/SeW6BCDe07Fw6ysGrbHy/qkfErt0t5rpMKK6YxcLDgOK6j5gxkf G2U9YnoUhPkuRH1ODSJp/cx0W/Ejyt0sQZytoxR5U4ptL84d3ZkDg5O9IZsZPzGqRIMb XKt+zKundQYMEmwEIFnApXfA390100aLYyYQu0+QdeWaXz0jvgoHESX5jVcXEFWpE0Ls PlSBUwKhebiMI85/dABrzukk69aroChZp5Gd0Pb0XzGRVU4Ivzgm/TrdsExt9xLm0FeE madS0erY1RoiqSwZmxWJlg9m6xXNDNRBAw+V84q4cwsqxErgOG4KjPZdSGgI+K0RmlNn hFgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmu.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si3464418pln.310.2017.11.12.04.54.30; Sun, 12 Nov 2017 04:54:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmu.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751336AbdKLMwj (ORCPT + 87 others); Sun, 12 Nov 2017 07:52:39 -0500 Received: from SMTP.ANDREW.CMU.EDU ([128.2.105.204]:42090 "EHLO smtp.andrew.cmu.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751150AbdKLMwi (ORCPT ); Sun, 12 Nov 2017 07:52:38 -0500 X-Greylist: delayed 742 seconds by postgrey-1.27 at vger.kernel.org; Sun, 12 Nov 2017 07:52:38 EST Received: from hedwig.ini.cmu.edu (HEDWIG.INI.CMU.EDU [128.2.16.51]) (user=somlo mech=LOGIN (0 bits)) by smtp.andrew.cmu.edu (8.15.2/8.15.2) with ESMTPSA id vACCfAYi086538 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 12 Nov 2017 07:41:12 -0500 Date: Sun, 12 Nov 2017 07:41:10 -0500 From: "Gabriel L. Somlo" To: =?iso-8859-1?Q?Marc-Andr=E9?= Lureau Cc: linux-kernel@vger.kernel.org, somlo@cmu.edu, qemu-devel@nongnu.org, mst@redhat.com Subject: Re: [PATCH v4 2/5] fw_cfg: add DMA register Message-ID: <20171112124110.GC19857@hedwig.ini.cmu.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20171031151938.14982-3-marcandre.lureau@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.1 (2017-09-22) X-PMX-Version: 6.3.0.2556906, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.11.12.123017 X-SMTP-Spam-Clean: 8% ( MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, DATE_TZ_NA 0, FROM_EDU_TLD 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CD 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0) X-SMTP-Spam-Score: 8% X-Scanned-By: MIMEDefang 2.78 on 128.2.105.204 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 31, 2017 at 04:19:35PM +0100, Marc-Andr� Lureau wrote: > Add an optional kernel module (or command line) parameter > using the following syntax: > > [qemu_fw_cfg.]ioport=@[::[:]] > or > [qemu_fw_cfg.]mmio=@[::[:]] > > and initializes the register address using given or default offset. > > Signed-off-by: Marc-Andr� Lureau Reviewed-by: Gabriel Somlo > --- > drivers/firmware/qemu_fw_cfg.c | 53 ++++++++++++++++++++++++++++++++---------- > 1 file changed, 41 insertions(+), 12 deletions(-) > > diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c > index 5cfe39f7a45f..1f3e8545dab7 100644 > --- a/drivers/firmware/qemu_fw_cfg.c > +++ b/drivers/firmware/qemu_fw_cfg.c > @@ -10,20 +10,21 @@ > * and select subsets of aarch64), a Device Tree node (on arm), or using > * a kernel module (or command line) parameter with the following syntax: > * > - * [qemu_fw_cfg.]ioport=@[::] > + * [qemu_fw_cfg.]ioport=@[::[:]] > * or > - * [qemu_fw_cfg.]mmio=@[::] > + * [qemu_fw_cfg.]mmio=@[::[:]] > * > * where: > * := size of ioport or mmio range > * := physical base address of ioport or mmio range > * := (optional) offset of control register > * := (optional) offset of data register > + * := (optional) offset of dma register > * > * e.g.: > - * qemu_fw_cfg.ioport=2@0x510:0:1 (the default on x86) > + * qemu_fw_cfg.ioport=12@0x510:0:1:4 (the default on x86) > * or > - * qemu_fw_cfg.mmio=0xA@0x9020000:8:0 (the default on arm) > + * qemu_fw_cfg.mmio=16@0x9020000:8:0:16 (the default on arm) > */ > > #include > @@ -63,6 +64,7 @@ static resource_size_t fw_cfg_p_size; > static void __iomem *fw_cfg_dev_base; > static void __iomem *fw_cfg_reg_ctrl; > static void __iomem *fw_cfg_reg_data; > +static void __iomem *fw_cfg_reg_dma; > > /* atomic access to fw_cfg device (potentially slow i/o, so using mutex) */ > static DEFINE_MUTEX(fw_cfg_dev_lock); > @@ -118,12 +120,14 @@ static void fw_cfg_io_cleanup(void) > # if (defined(CONFIG_ARM) || defined(CONFIG_ARM64)) > # define FW_CFG_CTRL_OFF 0x08 > # define FW_CFG_DATA_OFF 0x00 > +# define FW_CFG_DMA_OFF 0x10 > # elif (defined(CONFIG_PPC_PMAC) || defined(CONFIG_SPARC32)) /* ppc/mac,sun4m */ > # define FW_CFG_CTRL_OFF 0x00 > # define FW_CFG_DATA_OFF 0x02 > # elif (defined(CONFIG_X86) || defined(CONFIG_SPARC64)) /* x86, sun4u */ > # define FW_CFG_CTRL_OFF 0x00 > # define FW_CFG_DATA_OFF 0x01 > +# define FW_CFG_DMA_OFF 0x04 > # else > # error "QEMU FW_CFG not available on this architecture!" > # endif > @@ -133,7 +137,7 @@ static void fw_cfg_io_cleanup(void) > static int fw_cfg_do_platform_probe(struct platform_device *pdev) > { > char sig[FW_CFG_SIG_SIZE]; > - struct resource *range, *ctrl, *data; > + struct resource *range, *ctrl, *data, *dma; > > /* acquire i/o range details */ > fw_cfg_is_mmio = false; > @@ -170,6 +174,7 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev) > /* were custom register offsets provided (e.g. on the command line)? */ > ctrl = platform_get_resource_byname(pdev, IORESOURCE_REG, "ctrl"); > data = platform_get_resource_byname(pdev, IORESOURCE_REG, "data"); > + dma = platform_get_resource_byname(pdev, IORESOURCE_REG, "dma"); > if (ctrl && data) { > fw_cfg_reg_ctrl = fw_cfg_dev_base + ctrl->start; > fw_cfg_reg_data = fw_cfg_dev_base + data->start; > @@ -179,6 +184,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev) > fw_cfg_reg_data = fw_cfg_dev_base + FW_CFG_DATA_OFF; > } > > + if (dma) > + fw_cfg_reg_dma = fw_cfg_dev_base + dma->start; > +#ifdef FW_CFG_DMA_OFF > + else > + fw_cfg_reg_dma = fw_cfg_dev_base + FW_CFG_DMA_OFF; > +#endif > + > /* verify fw_cfg device signature */ > fw_cfg_read_blob(FW_CFG_SIGNATURE, sig, 0, FW_CFG_SIG_SIZE); > if (memcmp(sig, "QEMU", FW_CFG_SIG_SIZE) != 0) { > @@ -628,6 +640,7 @@ static struct platform_device *fw_cfg_cmdline_dev; > /* use special scanf/printf modifier for phys_addr_t, resource_size_t */ > #define PH_ADDR_SCAN_FMT "@%" __PHYS_ADDR_PREFIX "i%n" \ > ":%" __PHYS_ADDR_PREFIX "i" \ > + ":%" __PHYS_ADDR_PREFIX "i%n" \ > ":%" __PHYS_ADDR_PREFIX "i%n" > > #define PH_ADDR_PR_1_FMT "0x%" __PHYS_ADDR_PREFIX "x@" \ > @@ -637,12 +650,15 @@ static struct platform_device *fw_cfg_cmdline_dev; > ":%" __PHYS_ADDR_PREFIX "u" \ > ":%" __PHYS_ADDR_PREFIX "u" > > +#define PH_ADDR_PR_4_FMT PH_ADDR_PR_3_FMT \ > + ":%" __PHYS_ADDR_PREFIX "u" > + > static int fw_cfg_cmdline_set(const char *arg, const struct kernel_param *kp) > { > - struct resource res[3] = {}; > + struct resource res[4] = {}; > char *str; > phys_addr_t base; > - resource_size_t size, ctrl_off, data_off; > + resource_size_t size, ctrl_off, data_off, dma_off; > int processed, consumed = 0; > > /* only one fw_cfg device can exist system-wide, so if one > @@ -658,19 +674,20 @@ static int fw_cfg_cmdline_set(const char *arg, const struct kernel_param *kp) > /* consume "" portion of command line argument */ > size = memparse(arg, &str); > > - /* get "@[::]" chunks */ > + /* get "@[::[:]]" chunks */ > processed = sscanf(str, PH_ADDR_SCAN_FMT, > &base, &consumed, > - &ctrl_off, &data_off, &consumed); > + &ctrl_off, &data_off, &consumed, > + &dma_off, &consumed); > > - /* sscanf() must process precisely 1 or 3 chunks: > + /* sscanf() must process precisely 1, 3 or 4 chunks: > * is mandatory, optionally followed by > - * and ; > + * and , and ; > * there must be no extra characters after the last chunk, > * so str[consumed] must be '\0'. > */ > if (str[consumed] || > - (processed != 1 && processed != 3)) > + (processed != 1 && processed != 3 && processed != 4)) > return -EINVAL; > > res[0].start = base; > @@ -687,6 +704,11 @@ static int fw_cfg_cmdline_set(const char *arg, const struct kernel_param *kp) > res[2].start = data_off; > res[2].flags = IORESOURCE_REG; > } > + if (processed > 3) { > + res[3].name = "dma"; > + res[3].start = dma_off; > + res[3].flags = IORESOURCE_REG; > + } > > /* "processed" happens to nicely match the number of resources > * we need to pass in to this platform device. > @@ -721,6 +743,13 @@ static int fw_cfg_cmdline_get(char *buf, const struct kernel_param *kp) > fw_cfg_cmdline_dev->resource[0].start, > fw_cfg_cmdline_dev->resource[1].start, > fw_cfg_cmdline_dev->resource[2].start); > + case 4: > + return snprintf(buf, PAGE_SIZE, PH_ADDR_PR_4_FMT, > + resource_size(&fw_cfg_cmdline_dev->resource[0]), > + fw_cfg_cmdline_dev->resource[0].start, > + fw_cfg_cmdline_dev->resource[1].start, > + fw_cfg_cmdline_dev->resource[2].start, > + fw_cfg_cmdline_dev->resource[3].start); > } > > /* Should never get here */ > -- > 2.15.0.rc0.40.gaefcc5f6f > From 1582786988707911918@xxx Tue Oct 31 15:21:39 +0000 2017 X-GM-THRID: 1582786988707911918 X-Gmail-Labels: Inbox,Category Forums