Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1213432 > unrolled thread

Re: [PATCH V2 2/4] ACPI/scan: Clean up acpi_check_dma

Started by"Rafael J. Wysocki" <rjw@rjwysocki.net>
First post2015-08-26 01:30 +0200
Last post2015-08-26 04:20 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH V2 2/4] ACPI/scan: Clean up acpi_check_dma "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-08-26 01:30 +0200
    Re: [PATCH V2 2/4] ACPI/scan: Clean up acpi_check_dma "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-08-26 04:20 +0200

#1213432 — Re: [PATCH V2 2/4] ACPI/scan: Clean up acpi_check_dma

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2015-08-26 01:30 +0200
SubjectRe: [PATCH V2 2/4] ACPI/scan: Clean up acpi_check_dma
Message-ID<q1vPc-4OX-11@gated-at.bofh.it>
On Wednesday, August 26, 2015 12:33:27 AM Suravee Suthikulpanit wrote:
> The original name of acpi_check_dma() function does not clearly tell what
> exactly it is checking. Also, returning two boolean values (one to indicate
> device is DMA capability, and the other to inidicate device coherency
> attribute) can be confusing.
> 
> So, in order to simplify the function, this patch renames acpi_check_dma()
> to acpi_check_dma_coherency() to clearly indicate the purpose of this
> function, and only returns an integer where -1 means DMA not supported,
> 1 means coherent DMA, and 0 means non-coherent DMA.
> 
> Also, this patch moves the function into drivers/acpi/scan.c since
> it is easier to follow the logic in the acpi_init_coherency() in the
> same file here.
> 
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> CC: Bjorn Helgaas <bhelgaas@google.com>
> CC: Catalin Marinas <catalin.marinas@arm.com>
> CC: Rob Herring <robh+dt@kernel.org>
> CC: Will Deacon <will.deacon@arm.com>
> CC: Rafael J. Wysocki <rjw@rjwysocki.net>
> ---
>  drivers/acpi/acpi_platform.c |  7 ++++++-
>  drivers/acpi/glue.c          |  5 +++--
>  drivers/acpi/scan.c          | 39 +++++++++++++++++++++++++++++++++++++++
>  drivers/base/property.c      |  8 ++++++--
>  include/acpi/acpi_bus.h      | 36 ++----------------------------------
>  include/linux/acpi.h         |  4 ++--
>  6 files changed, 58 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
> index 06a67d5..2261e85 100644
> --- a/drivers/acpi/acpi_platform.c
> +++ b/drivers/acpi/acpi_platform.c
> @@ -103,7 +103,12 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
>  	pdevinfo.res = resources;
>  	pdevinfo.num_res = count;
>  	pdevinfo.fwnode = acpi_fwnode_handle(adev);
> -	pdevinfo.dma_mask = acpi_check_dma(adev, NULL) ? DMA_BIT_MASK(32) : 0;
> +
> +	if (-1 != acpi_check_dma_coherency(adev))
> +		pdevinfo.dma_mask = DMA_BIT_MASK(32);
> +	else
> +		pdevinfo.dma_mask = 0;
> +
>  	pdev = platform_device_register_full(&pdevinfo);
>  	if (IS_ERR(pdev))
>  		dev_err(&adev->dev, "platform device creation failed: %ld\n",
> diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
> index b9657af..55cf916 100644
> --- a/drivers/acpi/glue.c
> +++ b/drivers/acpi/glue.c
> @@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
>  	struct list_head *physnode_list;
>  	unsigned int node_id;
>  	int retval = -EINVAL;
> -	bool coherent;
> +	int coherent;

enum, anyone?  With clearly defined values?


>  
>  	if (has_acpi_companion(dev)) {
>  		if (acpi_dev) {
> @@ -225,7 +225,8 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
>  	if (!has_acpi_companion(dev))
>  		ACPI_COMPANION_SET(dev, acpi_dev);
>  
> -	if (acpi_check_dma(acpi_dev, &coherent))
> +	coherent = acpi_check_dma_coherency(acpi_dev);
> +	if (coherent != -1)

Like here I'm not sure why -1 is special?


>  		arch_setup_dma_ops(dev, 0, 0, NULL, coherent);
>  
>  	acpi_physnode_link_name(physical_node_name, node_id);

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1213502

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2015-08-26 04:20 +0200
Message-ID<q1ytI-pJ-5@gated-at.bofh.it>
In reply to#1213432
On Wednesday, August 26, 2015 09:00:23 AM Suravee Suthikulpanit wrote:
> Hi Rafael,
> 
> On 8/26/15 06:48, Rafael J. Wysocki wrote:
> 
> >[...]
> > On Wednesday, August 26, 2015 12:33:27 AM Suravee Suthikulpanit wrote:
> >> diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
> >> index b9657af..55cf916 100644
> >> --- a/drivers/acpi/glue.c
> >> +++ b/drivers/acpi/glue.c
> >> @@ -168,7 +168,7 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
> >>   	struct list_head *physnode_list;
> >>   	unsigned int node_id;
> >>   	int retval = -EINVAL;
> >> -	bool coherent;
> >> +	int coherent;
> >
> > enum, anyone?  With clearly defined values?
> 
> Originally I had defined
> 
> enum acpi_dma_coherency {
> 	ACPI_DMA_NON_COHERENT,
> 	ACPI_DMA_COHERENT,
> 	APCI_DMA_NOT_SUPPORTED = -1,
> };
> 
> Although, this would need to be defined in the include/linux/acpi.h, and 
> will be used also for #ifndef CONFIG_ACPI code to return errors. I was 
> not sure if this would be too much. If this is preferred, I'll add this 
> back in.
> 
> >>
> >>   	if (has_acpi_companion(dev)) {
> >>   		if (acpi_dev) {
> >> @@ -225,7 +225,8 @@ int acpi_bind_one(struct device *dev, struct acpi_device *acpi_dev)
> >>   	if (!has_acpi_companion(dev))
> >>   		ACPI_COMPANION_SET(dev, acpi_dev);
> >>
> >> -	if (acpi_check_dma(acpi_dev, &coherent))
> >> +	coherent = acpi_check_dma_coherency(acpi_dev);
> >> +	if (coherent != -1)
> >
> > Like here I'm not sure why -1 is special?
> 
> It's just another value to communicate that DMA is not supported. :)

OK

So maybe use 0/1 for the coherence thing and a proper error code
(-ENOTSUPP seems to be a good candidate) for the "no DMA" case?

Then, if you rename the local variable to something like "ret",
it will be slightly less confusing.

And instead of checking against a specific negative value, you can
simply use "if (stuff < 0)" or "if (stuff >= 0)" to check whether or
not it is supported at all.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web