Re: [PATCH 1/4] pci-arbiter: Remove embedded pciaccess code

2019-11-03 Thread Samuel Thibault
Joan Lledó, le dim. 03 nov. 2019 18:32:31 +0100, a ecrit:
> El 3/11/19 a les 17:56, Samuel Thibault ha escrit:
> > After applying the patch, my hurd box is stuck at
> > 
> > Configuring network interfaces...
> 
> Could it be because GNU Mach is restricting the access to io ports to
> one process, and then when netdde tries to access, it can't b/c the
> arbiter arrived before?

netdde uses libpciaccess, which is supposed to use the pci arbiter.

> > I have libpciaccess0:hurd-i386 0.14-1+hurd.2
> 
> Does that version include Damien patches?

Yes, see 
http://ftp.ports.debian.org/debian-ports/pool-hurd-i386/main/libp/libpciaccess/libpciaccess_0.14-1+hurd.2.diff.gz
 the 99-pci-arbiter* patches.
It only reverts to x86 ports if it can't connect to the arbiter.
And with the patch you have sent today it would not, and thus the
arbiter will only try to connect to itself.

Samuel



Re: [PATCH 1/4] pci-arbiter: Remove embedded pciaccess code

2019-11-03 Thread Joan Lledó
Hi,

El 3/11/19 a les 17:56, Samuel Thibault ha escrit:
> After applying the patch, my hurd box is stuck at
> 
> Configuring network interfaces...


Could it be because GNU Mach is restricting the access to io ports to
one process, and then when netdde tries to access, it can't b/c the
arbiter arrived before?

> I have libpciaccess0:hurd-i386 0.14-1+hurd.2

Does that version include Damien patches? Otherwise the library will
ignore the arbiter and try to access the ports directly.



Re: [PATCH 1/4] pci-arbiter: Remove embedded pciaccess code

2019-11-03 Thread Samuel Thibault
Joan Lledó via Bug reports for the GNU Hurd, le dim. 03 nov. 2019 10:38:25 
+0100, a ecrit:
> This patch removes all embedded pciaccess code from the arbiter
> and instead uses the external pciaccess library.

After applying the patch, my hurd box is stuck at

Configuring network interfaces...

I have libpciaccess0:hurd-i386 0.14-1+hurd.2

I guess the pci-arbiter is here not managing to revert to x86 access
method. We have to do something about that.

Samuel



[PATCH 1/4] pci-arbiter: Remove embedded pciaccess code

2019-11-03 Thread Joan Lledó via Bug reports for the GNU Hurd
From: Damien Zammit 

This patch removes all embedded pciaccess code from the arbiter
and instead uses the external pciaccess library.

* pci-arbiter/Makefile:
* Remove pci_access.c and x86_pci.c from the sources.
* pci-arbiter/func_files.c:
* io_config_file: Use a harcoded PCI config size.
* read_rom_file:
Grab the full rom first, then return the
requested amount.
* pci-arbiter/main.c:
* main: Call create_fs_tree() w/o pci_sys.
Since it's not part of the translator anymore.
* pci-arbiter/netfs_impl.c:
* netfs_attempt_read:
Send pci_device_cfg_read() as the read op.
* netfs_attempt_write:
Send pci_device_cfg_write() as the write op.
* pci-arbiter/pci-ops.c:
* S_pci_conf_read: Call libpciaccess' pci_device_cfg_read().
* S_pci_conf_write: Call libpciaccess' pci_device_cfg_write().
* S_pci_get_dev_rom:
Set rom.base_addr to zero for the moment, until
  libpciaccess esposes it properly.
* pci-arbiter/pci_access.c: Deleted
* pci-arbiter/pci_access.h: Deleted
* pci-arbiter/pcifs.c:
* create_fs_tree:
Remove the pci_sys parameter.
Use libpciaccess' iterator.
Use a hardcoded config space size.
* pci-arbiter/pcifs.h: Definitions for changes in pcifs.c.
* pci-arbiter/x86_pci.c: Deleted.
* pci-arbiter/x86_pci.h: Deleted.
---
 pci-arbiter/Makefile |   4 +-
 pci-arbiter/TODO |   9 +-
 pci-arbiter/func_files.c |  34 +-
 pci-arbiter/func_files.h |   4 +
 pci-arbiter/main.c   |   6 +-
 pci-arbiter/netfs_impl.c |  22 +-
 pci-arbiter/pci-ops.c|   8 +-
 pci-arbiter/pci_access.c |  51 ---
 pci-arbiter/pci_access.h | 187 -
 pci-arbiter/pcifs.c  |  24 +-
 pci-arbiter/pcifs.h  |  11 +-
 pci-arbiter/x86_pci.c| 843 ---
 pci-arbiter/x86_pci.h|  34 --
 13 files changed, 68 insertions(+), 1169 deletions(-)
 delete mode 100644 pci-arbiter/pci_access.c
 delete mode 100644 pci-arbiter/pci_access.h
 delete mode 100644 pci-arbiter/x86_pci.c
 delete mode 100644 pci-arbiter/x86_pci.h

diff --git a/pci-arbiter/Makefile b/pci-arbiter/Makefile
index 357bb081..b13aefa8 100644
--- a/pci-arbiter/Makefile
+++ b/pci-arbiter/Makefile
@@ -20,14 +20,14 @@ makemode= server
 
 PORTDIR = $(srcdir)/port
 
-SRCS   = main.c pci-ops.c pci_access.c x86_pci.c netfs_impl.c \
+SRCS   = main.c pci-ops.c netfs_impl.c \
  pcifs.c ncache.c options.c func_files.c startup.c \
  startup-ops.c
 MIGSRCS= pciServer.c startup_notifyServer.c
 OBJS   = $(patsubst %.S,%.o,$(patsubst %.c,%.o, $(SRCS) $(MIGSRCS)))
 
 HURDLIBS= fshelp ports shouldbeinlibc netfs iohelp ihash
-LDLIBS = -lpthread
+LDLIBS = -lpthread -lpciaccess
 
 target = pci-arbiter
 
diff --git a/pci-arbiter/TODO b/pci-arbiter/TODO
index 22ae72a8..20060842 100644
--- a/pci-arbiter/TODO
+++ b/pci-arbiter/TODO
@@ -5,11 +5,10 @@
 
 - pci_get_ndevs should be deprecated, applications shouldn't be relying on this
 
-- we shouldn't duplicate pci_access.[ch] x86_pci.[ch] from libpciaccess, we
-  should get libpciaccess to expose pci_system_x86_create() to keep the
-  maintenance of x86 port knocking there.
+- In pci-ops.c - config_block_op:
+  Update len with remaining allowed size once op() returns EIO
+  so that we get short reads/writes implemented by leaving it to pciaccess
 
-  At least one difference with libpciaccess is the refresh operation. Perhaps
-  we'd need to extend libpciaccess to fix that.
+- Upstream hurdish access method + x86 fixes to libpciaccess
 
   BTW we could also support libpci.
diff --git a/pci-arbiter/func_files.c b/pci-arbiter/func_files.c
index 7df94d2f..c7da6978 100644
--- a/pci-arbiter/func_files.c
+++ b/pci-arbiter/func_files.c
@@ -35,10 +35,11 @@ config_block_op (struct pci_device *dev, off_t offset, 
size_t * len,
 {
   error_t err;
   size_t pendent = *len;
+  pciaddr_t actual = 0;
 
   while (pendent >= 4)
 {
-  err = op (dev->bus, dev->dev, dev->func, offset, data, 4);
+  err = op (dev, data, offset, 4, &actual);
   if (err)
return err;
 
@@ -49,7 +50,7 @@ config_block_op (struct pci_device *dev, off_t offset, size_t 
* len,
 
   if (pendent >= 2)
 {
-  err = op (dev->bus, dev->dev, dev->func, offset, data, 2);
+  err = op (dev, data, offset, 2, &actual);
   if (err)
return err;
 
@@ -60,7 +61,7 @@ config_block_op (struct pci_device *dev, off_t offset, size_t 
* len,
 
   if (pendent)
 {
-  err = op (dev->bus, dev->dev, dev->func, offset, data, 1);
+  err = op (dev, data, offset, 1, &actual);
   if (err)
return err;
 
@@ -85,10 +86,10 @@ io_config_file (struct pci_device * dev, off_t offset, 
size_t * len,
   assert_backtrace (dev != 0);
 
   /* Don't exceed the config space size */
-  if (offset > dev->config_size)
+  if (of