devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Andrew Jeffery" <andrew@aj.id.au>
To: Eddie James <eajames@linux.ibm.com>, linux-aspeed@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Rob Herring <robh+dt@kernel.org>,
	mark.rutland@arm.com, devicetree@vger.kernel.org,
	Joel Stanley <joel@jms.id.au>
Subject: Re: [PATCH v2 4/7] drivers/soc: xdma: Add PCI device configuration sysfs
Date: Tue, 21 May 2019 12:52:17 +0930	[thread overview]
Message-ID: <e7592bb9-c455-4eca-9c42-2ab16d04a57f@www.fastmail.com> (raw)
In-Reply-To: <1558383565-11821-5-git-send-email-eajames@linux.ibm.com>



On Tue, 21 May 2019, at 05:51, Eddie James wrote:
> The AST2500 has two PCI devices embedded. The XDMA engine can use either
> device to perform DMA transfers. Users need the capability to choose
> which device to use. This commit therefore adds two sysfs files that
> toggle the AST2500 and XDMA engine between the two PCI devices.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> ---
>  drivers/soc/aspeed/aspeed-xdma.c | 64 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 64 insertions(+)
> 
> diff --git a/drivers/soc/aspeed/aspeed-xdma.c 
> b/drivers/soc/aspeed/aspeed-xdma.c
> index 2162ca0..002b571 100644
> --- a/drivers/soc/aspeed/aspeed-xdma.c
> +++ b/drivers/soc/aspeed/aspeed-xdma.c
> @@ -667,6 +667,64 @@ static void aspeed_xdma_free_vga_blks(struct 
> aspeed_xdma *ctx)
>  	}
>  }
>  
> +static int aspeed_xdma_change_pcie_conf(struct aspeed_xdma *ctx, u32 conf)
> +{
> +	int rc;
> +
> +	mutex_lock(&ctx->start_lock);
> +	rc = wait_event_interruptible_timeout(ctx->wait,
> +					      !test_bit(XDMA_IN_PRG,
> +							&ctx->flags),
> +					      msecs_to_jiffies(1000));
> +	if (rc < 0) {
> +		mutex_unlock(&ctx->start_lock);
> +		return -EINTR;
> +	}
> +
> +	/* previous op didn't complete, wake up waiters anyway */
> +	if (!rc)
> +		wake_up_interruptible_all(&ctx->wait);
> +
> +	reset_control_assert(ctx->reset);
> +	msleep(10);
> +
> +	aspeed_scu_pcie_write(ctx, conf);
> +	msleep(10);
> +
> +	reset_control_deassert(ctx->reset);
> +	msleep(10);
> +
> +	aspeed_xdma_init_eng(ctx);
> +
> +	mutex_unlock(&ctx->start_lock);
> +
> +	return 0;
> +}
> +
> +static ssize_t aspeed_xdma_use_bmc(struct device *dev,
> +				   struct device_attribute *attr,
> +				   const char *buf, size_t count)
> +{
> +	int rc;
> +	struct aspeed_xdma *ctx = dev_get_drvdata(dev);
> +
> +	rc = aspeed_xdma_change_pcie_conf(ctx, aspeed_xdma_bmc_pcie_conf);
> +	return rc ?: count;
> +}
> +static DEVICE_ATTR(use_bmc, 0200, NULL, aspeed_xdma_use_bmc);
> +
> +static ssize_t aspeed_xdma_use_vga(struct device *dev,
> +				   struct device_attribute *attr,
> +				   const char *buf, size_t count)
> +{
> +	int rc;
> +	struct aspeed_xdma *ctx = dev_get_drvdata(dev);
> +
> +	rc = aspeed_xdma_change_pcie_conf(ctx, aspeed_xdma_vga_pcie_conf);
> +	return rc ?: count;
> +}
> +static DEVICE_ATTR(use_vga, 0200, NULL, aspeed_xdma_use_vga);
> +
>  static int aspeed_xdma_probe(struct platform_device *pdev)
>  {
>  	int irq;
> @@ -745,6 +803,9 @@ static int aspeed_xdma_probe(struct platform_device *pdev)
>  		return rc;
>  	}
>  
> +	device_create_file(dev, &dev_attr_use_bmc);
> +	device_create_file(dev, &dev_attr_use_vga);

Two attributes is a broken approach IMO. This gives the false representation of 4
states (neither, vga, bmc, both) when really there are only two (vga and bmc). I
think we should have one attribute that reacts to "vga" and "bmc" writes.

Andrew

> +
>  	return 0;
>  }
>  
> @@ -752,6 +813,9 @@ static int aspeed_xdma_remove(struct platform_device *pdev)
>  {
>  	struct aspeed_xdma *ctx = platform_get_drvdata(pdev);
>  
> +	device_remove_file(ctx->dev, &dev_attr_use_vga);
> +	device_remove_file(ctx->dev, &dev_attr_use_bmc);
> +
>  	misc_deregister(&ctx->misc);
>  
>  	aspeed_xdma_free_vga_blks(ctx);
> -- 
> 1.8.3.1
> 
>

  reply	other threads:[~2019-05-21  3:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 20:19 [PATCH v2 0/7] drivers/soc: Add Aspeed XDMA Engine Driver Eddie James
2019-05-20 20:19 ` [PATCH v2 1/7] dt-bindings: soc: Add Aspeed XDMA engine binding documentation Eddie James
2019-05-20 20:19 ` [PATCH v2 2/7] drivers/soc: Add Aspeed XDMA Engine Driver Eddie James
2019-05-21 12:02   ` Arnd Bergmann
2019-05-24 16:08     ` Eddie James
2019-05-29  1:59       ` Andrew Jeffery
2019-05-20 20:19 ` [PATCH v2 3/7] drivers/soc: xdma: Add user interface Eddie James
2019-05-21  3:52   ` Andrew Jeffery
2019-05-20 20:19 ` [PATCH v2 4/7] drivers/soc: xdma: Add PCI device configuration sysfs Eddie James
2019-05-21  3:22   ` Andrew Jeffery [this message]
2019-05-21 12:06   ` Arnd Bergmann
2019-05-20 20:19 ` [PATCH v2 5/7] drivers/soc: xdma: Add debugfs entries Eddie James
2019-05-21 11:58   ` Arnd Bergmann
2019-05-20 20:19 ` [PATCH v2 6/7] ARM: dts: aspeed: Add XDMA Engine Eddie James
2019-05-20 20:19 ` [PATCH v2 7/7] ARM: dts: aspeed: witherspoon: Enable " Eddie James

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=e7592bb9-c455-4eca-9c42-2ab16d04a57f@www.fastmail.com \
    --to=andrew@aj.id.au \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=eajames@linux.ibm.com \
    --cc=joel@jms.id.au \
    --cc=linux-aspeed@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).