Hrm does not apply cleanly - Maybe I should just grab the CVS of if_em.c ?
bash-4.1# patch -i if_em.c.patch Hmm... Looks like a unified diff to me... The text leading up to this was: -------------------------- |Index: if_em.c |=================================================================== |RCS file: /cvs/src/sys/dev/pci/if_em.c,v |retrieving revision 1.256 |diff -u -p -r1.256 if_em.c |--- if_em.c 22 Apr 2011 10:09:57 -0000 1.256 |+++ if_em.c 1 Jun 2011 09:40:53 -0000 -------------------------- Patching file if_em.c using Plan A... Hunk #1 failed at 3014. Hunk #2 failed at 3053. 2 out of 2 hunks failed--saving rejects to if_em.c.rej done bash-4.1# cat if_em.c.rej @@ -3014,26 +3014,38 @@ em_write_pci_cfg(struct em_hw *hw, uint32_t reg, uint16_t *value) { struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; - pci_chipset_tag_t pc = pa->pa_pc; - /* Should we do read/mask/write...? 16 vs 32 bit!!! */ - pci_conf_write(pc, pa->pa_tag, reg, *value); + pcireg_t val; + + val = pci_conf_read(pa->pa_pc, pa->pa_tag, reg & ~0x3); + if (reg & 0x2) { + val &= 0x0000ffff; + val |= (*value << 16); + } else { + val &= 0xffff0000; + val |= *value; + } + pci_conf_write(pa->pa_pc, pa->pa_tag, reg & ~0x3, val); } void em_read_pci_cfg(struct em_hw *hw, uint32_t reg, uint16_t *value) { struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; - pci_chipset_tag_t pc = pa->pa_pc; - *value = pci_conf_read(pc, pa->pa_tag, reg); + pcireg_t val; + + val = pci_conf_read(pa->pa_pc, pa->pa_tag, reg & ~0x3); + if (reg & 0x2) + *value = (val >> 16) & 0xffff; + else + *value = val & 0xffff; } void em_pci_set_mwi(struct em_hw *hw) { struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; - pci_chipset_tag_t pc = pa->pa_pc; - /* Should we do read/mask/write...? 16 vs 32 bit!!! */ - pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, + + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, (hw->pci_cmd_word | CMD_MEM_WRT_INVALIDATE)); } @@ -3041,9 +3053,8 @@ em_pci_clear_mwi(struct em_hw *hw) { struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; - pci_chipset_tag_t pc = pa->pa_pc; - /* Should we do read/mask/write...? 16 vs 32 bit!!! */ - pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, + + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, (hw->pci_cmd_word & ~CMD_MEM_WRT_INVALIDATE)); } On 1 June 2011 21:41, Mark Kettenis <mark.kette...@xs4all.nl> wrote: > Can you try the diff below? > > Index: if_em.c > =================================================================== > RCS file: /cvs/src/sys/dev/pci/if_em.c,v > retrieving revision 1.256 > diff -u -p -r1.256 if_em.c > --- if_em.c 22 Apr 2011 10:09:57 -0000 1.256 > +++ if_em.c 1 Jun 2011 09:40:53 -0000 > @@ -3014,26 +3014,38 @@ void > em_write_pci_cfg(struct em_hw *hw, uint32_t reg, uint16_t *value) > { > struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; > - pci_chipset_tag_t pc = pa->pa_pc; > - /* Should we do read/mask/write...? 16 vs 32 bit!!! */ > - pci_conf_write(pc, pa->pa_tag, reg, *value); > + pcireg_t val; > + > + val = pci_conf_read(pa->pa_pc, pa->pa_tag, reg & ~0x3); > + if (reg & 0x2) { > + val &= 0x0000ffff; > + val |= (*value << 16); > + } else { > + val &= 0xffff0000; > + val |= *value; > + } > + pci_conf_write(pa->pa_pc, pa->pa_tag, reg & ~0x3, val); > } > > void > em_read_pci_cfg(struct em_hw *hw, uint32_t reg, uint16_t *value) > { > struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; > - pci_chipset_tag_t pc = pa->pa_pc; > - *value = pci_conf_read(pc, pa->pa_tag, reg); > + pcireg_t val; > + > + val = pci_conf_read(pa->pa_pc, pa->pa_tag, reg & ~0x3); > + if (reg & 0x2) > + *value = (val >> 16) & 0xffff; > + else > + *value = val & 0xffff; > } > > void > em_pci_set_mwi(struct em_hw *hw) > { > struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; > - pci_chipset_tag_t pc = pa->pa_pc; > - /* Should we do read/mask/write...? 16 vs 32 bit!!! */ > - pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, > + > + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, > (hw->pci_cmd_word | CMD_MEM_WRT_INVALIDATE)); > } > > @@ -3041,9 +3053,8 @@ void > em_pci_clear_mwi(struct em_hw *hw) > { > struct pci_attach_args *pa = &((struct em_osdep *)hw->back)->em_pa; > - pci_chipset_tag_t pc = pa->pa_pc; > - /* Should we do read/mask/write...? 16 vs 32 bit!!! */ > - pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, > + > + pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, > (hw->pci_cmd_word & ~CMD_MEM_WRT_INVALIDATE)); > }