From patchwork Wed Dec 6 21:03:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Groves X-Patchwork-Id: 13482266 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=jagalactic.com header.i=@jagalactic.com header.b="Gh00IKI6"; dkim=pass (1024-bit key) header.d=amazonses.com header.i=@amazonses.com header.b="NW7tCRxl" Received: from a48-177.smtp-out.amazonses.com (a48-177.smtp-out.amazonses.com [54.240.48.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FD54D5F; Wed, 6 Dec 2023 13:03:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=rjayupzefgi7e6fmzxcxe4cv4arrjs35; d=jagalactic.com; t=1701896583; h=Subject:From:To:Cc:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References:Message-Id; bh=e0bZT30UH1862XrWsVHqzzsCoSyaKyeDEuFIkGW3TKY=; b=Gh00IKI6t9fOKgjqE6YFIhcjyQor578P/1MegN/5vV9/jtEyl8cfP3Lheqzc0VsI NRgb8mB8GwqxqlBcW1Vn/0m+NMV6B4h3/m2UxxR0w3mHPxNIco2Ev6A6U6idxfsuyJ4 gOyTUP6/x2OtP7nRZSTw47BFWyT1VUNdZ13bqnhY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=224i4yxa5dv7c2xz3womw6peuasteono; d=amazonses.com; t=1701896583; h=Subject:From:To:Cc:Date:Mime-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References:Message-Id:Feedback-ID; bh=e0bZT30UH1862XrWsVHqzzsCoSyaKyeDEuFIkGW3TKY=; b=NW7tCRxlP/1HBef1QmUwjcm9DfQkebr/ip8jTKUj0UIv7PxfzNq0pmXkm+6Sca+s qVP0dQC9V9l9Qf10Nlmq5JLV8kZuhy/TgXLFj6RKaEAGDsjTW82pD8PddbhiY8KE/LP /yTfu2c4+9KP7eQAv3oob9ay0e0ew5UD28HZWMtY= Subject: [PATCH RFC 2/4] dev_dax_iomap: Temporary hacks due to linkage issues From: =?utf-8?q?John_Groves?= To: =?utf-8?q?Dan_Williams?= , =?utf-8?q?John_Grov?= =?utf-8?q?es?= , =?utf-8?q?John_Groves?= Cc: =?utf-8?q?Vishal_Verma?= , =?utf-8?q?Dave_Jian?= =?utf-8?q?g?= , =?utf-8?q?nvdimm=40lists=2Elinux=2Ede?= =?utf-8?q?v?= , =?utf-8?q?linux-cxl=40vger=2Ekernel?= =?utf-8?q?=2Eorg?= , =?utf-8?q?linux-kernel=40vg?= =?utf-8?q?er=2Ekernel=2Eorg?= , =?utf-8?q?lin?= =?utf-8?q?ux-fsdevel=40vger=2Ekernel=2Eorg?= , =?utf-8?q?John_Groves?= Date: Wed, 6 Dec 2023 21:03:02 +0000 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 In-Reply-To: <20231206210252.52107-1-john@jagalactic.com> References: <20231206210252.52107-1-john@jagalactic.com> <20231206210252.52107-3-john@jagalactic.com> X-Mailer: Amazon WorkMail Thread-Index: AQHaKIeW9Nsmb4x1TnOasHllAnJBRAAAAKIK Thread-Topic: [PATCH RFC 2/4] dev_dax_iomap: Temporary hacks due to linkage issues X-Wm-Sent-Timestamp: 1701896581 X-Original-Mailer: git-send-email 2.39.3 (Apple Git-145) Message-ID: <0100018c40f0f6d8-1460addc-79af-4f6d-b791-147340e4c972-000000@email.amazonses.com> Feedback-ID: 1.us-east-1.LF00NED762KFuBsfzrtoqw+Brn/qlF9OYdxWukAhsl8=:AmazonSES X-SES-Outgoing: 2023.12.06-54.240.48.177 From: John Groves These are functions that should be called from outside, but I had linkage issues and did this hack instead. Will fix in the "real" patches... --- drivers/dax/bus.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 1659b787b65f..1b55fd7aabaf 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1324,6 +1324,56 @@ static const struct device_type dev_dax_type = { .groups = dax_attribute_groups, }; +#if IS_ENABLED(CONFIG_DEV_DAX_IOMAP) + +/* + * This is write_pmem() from pmem.c + */ +static void write_dax(void *pmem_addr, struct page *page, + unsigned int off, unsigned int len) +{ + unsigned int chunk; + void *mem; + + while (len) { + mem = kmap_atomic(page); + chunk = min_t(unsigned int, len, PAGE_SIZE - off); + memcpy_flushcache(pmem_addr, mem + off, chunk); + kunmap_atomic(mem); + len -= chunk; + off = 0; + page++; + pmem_addr += chunk; + } +} + +/* + * This function is from drivers/dax/device.c + * For some reason EXPORT_SYMBOL(dax_pgoff_to_phys) didn't result in linkable code + */ +phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, + unsigned long size) +{ + int i; + + for (i = 0; i < dev_dax->nr_range; i++) { + struct dev_dax_range *dax_range = &dev_dax->ranges[i]; + struct range *range = &dax_range->range; + unsigned long long pgoff_end; + phys_addr_t phys; + + pgoff_end = dax_range->pgoff + PHYS_PFN(range_len(range)) - 1; + if (pgoff < dax_range->pgoff || pgoff > pgoff_end) + continue; + phys = PFN_PHYS(pgoff - dax_range->pgoff) + range->start; + if (phys + size - 1 <= range->end) + return phys; + break; + } + return -1; +} + + struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) { struct dax_region *dax_region = data->dax_region;