lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54F0D688.5090006@ti.com>
Date:	Fri, 27 Feb 2015 15:41:44 -0500
From:	Murali Karicheri <m-karicheri2@...com>
To:	Bjorn Helgaas <bhelgaas@...gle.com>
CC:	<linux-arm-kernel@...ts.infradead.org>,
	<linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>,
	<linux-pci@...r.kernel.org>, Joerg Roedel <joro@...tes.org>,
	Grant Likely <grant.likely@...aro.org>,
	Rob Herring <robh+dt@...nel.org>,
	Will Deacon <will.deacon@....com>,
	Russell King <linux@....linux.org.uk>,
	Arnd Bergmann <arnd@...db.de>,
	Suravee Suthikulpanit <Suravee.Suthikulpanit@....com>,
	Catalin Marinas <catalin.marinas@....com>
Subject: Re: [PATCH v1] of: calculate masks of the device based on dma-range
 size

On 02/25/2015 07:20 PM, Bjorn Helgaas wrote:
> [+cc Catalin]
>
> On Wed, Feb 11, 2015 at 12:53:35PM -0500, Murali Karicheri wrote:
>> This patch update of_dma_configure() API to calculate the
>> masks (dma_mask and coherent_dma_mask) based on the dma-range
>> values set in DT for the device. Also limit the mask to lower
>> of the default mask and mask calculated.
>>
>> Cc: Joerg Roedel<joro@...tes.org>
>> Cc: Grant Likely<grant.likely@...aro.org>
>> Cc: Rob Herring<robh+dt@...nel.org>
>> Cc: Bjorn Helgaas<bhelgaas@...gle.com>
>> Cc: Will Deacon<will.deacon@....com>
>> Cc: Russell King<linux@....linux.org.uk>
>> Cc: Arnd Bergmann<arnd@...db.de>
>> Cc: Suravee Suthikulpanit<Suravee.Suthikulpanit@....com>
>>
>> Signed-off-by: Murali Karicheri<m-karicheri2@...com>
>
> Applied with Catalin's reviewed-by to pci/iommu for v4.1, thanks!
>
> I agree with Catalin's comment about the "size = 1ULL<<  32" line.
> I don't see how that will make a difference, so I dropped it.  The
> patch I merged is below.  Let me know if you think we do need that
> line or any other tweaks.
>
> Bjorn
>
> commit a5a1dd69080dfcf53bfd6e179f3db68e824aeaae
> Author: Murali Karicheri<m-karicheri2@...com>
> Date:   Wed Feb 25 17:21:04 2015 -0600
>
>      of: Calculate device DMA masks based on DT dma-range size
>
>      Calculate the dma_mask and coherent_dma_mask based on the dma-range values
>      set in DT for the device.
>
>      Limit the mask to lower of the default mask and mask calculated.
>
>      Signed-off-by: Murali Karicheri<m-karicheri2@...com>
>      Signed-off-by: Bjorn Helgaas<bhelgaas@...gle.com>
>      Reviewed-by: Catalin Marinas<catalin.marinas@....com>
>      CC: Joerg Roedel<joro@...tes.org>
>      CC: Grant Likely<grant.likely@...aro.org>
>      CC: Rob Herring<robh+dt@...nel.org>
>      CC: Will Deacon<will.deacon@....com>
>      CC: Russell King<linux@....linux.org.uk>
>      CC: Arnd Bergmann<arnd@...db.de>
>      CC: Suravee Suthikulpanit<Suravee.Suthikulpanit@....com>
>
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 28e743888402..20c1332a0018 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -90,10 +90,11 @@ void of_dma_configure(struct device *dev, struct device_node *np)
>   	struct iommu_ops *iommu;
>
>   	/*
> -	 * Set default dma-mask to 32 bit.  Drivers are expected to setup
> -	 * the correct supported dma_mask.
> +	 * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
> +	 * setup the correct supported mask.
>   	 */
> -	dev->coherent_dma_mask = DMA_BIT_MASK(32);
> +	if (!dev->coherent_dma_mask)
> +		dev->coherent_dma_mask = DMA_BIT_MASK(32);
>
>   	/*
>   	 * Set it to coherent_dma_mask by default if the architecture
> @@ -128,6 +129,15 @@ void of_dma_configure(struct device *dev, struct device_node *np)
>
>   	dev->dma_pfn_offset = offset;
>
> +	/*
> +	 * Limit coherent and dma mask based on size and default mask
> +	 * set by the driver.
> +	 */
> +	dev->coherent_dma_mask = min(dev->coherent_dma_mask,
> +				     DMA_BIT_MASK(ilog2(dma_addr + size)));
> +	*dev->dma_mask = min((*dev->dma_mask),
> +			     DMA_BIT_MASK(ilog2(dma_addr + size)));
> +
>   	coherent = of_dma_is_coherent(np);
>   	dev_dbg(dev, "device is%sdma coherent\n",
>   		coherent ? " " : " not ");
Bjorn,

Thanks. Looks good to me.

Murali

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ