Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1429072

Re: [PATCH v13 01/16] PCI: Let pci_mmap_page_range() take resource address

From Yinghai Lu <yinghai@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v13 01/16] PCI: Let pci_mmap_page_range() take resource address
Date 2016-06-22 21:30 +0200
Message-ID <rMW0y-7AM-23@gated-at.bofh.it> (permalink)
References <rLebf-6rx-3@gated-at.bofh.it> <rLebl-6rx-21@gated-at.bofh.it> <rLnod-3UQ-21@gated-at.bofh.it> <rMI7f-76A-7@gated-at.bofh.it> <rMSgh-5bN-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, Jun 22, 2016 at 8:22 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Tue, Jun 21, 2016 at 09:32:49PM -0700, Yinghai Lu wrote:
>
> If sparc is broken, let's make this a tiny sparc-only patch that fixes
> only the breakage -- no cleanup or restructuring.  Then we can do the
> more extensive work in a separate patch.

ok. please check attached two patches that take position for
[PATCH v13 01/16]

>
> The example mmap() I keep asking for would be very helpful to me in
> understanding the problem.  It would probably also help folks who
> maintain user programs that use mmap.  They need to figure out whether
> they have code that worked most places but has always been broken on
> sparc, or code that depended on the previous sparc behavior and will
> be broken by this change, or what.

ok.

calling : ./test_mmap_proc /proc/bus/pci/0000:00/04.0 0x2000000

code : test_mmap_proc.c

#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define PCIIOC_BASE             ('P' << 24 | 'C' << 16 | 'I' << 8)
#define PCIIOC_CONTROLLER       (PCIIOC_BASE | 0x00)    /* Get
controller for PCI device. */
#define PCIIOC_MMAP_IS_IO       (PCIIOC_BASE | 0x01)    /* Set mmap
state to I/O space. */
#define PCIIOC_MMAP_IS_MEM      (PCIIOC_BASE | 0x02)    /* Set mmap
state to MEM space. */
#define PCIIOC_WRITE_COMBINE    (PCIIOC_BASE | 0x03)    /*
Enable/disable write-combining. */

/* sparc64 */
#define PAGE_SHIFT 13
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))

int main(int argc, char *argv[])
{
  int i;
  int fd;
  char *addr;
  unsigned long offset = 0;
  unsigned long left = 0;

  fd = open(argv[1], O_RDONLY);
  if (fd < 0) {
    perror("open");
    return 1;
  }

  if (argc > 2)
     sscanf(argv[2], "0x%lx", &offset);

  left = offset & (PAGE_SIZE - 1);
  offset &= PAGE_MASK;

  ioctl(fd, PCIIOC_MMAP_IS_MEM);
  addr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, offset);
  if (addr == MAP_FAILED) {
    perror("mmap");
    return 1;
  }

  printf("map finished\n");


  for (i = 0; i < 8; i++)
    printf("%x ", addr[i + left]);
  printf("\n");

  munmap(addr, PAGE_SIZE);

  close(fd);

  return 0;
}

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v13 01/16] PCI: Let pci_mmap_page_range() take resource address Yinghai Lu <yinghai@kernel.org> - 2016-06-18 04:30 +0200
  Re: [PATCH v13 01/16] PCI: Let pci_mmap_page_range() take resource  address Bjorn Helgaas <helgaas@kernel.org> - 2016-06-18 14:20 +0200
    Re: [PATCH v13 01/16] PCI: Let pci_mmap_page_range() take resource address Yinghai Lu <yinghai@kernel.org> - 2016-06-22 06:40 +0200
      Re: [PATCH v13 01/16] PCI: Let pci_mmap_page_range() take resource  address Bjorn Helgaas <helgaas@kernel.org> - 2016-06-22 17:30 +0200
        Re: [PATCH v13 01/16] PCI: Let pci_mmap_page_range() take resource address Yinghai Lu <yinghai@kernel.org> - 2016-06-22 21:30 +0200

csiph-web