[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Aw: Re: [PATCH] Make EHCI driver interrupt handler follow PCI-BIOS specification.



> Gesendet: Mittwoch, 08. Oktober 2014 um 17:56 Uhr
> Von: "Alan Hourihane" <alanh@fairlite.co.uk>
> An: mint@lists.fishpool.fi
> Betreff: Re: [MiNT] [PATCH] Make EHCI driver interrupt handler follow PCI-BIOS specification.

> I think you're just being lucky, because you restore the registers later.
> 
> But essentially, I think this step is a no-op, because GCC will save/restore
> it's accessed registers anyway.

only true for registers that gcc doesn't consider scratch (d0-d1/a0-a1). Those will not be restored, you need to take care of them yourself. At least within interrupt handlers.

> 
> Also, you save/restore D1/A1 but the comment says D0/A0.
> 
the comment says d0/a0 are allowed to be garbled, so he consequently saves and restores only d0/d1. This is correct.

The code _might_ even work (by chance) since the function doesn't have any parameters and doesn't call any function with parameters itself (ehci_writel() and ehci_readl() are just macros). As long as gcc has enough registers at its disposal, it probably won't touch the stack.

But such programming habit is of course very fragile and dangerous and should be avoided. Just adding another variable can break everything.

@David: also note that asm() statements without "memory" in their clobber list are subject to being moved around by the optimizer as it sees fit (especially if it runs out of registers, so again, just adding another local variable can break everything). You can't expect individual asm() lines to be executed in the order you have written them without "memory". "memory" will nail them to where they have been written.

Cheers,
Markus