Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* an initial RISC-V Linux 4.18 tree
@ 2018-06-19 17:14 Christoph Hellwig
  2018-06-20 17:50 ` Atish Patra
  2018-06-20 17:59 ` Palmer Dabbelt
  0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2018-06-19 17:14 UTC (permalink / raw)
  To: linux-riscv

Hi all,

there had been some requests for a more updated working RISC-V
tree.  Based on that I decided that instead of a private working
tree for 4.18 I'd start a public tree:

    git://git.infradead.org/users/hch/riscv.git riscv-linux-4.18

Gitweb:

    http://git.infradead.org/users/hch/riscv.git/shortlog/refs/heads/riscv-linux-4.18

For now this just contains core patches, that is whatever I want/need
on Qemu, or what looks like it.  I've also done all the usual cleanups
to get the code submission ready, the only exception is the
documentation of the PLIC register map as pointed out by Jonathan last
time around - I'll need someone more familiar with the hardware and
driver to fix that up.

Except for that the patches should be good to be submitted, I can
help a bit with that, but in general having the original authors submit
it would be preferred.

The tree is going to get rebased as needed.

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

* an initial RISC-V Linux 4.18 tree
  2018-06-19 17:14 an initial RISC-V Linux 4.18 tree Christoph Hellwig
@ 2018-06-20 17:50 ` Atish Patra
  2018-06-20 17:59 ` Palmer Dabbelt
  1 sibling, 0 replies; 6+ messages in thread
From: Atish Patra @ 2018-06-20 17:50 UTC (permalink / raw)
  To: linux-riscv

On 6/19/18 10:15 AM, Christoph Hellwig wrote:
> Hi all,
> 
> there had been some requests for a more updated working RISC-V
> tree.  Based on that I decided that instead of a private working
> tree for 4.18 I'd start a public tree:
> 
>      git://git.infradead.org/users/hch/riscv.git riscv-linux-4.18
> 
> Gitweb:
> 
>      http://git.infradead.org/users/hch/riscv.git/shortlog/refs/heads/riscv-linux-4.18
> 
There are some other timer related patches present in palmer?s wip_timer 
branch.
https://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git/log/?h=wip-timer

(I have few of them as well)

Should I rebase my/other patches on top of your repo and resend?

Regards,
Atish

> For now this just contains core patches, that is whatever I want/need
> on Qemu, or what looks like it.  I've also done all the usual cleanups
> to get the code submission ready, the only exception is the
> documentation of the PLIC register map as pointed out by Jonathan last
> time around - I'll need someone more familiar with the hardware and
> driver to fix that up.
> 
> Except for that the patches should be good to be submitted, I can
> help a bit with that, but in general having the original authors submit
> it would be preferred.
> 
> The tree is going to get rebased as needed.
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
> 

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

* an initial RISC-V Linux 4.18 tree
  2018-06-19 17:14 an initial RISC-V Linux 4.18 tree Christoph Hellwig
  2018-06-20 17:50 ` Atish Patra
@ 2018-06-20 17:59 ` Palmer Dabbelt
  2018-06-21  6:30   ` Christoph Hellwig
  1 sibling, 1 reply; 6+ messages in thread
From: Palmer Dabbelt @ 2018-06-20 17:59 UTC (permalink / raw)
  To: linux-riscv

On Tue, 19 Jun 2018 10:14:44 PDT (-0700), Christoph Hellwig wrote:
> Hi all,
>
> there had been some requests for a more updated working RISC-V
> tree.  Based on that I decided that instead of a private working
> tree for 4.18 I'd start a public tree:
>
>     git://git.infradead.org/users/hch/riscv.git riscv-linux-4.18
>
> Gitweb:
>
>     http://git.infradead.org/users/hch/riscv.git/shortlog/refs/heads/riscv-linux-4.18
>
> For now this just contains core patches, that is whatever I want/need
> on Qemu, or what looks like it.  I've also done all the usual cleanups
> to get the code submission ready, the only exception is the
> documentation of the PLIC register map as pointed out by Jonathan last
> time around - I'll need someone more familiar with the hardware and
> driver to fix that up.
>
> Except for that the patches should be good to be submitted, I can
> help a bit with that, but in general having the original authors submit
> it would be preferred.
>
> The tree is going to get rebased as needed.

Thanks.  Unfortunately I think some of these aren't actually ready to go, which 
is why they've been blocked for a bit:

* d0789843f663 (irqchip: RISC-V Local Interrupt Controller Driver): This still 
  calls riscv_*_interrupt(), which we need to refactor to live behind a more 
  generic interface.
* 8f9146865931 ("irqchip: New RISC-V PLIC Driver"): Aside from the memory map 
  questions you mentioned, there's also some question as to what IRQ handling 
  flow we should use and how to properly register interrupts for harts that are 
  not yet alive.
* 5b6b2ec0ed9c ("clocksource: new RISC-V SBI timer driver"): This still uses 
  riscv_timebase, which isn't a sane interface.
* 3aa32277ef89 ("base: fix order of OF initialization"): IIRC this was supposed 
  to be solved in some other way, but I've managed to forget exactly what the 
  comments were.

It's possible I'm too worried about decoupling the drivers from the arch code.  
If that's the case then I don't mind submitting these patches now, as at least 
we'll be able to have everything in master.

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

* an initial RISC-V Linux 4.18 tree
  2018-06-20 17:59 ` Palmer Dabbelt
@ 2018-06-21  6:30   ` Christoph Hellwig
  2018-06-21 13:58     ` Christoph Hellwig
  2018-06-21 16:06     ` Palmer Dabbelt
  0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2018-06-21  6:30 UTC (permalink / raw)
  To: linux-riscv

On Wed, Jun 20, 2018 at 10:59:59AM -0700, Palmer Dabbelt wrote:
> Thanks.  Unfortunately I think some of these aren't actually ready to go,
> which is why they've been blocked for a bit:
> 
> * d0789843f663 (irqchip: RISC-V Local Interrupt Controller Driver): This
> still  calls riscv_*_interrupt(), which we need to refactor to live behind a
> more  generic interface.

I don't really think that is a problem.  Especially in the irq path
I'd rather avoid indirections than spuriously adding them.

> * 8f9146865931 ("irqchip: New RISC-V PLIC Driver"): Aside from the memory
> map  questions you mentioned, there's also some question as to what IRQ
> handling  flow we should use and how to properly register interrupts for
> harts that are  not yet alive.

Is this an urgen problem?

> * 5b6b2ec0ed9c ("clocksource: new RISC-V SBI timer driver"): This still uses
> riscv_timebase, which isn't a sane interface.

It's not really too bad.  Yes, based on some of your work it should be
per-hart, but that is something that can be easily fixed up.

> * 3aa32277ef89 ("base: fix order of OF initialization"): IIRC this was
> supposed  to be solved in some other way, but I've managed to forget exactly
> what the  comments were.
> 
> It's possible I'm too worried about decoupling the drivers from the arch
> code.  If that's the case then I don't mind submitting these patches now, as
> at least we'll be able to have everything in master.

These aren't really drivers, but they are arch code, so I really don't
think they should be decoupled for decouplings sake.

So if you have an update for the PLIC memory map I'd really like to
start submitting them so that we have an actually working RISC-V port
upstream.

Btw, the early console code doesn't seem to have any further
dependencies, any chance you could just send that on to Linus at the
next opportunity?

> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
---end quoted text---

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

* an initial RISC-V Linux 4.18 tree
  2018-06-21  6:30   ` Christoph Hellwig
@ 2018-06-21 13:58     ` Christoph Hellwig
  2018-06-21 16:06     ` Palmer Dabbelt
  1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2018-06-21 13:58 UTC (permalink / raw)
  To: linux-riscv

What about just removing the register map comment entirely, and
instead just use ?elf-describing macros for addressing, inspired
by the FreeBSD PLIC driver:

diff --git a/drivers/irqchip/irq-riscv-plic.c b/drivers/irqchip/irq-riscv-plic.c
index 395b8e7c17f4..3b9ada3a6f8a 100644
--- a/drivers/irqchip/irq-riscv-plic.c
+++ b/drivers/irqchip/irq-riscv-plic.c
@@ -35,64 +35,24 @@
 #define MAX_CONTEXTS	15872
 
 /*
- * The PLIC consists of memory-mapped control registers, with a memory map as
- * follows:
- *
- * base + 0x000000: Reserved (interrupt source 0 does not exist)
- * base + 0x000004: Interrupt source 1 priority
- * base + 0x000008: Interrupt source 2 priority
- * ...
- * base + 0x000FFC: Interrupt source 1023 priority
- * base + 0x001000: Pending 0
- * base + 0x001FFF: Pending
- * base + 0x002000: Enable bits for sources 0-31 on context 0
- * base + 0x002004: Enable bits for sources 32-63 on context 0
- * ...
- * base + 0x0020FC: Enable bits for sources 992-1023 on context 0
- * base + 0x002080: Enable bits for sources 0-31 on context 1
- * ...
- * base + 0x002100: Enable bits for sources 0-31 on context 2
- * ...
- * base + 0x1F1F80: Enable bits for sources 992-1023 on context 15871
- * base + 0x1F1F84: Reserved
- * ...              (higher context IDs would fit here, but wouldn't fit
- *                   inside the per-context priority vector)
- * base + 0x1FFFFC: Reserved
- * base + 0x200000: Priority threshold for context 0
- * base + 0x200004: Claim/complete for context 0
- * base + 0x200008: Reserved
- * ...
- * base + 0x200FFC: Reserved
- * base + 0x201000: Priority threshold for context 1
- * base + 0x201004: Claim/complete for context 1
- * ...
- * base + 0xFFE000: Priority threshold for context 15871
- * base + 0xFFE004: Claim/complete for context 15871
- * base + 0xFFE008: Reserved
- * ...
- * base + 0xFFFFFC: Reserved
+ * Each interrupt source has a priority register associated with it.
+ * (although for now we always assign a priority of 0).
  */
-
-/* Each interrupt source has a priority register associated with it. */
-#define PRIORITY_BASE		0
-#define PRIORITY_PER_ID		4
+#define PLIC_PRIORITY(irq)		(0x000000 + (irq) * 0x4)
 
 /*
  * Each hart context has a vector of interrupt enable bits associated with it.
  * There's one bit for each interrupt source.
  */
-#define ENABLE_BASE		0x2000
-#define ENABLE_PER_HART		0x80
+#define PLIC_ENABLE(ctxid, irq)		(0x002000 + (ctxid) * 0x80 + (irq) / 32)
 
 /*
  * Each hart context has a set of control registers associated with it.  Right
  * now there's only two: a source priority threshold over which the hart will
  * take an interrupt, and a register to claim interrupts.
  */
-#define CONTEXT_BASE		0x200000
-#define CONTEXT_PER_HART	0x1000
-#define CONTEXT_THRESHOLD	0
-#define CONTEXT_CLAIM		4
+#define PLIC_THRESHOLD(ctxid)		(0x200000 + (ctxid) * 0x1000 + 0x0)
+#define PLIC_CLAIM(ctxid)		(0x200000 + (ctxid) * 0x1000 + 0x4)
 
 /*
  * PLIC devices are named like 'riscv,plic0,%llx', this is enough space to
@@ -117,32 +77,6 @@ struct plic_data {
 	spinlock_t		lock;
 };
 
-/* Addressing helper functions. */
-static inline u32 __iomem *plic_enable_vector(struct plic_data *data,
-		int contextid)
-{
-	return data->reg + ENABLE_BASE + contextid * ENABLE_PER_HART;
-}
-
-static inline u32 __iomem *plic_priority(struct plic_data *data, int hwirq)
-{
-	return data->reg + PRIORITY_BASE + hwirq * PRIORITY_PER_ID;
-}
-
-static inline u32 __iomem *plic_hart_threshold(struct plic_data *data,
-		int contextid)
-{
-	return data->reg + CONTEXT_BASE + CONTEXT_PER_HART * contextid +
-			CONTEXT_THRESHOLD;
-}
-
-static inline u32 __iomem *plic_hart_claim(struct plic_data *data,
-		int contextid)
-{
-	return data->reg + CONTEXT_BASE + CONTEXT_PER_HART * contextid +
-			CONTEXT_CLAIM;
-}
-
 /*
  * Handling an interrupt is a two-step process: first you claim the interrupt
  * by reading the claim register, then you complete the interrupt by writing
@@ -151,33 +85,33 @@ static inline u32 __iomem *plic_hart_claim(struct plic_data *data,
  */
 static inline u32 plic_claim(struct plic_data *data, int contextid)
 {
-	return readl(plic_hart_claim(data, contextid));
+	return readl(data->reg + PLIC_CLAIM(contextid));
 }
 
-static inline void
-plic_complete(struct plic_data *data, int contextid, u32 claim)
+static inline void plic_complete(struct plic_data *data, int contextid,
+		u32 claim)
 {
-	writel(claim, plic_hart_claim(data, contextid));
+	writel(claim, data->reg + PLIC_CLAIM(contextid));
 }
 
 /* Explicit interrupt masking. */
 static void plic_disable(struct plic_data *data, int contextid, int hwirq)
 {
-	u32 __iomem *reg = plic_enable_vector(data, contextid) + (hwirq / 32);
+	u32 off = PLIC_ENABLE(contextid, hwirq);
 	u32 mask = ~(1 << (hwirq % 32));
 
 	spin_lock(&data->lock);
-	writel(readl(reg) & mask, reg);
+	writel(readl(data->reg + off) & mask, data->reg + off);
 	spin_unlock(&data->lock);
 }
 
 static void plic_enable(struct plic_data *data, int contextid, int hwirq)
 {
-	u32 __iomem *reg = plic_enable_vector(data, contextid) + (hwirq / 32);
+	u32 off = PLIC_ENABLE(contextid, hwirq);
 	u32 bit = 1 << (hwirq % 32);
 
 	spin_lock(&data->lock);
-	writel(readl(reg) | bit, reg);
+	writel(readl(data->reg + off) | bit, data->reg + off);
 	spin_unlock(&data->lock);
 }
 
@@ -188,6 +122,7 @@ static void plic_enable(struct plic_data *data, int contextid, int hwirq)
 static void plic_irq_mask(struct irq_data *d)
 {
 }
+
 static void plic_irq_unmask(struct irq_data *d)
 {
 }
@@ -195,10 +130,9 @@ static void plic_irq_unmask(struct irq_data *d)
 static void plic_irq_enable(struct irq_data *d)
 {
 	struct plic_data *data = irq_data_get_irq_chip_data(d);
-	void __iomem *priority = plic_priority(data, d->hwirq);
 	int i;
 
-	writel(1, priority);
+	writel(0, data->reg + PLIC_PRIORITY(d->hwirq));
 	for (i = 0; i < data->handlers; ++i)
 		if (data->handler[i].present)
 			plic_enable(data, i, d->hwirq);
@@ -207,10 +141,9 @@ static void plic_irq_enable(struct irq_data *d)
 static void plic_irq_disable(struct irq_data *d)
 {
 	struct plic_data *data = irq_data_get_irq_chip_data(d);
-	void __iomem *priority = plic_priority(data, d->hwirq);
 	int i;
 
-	writel(0, priority);
+	writel(0, data->reg + PLIC_PRIORITY(d->hwirq));
 	for (i = 0; i < data->handlers; ++i)
 		if (data->handler[i].present)
 			plic_disable(data, i, d->hwirq);
@@ -337,7 +270,7 @@ static int plic_init(struct device_node *node, struct device_node *parent)
 		handler->contextid = i;
 		handler->data = data;
 		/* hwirq prio must be > this to trigger an interrupt */
-		writel(0, plic_hart_threshold(data, i));
+		writel(0, data->reg + PLIC_THRESHOLD(i));
 
 		for (hwirq = 1; hwirq <= data->ndev; ++hwirq)
 			plic_disable(data, i, hwirq);

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

* an initial RISC-V Linux 4.18 tree
  2018-06-21  6:30   ` Christoph Hellwig
  2018-06-21 13:58     ` Christoph Hellwig
@ 2018-06-21 16:06     ` Palmer Dabbelt
  1 sibling, 0 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-06-21 16:06 UTC (permalink / raw)
  To: linux-riscv

On Wed, 20 Jun 2018 23:30:14 PDT (-0700), Christoph Hellwig wrote:
> On Wed, Jun 20, 2018 at 10:59:59AM -0700, Palmer Dabbelt wrote:
>> Thanks.  Unfortunately I think some of these aren't actually ready to go,
>> which is why they've been blocked for a bit:
>>
>> * d0789843f663 (irqchip: RISC-V Local Interrupt Controller Driver): This
>> still  calls riscv_*_interrupt(), which we need to refactor to live behind a
>> more  generic interface.
>
> I don't really think that is a problem.  Especially in the irq path
> I'd rather avoid indirections than spuriously adding them.
>
>> * 8f9146865931 ("irqchip: New RISC-V PLIC Driver"): Aside from the memory
>> map  questions you mentioned, there's also some question as to what IRQ
>> handling  flow we should use and how to properly register interrupts for
>> harts that are  not yet alive.
>
> Is this an urgen problem?
>
>> * 5b6b2ec0ed9c ("clocksource: new RISC-V SBI timer driver"): This still uses
>> riscv_timebase, which isn't a sane interface.
>
> It's not really too bad.  Yes, based on some of your work it should be
> per-hart, but that is something that can be easily fixed up.
>
>> * 3aa32277ef89 ("base: fix order of OF initialization"): IIRC this was
>> supposed  to be solved in some other way, but I've managed to forget exactly
>> what the  comments were.
>>
>> It's possible I'm too worried about decoupling the drivers from the arch
>> code.  If that's the case then I don't mind submitting these patches now, as
>> at least we'll be able to have everything in master.
>
> These aren't really drivers, but they are arch code, so I really don't
> think they should be decoupled for decouplings sake.
>
> So if you have an update for the PLIC memory map I'd really like to
> start submitting them so that we have an actually working RISC-V port
> upstream.
>
> Btw, the early console code doesn't seem to have any further
> dependencies, any chance you could just send that on to Linus at the
> next opportunity?

If you think they're in good enough shape then I don't mind submitting them.  
I'll start sending out patches.

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

end of thread, other threads:[~2018-06-21 16:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-19 17:14 an initial RISC-V Linux 4.18 tree Christoph Hellwig
2018-06-20 17:50 ` Atish Patra
2018-06-20 17:59 ` Palmer Dabbelt
2018-06-21  6:30   ` Christoph Hellwig
2018-06-21 13:58     ` Christoph Hellwig
2018-06-21 16:06     ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox