History

iommu/fsl: Various cleanups

Currently a PAMU driver patch is very likely to receive some checkpatch complaints about the code in the context of the patch. This patch is an attempt to fix most of that and make the driver more readable Also fixed a subset of the sparse and coccinelle reported issues.

Emil Medve committed 11 years ago

Commit cd70d461 parent 8cd4f754 files · +179 −216Browse files

Unified · Split

4 files
  1. arch/powerpc/include/asm/fsl_pamu_stash.h +2 −2
  2. drivers/iommu/fsl_pamu.c +95 −108
  3. drivers/iommu/fsl_pamu.h +8 −7
  4. drivers/iommu/fsl_pamu_domain.c +74 −99
arch/powerpc/include/asm/fsl_pamu_stash.h+2−2
@@ -32,8 +32,8 @@ enum pamu_stash_target { · 31 unmodified lines
3232 */
3333
3434 struct pamu_stash_attribute {
35− u32 cpu; /* cpu number */
36− u32 cache; /* cache to stash to: L1,L2,L3 */
35+ u32 cpu; /* cpu number */
36+ u32 cache; /* cache to stash to: L1,L2,L3 */
3737 };
3838
3939 #endif /* __FSL_PAMU_STASH_H */
drivers/iommu/fsl_pamu.c+95−108
@@ -18,22 +18,13 @@ · 17 unmodified lines
1818
1919 #define pr_fmt(fmt) "fsl-pamu: %s: " fmt, __func__
2020
21−#include <linux/init.h>
22−#include <linux/iommu.h>
23−#include <linux/slab.h>
24−#include <linux/module.h>
25−#include <linux/types.h>
26−#include <linux/mm.h>
21+#include "fsl_pamu.h"
22+
2723 #include <linux/interrupt.h>
28−#include <linux/device.h>
29−#include <linux/of_platform.h>
30−#include <linux/bootmem.h>
3124 #include <linux/genalloc.h>
32−#include <asm/io.h>
33−#include <asm/bitops.h>
34−#include <asm/fsl_guts.h>
3525
36−#include "fsl_pamu.h"
26+#include <asm/mpc85xx.h>
27+#include <asm/fsl_guts.h>
3728
3829 /* define indexes for each operation mapping scenario */
3930 #define OMI_QMAN 0x00
@@ -44,13 +35,13 @@ · 4 unmodified lines
4435 #define make64(high, low) (((u64)(high) << 32) | (low))
4536
4637 struct pamu_isr_data {
47− void __iomem *pamu_reg_base; /* Base address of PAMU regs*/
38+ void __iomem *pamu_reg_base; /* Base address of PAMU regs */
4839 unsigned int count; /* The number of PAMUs */
4940 };
5041
5142 static struct paace *ppaact;
5243 static struct paace *spaact;
53−static struct ome *omt;
44+static struct ome *omt __initdata;
5445
5546 /*
5647 * Table for matching compatible strings, for device tree
@@ -58,14 +49,13 @@ static struct ome *omt; · 1 unmodified line
5849 * "fsl,qoriq-device-config-2.0" corresponds to T4 & B4
5950 * SOCs. For the older SOCs "fsl,qoriq-device-config-1.0"
6051 * string would be used.
61−*/
62−static const struct of_device_id guts_device_ids[] = {
52+ */
53+static const struct of_device_id guts_device_ids[] __initconst = {
6354 { .compatible = "fsl,qoriq-device-config-1.0", },
6455 { .compatible = "fsl,qoriq-device-config-2.0", },
6556 {}
6657 };
6758
68−
6959 /*
7060 * Table for matching compatible strings, for device tree
7161 * L3 cache controller node.
@@ -73,7 +63,7 @@ static const struct of_device_id guts_device_ids[] = { · 1 unmodified line
7363 * "fsl,b4860-l3-cache-controller" corresponds to B4 &
7464 * "fsl,p4080-l3-cache-controller" corresponds to other,
7565 * SOCs.
76−*/
66+ */
7767 static const struct of_device_id l3_device_ids[] = {
7868 { .compatible = "fsl,t4240-l3-cache-controller", },
7969 { .compatible = "fsl,b4860-l3-cache-controller", },
@@ -85,7 +75,7 @@ static const struct of_device_id l3_device_ids[] = { · 5 unmodified lines
8575 static u32 max_subwindow_count;
8676
8777 /* Pool for fspi allocation */
88−struct gen_pool *spaace_pool;
78+static struct gen_pool *spaace_pool;
8979
9080 /**
9181 * pamu_get_max_subwin_cnt() - Return the maximum supported
@@ -170,7 +160,7 @@ int pamu_disable_liodn(int liodn) · 78 unmodified lines
170160 static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size)
171161 {
172162 /* Bug if not a power of 2 */
173− BUG_ON((addrspace_size & (addrspace_size - 1)));
163+ BUG_ON(addrspace_size & (addrspace_size - 1));
174164
175165 /* window size is 2^(WSE+1) bytes */
176166 return fls64(addrspace_size) - 2;
@@ -179,8 +169,8 @@ static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size) · 2 unmodified lines
179169 /* Derive the PAACE window count encoding for the subwindow count */
180170 static unsigned int map_subwindow_cnt_to_wce(u32 subwindow_cnt)
181171 {
182− /* window count is 2^(WCE+1) bytes */
183− return __ffs(subwindow_cnt) - 1;
172+ /* window count is 2^(WCE+1) bytes */
173+ return __ffs(subwindow_cnt) - 1;
184174 }
185175
186176 /*
@@ -241,7 +231,7 @@ static struct paace *pamu_get_spaace(struct paace *paace, u32 wnum) · 54 unmodified lines
241231 * If no SPAACE entry is available or the allocator can not reserve the required
242232 * number of contiguous entries function returns ULONG_MAX indicating a failure.
243233 *
244−*/
234+ */
245235 static unsigned long pamu_get_fspi_and_allocate(u32 subwin_cnt)
246236 {
247237 unsigned long spaace_addr;
@@ -288,9 +278,8 @@ int pamu_update_paace_stash(int liodn, u32 subwin, u32 value) · 40 unmodified lines
288278 }
289279 if (subwin) {
290280 paace = pamu_get_spaace(paace, subwin - 1);
291− if (!paace) {
281+ if (!paace)
292282 return -ENOENT;
293− }
294283 }
295284 set_bf(paace->impl_attr, PAACE_IA_CID, value);
296285
@@ -311,14 +300,12 @@ int pamu_disable_spaace(int liodn, u32 subwin) · 14 unmodified lines
311300 }
312301 if (subwin) {
313302 paace = pamu_get_spaace(paace, subwin - 1);
314− if (!paace) {
303+ if (!paace)
315304 return -ENOENT;
316− }
317− set_bf(paace->addr_bitfields, PAACE_AF_V,
318− PAACE_V_INVALID);
305+ set_bf(paace->addr_bitfields, PAACE_AF_V, PAACE_V_INVALID);
319306 } else {
320307 set_bf(paace->addr_bitfields, PAACE_AF_AP,
321− PAACE_AP_PERMS_DENIED);
308+ PAACE_AP_PERMS_DENIED);
322309 }
323310
324311 mb();
@@ -326,7 +313,6 @@ int pamu_disable_spaace(int liodn, u32 subwin) · 1 unmodified line
326313 return 0;
327314 }
328315
329−
330316 /**
331317 * pamu_config_paace() - Sets up PPAACE entry for specified liodn
332318 *
@@ -352,7 +338,8 @@ int pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size, · 19 unmodified lines
352338 unsigned long fspi;
353339
354340 if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE) {
355− pr_debug("window size too small or not a power of two %pa\n", &win_size);
341+ pr_debug("window size too small or not a power of two %pa\n",
342+ &win_size);
356343 return -EINVAL;
357344 }
358345
@@ -362,13 +349,12 @@ int pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size, · 3 unmodified lines
362349 }
363350
364351 ppaace = pamu_get_ppaace(liodn);
365− if (!ppaace) {
352+ if (!ppaace)
366353 return -ENOENT;
367− }
368354
369355 /* window size is 2^(WSE+1) bytes */
370356 set_bf(ppaace->addr_bitfields, PPAACE_AF_WSE,
371− map_addrspace_size_to_wse(win_size));
357+ map_addrspace_size_to_wse(win_size));
372358
373359 pamu_init_ppaace(ppaace);
374360
@@ -442,7 +428,6 @@ int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin, · 67 unmodified lines
442428 {
443429 struct paace *paace;
444430
445−
446431 /* setup sub-windows */
447432 if (!subwin_cnt) {
448433 pr_debug("Invalid subwindow count\n");
@@ -510,11 +495,11 @@ int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin, · 61 unmodified lines
510495 }
511496
512497 /**
513−* get_ome_index() - Returns the index in the operation mapping table
514−* for device.
515−* @*omi_index: pointer for storing the index value
516−*
517−*/
498+ * get_ome_index() - Returns the index in the operation mapping table
499+ * for device.
500+ * @*omi_index: pointer for storing the index value
501+ *
502+ */
518503 void get_ome_index(u32 *omi_index, struct device *dev)
519504 {
520505 if (of_device_is_compatible(dev->of_node, "fsl,qman-portal"))
@@ -544,9 +529,10 @@ u32 get_stash_id(u32 stash_dest_hint, u32 vcpu) · 23 unmodified lines
544529 if (stash_dest_hint == PAMU_ATTR_CACHE_L3) {
545530 node = of_find_matching_node(NULL, l3_device_ids);
546531 if (node) {
547− prop = of_get_property(node, "cache-stash-id", 0);
532+ prop = of_get_property(node, "cache-stash-id", NULL);
548533 if (!prop) {
549− pr_debug("missing cache-stash-id at %s\n", node->full_name);
534+ pr_debug("missing cache-stash-id at %s\n",
535+ node->full_name);
550536 of_node_put(node);
551537 return ~(u32)0;
552538 }
@@ -570,9 +556,10 @@ found_cpu_node: · 17 unmodified lines
570556 /* find the hwnode that represents the cache */
571557 for (cache_level = PAMU_ATTR_CACHE_L1; (cache_level < PAMU_ATTR_CACHE_L3) && found; cache_level++) {
572558 if (stash_dest_hint == cache_level) {
573− prop = of_get_property(node, "cache-stash-id", 0);
559+ prop = of_get_property(node, "cache-stash-id", NULL);
574560 if (!prop) {
575− pr_debug("missing cache-stash-id at %s\n", node->full_name);
561+ pr_debug("missing cache-stash-id at %s\n",
562+ node->full_name);
576563 of_node_put(node);
577564 return ~(u32)0;
578565 }
@@ -580,10 +567,10 @@ found_cpu_node: · 1 unmodified line
580567 return be32_to_cpup(prop);
581568 }
582569
583− prop = of_get_property(node, "next-level-cache", 0);
570+ prop = of_get_property(node, "next-level-cache", NULL);
584571 if (!prop) {
585572 pr_debug("can't find next-level-cache at %s\n",
586− node->full_name);
573+ node->full_name);
587574 of_node_put(node);
588575 return ~(u32)0; /* can't traverse any further */
589576 }
@@ -598,7 +585,7 @@ found_cpu_node: · 8 unmodified lines
598585 }
599586
600587 pr_debug("stash dest not found for %d on vcpu %d\n",
601− stash_dest_hint, vcpu);
588+ stash_dest_hint, vcpu);
602589 return ~(u32)0;
603590 }
604591
@@ -612,7 +599,7 @@ found_cpu_node: · 7 unmodified lines
612599 * Memory accesses to QMAN and BMAN private memory need not be coherent, so
613600 * clear the PAACE entry coherency attribute for them.
614601 */
615−static void setup_qbman_paace(struct paace *ppaace, int paace_type)
602+static void __init setup_qbman_paace(struct paace *ppaace, int paace_type)
616603 {
617604 switch (paace_type) {
618605 case QMAN_PAACE:
@@ -626,7 +613,7 @@ static void setup_qbman_paace(struct paace *ppaace, int paace_type) · 7 unmodified lines
626613 case QMAN_PORTAL_PAACE:
627614 set_bf(ppaace->impl_attr, PAACE_IA_OTM, PAACE_OTM_INDEXED);
628615 ppaace->op_encode.index_ot.omi = OMI_QMAN;
629− /*Set DQRR and Frame stashing for the L3 cache */
616+ /* Set DQRR and Frame stashing for the L3 cache */
630617 set_bf(ppaace->impl_attr, PAACE_IA_CID, get_stash_id(PAMU_ATTR_CACHE_L3, 0));
631618 break;
632619 case BMAN_PAACE:
@@ -679,7 +666,7 @@ static void __init setup_omt(struct ome *omt) · 46 unmodified lines
679666 * Get the maximum number of PAACT table entries
680667 * and subwindows supported by PAMU
681668 */
682−static void get_pamu_cap_values(unsigned long pamu_reg_base)
669+static void __init get_pamu_cap_values(unsigned long pamu_reg_base)
683670 {
684671 u32 pc_val;
685672
@@ -689,9 +676,9 @@ static void get_pamu_cap_values(unsigned long pamu_reg_base) · 3 unmodified lines
689676 }
690677
691678 /* Setup PAMU registers pointing to PAACT, SPAACT and OMT */
692−int setup_one_pamu(unsigned long pamu_reg_base, unsigned long pamu_reg_size,
693− phys_addr_t ppaact_phys, phys_addr_t spaact_phys,
694− phys_addr_t omt_phys)
679+static int __init setup_one_pamu(unsigned long pamu_reg_base, unsigned long pamu_reg_size,
680+ phys_addr_t ppaact_phys, phys_addr_t spaact_phys,
681+ phys_addr_t omt_phys)
695682 {
696683 u32 *pc;
697684 struct pamu_mmap_regs *pamu_regs;
@@ -727,7 +714,7 @@ int setup_one_pamu(unsigned long pamu_reg_base, unsigned long pamu_reg_size, · 29 unmodified lines
727714 */
728715
729716 out_be32((u32 *)(pamu_reg_base + PAMU_PICS),
730− PAMU_ACCESS_VIOLATION_ENABLE);
717+ PAMU_ACCESS_VIOLATION_ENABLE);
731718 out_be32(pc, PAMU_PC_PE | PAMU_PC_OCE | PAMU_PC_SPCC | PAMU_PC_PPCC);
732719 return 0;
733720 }
@@ -757,9 +744,9 @@ static void __init setup_liodns(void) · 23 unmodified lines
757744 ppaace->wbah = 0;
758745 set_bf(ppaace->addr_bitfields, PPAACE_AF_WBAL, 0);
759746 set_bf(ppaace->impl_attr, PAACE_IA_ATM,
760− PAACE_ATM_NO_XLATE);
747+ PAACE_ATM_NO_XLATE);
761748 set_bf(ppaace->addr_bitfields, PAACE_AF_AP,
762− PAACE_AP_PERMS_ALL);
749+ PAACE_AP_PERMS_ALL);
763750 if (of_device_is_compatible(node, "fsl,qman-portal"))
764751 setup_qbman_paace(ppaace, QMAN_PORTAL_PAACE);
765752 if (of_device_is_compatible(node, "fsl,qman"))
@@ -772,7 +759,7 @@ static void __init setup_liodns(void) · 6 unmodified lines
772759 }
773760 }
774761
775−irqreturn_t pamu_av_isr(int irq, void *arg)
762+static irqreturn_t pamu_av_isr(int irq, void *arg)
776763 {
777764 struct pamu_isr_data *data = arg;
778765 phys_addr_t phys;
@@ -792,14 +779,16 @@ irqreturn_t pamu_av_isr(int irq, void *arg) · 13 unmodified lines
792779 pr_emerg("POES2=%08x\n", in_be32(p + PAMU_POES2));
793780 pr_emerg("AVS1=%08x\n", avs1);
794781 pr_emerg("AVS2=%08x\n", in_be32(p + PAMU_AVS2));
795− pr_emerg("AVA=%016llx\n", make64(in_be32(p + PAMU_AVAH),
796− in_be32(p + PAMU_AVAL)));
782+ pr_emerg("AVA=%016llx\n",
783+ make64(in_be32(p + PAMU_AVAH),
784+ in_be32(p + PAMU_AVAL)));
797785 pr_emerg("UDAD=%08x\n", in_be32(p + PAMU_UDAD));
798− pr_emerg("POEA=%016llx\n", make64(in_be32(p + PAMU_POEAH),
799− in_be32(p + PAMU_POEAL)));
786+ pr_emerg("POEA=%016llx\n",
787+ make64(in_be32(p + PAMU_POEAH),
788+ in_be32(p + PAMU_POEAL)));
800789
801790 phys = make64(in_be32(p + PAMU_POEAH),
802− in_be32(p + PAMU_POEAL));
791+ in_be32(p + PAMU_POEAL));
803792
804793 /* Assume that POEA points to a PAACE */
805794 if (phys) {
@@ -807,11 +796,12 @@ irqreturn_t pamu_av_isr(int irq, void *arg) · 1 unmodified line
807796
808797 /* Only the first four words are relevant */
809798 for (j = 0; j < 4; j++)
810− pr_emerg("PAACE[%u]=%08x\n", j, in_be32(paace + j));
799+ pr_emerg("PAACE[%u]=%08x\n",
800+ j, in_be32(paace + j));
811801 }
812802
813803 /* clear access violation condition */
814− out_be32((p + PAMU_AVS1), avs1 & PAMU_AV_MASK);
804+ out_be32(p + PAMU_AVS1, avs1 & PAMU_AV_MASK);
815805 paace = pamu_get_ppaace(avs1 >> PAMU_AVS1_LIODN_SHIFT);
816806 BUG_ON(!paace);
817807 /* check if we got a violation for a disabled LIODN */
@@ -827,13 +817,13 @@ irqreturn_t pamu_av_isr(int irq, void *arg) · 9 unmodified lines
827817 /* Disable the LIODN */
828818 ret = pamu_disable_liodn(avs1 >> PAMU_AVS1_LIODN_SHIFT);
829819 BUG_ON(ret);
830− pr_emerg("Disabling liodn %x\n", avs1 >> PAMU_AVS1_LIODN_SHIFT);
820+ pr_emerg("Disabling liodn %x\n",
821+ avs1 >> PAMU_AVS1_LIODN_SHIFT);
831822 }
832823 out_be32((p + PAMU_PICS), pics);
833824 }
834825 }
835826
836−
837827 return IRQ_HANDLED;
838828 }
839829
@@ -952,7 +942,7 @@ static int __init create_csd(phys_addr_t phys, size_t size, u32 csd_port_id) · 112 unmodified lines
952942 }
953943
954944 if (i == 0 || i == num_laws) {
955− /* This should never happen*/
945+ /* This should never happen */
956946 ret = -ENOENT;
957947 goto error;
958948 }
@@ -998,26 +988,27 @@ error: · 39 unmodified lines
998988 static const struct {
999989 u32 svr;
1000990 u32 port_id;
1001−} port_id_map[] = {
1002− {0x82100010, 0xFF000000}, /* P2040 1.0 */
1003− {0x82100011, 0xFF000000}, /* P2040 1.1 */
1004− {0x82100110, 0xFF000000}, /* P2041 1.0 */
1005− {0x82100111, 0xFF000000}, /* P2041 1.1 */
1006− {0x82110310, 0xFF000000}, /* P3041 1.0 */
1007− {0x82110311, 0xFF000000}, /* P3041 1.1 */
1008− {0x82010020, 0xFFF80000}, /* P4040 2.0 */
1009− {0x82000020, 0xFFF80000}, /* P4080 2.0 */
1010− {0x82210010, 0xFC000000}, /* P5010 1.0 */
1011− {0x82210020, 0xFC000000}, /* P5010 2.0 */
1012− {0x82200010, 0xFC000000}, /* P5020 1.0 */
1013− {0x82050010, 0xFF800000}, /* P5021 1.0 */
1014− {0x82040010, 0xFF800000}, /* P5040 1.0 */
991+} port_id_map[] __initconst = {
992+ {(SVR_P2040 << 8) | 0x10, 0xFF000000}, /* P2040 1.0 */
993+ {(SVR_P2040 << 8) | 0x11, 0xFF000000}, /* P2040 1.1 */
994+ {(SVR_P2041 << 8) | 0x10, 0xFF000000}, /* P2041 1.0 */
995+ {(SVR_P2041 << 8) | 0x11, 0xFF000000}, /* P2041 1.1 */
996+ {(SVR_P3041 << 8) | 0x10, 0xFF000000}, /* P3041 1.0 */
997+ {(SVR_P3041 << 8) | 0x11, 0xFF000000}, /* P3041 1.1 */
998+ {(SVR_P4040 << 8) | 0x20, 0xFFF80000}, /* P4040 2.0 */
999+ {(SVR_P4080 << 8) | 0x20, 0xFFF80000}, /* P4080 2.0 */
1000+ {(SVR_P5010 << 8) | 0x10, 0xFC000000}, /* P5010 1.0 */
1001+ {(SVR_P5010 << 8) | 0x20, 0xFC000000}, /* P5010 2.0 */
1002+ {(SVR_P5020 << 8) | 0x10, 0xFC000000}, /* P5020 1.0 */
1003+ {(SVR_P5021 << 8) | 0x10, 0xFF800000}, /* P5021 1.0 */
1004+ {(SVR_P5040 << 8) | 0x10, 0xFF800000}, /* P5040 1.0 */
10151005 };
10161006
10171007 #define SVR_SECURITY 0x80000 /* The Security (E) bit */
10181008
10191009 static int __init fsl_pamu_probe(struct platform_device *pdev)
10201010 {
1011+ struct device *dev = &pdev->dev;
10211012 void __iomem *pamu_regs = NULL;
10221013 struct ccsr_guts __iomem *guts_regs = NULL;
10231014 u32 pamubypenr, pamu_counter;
@@ -1042,22 +1033,21 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 18 unmodified lines
10421033 * NOTE : All PAMUs share the same LIODN tables.
10431034 */
10441035
1045− pamu_regs = of_iomap(pdev->dev.of_node, 0);
1036+ pamu_regs = of_iomap(dev->of_node, 0);
10461037 if (!pamu_regs) {
1047− dev_err(&pdev->dev, "ioremap of PAMU node failed\n");
1038+ dev_err(dev, "ioremap of PAMU node failed\n");
10481039 return -ENOMEM;
10491040 }
1050− of_get_address(pdev->dev.of_node, 0, &size, NULL);
1041+ of_get_address(dev->of_node, 0, &size, NULL);
10511042
1052− irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
1043+ irq = irq_of_parse_and_map(dev->of_node, 0);
10531044 if (irq == NO_IRQ) {
1054− dev_warn(&pdev->dev, "no interrupts listed in PAMU node\n");
1045+ dev_warn(dev, "no interrupts listed in PAMU node\n");
10551046 goto error;
10561047 }
10571048
1058− data = kzalloc(sizeof(struct pamu_isr_data), GFP_KERNEL);
1049+ data = kzalloc(sizeof(*data), GFP_KERNEL);
10591050 if (!data) {
1060− dev_err(&pdev->dev, "PAMU isr data memory allocation failed\n");
10611051 ret = -ENOMEM;
10621052 goto error;
10631053 }
@@ -1067,15 +1057,14 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 3 unmodified lines
10671057 /* The ISR needs access to the regs, so we won't iounmap them */
10681058 ret = request_irq(irq, pamu_av_isr, 0, "pamu", data);
10691059 if (ret < 0) {
1070− dev_err(&pdev->dev, "error %i installing ISR for irq %i\n",
1071− ret, irq);
1060+ dev_err(dev, "error %i installing ISR for irq %i\n", ret, irq);
10721061 goto error;
10731062 }
10741063
10751064 guts_node = of_find_matching_node(NULL, guts_device_ids);
10761065 if (!guts_node) {
1077− dev_err(&pdev->dev, "could not find GUTS node %s\n",
1078− pdev->dev.of_node->full_name);
1066+ dev_err(dev, "could not find GUTS node %s\n",
1067+ dev->of_node->full_name);
10791068 ret = -ENODEV;
10801069 goto error;
10811070 }
@@ -1083,7 +1072,7 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 1 unmodified line
10831072 guts_regs = of_iomap(guts_node, 0);
10841073 of_node_put(guts_node);
10851074 if (!guts_regs) {
1086− dev_err(&pdev->dev, "ioremap of GUTS node failed\n");
1075+ dev_err(dev, "ioremap of GUTS node failed\n");
10871076 ret = -ENODEV;
10881077 goto error;
10891078 }
@@ -1103,7 +1092,7 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 13 unmodified lines
11031092
11041093 p = alloc_pages(GFP_KERNEL | __GFP_ZERO, order);
11051094 if (!p) {
1106− dev_err(&pdev->dev, "unable to allocate PAACT/SPAACT/OMT block\n");
1095+ dev_err(dev, "unable to allocate PAACT/SPAACT/OMT block\n");
11071096 ret = -ENOMEM;
11081097 goto error;
11091098 }
@@ -1113,7 +1102,7 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 3 unmodified lines
11131102
11141103 /* Make sure the memory is naturally aligned */
11151104 if (ppaact_phys & ((PAGE_SIZE << order) - 1)) {
1116− dev_err(&pdev->dev, "PAACT/OMT block is unaligned\n");
1105+ dev_err(dev, "PAACT/OMT block is unaligned\n");
11171106 ret = -ENOMEM;
11181107 goto error;
11191108 }
@@ -1121,7 +1110,7 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 1 unmodified line
11211110 spaact = (void *)ppaact + (PAGE_SIZE << get_order(PAACT_SIZE));
11221111 omt = (void *)spaact + (PAGE_SIZE << get_order(SPAACT_SIZE));
11231112
1124− dev_dbg(&pdev->dev, "ppaact virt=%p phys=%pa\n", ppaact, &ppaact_phys);
1113+ dev_dbg(dev, "ppaact virt=%p phys=%pa\n", ppaact, &ppaact_phys);
11251114
11261115 /* Check to see if we need to implement the work-around on this SOC */
11271116
@@ -1129,21 +1118,19 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 1 unmodified line
11291118 for (i = 0; i < ARRAY_SIZE(port_id_map); i++) {
11301119 if (port_id_map[i].svr == (mfspr(SPRN_SVR) & ~SVR_SECURITY)) {
11311120 csd_port_id = port_id_map[i].port_id;
1132− dev_dbg(&pdev->dev, "found matching SVR %08x\n",
1121+ dev_dbg(dev, "found matching SVR %08x\n",
11331122 port_id_map[i].svr);
11341123 break;
11351124 }
11361125 }
11371126
11381127 if (csd_port_id) {
1139− dev_dbg(&pdev->dev, "creating coherency subdomain at address "
1140− "%pa, size %zu, port id 0x%08x", &ppaact_phys,
1141− mem_size, csd_port_id);
1128+ dev_dbg(dev, "creating coherency subdomain at address %pa, size %zu, port id 0x%08x",
1129+ &ppaact_phys, mem_size, csd_port_id);
11421130
11431131 ret = create_csd(ppaact_phys, mem_size, csd_port_id);
11441132 if (ret) {
1145− dev_err(&pdev->dev, "could not create coherence "
1146− "subdomain\n");
1133+ dev_err(dev, "could not create coherence subdomain\n");
11471134 return ret;
11481135 }
11491136 }
@@ -1154,7 +1141,7 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 4 unmodified lines
11541141 spaace_pool = gen_pool_create(ilog2(sizeof(struct paace)), -1);
11551142 if (!spaace_pool) {
11561143 ret = -ENOMEM;
1157− dev_err(&pdev->dev, "PAMU : failed to allocate spaace gen pool\n");
1144+ dev_err(dev, "Failed to allocate spaace gen pool\n");
11581145 goto error;
11591146 }
11601147
@@ -1167,9 +1154,9 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 6 unmodified lines
11671154 for (pamu_reg_off = 0, pamu_counter = 0x80000000; pamu_reg_off < size;
11681155 pamu_reg_off += PAMU_OFFSET, pamu_counter >>= 1) {
11691156
1170− pamu_reg_base = (unsigned long) pamu_regs + pamu_reg_off;
1157+ pamu_reg_base = (unsigned long)pamu_regs + pamu_reg_off;
11711158 setup_one_pamu(pamu_reg_base, pamu_reg_off, ppaact_phys,
1172− spaact_phys, omt_phys);
1159+ spaact_phys, omt_phys);
11731160 /* Disable PAMU bypass for this PAMU */
11741161 pamubypenr &= ~pamu_counter;
11751162 }
@@ -1181,7 +1168,7 @@ static int __init fsl_pamu_probe(struct platform_device *pdev) · 5 unmodified lines
11811168
11821169 iounmap(guts_regs);
11831170
1184− /* Enable DMA for the LIODNs in the device tree*/
1171+ /* Enable DMA for the LIODNs in the device tree */
11851172
11861173 setup_liodns();
11871174
drivers/iommu/fsl_pamu.h+8−7
@@ -19,13 +19,15 @@ · 18 unmodified lines
1919 #ifndef __FSL_PAMU_H
2020 #define __FSL_PAMU_H
2121
22+#include <linux/iommu.h>
23+
2224 #include <asm/fsl_pamu_stash.h>
2325
2426 /* Bit Field macros
2527 * v = bit field variable; m = mask, m##_SHIFT = shift, x = value to load
2628 */
27−#define set_bf(v, m, x) (v = ((v) & ~(m)) | (((x) << (m##_SHIFT)) & (m)))
28−#define get_bf(v, m) (((v) & (m)) >> (m##_SHIFT))
29+#define set_bf(v, m, x) (v = ((v) & ~(m)) | (((x) << m##_SHIFT) & (m)))
30+#define get_bf(v, m) (((v) & (m)) >> m##_SHIFT)
2931
3032 /* PAMU CCSR space */
3133 #define PAMU_PGC 0x00000000 /* Allows all peripheral accesses */
@@ -65,7 +67,7 @@ struct pamu_mmap_regs { · 33 unmodified lines
6567 #define PAMU_AVS1_GCV 0x2000
6668 #define PAMU_AVS1_PDV 0x4000
6769 #define PAMU_AV_MASK (PAMU_AVS1_AV | PAMU_AVS1_OTV | PAMU_AVS1_APV | PAMU_AVS1_WAV \
68− | PAMU_AVS1_LAV | PAMU_AVS1_GCV | PAMU_AVS1_PDV)
70+ | PAMU_AVS1_LAV | PAMU_AVS1_GCV | PAMU_AVS1_PDV)
6971 #define PAMU_AVS1_LIODN_SHIFT 16
7072 #define PAMU_LAV_LIODN_NOT_IN_PPAACT 0x400
7173
@@ -198,8 +200,7 @@ struct pamu_mmap_regs { · 126 unmodified lines
198200 #define PAACE_ATM_NO_XLATE 0x00
199201 #define PAACE_ATM_WINDOW_XLATE 0x01
200202 #define PAACE_ATM_PAGE_XLATE 0x02
201−#define PAACE_ATM_WIN_PG_XLATE \
202− (PAACE_ATM_WINDOW_XLATE | PAACE_ATM_PAGE_XLATE)
203+#define PAACE_ATM_WIN_PG_XLATE (PAACE_ATM_WINDOW_XLATE | PAACE_ATM_PAGE_XLATE)
203204 #define PAACE_OTM_NO_XLATE 0x00
204205 #define PAACE_OTM_IMMEDIATE 0x01
205206 #define PAACE_OTM_INDEXED 0x02
@@ -219,7 +220,7 @@ struct pamu_mmap_regs { · 13 unmodified lines
219220 #define PAACE_TCEF_FORMAT0_8B 0x00
220221 #define PAACE_TCEF_FORMAT1_RSVD 0x01
221222 /*
222− * Hard coded value for the PAACT size to accomodate
223+ * Hard coded value for the PAACT size to accommodate
223224 * maximum LIODN value generated by u-boot.
224225 */
225226 #define PAACE_NUMBER_ENTRIES 0x500
@@ -332,7 +333,7 @@ struct paace { · 106 unmodified lines
332333 #define NUM_MOE 128
333334 struct ome {
334335 u8 moe[NUM_MOE];
335−} __attribute__((packed));
336+} __packed;
336337
337338 #define PAACT_SIZE (sizeof(struct paace) * PAACE_NUMBER_ENTRIES)
338339 #define SPAACT_SIZE (sizeof(struct paace) * SPAACE_NUMBER_ENTRIES)
drivers/iommu/fsl_pamu_domain.c+74−99
@@ -19,26 +19,10 @@ · 18 unmodified lines
1919
2020 #define pr_fmt(fmt) "fsl-pamu-domain: %s: " fmt, __func__
2121
22−#include <linux/init.h>
23−#include <linux/iommu.h>
24−#include <linux/notifier.h>
25−#include <linux/slab.h>
26−#include <linux/module.h>
27−#include <linux/types.h>
28−#include <linux/mm.h>
29−#include <linux/interrupt.h>
30−#include <linux/device.h>
31−#include <linux/of_platform.h>
32−#include <linux/bootmem.h>
33−#include <linux/err.h>
34−#include <asm/io.h>
35−#include <asm/bitops.h>
36−
37−#include <asm/pci-bridge.h>
38−#include <sysdev/fsl_pci.h>
39−
4022 #include "fsl_pamu_domain.h"
4123
24+#include <sysdev/fsl_pci.h>
25+
4226 /*
4327 * Global spinlock that needs to be held while
4428 * configuring PAMU.
@@ -51,23 +35,21 @@ static DEFINE_SPINLOCK(device_domain_lock); · 6 unmodified lines
5135
5236 static int __init iommu_init_mempool(void)
5337 {
54−
5538 fsl_pamu_domain_cache = kmem_cache_create("fsl_pamu_domain",
56− sizeof(struct fsl_dma_domain),
57− 0,
58− SLAB_HWCACHE_ALIGN,
59−
60− NULL);
39+ sizeof(struct fsl_dma_domain),
40+ 0,
41+ SLAB_HWCACHE_ALIGN,
42+ NULL);
6143 if (!fsl_pamu_domain_cache) {
6244 pr_debug("Couldn't create fsl iommu_domain cache\n");
6345 return -ENOMEM;
6446 }
6547
6648 iommu_devinfo_cache = kmem_cache_create("iommu_devinfo",
67− sizeof(struct device_domain_info),
68− 0,
69− SLAB_HWCACHE_ALIGN,
70− NULL);
49+ sizeof(struct device_domain_info),
50+ 0,
51+ SLAB_HWCACHE_ALIGN,
52+ NULL);
7153 if (!iommu_devinfo_cache) {
7254 pr_debug("Couldn't create devinfo cache\n");
7355 kmem_cache_destroy(fsl_pamu_domain_cache);
@@ -80,8 +62,7 @@ static int __init iommu_init_mempool(void) · 6 unmodified lines
8062 static phys_addr_t get_phys_addr(struct fsl_dma_domain *dma_domain, dma_addr_t iova)
8163 {
8264 u32 win_cnt = dma_domain->win_cnt;
83− struct dma_window *win_ptr =
84− &dma_domain->win_arr[0];
65+ struct dma_window *win_ptr = &dma_domain->win_arr[0];
8566 struct iommu_domain_geometry *geom;
8667
8768 geom = &dma_domain->iommu_domain->geometry;
@@ -103,22 +84,20 @@ static phys_addr_t get_phys_addr(struct fsl_dma_domain *dma_domain, dma_addr_t i · 15 unmodified lines
10384 }
10485
10586 if (win_ptr->valid)
106− return (win_ptr->paddr + (iova & (win_ptr->size - 1)));
87+ return win_ptr->paddr + (iova & (win_ptr->size - 1));
10788
10889 return 0;
10990 }
11091
11192 static int map_subwins(int liodn, struct fsl_dma_domain *dma_domain)
11293 {
113− struct dma_window *sub_win_ptr =
114− &dma_domain->win_arr[0];
94+ struct dma_window *sub_win_ptr = &dma_domain->win_arr[0];
11595 int i, ret;
11696 unsigned long rpn, flags;
11797
11898 for (i = 0; i < dma_domain->win_cnt; i++) {
11999 if (sub_win_ptr[i].valid) {
120− rpn = sub_win_ptr[i].paddr >>
121− PAMU_PAGE_SHIFT;
100+ rpn = sub_win_ptr[i].paddr >> PAMU_PAGE_SHIFT;
122101 spin_lock_irqsave(&iommu_lock, flags);
123102 ret = pamu_config_spaace(liodn, dma_domain->win_cnt, i,
124103 sub_win_ptr[i].size,
@@ -130,7 +109,7 @@ static int map_subwins(int liodn, struct fsl_dma_domain *dma_domain) · 5 unmodified lines
130109 sub_win_ptr[i].prot);
131110 spin_unlock_irqrestore(&iommu_lock, flags);
132111 if (ret) {
133− pr_debug("PAMU SPAACE configuration failed for liodn %d\n",
112+ pr_debug("SPAACE configuration failed for liodn %d\n",
134113 liodn);
135114 return ret;
136115 }
@@ -156,8 +135,7 @@ static int map_win(int liodn, struct fsl_dma_domain *dma_domain) · 19 unmodified lines
156135 0, wnd->prot);
157136 spin_unlock_irqrestore(&iommu_lock, flags);
158137 if (ret)
159− pr_debug("PAMU PAACE configuration failed for liodn %d\n",
160− liodn);
138+ pr_debug("PAACE configuration failed for liodn %d\n", liodn);
161139
162140 return ret;
163141 }
@@ -169,7 +147,6 @@ static int map_liodn(int liodn, struct fsl_dma_domain *dma_domain) · 5 unmodified lines
169147 return map_subwins(liodn, dma_domain);
170148 else
171149 return map_win(liodn, dma_domain);
172−
173150 }
174151
175152 /* Update window/subwindow mapping for the LIODN */
@@ -190,7 +167,8 @@ static int update_liodn(int liodn, struct fsl_dma_domain *dma_domain, u32 wnd_nr · 14 unmodified lines
190167 (wnd_nr > 0) ? 1 : 0,
191168 wnd->prot);
192169 if (ret)
193− pr_debug("Subwindow reconfiguration failed for liodn %d\n", liodn);
170+ pr_debug("Subwindow reconfiguration failed for liodn %d\n",
171+ liodn);
194172 } else {
195173 phys_addr_t wnd_addr;
196174
@@ -200,10 +178,11 @@ static int update_liodn(int liodn, struct fsl_dma_domain *dma_domain, u32 wnd_nr · 3 unmodified lines
200178 wnd->size,
201179 ~(u32)0,
202180 wnd->paddr >> PAMU_PAGE_SHIFT,
203− dma_domain->snoop_id, dma_domain->stash_id,
204− 0, wnd->prot);
181+ dma_domain->snoop_id, dma_domain->stash_id,
182+ 0, wnd->prot);
205183 if (ret)
206− pr_debug("Window reconfiguration failed for liodn %d\n", liodn);
184+ pr_debug("Window reconfiguration failed for liodn %d\n",
185+ liodn);
207186 }
208187
209188 spin_unlock_irqrestore(&iommu_lock, flags);
@@ -212,14 +191,15 @@ static int update_liodn(int liodn, struct fsl_dma_domain *dma_domain, u32 wnd_nr · 2 unmodified lines
212191 }
213192
214193 static int update_liodn_stash(int liodn, struct fsl_dma_domain *dma_domain,
215− u32 val)
194+ u32 val)
216195 {
217196 int ret = 0, i;
218197 unsigned long flags;
219198
220199 spin_lock_irqsave(&iommu_lock, flags);
221200 if (!dma_domain->win_arr) {
222− pr_debug("Windows not configured, stash destination update failed for liodn %d\n", liodn);
201+ pr_debug("Windows not configured, stash destination update failed for liodn %d\n",
202+ liodn);
223203 spin_unlock_irqrestore(&iommu_lock, flags);
224204 return -EINVAL;
225205 }
@@ -227,7 +207,8 @@ static int update_liodn_stash(int liodn, struct fsl_dma_domain *dma_domain, · 1 unmodified line
227207 for (i = 0; i < dma_domain->win_cnt; i++) {
228208 ret = pamu_update_paace_stash(liodn, i, val);
229209 if (ret) {
230− pr_debug("Failed to update SPAACE %d field for liodn %d\n ", i, liodn);
210+ pr_debug("Failed to update SPAACE %d field for liodn %d\n ",
211+ i, liodn);
231212 spin_unlock_irqrestore(&iommu_lock, flags);
232213 return ret;
233214 }
@@ -240,9 +221,9 @@ static int update_liodn_stash(int liodn, struct fsl_dma_domain *dma_domain, · 6 unmodified lines
240221
241222 /* Set the geometry parameters for a LIODN */
242223 static int pamu_set_liodn(int liodn, struct device *dev,
243− struct fsl_dma_domain *dma_domain,
244− struct iommu_domain_geometry *geom_attr,
245− u32 win_cnt)
224+ struct fsl_dma_domain *dma_domain,
225+ struct iommu_domain_geometry *geom_attr,
226+ u32 win_cnt)
246227 {
247228 phys_addr_t window_addr, window_size;
248229 phys_addr_t subwin_size;
@@ -268,7 +249,8 @@ static int pamu_set_liodn(int liodn, struct device *dev, · 19 unmodified lines
268249 dma_domain->stash_id, win_cnt, 0);
269250 spin_unlock_irqrestore(&iommu_lock, flags);
270251 if (ret) {
271− pr_debug("PAMU PAACE configuration failed for liodn %d, win_cnt =%d\n", liodn, win_cnt);
252+ pr_debug("PAACE configuration failed for liodn %d, win_cnt =%d\n",
253+ liodn, win_cnt);
272254 return ret;
273255 }
274256
@@ -285,7 +267,8 @@ static int pamu_set_liodn(int liodn, struct device *dev, · 10 unmodified lines
285267 0, 0);
286268 spin_unlock_irqrestore(&iommu_lock, flags);
287269 if (ret) {
288− pr_debug("PAMU SPAACE configuration failed for liodn %d\n", liodn);
270+ pr_debug("SPAACE configuration failed for liodn %d\n",
271+ liodn);
289272 return ret;
290273 }
291274 }
@@ -301,13 +284,13 @@ static int check_size(u64 size, dma_addr_t iova) · 9 unmodified lines
301284 * to PAMU page size.
302285 */
303286 if ((size & (size - 1)) || size < PAMU_PAGE_SIZE) {
304− pr_debug("%s: size too small or not a power of two\n", __func__);
287+ pr_debug("Size too small or not a power of two\n");
305288 return -EINVAL;
306289 }
307290
308− /* iova must be page size aligned*/
291+ /* iova must be page size aligned */
309292 if (iova & (size - 1)) {
310− pr_debug("%s: address is not aligned with window size\n", __func__);
293+ pr_debug("Address is not aligned with window size\n");
311294 return -EINVAL;
312295 }
313296
@@ -396,16 +379,15 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d · 82 unmodified lines
396379 if (!dev->archdata.iommu_domain)
397380 dev->archdata.iommu_domain = info;
398381 spin_unlock_irqrestore(&device_domain_lock, flags);
399−
400382 }
401383
402384 static phys_addr_t fsl_pamu_iova_to_phys(struct iommu_domain *domain,
403− dma_addr_t iova)
385+ dma_addr_t iova)
404386 {
405387 struct fsl_dma_domain *dma_domain = domain->priv;
406388
407− if ((iova < domain->geometry.aperture_start) ||
408− iova > (domain->geometry.aperture_end))
389+ if (iova < domain->geometry.aperture_start ||
390+ iova > domain->geometry.aperture_end)
409391 return 0;
410392
411393 return get_phys_addr(dma_domain, iova);
@@ -460,7 +442,7 @@ static int pamu_set_domain_geometry(struct fsl_dma_domain *dma_domain, · 48 unmodified lines
460442
461443 list_for_each_entry(info, &dma_domain->devices, link) {
462444 ret = pamu_set_liodn(info->liodn, info->dev, dma_domain,
463− geom_attr, win_cnt);
445+ geom_attr, win_cnt);
464446 if (ret)
465447 break;
466448 }
@@ -543,7 +525,6 @@ static void fsl_pamu_window_disable(struct iommu_domain *domain, u32 wnd_nr) · 76 unmodified lines
543525 }
544526
545527 spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
546−
547528 }
548529
549530 static int fsl_pamu_window_enable(struct iommu_domain *domain, u32 wnd_nr,
@@ -576,7 +557,7 @@ static int fsl_pamu_window_enable(struct iommu_domain *domain, u32 wnd_nr, · 26 unmodified lines
576557
577558 win_size = dma_domain->geom_size >> ilog2(dma_domain->win_cnt);
578559 if (size > win_size) {
579− pr_debug("Invalid window size \n");
560+ pr_debug("Invalid window size\n");
580561 spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
581562 return -EINVAL;
582563 }
@@ -622,8 +603,8 @@ static int fsl_pamu_window_enable(struct iommu_domain *domain, u32 wnd_nr, · 39 unmodified lines
622603 * and window mappings.
623604 */
624605 static int handle_attach_device(struct fsl_dma_domain *dma_domain,
625− struct device *dev, const u32 *liodn,
626− int num)
606+ struct device *dev, const u32 *liodn,
607+ int num)
627608 {
628609 unsigned long flags;
629610 struct iommu_domain *domain = dma_domain->iommu_domain;
@@ -632,11 +613,10 @@ static int handle_attach_device(struct fsl_dma_domain *dma_domain, · 2 unmodified lines
632613
633614 spin_lock_irqsave(&dma_domain->domain_lock, flags);
634615 for (i = 0; i < num; i++) {
635−
636616 /* Ensure that LIODN value is valid */
637617 if (liodn[i] >= PAACE_NUMBER_ENTRIES) {
638618 pr_debug("Invalid liodn %d, attach device failed for %s\n",
639− liodn[i], dev->of_node->full_name);
619+ liodn[i], dev->of_node->full_name);
640620 ret = -EINVAL;
641621 break;
642622 }
@@ -649,9 +629,9 @@ static int handle_attach_device(struct fsl_dma_domain *dma_domain, · 6 unmodified lines
649629 */
650630 if (dma_domain->win_arr) {
651631 u32 win_cnt = dma_domain->win_cnt > 1 ? dma_domain->win_cnt : 0;
632+
652633 ret = pamu_set_liodn(liodn[i], dev, dma_domain,
653− &domain->geometry,
654− win_cnt);
634+ &domain->geometry, win_cnt);
655635 if (ret)
656636 break;
657637 if (dma_domain->mapped) {
@@ -698,19 +678,18 @@ static int fsl_pamu_attach_device(struct iommu_domain *domain, · 40 unmodified lines
698678 liodn = of_get_property(dev->of_node, "fsl,liodn", &len);
699679 if (liodn) {
700680 liodn_cnt = len / sizeof(u32);
701− ret = handle_attach_device(dma_domain, dev,
702− liodn, liodn_cnt);
681+ ret = handle_attach_device(dma_domain, dev, liodn, liodn_cnt);
703682 } else {
704683 pr_debug("missing fsl,liodn property at %s\n",
705− dev->of_node->full_name);
706− ret = -EINVAL;
684+ dev->of_node->full_name);
685+ ret = -EINVAL;
707686 }
708687
709688 return ret;
710689 }
711690
712691 static void fsl_pamu_detach_device(struct iommu_domain *domain,
713− struct device *dev)
692+ struct device *dev)
714693 {
715694 struct fsl_dma_domain *dma_domain = domain->priv;
716695 const u32 *prop;
@@ -738,7 +717,7 @@ static void fsl_pamu_detach_device(struct iommu_domain *domain, · 21 unmodified lines
738717 detach_device(dev, dma_domain);
739718 else
740719 pr_debug("missing fsl,liodn property at %s\n",
741− dev->of_node->full_name);
720+ dev->of_node->full_name);
742721 }
743722
744723 static int configure_domain_geometry(struct iommu_domain *domain, void *data)
@@ -754,10 +733,10 @@ static int configure_domain_geometry(struct iommu_domain *domain, void *data) · 9 unmodified lines
754733 * DMA outside of the geometry.
755734 */
756735 if (check_size(geom_size, geom_attr->aperture_start) ||
757− !geom_attr->force_aperture) {
758− pr_debug("Invalid PAMU geometry attributes\n");
759− return -EINVAL;
760− }
736+ !geom_attr->force_aperture) {
737+ pr_debug("Invalid PAMU geometry attributes\n");
738+ return -EINVAL;
739+ }
761740
762741 spin_lock_irqsave(&dma_domain->domain_lock, flags);
763742 if (dma_domain->enabled) {
@@ -786,7 +765,7 @@ static int configure_domain_stash(struct fsl_dma_domain *dma_domain, void *data) · 22 unmodified lines
786765 spin_lock_irqsave(&dma_domain->domain_lock, flags);
787766
788767 memcpy(&dma_domain->dma_stash, stash_attr,
789− sizeof(struct pamu_stash_attribute));
768+ sizeof(struct pamu_stash_attribute));
790769
791770 dma_domain->stash_id = get_stash_id(stash_attr->cache,
792771 stash_attr->cpu);
@@ -803,7 +782,7 @@ static int configure_domain_stash(struct fsl_dma_domain *dma_domain, void *data) · 10 unmodified lines
803782 return ret;
804783 }
805784
806−/* Configure domain dma state i.e. enable/disable DMA*/
785+/* Configure domain dma state i.e. enable/disable DMA */
807786 static int configure_domain_dma_state(struct fsl_dma_domain *dma_domain, bool enable)
808787 {
809788 struct device_domain_info *info;
@@ -819,8 +798,7 @@ static int configure_domain_dma_state(struct fsl_dma_domain *dma_domain, bool en · 9 unmodified lines
819798 }
820799
821800 dma_domain->enabled = enable;
822− list_for_each_entry(info, &dma_domain->devices,
823− link) {
801+ list_for_each_entry(info, &dma_domain->devices, link) {
824802 ret = (enable) ? pamu_enable_liodn(info->liodn) :
825803 pamu_disable_liodn(info->liodn);
826804 if (ret)
@@ -833,12 +811,11 @@ static int configure_domain_dma_state(struct fsl_dma_domain *dma_domain, bool en · 6 unmodified lines
833811 }
834812
835813 static int fsl_pamu_set_domain_attr(struct iommu_domain *domain,
836− enum iommu_attr attr_type, void *data)
814+ enum iommu_attr attr_type, void *data)
837815 {
838816 struct fsl_dma_domain *dma_domain = domain->priv;
839817 int ret = 0;
840818
841−
842819 switch (attr_type) {
843820 case DOMAIN_ATTR_GEOMETRY:
844821 ret = configure_domain_geometry(domain, data);
@@ -853,22 +830,21 @@ static int fsl_pamu_set_domain_attr(struct iommu_domain *domain, · 8 unmodified lines
853830 pr_debug("Unsupported attribute type\n");
854831 ret = -EINVAL;
855832 break;
856− };
833+ }
857834
858835 return ret;
859836 }
860837
861838 static int fsl_pamu_get_domain_attr(struct iommu_domain *domain,
862− enum iommu_attr attr_type, void *data)
839+ enum iommu_attr attr_type, void *data)
863840 {
864841 struct fsl_dma_domain *dma_domain = domain->priv;
865842 int ret = 0;
866843
867−
868844 switch (attr_type) {
869845 case DOMAIN_ATTR_FSL_PAMU_STASH:
870− memcpy((struct pamu_stash_attribute *) data, &dma_domain->dma_stash,
871− sizeof(struct pamu_stash_attribute));
846+ memcpy(data, &dma_domain->dma_stash,
847+ sizeof(struct pamu_stash_attribute));
872848 break;
873849 case DOMAIN_ATTR_FSL_PAMU_ENABLE:
874850 *(int *)data = dma_domain->enabled;
@@ -880,7 +856,7 @@ static int fsl_pamu_get_domain_attr(struct iommu_domain *domain, · 5 unmodified lines
880856 pr_debug("Unsupported attribute type\n");
881857 ret = -EINVAL;
882858 break;
883− };
859+ }
884860
885861 return ret;
886862 }
@@ -903,11 +879,8 @@ static bool check_pci_ctl_endpt_part(struct pci_controller *pci_ctl) · 16 unmodified lines
903879 /* Check the PCI controller version number by readding BRR1 register */
904880 version = in_be32(pci_ctl->cfg_addr + (PCI_FSL_BRR1 >> 2));
905881 version &= PCI_FSL_BRR1_VER;
906− /* If PCI controller version is >= 0x204 we can partition endpoints*/
907− if (version >= 0x204)
908− return 1;
909−
910− return 0;
882+ /* If PCI controller version is >= 0x204 we can partition endpoints */
883+ return version >= 0x204;
911884 }
912885
913886 /* Get iommu group information from peer devices or devices on the parent bus */
@@ -968,8 +941,9 @@ static struct iommu_group *get_pci_device_group(struct pci_dev *pdev) · 54 unmodified lines
968941 if (pci_ctl->parent->iommu_group) {
969942 group = get_device_iommu_group(pci_ctl->parent);
970943 iommu_group_remove_device(pci_ctl->parent);
971− } else
944+ } else {
972945 group = get_shared_pci_device_group(pdev);
946+ }
973947 }
974948
975949 if (!group)
@@ -1055,11 +1029,12 @@ static int fsl_pamu_set_windows(struct iommu_domain *domain, u32 w_count) · 79 unmodified lines
10551029 }
10561030
10571031 ret = pamu_set_domain_geometry(dma_domain, &domain->geometry,
1058− ((w_count > 1) ? w_count : 0));
1032+ w_count > 1 ? w_count : 0);
10591033 if (!ret) {
10601034 kfree(dma_domain->win_arr);
1061− dma_domain->win_arr = kzalloc(sizeof(struct dma_window) *
1062− w_count, GFP_ATOMIC);
1035+ dma_domain->win_arr = kcalloc(w_count,
1036+ sizeof(*dma_domain->win_arr),
1037+ GFP_ATOMIC);
10631038 if (!dma_domain->win_arr) {
10641039 spin_unlock_irqrestore(&dma_domain->domain_lock, flags);
10651040 return -ENOMEM;
@@ -1095,7 +1070,7 @@ static const struct iommu_ops fsl_pamu_ops = { · 29 unmodified lines
10951070 .remove_device = fsl_pamu_remove_device,
10961071 };
10971072
1098−int pamu_domain_init(void)
1073+int __init pamu_domain_init(void)
10991074 {
11001075 int ret = 0;
11011076

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t