* [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver.
@ 2014-06-24 13:57 Varun Sethi
2014-06-24 13:57 ` [PATCH 1/3] iommu/fsl: Fix PAMU window size check Varun Sethi
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Varun Sethi @ 2014-06-24 13:57 UTC (permalink / raw)
To: iommu, joro, linux-kernel, linuxppc-dev, alex.williamson; +Cc: Varun Sethi
This patch set contains fixes for the PAMU driver.
The patches are based on 3.16-rc1.
Varun Sethi (3):
Fix PAMU window size check.
Fix the device domain attach condition.
Fix the error condition during iommu group creation.
drivers/iommu/fsl_pamu.c | 8 ++++----
drivers/iommu/fsl_pamu_domain.c | 19 +++++++++----------
2 files changed, 13 insertions(+), 14 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/3] iommu/fsl: Fix PAMU window size check.
2014-06-24 13:57 [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Varun Sethi
@ 2014-06-24 13:57 ` Varun Sethi
2014-07-04 10:44 ` Joerg Roedel
2014-06-24 13:57 ` [PATCH 2/3] iommu/fsl: Fix the device domain attach condition Varun Sethi
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Varun Sethi @ 2014-06-24 13:57 UTC (permalink / raw)
To: iommu, joro, linux-kernel, linuxppc-dev, alex.williamson; +Cc: Varun Sethi
is_power_of_2 requires an unsigned long parameter which would
lead to truncation of 64 bit values on 32 bit architectures.
__ffs also expects an unsigned long parameter thus won't work
for 64 bit values on 32 bit architectures.
Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
---
drivers/iommu/fsl_pamu.c | 8 ++++----
drivers/iommu/fsl_pamu_domain.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
index b99dd88..bb446d7 100644
--- a/drivers/iommu/fsl_pamu.c
+++ b/drivers/iommu/fsl_pamu.c
@@ -170,10 +170,10 @@ int pamu_disable_liodn(int liodn)
static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size)
{
/* Bug if not a power of 2 */
- BUG_ON(!is_power_of_2(addrspace_size));
+ BUG_ON((addrspace_size & (addrspace_size - 1)));
/* window size is 2^(WSE+1) bytes */
- return __ffs(addrspace_size) - 1;
+ return fls64(addrspace_size) - 2;
}
/* Derive the PAACE window count encoding for the subwindow count */
@@ -351,7 +351,7 @@ int pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size,
struct paace *ppaace;
unsigned long fspi;
- if (!is_power_of_2(win_size) || win_size < PAMU_PAGE_SIZE) {
+ if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE) {
pr_debug("window size too small or not a power of two %llx\n", win_size);
return -EINVAL;
}
@@ -464,7 +464,7 @@ int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin,
return -ENOENT;
}
- if (!is_power_of_2(subwin_size) || subwin_size < PAMU_PAGE_SIZE) {
+ if ((subwin_size & (subwin_size - 1)) || subwin_size < PAMU_PAGE_SIZE) {
pr_debug("subwindow size out of range, or not a power of 2\n");
return -EINVAL;
}
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 93072ba..3dd0b8e 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -301,7 +301,7 @@ static int check_size(u64 size, dma_addr_t iova)
* Size must be a power of two and at least be equal
* to PAMU page size.
*/
- if (!is_power_of_2(size) || size < PAMU_PAGE_SIZE) {
+ if ((size & (size - 1)) || size < PAMU_PAGE_SIZE) {
pr_debug("%s: size too small or not a power of two\n", __func__);
return -EINVAL;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/3] iommu/fsl: Fix the device domain attach condition.
2014-06-24 13:57 [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Varun Sethi
2014-06-24 13:57 ` [PATCH 1/3] iommu/fsl: Fix PAMU window size check Varun Sethi
@ 2014-06-24 13:57 ` Varun Sethi
2014-07-04 10:54 ` Joerg Roedel
2014-06-24 13:57 ` [PATCH 3/3] iommu/fsl: Fix the error condition during iommu group Varun Sethi
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Varun Sethi @ 2014-06-24 13:57 UTC (permalink / raw)
To: iommu, joro, linux-kernel, linuxppc-dev, alex.williamson; +Cc: Varun Sethi
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/3] iommu/fsl: Fix the error condition during iommu group
2014-06-24 13:57 [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Varun Sethi
2014-06-24 13:57 ` [PATCH 1/3] iommu/fsl: Fix PAMU window size check Varun Sethi
2014-06-24 13:57 ` [PATCH 2/3] iommu/fsl: Fix the device domain attach condition Varun Sethi
@ 2014-06-24 13:57 ` Varun Sethi
[not found] ` <1403618237-26248-2-git-send-email-Varun.Sethi__13822.953499812$1403630309$gmane$org@freescale.com>
2014-07-07 8:32 ` [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Joerg Roedel
4 siblings, 0 replies; 12+ messages in thread
From: Varun Sethi @ 2014-06-24 13:57 UTC (permalink / raw)
To: iommu, joro, linux-kernel, linuxppc-dev, alex.williamson; +Cc: Varun Sethi
Earlier PTR_ERR was being returned even if group was set to null.
Now, we explicitly set an ERR_PTR value in case the group pointer is
NULL.
Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
---
drivers/iommu/fsl_pamu_domain.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 54060d1..af47648 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -1037,12 +1037,15 @@ root_bus:
group = get_shared_pci_device_group(pdev);
}
+ if (!group)
+ group = ERR_PTR(-ENODEV);
+
return group;
}
static int fsl_pamu_add_device(struct device *dev)
{
- struct iommu_group *group = NULL;
+ struct iommu_group *group = ERR_PTR(-ENODEV);
struct pci_dev *pdev;
const u32 *prop;
int ret, len;
@@ -1065,7 +1068,7 @@ static int fsl_pamu_add_device(struct device *dev)
group = get_device_iommu_group(dev);
}
- if (!group || IS_ERR(group))
+ if (IS_ERR(group))
return PTR_ERR(group);
ret = iommu_group_add_device(group, dev);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] iommu/fsl: Fix PAMU window size check.
[not found] ` <1403618237-26248-2-git-send-email-Varun.Sethi__13822.953499812$1403630309$gmane$org@freescale.com>
@ 2014-07-02 7:46 ` Emil Medve
2014-07-02 8:58 ` Varun Sethi
0 siblings, 1 reply; 12+ messages in thread
From: Emil Medve @ 2014-07-02 7:46 UTC (permalink / raw)
To: Varun Sethi, iommu, joro, linux-kernel, linuxppc-dev, alex.williamson
On 06/24/2014 08:57 AM, Varun Sethi wrote:
> is_power_of_2 requires an unsigned long parameter which would
> lead to truncation of 64 bit values on 32 bit architectures.
>
> __ffs also expects an unsigned long parameter thus won't work
> for 64 bit values on 32 bit architectures.
>
> Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
> ---
> drivers/iommu/fsl_pamu.c | 8 ++++----
> drivers/iommu/fsl_pamu_domain.c | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
Tested-by: Emil Medve <Emilian.Medve@Freescale.com>
On a P4080 DS (i.e. 32-bit SoC)
Cheers,
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 1/3] iommu/fsl: Fix PAMU window size check.
2014-07-02 7:46 ` [PATCH 1/3] iommu/fsl: Fix PAMU window size check Emil Medve
@ 2014-07-02 8:58 ` Varun Sethi
0 siblings, 0 replies; 12+ messages in thread
From: Varun Sethi @ 2014-07-02 8:58 UTC (permalink / raw)
To: Emilian Medve, iommu, joro, linux-kernel, linuxppc-dev, alex.williamson
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1167 bytes --]
Thanks Emil.
> -----Original Message-----
> From: Emil Medve [mailto:Emilian.Medve@Freescale.com]
> Sent: Wednesday, July 02, 2014 1:16 PM
> To: Sethi Varun-B16395; iommu@lists.linux-foundation.org;
> joro@8bytes.org; linux-kernel@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org; alex.williamson@redhat.com
> Subject: Re: [PATCH 1/3] iommu/fsl: Fix PAMU window size check.
>
> On 06/24/2014 08:57 AM, Varun Sethi wrote:
> > is_power_of_2 requires an unsigned long parameter which would lead to
> > truncation of 64 bit values on 32 bit architectures.
> >
> > __ffs also expects an unsigned long parameter thus won't work for 64
> > bit values on 32 bit architectures.
> >
> > Signed-off-by: Varun Sethi <Varun.Sethi@freescale.com>
> > ---
> > drivers/iommu/fsl_pamu.c | 8 ++++----
> > drivers/iommu/fsl_pamu_domain.c | 2 +-
> > 2 files changed, 5 insertions(+), 5 deletions(-)
>
> Tested-by: Emil Medve <Emilian.Medve@Freescale.com>
>
> On a P4080 DS (i.e. 32-bit SoC)
>
>
> Cheers,
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/3] iommu/fsl: Fix PAMU window size check.
2014-06-24 13:57 ` [PATCH 1/3] iommu/fsl: Fix PAMU window size check Varun Sethi
@ 2014-07-04 10:44 ` Joerg Roedel
2014-07-04 12:47 ` Varun Sethi
0 siblings, 1 reply; 12+ messages in thread
From: Joerg Roedel @ 2014-07-04 10:44 UTC (permalink / raw)
To: Varun Sethi; +Cc: iommu, linux-kernel, linuxppc-dev, alex.williamson
On Tue, Jun 24, 2014 at 07:27:15PM +0530, Varun Sethi wrote:
> /* window size is 2^(WSE+1) bytes */
> - return __ffs(addrspace_size) - 1;
> + return fls64(addrspace_size) - 2;
This looks bogus, why do you replace ffs (find-first-bit) by fls
(find-last-bit)?
Joerg
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/3] iommu/fsl: Fix the device domain attach condition.
2014-06-24 13:57 ` [PATCH 2/3] iommu/fsl: Fix the device domain attach condition Varun Sethi
@ 2014-07-04 10:54 ` Joerg Roedel
2014-07-04 12:50 ` Varun Sethi
0 siblings, 1 reply; 12+ messages in thread
From: Joerg Roedel @ 2014-07-04 10:54 UTC (permalink / raw)
To: Varun Sethi; +Cc: iommu, linux-kernel, linuxppc-dev, alex.williamson
Hmm,
On Tue, Jun 24, 2014 at 07:27:16PM +0530, Varun Sethi wrote:
> - old_domain_info = find_domain(dev);
> + old_domain_info = dev->archdata.iommu_domain;
> if (old_domain_info && old_domain_info->domain != dma_domain) {
> spin_unlock_irqrestore(&device_domain_lock, flags);
> detach_device(dev, old_domain_info->domain);
Wouldn't this set dev->archdata.iommu_domain to NULL anyway, so that ...
> @@ -399,7 +394,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d
> * the info for the first LIODN as all
> * LIODNs share the same domain
> */
> - if (!old_domain_info)
> + if (!dev->archdata.iommu_domain)
> dev->archdata.iommu_domain = info;
We already know that it _must_ be NULL here?
> spin_unlock_irqrestore(&device_domain_lock, flags);
This would shrink down the patch to:
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 93072ba..d21b554 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -399,8 +399,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d
* the info for the first LIODN as all
* LIODNs share the same domain
*/
- if (!old_domain_info)
- dev->archdata.iommu_domain = info;
+ dev->archdata.iommu_domain = info;
spin_unlock_irqrestore(&device_domain_lock, flags);
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* RE: [PATCH 1/3] iommu/fsl: Fix PAMU window size check.
2014-07-04 10:44 ` Joerg Roedel
@ 2014-07-04 12:47 ` Varun Sethi
0 siblings, 0 replies; 12+ messages in thread
From: Varun Sethi @ 2014-07-04 12:47 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, linuxppc-dev, alex.williamson
> -----Original Message-----
> From: Joerg Roedel [mailto:joro@8bytes.org]
> Sent: Friday, July 04, 2014 4:15 PM
> To: Sethi Varun-B16395
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> linuxppc-dev@lists.ozlabs.org; alex.williamson@redhat.com
> Subject: Re: [PATCH 1/3] iommu/fsl: Fix PAMU window size check.
>
> On Tue, Jun 24, 2014 at 07:27:15PM +0530, Varun Sethi wrote:
> > /* window size is 2^(WSE+1) bytes */
> > - return __ffs(addrspace_size) - 1;
> > + return fls64(addrspace_size) - 2;
>
> This looks bogus, why do you replace ffs (find-first-bit) by fls (find-
> last-bit)?
>
Address space size is always a power of 2. This change was required to handle address sizes > 32bit width on 32 bit architectures.
-Varun
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 2/3] iommu/fsl: Fix the device domain attach condition.
2014-07-04 10:54 ` Joerg Roedel
@ 2014-07-04 12:50 ` Varun Sethi
0 siblings, 0 replies; 12+ messages in thread
From: Varun Sethi @ 2014-07-04 12:50 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, linuxppc-dev, alex.williamson
> -----Original Message-----
> From: Joerg Roedel [mailto:joro@8bytes.org]
> Sent: Friday, July 04, 2014 4:25 PM
> To: Sethi Varun-B16395
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> linuxppc-dev@lists.ozlabs.org; alex.williamson@redhat.com
> Subject: Re: [PATCH 2/3] iommu/fsl: Fix the device domain attach
> condition.
>
> Hmm,
>
> On Tue, Jun 24, 2014 at 07:27:16PM +0530, Varun Sethi wrote:
> > - old_domain_info = find_domain(dev);
> > + old_domain_info = dev->archdata.iommu_domain;
> > if (old_domain_info && old_domain_info->domain != dma_domain) {
> > spin_unlock_irqrestore(&device_domain_lock, flags);
> > detach_device(dev, old_domain_info->domain);
>
> Wouldn't this set dev->archdata.iommu_domain to NULL anyway, so that ...
>
Not for the case where device has multiple LIODNs.
> > @@ -399,7 +394,7 @@ static void attach_device(struct fsl_dma_domain
> *dma_domain, int liodn, struct d
> > * the info for the first LIODN as all
> > * LIODNs share the same domain
> > */
> > - if (!old_domain_info)
> > + if (!dev->archdata.iommu_domain)
> > dev->archdata.iommu_domain = info;
>
> We already know that it _must_ be NULL here?
>
That won't be true for devices having multiple LIODNs
> > spin_unlock_irqrestore(&device_domain_lock, flags);
>
> This would shrink down the patch to:
>
> diff --git a/drivers/iommu/fsl_pamu_domain.c
> b/drivers/iommu/fsl_pamu_domain.c index 93072ba..d21b554 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -399,8 +399,7 @@ static void attach_device(struct fsl_dma_domain
> *dma_domain, int liodn, struct d
> * the info for the first LIODN as all
> * LIODNs share the same domain
> */
> - if (!old_domain_info)
> - dev->archdata.iommu_domain = info;
> + dev->archdata.iommu_domain = info;
For devices having multiple LIODNs, we don't want to overwrite the info.
-Varun
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver.
2014-06-24 13:57 [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Varun Sethi
` (3 preceding siblings ...)
[not found] ` <1403618237-26248-2-git-send-email-Varun.Sethi__13822.953499812$1403630309$gmane$org@freescale.com>
@ 2014-07-07 8:32 ` Joerg Roedel
2014-07-07 8:55 ` Varun Sethi
4 siblings, 1 reply; 12+ messages in thread
From: Joerg Roedel @ 2014-07-07 8:32 UTC (permalink / raw)
To: Varun Sethi; +Cc: iommu, linux-kernel, linuxppc-dev, alex.williamson
On Tue, Jun 24, 2014 at 07:27:14PM +0530, Varun Sethi wrote:
> This patch set contains fixes for the PAMU driver.
> The patches are based on 3.16-rc1.
>
> Varun Sethi (3):
> Fix PAMU window size check.
> Fix the device domain attach condition.
> Fix the error condition during iommu group creation.
>
> drivers/iommu/fsl_pamu.c | 8 ++++----
> drivers/iommu/fsl_pamu_domain.c | 19 +++++++++----------
> 2 files changed, 13 insertions(+), 14 deletions(-)
Applied to iommu/fixes, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver.
2014-07-07 8:32 ` [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Joerg Roedel
@ 2014-07-07 8:55 ` Varun Sethi
0 siblings, 0 replies; 12+ messages in thread
From: Varun Sethi @ 2014-07-07 8:55 UTC (permalink / raw)
To: Joerg Roedel; +Cc: iommu, linux-kernel, linuxppc-dev, alex.williamson
Thanks Joerg.
> -----Original Message-----
> From: Joerg Roedel [mailto:joro@8bytes.org]
> Sent: Monday, July 07, 2014 2:02 PM
> To: Sethi Varun-B16395
> Cc: iommu@lists.linux-foundation.org; linux-kernel@vger.kernel.org;
> linuxppc-dev@lists.ozlabs.org; alex.williamson@redhat.com
> Subject: Re: [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver.
>
> On Tue, Jun 24, 2014 at 07:27:14PM +0530, Varun Sethi wrote:
> > This patch set contains fixes for the PAMU driver.
> > The patches are based on 3.16-rc1.
> >
> > Varun Sethi (3):
> > Fix PAMU window size check.
> > Fix the device domain attach condition.
> > Fix the error condition during iommu group creation.
> >
> > drivers/iommu/fsl_pamu.c | 8 ++++----
> > drivers/iommu/fsl_pamu_domain.c | 19 +++++++++----------
> > 2 files changed, 13 insertions(+), 14 deletions(-)
>
> Applied to iommu/fixes, thanks.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-07-07 8:55 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-24 13:57 [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Varun Sethi
2014-06-24 13:57 ` [PATCH 1/3] iommu/fsl: Fix PAMU window size check Varun Sethi
2014-07-04 10:44 ` Joerg Roedel
2014-07-04 12:47 ` Varun Sethi
2014-06-24 13:57 ` [PATCH 2/3] iommu/fsl: Fix the device domain attach condition Varun Sethi
2014-07-04 10:54 ` Joerg Roedel
2014-07-04 12:50 ` Varun Sethi
2014-06-24 13:57 ` [PATCH 3/3] iommu/fsl: Fix the error condition during iommu group Varun Sethi
[not found] ` <1403618237-26248-2-git-send-email-Varun.Sethi__13822.953499812$1403630309$gmane$org@freescale.com>
2014-07-02 7:46 ` [PATCH 1/3] iommu/fsl: Fix PAMU window size check Emil Medve
2014-07-02 8:58 ` Varun Sethi
2014-07-07 8:32 ` [PATCH 0/3] iommu/fsl: Fixes for the PAMU driver Joerg Roedel
2014-07-07 8:55 ` Varun Sethi
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).