All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] bcma: add empty PCIe hostmode functions if support is disabled
@ 2015-01-25 10:11 Rafał Miłecki
  2015-01-25 10:11 ` [PATCH 2/2] bcma: add early_init function for PCIe core and move some fix into it Rafał Miłecki
  2015-01-25 13:02 ` [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled Rafał Miłecki
  0 siblings, 2 replies; 7+ messages in thread
From: Rafał Miłecki @ 2015-01-25 10:11 UTC (permalink / raw)
  To: Kalle Valo, linux-wireless; +Cc: Hauke Mehrtens, Rafał Miłecki

This allows us to drop some #ifdef magic (mess).

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 drivers/bcma/bcma_private.h | 10 +++++++++-
 drivers/bcma/driver_pci.c   |  2 --
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 3f314c9..3242655 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -92,7 +92,7 @@ extern void __exit bcma_host_soc_unregister_driver(void);
 #else
 static inline int __init bcma_host_soc_register_driver(void)
 {
-	return 0;
+	return false;
 }
 static inline void __exit bcma_host_soc_unregister_driver(void)
 {
@@ -107,6 +107,14 @@ extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
 bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
 void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
+#else
+static inline bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
+{
+	return 0;
+}
+static inline void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
+{
+}
 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
 
 #ifdef CONFIG_BCMA_DRIVER_GPIO
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index 50329d1..b85a505 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -226,11 +226,9 @@ void bcma_core_pci_init(struct bcma_drv_pci *pc)
 	if (pc->setup_done)
 		return;
 
-#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
 	pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
 	if (pc->hostmode)
 		bcma_core_pci_hostmode_init(pc);
-#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
 
 	if (!pc->hostmode)
 		bcma_core_pci_clientmode_init(pc);
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] bcma: add early_init function for PCIe core and move some fix into it
  2015-01-25 10:11 [PATCH 1/2] bcma: add empty PCIe hostmode functions if support is disabled Rafał Miłecki
@ 2015-01-25 10:11 ` Rafał Miłecki
  2015-01-25 13:02 ` [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled Rafał Miłecki
  1 sibling, 0 replies; 7+ messages in thread
From: Rafał Miłecki @ 2015-01-25 10:11 UTC (permalink / raw)
  To: Kalle Valo, linux-wireless; +Cc: Hauke Mehrtens, Rafał Miłecki

There are some PCIe core fixes that need to be applied before accessing
SPROM, otherwise reading it may fail.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
This patch may make checkpatch.pl complain about line over 80 columns, but I
only moved this line from another place and it's a bit hard to make it fit 80
columns anyway.
---
 drivers/bcma/driver_pci.c            | 66 ++++++++++++++++++++++++------------
 drivers/bcma/main.c                  |  7 ++++
 include/linux/bcma/bcma_driver_pci.h |  2 ++
 3 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index b85a505..7866664 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -145,6 +145,47 @@ static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device,
 }
 
 /**************************************************
+ * Early init.
+ **************************************************/
+
+static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
+{
+	struct bcma_device *core = pc->core;
+	u16 val16, core_index;
+	uint regoff;
+
+	regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
+	core_index = (u16)core->core_index;
+
+	val16 = pcicore_read16(pc, regoff);
+	if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
+	     != core_index) {
+		val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
+			(val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
+		pcicore_write16(pc, regoff, val16);
+	}
+}
+
+/*
+ * Apply some early fixes required before accessing SPROM.
+ * See also si_pci_fixcfg.
+ */
+void bcma_core_pci_early_init(struct bcma_drv_pci *pc)
+{
+	if (pc->early_setup_done)
+		return;
+
+	pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
+	if (pc->hostmode)
+		goto out;
+
+	bcma_core_pci_fixcfg(pc);
+
+out:
+	pc->early_setup_done = true;
+}
+
+/**************************************************
  * Workarounds.
  **************************************************/
 
@@ -175,24 +216,6 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
 		                     tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
 }
 
-static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
-{
-	struct bcma_device *core = pc->core;
-	u16 val16, core_index;
-	uint regoff;
-
-	regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
-	core_index = (u16)core->core_index;
-
-	val16 = pcicore_read16(pc, regoff);
-	if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
-	     != core_index) {
-		val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
-			(val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
-		pcicore_write16(pc, regoff, val16);
-	}
-}
-
 /* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */
 /* Needs to happen when coming out of 'standby'/'hibernate' */
 static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc)
@@ -216,7 +239,6 @@ static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc)
 
 static void bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
 {
-	bcma_core_pci_fixcfg(pc);
 	bcma_pcicore_serdes_workaround(pc);
 	bcma_core_pci_config_fixup(pc);
 }
@@ -226,11 +248,11 @@ void bcma_core_pci_init(struct bcma_drv_pci *pc)
 	if (pc->setup_done)
 		return;
 
-	pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
+	bcma_core_pci_early_init(pc);
+
 	if (pc->hostmode)
 		bcma_core_pci_hostmode_init(pc);
-
-	if (!pc->hostmode)
+	else
 		bcma_core_pci_clientmode_init(pc);
 }
 
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 73b2ee3..38bde6e 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -402,6 +402,13 @@ int bcma_bus_register(struct bcma_bus *bus)
 		bcma_core_chipcommon_early_init(&bus->drv_cc);
 	}
 
+	/* Early init PCIE core */
+	core = bcma_find_core(bus, BCMA_CORE_PCIE);
+	if (core) {
+		bus->drv_pci[0].core = core;
+		bcma_core_pci_early_init(&bus->drv_pci[0]);
+	}
+
 	/* Cores providing flash access go before SPROM init */
 	list_for_each_entry(core, &bus->cores, list) {
 		if (bcma_is_core_needed_early(core->id.id))
diff --git a/include/linux/bcma/bcma_driver_pci.h b/include/linux/bcma/bcma_driver_pci.h
index 0333e60..3f809ae 100644
--- a/include/linux/bcma/bcma_driver_pci.h
+++ b/include/linux/bcma/bcma_driver_pci.h
@@ -223,6 +223,7 @@ struct bcma_drv_pci_host {
 
 struct bcma_drv_pci {
 	struct bcma_device *core;
+	u8 early_setup_done:1;
 	u8 setup_done:1;
 	u8 hostmode:1;
 
@@ -237,6 +238,7 @@ struct bcma_drv_pci {
 #define pcicore_write16(pc, offset, val)	bcma_write16((pc)->core, offset, val)
 #define pcicore_write32(pc, offset, val)	bcma_write32((pc)->core, offset, val)
 
+extern void bcma_core_pci_early_init(struct bcma_drv_pci *pc);
 extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
 				 struct bcma_device *core, bool enable);
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled
  2015-01-25 10:11 [PATCH 1/2] bcma: add empty PCIe hostmode functions if support is disabled Rafał Miłecki
  2015-01-25 10:11 ` [PATCH 2/2] bcma: add early_init function for PCIe core and move some fix into it Rafał Miłecki
@ 2015-01-25 13:02 ` Rafał Miłecki
  2015-01-26  6:58   ` Kalle Valo
  1 sibling, 1 reply; 7+ messages in thread
From: Rafał Miłecki @ 2015-01-25 13:02 UTC (permalink / raw)
  To: Kalle Valo, linux-wireless; +Cc: Hauke Mehrtens, Rafał Miłecki

This allows us to drop some #ifdef magic (mess).

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
V2: Return false in bcma_core_pci_is_in_hostmode
    Don't (accidentally) modify bcma_host_soc_register_driver
---
 drivers/bcma/bcma_private.h | 8 ++++++++
 drivers/bcma/driver_pci.c   | 2 --
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/bcma/bcma_private.h b/drivers/bcma/bcma_private.h
index 3f314c9..ac6c5fc 100644
--- a/drivers/bcma/bcma_private.h
+++ b/drivers/bcma/bcma_private.h
@@ -107,6 +107,14 @@ extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
 #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
 bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
 void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
+#else
+static inline bool bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc)
+{
+	return false;
+}
+static inline void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
+{
+}
 #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
 
 #ifdef CONFIG_BCMA_DRIVER_GPIO
diff --git a/drivers/bcma/driver_pci.c b/drivers/bcma/driver_pci.c
index 50329d1..b85a505 100644
--- a/drivers/bcma/driver_pci.c
+++ b/drivers/bcma/driver_pci.c
@@ -226,11 +226,9 @@ void bcma_core_pci_init(struct bcma_drv_pci *pc)
 	if (pc->setup_done)
 		return;
 
-#ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
 	pc->hostmode = bcma_core_pci_is_in_hostmode(pc);
 	if (pc->hostmode)
 		bcma_core_pci_hostmode_init(pc);
-#endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
 
 	if (!pc->hostmode)
 		bcma_core_pci_clientmode_init(pc);
-- 
1.8.4.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled
  2015-01-25 13:02 ` [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled Rafał Miłecki
@ 2015-01-26  6:58   ` Kalle Valo
  2015-01-26  8:11     ` Rafał Miłecki
  0 siblings, 1 reply; 7+ messages in thread
From: Kalle Valo @ 2015-01-26  6:58 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: linux-wireless, Hauke Mehrtens

Rafał Miłecki <zajec5@gmail.com> writes:

> This allows us to drop some #ifdef magic (mess).
>
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
> V2: Return false in bcma_core_pci_is_in_hostmode
>     Don't (accidentally) modify bcma_host_soc_register_driver

It would be far more reliable if you resend the whole patchset instead
of resending invidiviual patches within the set. Otherwise the chances
are that I apply the wrong version.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled
  2015-01-26  6:58   ` Kalle Valo
@ 2015-01-26  8:11     ` Rafał Miłecki
  2015-01-26 12:31       ` Kalle Valo
  0 siblings, 1 reply; 7+ messages in thread
From: Rafał Miłecki @ 2015-01-26  8:11 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless, Hauke Mehrtens

On 26 January 2015 at 07:58, Kalle Valo <kvalo@codeaurora.org> wrote:
> Rafał Miłecki <zajec5@gmail.com> writes:
>
>> This allows us to drop some #ifdef magic (mess).
>>
>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
>> ---
>> V2: Return false in bcma_core_pci_is_in_hostmode
>>     Don't (accidentally) modify bcma_host_soc_register_driver
>
> It would be far more reliable if you resend the whole patchset instead
> of resending invidiviual patches within the set. Otherwise the chances
> are that I apply the wrong version.

Oops. I always take care of removing old versions from patchwork and
using --in-reply-to, I was hoping it's OK.

How would you like whole patches to be re-send? Should I resend them
independently? Or should every patch from the patchset include
In-Reply-To pointing to its previous version?

Is this just an advise for the future, or would you like me to resend
this patchset too?

-- 
Rafał

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled
  2015-01-26  8:11     ` Rafał Miłecki
@ 2015-01-26 12:31       ` Kalle Valo
  2015-01-26 16:17         ` Rafał Miłecki
  0 siblings, 1 reply; 7+ messages in thread
From: Kalle Valo @ 2015-01-26 12:31 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: linux-wireless, Hauke Mehrtens

Rafał Miłecki <zajec5@gmail.com> writes:

> On 26 January 2015 at 07:58, Kalle Valo <kvalo@codeaurora.org> wrote:
>> Rafał Miłecki <zajec5@gmail.com> writes:
>>
>>> This allows us to drop some #ifdef magic (mess).
>>>
>>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
>>> ---
>>> V2: Return false in bcma_core_pci_is_in_hostmode
>>>     Don't (accidentally) modify bcma_host_soc_register_driver
>>
>> It would be far more reliable if you resend the whole patchset instead
>> of resending invidiviual patches within the set. Otherwise the chances
>> are that I apply the wrong version.
>
> Oops. I always take care of removing old versions from patchwork

Yeah, I noticed that. That's really helpful, thanks for that.

> and using --in-reply-to, I was hoping it's OK.

But still ordering is different which might introduce problems while I
apply them. And like in your case, when I have to take the patches from
email due to UTF-8 problems, it won't work at all.

> How would you like whole patches to be re-send? Should I resend them
> independently? Or should every patch from the patchset include
> In-Reply-To pointing to its previous version?

Let's say you have a ten patch patchset and you have to change something
in patch 3. I would prefer that you resend the whole patchset (all 10
patches) and each patch in the patchset has "v2". So the version is
actually version of the patchset, not of the individual patch.

I assumed this was standard practice everywhere in the kernel, but I
guess I was wrong.

> Is this just an advise for the future, or would you like me to resend
> this patchset too?

For the future.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled
  2015-01-26 12:31       ` Kalle Valo
@ 2015-01-26 16:17         ` Rafał Miłecki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafał Miłecki @ 2015-01-26 16:17 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless, Hauke Mehrtens

On 26 January 2015 at 13:31, Kalle Valo <kvalo@codeaurora.org> wrote:
> Rafał Miłecki <zajec5@gmail.com> writes:
>
>> On 26 January 2015 at 07:58, Kalle Valo <kvalo@codeaurora.org> wrote:
>>> Rafał Miłecki <zajec5@gmail.com> writes:
>>>
>>>> This allows us to drop some #ifdef magic (mess).
>>>>
>>>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
>>>> ---
>>>> V2: Return false in bcma_core_pci_is_in_hostmode
>>>>     Don't (accidentally) modify bcma_host_soc_register_driver
>>>
>>> It would be far more reliable if you resend the whole patchset instead
>>> of resending invidiviual patches within the set. Otherwise the chances
>>> are that I apply the wrong version.
>>
>> Oops. I always take care of removing old versions from patchwork
>
> Yeah, I noticed that. That's really helpful, thanks for that.
>
>> and using --in-reply-to, I was hoping it's OK.
>
> But still ordering is different which might introduce problems while I
> apply them. And like in your case, when I have to take the patches from
> email due to UTF-8 problems, it won't work at all.
>
>> How would you like whole patches to be re-send? Should I resend them
>> independently? Or should every patch from the patchset include
>> In-Reply-To pointing to its previous version?
>
> Let's say you have a ten patch patchset and you have to change something
> in patch 3. I would prefer that you resend the whole patchset (all 10
> patches) and each patch in the patchset has "v2". So the version is
> actually version of the patchset, not of the individual patch.
>
> I assumed this was standard practice everywhere in the kernel, but I
> guess I was wrong.

It could be just me, maybe I just didn't meet anyone complaining yet.

Thanks a lot for your help!

-- 
Rafał

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-26 16:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-25 10:11 [PATCH 1/2] bcma: add empty PCIe hostmode functions if support is disabled Rafał Miłecki
2015-01-25 10:11 ` [PATCH 2/2] bcma: add early_init function for PCIe core and move some fix into it Rafał Miłecki
2015-01-25 13:02 ` [PATCH V2 1/2] bcma: add empty PCIe hostmode functions if support is disabled Rafał Miłecki
2015-01-26  6:58   ` Kalle Valo
2015-01-26  8:11     ` Rafał Miłecki
2015-01-26 12:31       ` Kalle Valo
2015-01-26 16:17         ` Rafał Miłecki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.