Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755819AbdCGQE1 (ORCPT ); Tue, 7 Mar 2017 11:04:27 -0500 Received: from max.feld.cvut.cz ([147.32.192.36]:34697 "EHLO max.feld.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932508AbdCGQDp (ORCPT ); Tue, 7 Mar 2017 11:03:45 -0500 From: Michal Sojka To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: lisovy@gmail.com, Michal Sojka Subject: [PATCH 3/3] uio_mf624: Align memory regions to page size Date: Tue, 7 Mar 2017 15:09:48 +0100 Message-Id: <20170307140948.30099-3-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170307140948.30099-1-sojkam1@fel.cvut.cz> References: <20170307140948.30099-1-sojkam1@fel.cvut.cz> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1179 Lines: 34 Without that, one cannot mmap() the registers to user-space, at least since commit b65502879556 ("uio: we cannot mmap unaligned page contents"). Tested with real mf624 card. Signed-off-by: Michal Sojka --- drivers/uio/uio_mf624.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/uio/uio_mf624.c b/drivers/uio/uio_mf624.c index 8f30fa1af2ab..35187c052e8c 100644 --- a/drivers/uio/uio_mf624.c +++ b/drivers/uio/uio_mf624.c @@ -129,11 +129,15 @@ static int mf624_irqcontrol(struct uio_info *info, s32 irq_on) static int mf624_setup_mem(struct pci_dev *dev, int bar, struct uio_mem *mem, const char *name) { + resource_size_t start = pci_resource_start(dev, bar); + resource_size_t len = pci_resource_len(dev, bar); + mem->name = name; - mem->addr = pci_resource_start(dev, bar); + mem->addr = start & PAGE_MASK; + mem->offs = start & ~PAGE_MASK; if (!mem->addr) return -ENODEV; - mem->size = pci_resource_len(dev, bar); + mem->size = ((start & ~PAGE_MASK) + len + PAGE_SIZE - 1) & PAGE_MASK; mem->memtype = UIO_MEM_PHYS; mem->internal_addr = pci_ioremap_bar(dev, bar); if (!mem->internal_addr) -- 2.11.0