The following commit has been merged in the master branch: commit dc13e06fe7a60afa92a51398664ab521226769f4 Merge: e7db96b26dcc8a06c2d1178148d1883399399d64 b94351ceb98dd8c933ae5cf4db753784311334d5 Author: Stephen Rothwell sfr@canb.auug.org.au Date: Mon Jul 13 17:45:39 2020 +1000
Merge remote-tracking branch 'set_fs/set_fs-rw'
# Conflicts: # drivers/acpi/battery.c # fs/btrfs/file.c
diff --combined Documentation/process/clang-format.rst index 82676e5a7c6e,7f04493cba4f..57186ae91365 --- a/Documentation/process/clang-format.rst +++ b/Documentation/process/clang-format.rst @@@ -32,7 -32,7 +32,7 @@@ Linux distributions for a long time. Se your repositories. Otherwise, you can either download pre-built LLVM/clang binaries or build the source code from:
- http://releases.llvm.org/download.html + https://releases.llvm.org/download.html
See more information about the tool at:
@@@ -136,7 -136,7 +136,7 @@@ In particular, some very common ones yo static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, .write = probes_write, @@@ -147,7 -147,7 +147,7 @@@ static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, .write = probes_write, diff --combined arch/arm/mm/alignment.c index f4bfc1cac91a,412cab88402a..8666935340db --- a/arch/arm/mm/alignment.c +++ b/arch/arm/mm/alignment.c @@@ -164,7 -164,7 +164,7 @@@ static ssize_t alignment_proc_write(str
static const struct proc_ops alignment_proc_ops = { .proc_open = alignment_proc_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = single_release, .proc_write = alignment_proc_write, @@@ -799,7 -799,7 +799,7 @@@ static int alignment_get_thumb(struct p static int do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { - union offset_union uninitialized_var(offset); + union offset_union offset; unsigned long instrptr; int (*handler)(unsigned long addr, u32 instr, struct pt_regs *regs); unsigned int type; diff --combined arch/powerpc/mm/ptdump/hashpagetable.c index 5b8bd34cd3a1,94a6124f9740..930d9cfd6316 --- a/arch/powerpc/mm/ptdump/hashpagetable.c +++ b/arch/powerpc/mm/ptdump/hashpagetable.c @@@ -258,7 -258,7 +258,7 @@@ static int pseries_find(unsigned long e for (i = 0; i < HPTES_PER_GROUP; i += 4, hpte_group += 4) { lpar_rc = plpar_pte_read_4(0, hpte_group, (void *)ptes);
- if (lpar_rc != H_SUCCESS) + if (lpar_rc) continue; for (j = 0; j < 4; j++) { if (HPTE_V_COMPARE(ptes[j].v, want_v) && @@@ -533,7 -533,7 +533,7 @@@ static int ptdump_open(struct inode *in
static const struct file_operations ptdump_fops = { .open = ptdump_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined arch/um/kernel/process.c index 26b5e243d3fc,f3e4bd48f6d5..77caa0202fc3 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@@ -152,7 -152,7 +152,7 @@@ void fork_handler(void userspace(¤t->thread.regs.regs, current_thread_info()->aux_fp_regs); }
-int copy_thread_tls(unsigned long clone_flags, unsigned long sp, +int copy_thread(unsigned long clone_flags, unsigned long sp, unsigned long arg, struct task_struct * p, unsigned long tls) { void (*handler)(void); @@@ -312,7 -312,7 +312,7 @@@ static ssize_t sysemu_proc_write(struc
static const struct proc_ops sysemu_proc_ops = { .proc_open = sysemu_proc_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = single_release, .proc_write = sysemu_proc_write, diff --combined arch/x86/mm/pat/set_memory.c index d1b2a889f035,95b12dd5bf0e..355de93199ee --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@@ -135,7 -135,7 +135,7 @@@ static inline void cpa_inc_2m_checked(v
static inline void cpa_inc_4k_install(void) { - cpa_4k_install++; + data_race(cpa_4k_install++); }
static inline void cpa_inc_lp_sameprot(int level) @@@ -173,7 -173,7 +173,7 @@@ static int cpastats_open(struct inode *
static const struct file_operations cpastats_fops = { .open = cpastats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined block/blk-mq-debugfs.c index 3f09bcb8a6fd,4e427fc88a26..5c8333d1ceed --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@@ -404,7 -404,8 +404,7 @@@ static bool hctx_show_busy_rq(struct re const struct show_busy_params *params = data;
if (rq->mq_hctx == params->hctx) - __blk_mq_debugfs_rq_show(params->m, - list_entry_rq(&rq->queuelist)); + __blk_mq_debugfs_rq_show(params->m, rq);
return true; } @@@ -772,7 -773,7 +772,7 @@@ static int blk_mq_debugfs_release(struc
static const struct file_operations blk_mq_debugfs_fops = { .open = blk_mq_debugfs_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = blk_mq_debugfs_write, .llseek = seq_lseek, .release = blk_mq_debugfs_release, @@@ -826,6 -827,9 +826,6 @@@ void blk_mq_debugfs_register(struct req struct blk_mq_hw_ctx *hctx; int i;
- q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent), - blk_debugfs_root); - debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs);
/* @@@ -856,7 -860,9 +856,7 @@@
void blk_mq_debugfs_unregister(struct request_queue *q) { - debugfs_remove_recursive(q->debugfs_dir); q->sched_debugfs_dir = NULL; - q->debugfs_dir = NULL; }
static void blk_mq_debugfs_register_ctx(struct blk_mq_hw_ctx *hctx, diff --combined drivers/block/nbd.c index 3ff4054d6834,4c54d366afde..25208ff7166e --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@@ -784,7 -784,6 +784,7 @@@ static void recv_work(struct work_struc struct nbd_device *nbd = args->nbd; struct nbd_config *config = nbd->config; struct nbd_cmd *cmd; + struct request *rq;
while (1) { cmd = nbd_read_stat(nbd, args->index); @@@ -797,9 -796,7 +797,9 @@@ break; }
- blk_mq_complete_request(blk_mq_rq_from_pdu(cmd)); + rq = blk_mq_rq_from_pdu(cmd); + if (likely(!blk_should_fake_timeout(rq->q))) + blk_mq_complete_request(rq); } atomic_dec(&config->recv_threads); wake_up(&config->recv_wq); @@@ -1547,7 -1544,7 +1547,7 @@@ static int nbd_dbg_tasks_open(struct in
static const struct file_operations nbd_dbg_tasks_ops = { .open = nbd_dbg_tasks_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -1582,7 -1579,7 +1582,7 @@@ static int nbd_dbg_flags_open(struct in
static const struct file_operations nbd_dbg_flags_ops = { .open = nbd_dbg_flags_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/block/pktcdvd.c index 4becc1efe775,50c6d6eacb59..c81f637141c0 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@@ -36,7 -36,7 +36,7 @@@ * block device, assembling the pieces to full packets and queuing them to the * packet I/O scheduler. * - * At the top layer there is a custom make_request_fn function that forwards + * At the top layer there is a custom ->submit_bio function that forwards * read requests directly to the iosched queue and puts write requests in the * unaligned write queue. A kernel thread performs the necessary read * gathering to convert the unaligned writes to aligned writes and then feeds @@@ -464,7 -464,7 +464,7 @@@ static int pkt_debugfs_fops_open(struc
static const struct file_operations debug_fops = { .open = pkt_debugfs_fops_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -913,7 -913,7 +913,7 @@@ static void pkt_iosched_process_queue(s }
atomic_inc(&pd->cdrw.pending_bios); - generic_make_request(bio); + submit_bio_noacct(bio); } }
@@@ -2428,15 -2428,15 +2428,15 @@@ static void pkt_make_request_write(stru } }
-static blk_qc_t pkt_make_request(struct request_queue *q, struct bio *bio) +static blk_qc_t pkt_submit_bio(struct bio *bio) { struct pktcdvd_device *pd; char b[BDEVNAME_SIZE]; struct bio *split;
- blk_queue_split(q, &bio); + blk_queue_split(&bio);
- pd = q->queuedata; + pd = bio->bi_disk->queue->queuedata; if (!pd) { pr_err("%s incorrect request queue\n", bio_devname(bio, b)); goto end_io; @@@ -2480,7 -2480,7 +2480,7 @@@ split = bio; }
- pkt_make_request_write(q, split); + pkt_make_request_write(bio->bi_disk->queue, split); } while (split != bio);
return BLK_QC_T_NONE; @@@ -2685,7 -2685,6 +2685,7 @@@ static char *pkt_devnode(struct gendis
static const struct block_device_operations pktcdvd_ops = { .owner = THIS_MODULE, + .submit_bio = pkt_submit_bio, .open = pkt_open, .release = pkt_close, .ioctl = pkt_ioctl, @@@ -2750,7 -2749,7 +2750,7 @@@ static int pkt_setup_dev(dev_t dev, dev disk->flags = GENHD_FL_REMOVABLE; strcpy(disk->disk_name, pd->name); disk->private_data = pd; - disk->queue = blk_alloc_queue(pkt_make_request, NUMA_NO_NODE); + disk->queue = blk_alloc_queue(NUMA_NO_NODE); if (!disk->queue) goto out_mem2;
diff --combined drivers/block/rsxx/core.c index 7e261224ff10,1adfd0f273b4..e631749e14ca --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c @@@ -209,7 -209,7 +209,7 @@@ static const struct file_operations deb static const struct file_operations debugfs_stats_fops = { .owner = THIS_MODULE, .open = rsxx_attr_stats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -217,7 -217,7 +217,7 @@@ static const struct file_operations debugfs_pci_regs_fops = { .owner = THIS_MODULE, .open = rsxx_attr_pci_regs_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -562,15 -562,13 +562,15 @@@ static int rsxx_eeh_frozen(struct pci_d
for (i = 0; i < card->n_targets; i++) { if (card->ctrl[i].status.buf) - pci_free_consistent(card->dev, STATUS_BUFFER_SIZE8, - card->ctrl[i].status.buf, - card->ctrl[i].status.dma_addr); + dma_free_coherent(&card->dev->dev, + STATUS_BUFFER_SIZE8, + card->ctrl[i].status.buf, + card->ctrl[i].status.dma_addr); if (card->ctrl[i].cmd.buf) - pci_free_consistent(card->dev, COMMAND_BUFFER_SIZE8, - card->ctrl[i].cmd.buf, - card->ctrl[i].cmd.dma_addr); + dma_free_coherent(&card->dev->dev, + COMMAND_BUFFER_SIZE8, + card->ctrl[i].cmd.buf, + card->ctrl[i].cmd.dma_addr); }
return 0; @@@ -627,7 -625,7 +627,7 @@@ static int rsxx_eeh_fifo_flush_poll(str }
static pci_ers_result_t rsxx_error_detected(struct pci_dev *dev, - enum pci_channel_state error) + pci_channel_state_t error) { int st;
@@@ -713,15 -711,15 +713,15 @@@ static pci_ers_result_t rsxx_slot_reset failed_hw_buffers_init: for (i = 0; i < card->n_targets; i++) { if (card->ctrl[i].status.buf) - pci_free_consistent(card->dev, - STATUS_BUFFER_SIZE8, - card->ctrl[i].status.buf, - card->ctrl[i].status.dma_addr); + dma_free_coherent(&card->dev->dev, + STATUS_BUFFER_SIZE8, + card->ctrl[i].status.buf, + card->ctrl[i].status.dma_addr); if (card->ctrl[i].cmd.buf) - pci_free_consistent(card->dev, - COMMAND_BUFFER_SIZE8, - card->ctrl[i].cmd.buf, - card->ctrl[i].cmd.dma_addr); + dma_free_coherent(&card->dev->dev, + COMMAND_BUFFER_SIZE8, + card->ctrl[i].cmd.buf, + card->ctrl[i].cmd.dma_addr); } failed_hw_setup: rsxx_eeh_failure(dev); diff --combined drivers/crypto/hisilicon/qm.c index 6527c53b073f,a5c3e21e0fe6..b594dc72807c --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@@ -1054,7 -1054,7 +1054,7 @@@ static int qm_regs_open(struct inode *i static const struct file_operations qm_regs_fops = { .owner = THIS_MODULE, .open = qm_regs_open, - .read = seq_read, + .read_iter = seq_read_iter, .release = single_release, };
@@@ -1064,10 -1064,19 +1064,10 @@@ static ssize_t qm_cmd_read(struct file char buf[QM_DBG_READ_LEN]; int len;
- if (*pos) - return 0; - - if (count < QM_DBG_READ_LEN) - return -ENOSPC; - - len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", - "Please echo help to cmd to get help information"); + len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n", + "Please echo help to cmd to get help information");
- if (copy_to_user(buffer, buf, len)) - return -EFAULT; - - return (*pos = len); + return simple_read_from_buffer(buffer, count, pos, buf, len); }
static void *qm_ctx_alloc(struct hisi_qm *qm, size_t ctx_size, @@@ -1732,7 -1741,7 +1732,7 @@@ void hisi_qm_release_qp(struct hisi_qp } EXPORT_SYMBOL_GPL(hisi_qm_release_qp);
-static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid) +static int qm_qp_ctx_cfg(struct hisi_qp *qp, int qp_id, u32 pasid) { struct hisi_qm *qm = qp->qm; struct device *dev = &qm->pdev->dev; @@@ -1804,7 -1813,7 +1804,7 @@@ static int qm_start_qp_nolock(struct hi struct hisi_qm *qm = qp->qm; struct device *dev = &qm->pdev->dev; int qp_id = qp->qp_id; - int pasid = arg; + u32 pasid = arg; int ret;
if (!qm_qp_avail_state(qm, qp, QP_START)) @@@ -2170,12 -2179,8 +2170,12 @@@ static int qm_alloc_uacce(struct hisi_q .flags = UACCE_DEV_SVA, .ops = &uacce_qm_ops, }; + int ret;
- strncpy(interface.name, pdev->driver->name, sizeof(interface.name)); + ret = strscpy(interface.name, pdev->driver->name, + sizeof(interface.name)); + if (ret < 0) + return -ENAMETOOLONG;
uacce = uacce_alloc(&pdev->dev, &interface); if (IS_ERR(uacce)) @@@ -2686,12 -2691,24 +2686,12 @@@ static ssize_t qm_status_read(struct fi { struct hisi_qm *qm = filp->private_data; char buf[QM_DBG_READ_LEN]; - int val, cp_len, len; - - if (*pos) - return 0; - - if (count < QM_DBG_READ_LEN) - return -ENOSPC; + int val, len;
val = atomic_read(&qm->status.flags); - len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]); - if (!len) - return -EFAULT; - - cp_len = copy_to_user(buffer, buf, len); - if (cp_len) - return -EFAULT; + len = scnprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]);
- return (*pos = len); + return simple_read_from_buffer(buffer, count, pos, buf, len); }
static const struct file_operations qm_status_fops = { diff --combined drivers/crypto/qat/qat_common/adf_cfg.c index ac462796cefc,4b77c6f05b3e..44c7027f8096 --- a/drivers/crypto/qat/qat_common/adf_cfg.c +++ b/drivers/crypto/qat/qat_common/adf_cfg.c @@@ -1,5 -1,49 +1,5 @@@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - Copyright(c) 2014 Intel Corporation. - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - Contact Information: - qat-linux@intel.com - - BSD LICENSE - Copyright(c) 2014 Intel Corporation. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ +// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) +/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> #include <linux/list.h> @@@ -66,7 -110,7 +66,7 @@@ static int qat_dev_cfg_open(struct inod
static const struct file_operations qat_dev_cfg_fops = { .open = qat_dev_cfg_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release }; diff --combined drivers/crypto/qat/qat_common/adf_transport_debug.c index 2a2eccbf56ec,6133a869aeb1..659917c848d9 --- a/drivers/crypto/qat/qat_common/adf_transport_debug.c +++ b/drivers/crypto/qat/qat_common/adf_transport_debug.c @@@ -1,5 -1,49 +1,5 @@@ -/* - This file is provided under a dual BSD/GPLv2 license. When using or - redistributing this file, you may do so under either license. - - GPL LICENSE SUMMARY - Copyright(c) 2014 Intel Corporation. - This program is free software; you can redistribute it and/or modify - it under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - Contact Information: - qat-linux@intel.com - - BSD LICENSE - Copyright(c) 2014 Intel Corporation. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ +// SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) +/* Copyright(c) 2014 - 2020 Intel Corporation */ #include <linux/mutex.h> #include <linux/slab.h> #include <linux/seq_file.h> @@@ -98,7 -142,7 +98,7 @@@ static int adf_ring_open(struct inode *
static const struct file_operations adf_ring_debug_fops = { .open = adf_ring_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release }; @@@ -209,7 -253,7 +209,7 @@@ static int adf_bank_open(struct inode *
static const struct file_operations adf_bank_debug_fops = { .open = adf_bank_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release }; diff --combined drivers/gpio/gpiolib.c index 80137c1b3cdc,0ca1acff0e37..25ef7ed30a06 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@@ -17,16 -17,20 +17,16 @@@ #include <linux/gpio/driver.h> #include <linux/gpio/machine.h> #include <linux/pinctrl/consumer.h> -#include <linux/cdev.h> #include <linux/fs.h> -#include <linux/uaccess.h> #include <linux/compat.h> -#include <linux/anon_inodes.h> #include <linux/file.h> -#include <linux/kfifo.h> -#include <linux/poll.h> -#include <linux/timekeeping.h> #include <uapi/linux/gpio.h>
#include "gpiolib.h" #include "gpiolib-of.h" #include "gpiolib-acpi.h" +#include "gpiolib-cdev.h" +#include "gpiolib-sysfs.h"
#define CREATE_TRACE_POINTS #include <trace/events/gpio.h> @@@ -421,6 -425,1105 +421,6 @@@ bool gpiochip_line_is_valid(const struc } EXPORT_SYMBOL_GPL(gpiochip_line_is_valid);
-/* - * GPIO line handle management - */ - -/** - * struct linehandle_state - contains the state of a userspace handle - * @gdev: the GPIO device the handle pertains to - * @label: consumer label used to tag descriptors - * @descs: the GPIO descriptors held by this handle - * @numdescs: the number of descriptors held in the descs array - */ -struct linehandle_state { - struct gpio_device *gdev; - const char *label; - struct gpio_desc *descs[GPIOHANDLES_MAX]; - u32 numdescs; -}; - -#define GPIOHANDLE_REQUEST_VALID_FLAGS \ - (GPIOHANDLE_REQUEST_INPUT | \ - GPIOHANDLE_REQUEST_OUTPUT | \ - GPIOHANDLE_REQUEST_ACTIVE_LOW | \ - GPIOHANDLE_REQUEST_BIAS_PULL_UP | \ - GPIOHANDLE_REQUEST_BIAS_PULL_DOWN | \ - GPIOHANDLE_REQUEST_BIAS_DISABLE | \ - GPIOHANDLE_REQUEST_OPEN_DRAIN | \ - GPIOHANDLE_REQUEST_OPEN_SOURCE) - -static int linehandle_validate_flags(u32 flags) -{ - /* Return an error if an unknown flag is set */ - if (flags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) - return -EINVAL; - - /* - * Do not allow both INPUT & OUTPUT flags to be set as they are - * contradictory. - */ - if ((flags & GPIOHANDLE_REQUEST_INPUT) && - (flags & GPIOHANDLE_REQUEST_OUTPUT)) - return -EINVAL; - - /* - * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If - * the hardware actually supports enabling both at the same time the - * electrical result would be disastrous. - */ - if ((flags & GPIOHANDLE_REQUEST_OPEN_DRAIN) && - (flags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) - return -EINVAL; - - /* OPEN_DRAIN and OPEN_SOURCE flags only make sense for output mode. */ - if (!(flags & GPIOHANDLE_REQUEST_OUTPUT) && - ((flags & GPIOHANDLE_REQUEST_OPEN_DRAIN) || - (flags & GPIOHANDLE_REQUEST_OPEN_SOURCE))) - return -EINVAL; - - /* Bias flags only allowed for input or output mode. */ - if (!((flags & GPIOHANDLE_REQUEST_INPUT) || - (flags & GPIOHANDLE_REQUEST_OUTPUT)) && - ((flags & GPIOHANDLE_REQUEST_BIAS_DISABLE) || - (flags & GPIOHANDLE_REQUEST_BIAS_PULL_UP) || - (flags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN))) - return -EINVAL; - - /* Only one bias flag can be set. */ - if (((flags & GPIOHANDLE_REQUEST_BIAS_DISABLE) && - (flags & (GPIOHANDLE_REQUEST_BIAS_PULL_DOWN | - GPIOHANDLE_REQUEST_BIAS_PULL_UP))) || - ((flags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN) && - (flags & GPIOHANDLE_REQUEST_BIAS_PULL_UP))) - return -EINVAL; - - return 0; -} - -static long linehandle_set_config(struct linehandle_state *lh, - void __user *ip) -{ - struct gpiohandle_config gcnf; - struct gpio_desc *desc; - int i, ret; - u32 lflags; - unsigned long *flagsp; - - if (copy_from_user(&gcnf, ip, sizeof(gcnf))) - return -EFAULT; - - lflags = gcnf.flags; - ret = linehandle_validate_flags(lflags); - if (ret) - return ret; - - for (i = 0; i < lh->numdescs; i++) { - desc = lh->descs[i]; - flagsp = &desc->flags; - - assign_bit(FLAG_ACTIVE_LOW, flagsp, - lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW); - - assign_bit(FLAG_OPEN_DRAIN, flagsp, - lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN); - - assign_bit(FLAG_OPEN_SOURCE, flagsp, - lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE); - - assign_bit(FLAG_PULL_UP, flagsp, - lflags & GPIOHANDLE_REQUEST_BIAS_PULL_UP); - - assign_bit(FLAG_PULL_DOWN, flagsp, - lflags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN); - - assign_bit(FLAG_BIAS_DISABLE, flagsp, - lflags & GPIOHANDLE_REQUEST_BIAS_DISABLE); - - /* - * Lines have to be requested explicitly for input - * or output, else the line will be treated "as is". - */ - if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { - int val = !!gcnf.default_values[i]; - - ret = gpiod_direction_output(desc, val); - if (ret) - return ret; - } else if (lflags & GPIOHANDLE_REQUEST_INPUT) { - ret = gpiod_direction_input(desc); - if (ret) - return ret; - } - - atomic_notifier_call_chain(&desc->gdev->notifier, - GPIOLINE_CHANGED_CONFIG, desc); - } - return 0; -} - -static long linehandle_ioctl(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - struct linehandle_state *lh = filep->private_data; - void __user *ip = (void __user *)arg; - struct gpiohandle_data ghd; - DECLARE_BITMAP(vals, GPIOHANDLES_MAX); - int i; - - if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { - /* NOTE: It's ok to read values of output lines. */ - int ret = gpiod_get_array_value_complex(false, - true, - lh->numdescs, - lh->descs, - NULL, - vals); - if (ret) - return ret; - - memset(&ghd, 0, sizeof(ghd)); - for (i = 0; i < lh->numdescs; i++) - ghd.values[i] = test_bit(i, vals); - - if (copy_to_user(ip, &ghd, sizeof(ghd))) - return -EFAULT; - - return 0; - } else if (cmd == GPIOHANDLE_SET_LINE_VALUES_IOCTL) { - /* - * All line descriptors were created at once with the same - * flags so just check if the first one is really output. - */ - if (!test_bit(FLAG_IS_OUT, &lh->descs[0]->flags)) - return -EPERM; - - if (copy_from_user(&ghd, ip, sizeof(ghd))) - return -EFAULT; - - /* Clamp all values to [0,1] */ - for (i = 0; i < lh->numdescs; i++) - __assign_bit(i, vals, ghd.values[i]); - - /* Reuse the array setting function */ - return gpiod_set_array_value_complex(false, - true, - lh->numdescs, - lh->descs, - NULL, - vals); - } else if (cmd == GPIOHANDLE_SET_CONFIG_IOCTL) { - return linehandle_set_config(lh, ip); - } - return -EINVAL; -} - -#ifdef CONFIG_COMPAT -static long linehandle_ioctl_compat(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - return linehandle_ioctl(filep, cmd, (unsigned long)compat_ptr(arg)); -} -#endif - -static int linehandle_release(struct inode *inode, struct file *filep) -{ - struct linehandle_state *lh = filep->private_data; - struct gpio_device *gdev = lh->gdev; - int i; - - for (i = 0; i < lh->numdescs; i++) - gpiod_free(lh->descs[i]); - kfree(lh->label); - kfree(lh); - put_device(&gdev->dev); - return 0; -} - -static const struct file_operations linehandle_fileops = { - .release = linehandle_release, - .owner = THIS_MODULE, - .llseek = noop_llseek, - .unlocked_ioctl = linehandle_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = linehandle_ioctl_compat, -#endif -}; - -static int linehandle_create(struct gpio_device *gdev, void __user *ip) -{ - struct gpiohandle_request handlereq; - struct linehandle_state *lh; - struct file *file; - int fd, i, count = 0, ret; - u32 lflags; - - if (copy_from_user(&handlereq, ip, sizeof(handlereq))) - return -EFAULT; - if ((handlereq.lines == 0) || (handlereq.lines > GPIOHANDLES_MAX)) - return -EINVAL; - - lflags = handlereq.flags; - - ret = linehandle_validate_flags(lflags); - if (ret) - return ret; - - lh = kzalloc(sizeof(*lh), GFP_KERNEL); - if (!lh) - return -ENOMEM; - lh->gdev = gdev; - get_device(&gdev->dev); - - /* Make sure this is terminated */ - handlereq.consumer_label[sizeof(handlereq.consumer_label)-1] = '\0'; - if (strlen(handlereq.consumer_label)) { - lh->label = kstrdup(handlereq.consumer_label, - GFP_KERNEL); - if (!lh->label) { - ret = -ENOMEM; - goto out_free_lh; - } - } - - /* Request each GPIO */ - for (i = 0; i < handlereq.lines; i++) { - u32 offset = handlereq.lineoffsets[i]; - struct gpio_desc *desc = gpiochip_get_desc(gdev->chip, offset); - - if (IS_ERR(desc)) { - ret = PTR_ERR(desc); - goto out_free_descs; - } - - ret = gpiod_request(desc, lh->label); - if (ret) - goto out_free_descs; - lh->descs[i] = desc; - count = i + 1; - - if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW) - set_bit(FLAG_ACTIVE_LOW, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) - set_bit(FLAG_OPEN_DRAIN, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE) - set_bit(FLAG_OPEN_SOURCE, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_BIAS_DISABLE) - set_bit(FLAG_BIAS_DISABLE, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN) - set_bit(FLAG_PULL_DOWN, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_BIAS_PULL_UP) - set_bit(FLAG_PULL_UP, &desc->flags); - - ret = gpiod_set_transitory(desc, false); - if (ret < 0) - goto out_free_descs; - - /* - * Lines have to be requested explicitly for input - * or output, else the line will be treated "as is". - */ - if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { - int val = !!handlereq.default_values[i]; - - ret = gpiod_direction_output(desc, val); - if (ret) - goto out_free_descs; - } else if (lflags & GPIOHANDLE_REQUEST_INPUT) { - ret = gpiod_direction_input(desc); - if (ret) - goto out_free_descs; - } - - atomic_notifier_call_chain(&desc->gdev->notifier, - GPIOLINE_CHANGED_REQUESTED, desc); - - dev_dbg(&gdev->dev, "registered chardev handle for line %d\n", - offset); - } - /* Let i point at the last handle */ - i--; - lh->numdescs = handlereq.lines; - - fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC); - if (fd < 0) { - ret = fd; - goto out_free_descs; - } - - file = anon_inode_getfile("gpio-linehandle", - &linehandle_fileops, - lh, - O_RDONLY | O_CLOEXEC); - if (IS_ERR(file)) { - ret = PTR_ERR(file); - goto out_put_unused_fd; - } - - handlereq.fd = fd; - if (copy_to_user(ip, &handlereq, sizeof(handlereq))) { - /* - * fput() will trigger the release() callback, so do not go onto - * the regular error cleanup path here. - */ - fput(file); - put_unused_fd(fd); - return -EFAULT; - } - - fd_install(fd, file); - - dev_dbg(&gdev->dev, "registered chardev handle for %d lines\n", - lh->numdescs); - - return 0; - -out_put_unused_fd: - put_unused_fd(fd); -out_free_descs: - for (i = 0; i < count; i++) - gpiod_free(lh->descs[i]); - kfree(lh->label); -out_free_lh: - kfree(lh); - put_device(&gdev->dev); - return ret; -} - -/* - * GPIO line event management - */ - -/** - * struct lineevent_state - contains the state of a userspace event - * @gdev: the GPIO device the event pertains to - * @label: consumer label used to tag descriptors - * @desc: the GPIO descriptor held by this event - * @eflags: the event flags this line was requested with - * @irq: the interrupt that trigger in response to events on this GPIO - * @wait: wait queue that handles blocking reads of events - * @events: KFIFO for the GPIO events - * @timestamp: cache for the timestamp storing it between hardirq - * and IRQ thread, used to bring the timestamp close to the actual - * event - */ -struct lineevent_state { - struct gpio_device *gdev; - const char *label; - struct gpio_desc *desc; - u32 eflags; - int irq; - wait_queue_head_t wait; - DECLARE_KFIFO(events, struct gpioevent_data, 16); - u64 timestamp; -}; - -#define GPIOEVENT_REQUEST_VALID_FLAGS \ - (GPIOEVENT_REQUEST_RISING_EDGE | \ - GPIOEVENT_REQUEST_FALLING_EDGE) - -static __poll_t lineevent_poll(struct file *filep, - struct poll_table_struct *wait) -{ - struct lineevent_state *le = filep->private_data; - __poll_t events = 0; - - poll_wait(filep, &le->wait, wait); - - if (!kfifo_is_empty_spinlocked_noirqsave(&le->events, &le->wait.lock)) - events = EPOLLIN | EPOLLRDNORM; - - return events; -} - - -static ssize_t lineevent_read(struct file *filep, - char __user *buf, - size_t count, - loff_t *f_ps) -{ - struct lineevent_state *le = filep->private_data; - struct gpioevent_data ge; - ssize_t bytes_read = 0; - int ret; - - if (count < sizeof(ge)) - return -EINVAL; - - do { - spin_lock(&le->wait.lock); - if (kfifo_is_empty(&le->events)) { - if (bytes_read) { - spin_unlock(&le->wait.lock); - return bytes_read; - } - - if (filep->f_flags & O_NONBLOCK) { - spin_unlock(&le->wait.lock); - return -EAGAIN; - } - - ret = wait_event_interruptible_locked(le->wait, - !kfifo_is_empty(&le->events)); - if (ret) { - spin_unlock(&le->wait.lock); - return ret; - } - } - - ret = kfifo_out(&le->events, &ge, 1); - spin_unlock(&le->wait.lock); - if (ret != 1) { - /* - * This should never happen - we were holding the lock - * from the moment we learned the fifo is no longer - * empty until now. - */ - ret = -EIO; - break; - } - - if (copy_to_user(buf + bytes_read, &ge, sizeof(ge))) - return -EFAULT; - bytes_read += sizeof(ge); - } while (count >= bytes_read + sizeof(ge)); - - return bytes_read; -} - -static int lineevent_release(struct inode *inode, struct file *filep) -{ - struct lineevent_state *le = filep->private_data; - struct gpio_device *gdev = le->gdev; - - free_irq(le->irq, le); - gpiod_free(le->desc); - kfree(le->label); - kfree(le); - put_device(&gdev->dev); - return 0; -} - -static long lineevent_ioctl(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - struct lineevent_state *le = filep->private_data; - void __user *ip = (void __user *)arg; - struct gpiohandle_data ghd; - - /* - * We can get the value for an event line but not set it, - * because it is input by definition. - */ - if (cmd == GPIOHANDLE_GET_LINE_VALUES_IOCTL) { - int val; - - memset(&ghd, 0, sizeof(ghd)); - - val = gpiod_get_value_cansleep(le->desc); - if (val < 0) - return val; - ghd.values[0] = val; - - if (copy_to_user(ip, &ghd, sizeof(ghd))) - return -EFAULT; - - return 0; - } - return -EINVAL; -} - -#ifdef CONFIG_COMPAT -static long lineevent_ioctl_compat(struct file *filep, unsigned int cmd, - unsigned long arg) -{ - return lineevent_ioctl(filep, cmd, (unsigned long)compat_ptr(arg)); -} -#endif - -static const struct file_operations lineevent_fileops = { - .release = lineevent_release, - .read = lineevent_read, - .poll = lineevent_poll, - .owner = THIS_MODULE, - .llseek = noop_llseek, - .unlocked_ioctl = lineevent_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = lineevent_ioctl_compat, -#endif -}; - -static irqreturn_t lineevent_irq_thread(int irq, void *p) -{ - struct lineevent_state *le = p; - struct gpioevent_data ge; - int ret; - - /* Do not leak kernel stack to userspace */ - memset(&ge, 0, sizeof(ge)); - - /* - * We may be running from a nested threaded interrupt in which case - * we didn't get the timestamp from lineevent_irq_handler(). - */ - if (!le->timestamp) - ge.timestamp = ktime_get_ns(); - else - ge.timestamp = le->timestamp; - - if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE - && le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) { - int level = gpiod_get_value_cansleep(le->desc); - if (level) - /* Emit low-to-high event */ - ge.id = GPIOEVENT_EVENT_RISING_EDGE; - else - /* Emit high-to-low event */ - ge.id = GPIOEVENT_EVENT_FALLING_EDGE; - } else if (le->eflags & GPIOEVENT_REQUEST_RISING_EDGE) { - /* Emit low-to-high event */ - ge.id = GPIOEVENT_EVENT_RISING_EDGE; - } else if (le->eflags & GPIOEVENT_REQUEST_FALLING_EDGE) { - /* Emit high-to-low event */ - ge.id = GPIOEVENT_EVENT_FALLING_EDGE; - } else { - return IRQ_NONE; - } - - ret = kfifo_in_spinlocked_noirqsave(&le->events, &ge, - 1, &le->wait.lock); - if (ret) - wake_up_poll(&le->wait, EPOLLIN); - else - pr_debug_ratelimited("event FIFO is full - event dropped\n"); - - return IRQ_HANDLED; -} - -static irqreturn_t lineevent_irq_handler(int irq, void *p) -{ - struct lineevent_state *le = p; - - /* - * Just store the timestamp in hardirq context so we get it as - * close in time as possible to the actual event. - */ - le->timestamp = ktime_get_ns(); - - return IRQ_WAKE_THREAD; -} - -static int lineevent_create(struct gpio_device *gdev, void __user *ip) -{ - struct gpioevent_request eventreq; - struct lineevent_state *le; - struct gpio_desc *desc; - struct file *file; - u32 offset; - u32 lflags; - u32 eflags; - int fd; - int ret; - int irqflags = 0; - - if (copy_from_user(&eventreq, ip, sizeof(eventreq))) - return -EFAULT; - - offset = eventreq.lineoffset; - lflags = eventreq.handleflags; - eflags = eventreq.eventflags; - - desc = gpiochip_get_desc(gdev->chip, offset); - if (IS_ERR(desc)) - return PTR_ERR(desc); - - /* Return an error if a unknown flag is set */ - if ((lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) || - (eflags & ~GPIOEVENT_REQUEST_VALID_FLAGS)) - return -EINVAL; - - /* This is just wrong: we don't look for events on output lines */ - if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) || - (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) || - (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) - return -EINVAL; - - /* Only one bias flag can be set. */ - if (((lflags & GPIOHANDLE_REQUEST_BIAS_DISABLE) && - (lflags & (GPIOHANDLE_REQUEST_BIAS_PULL_DOWN | - GPIOHANDLE_REQUEST_BIAS_PULL_UP))) || - ((lflags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN) && - (lflags & GPIOHANDLE_REQUEST_BIAS_PULL_UP))) - return -EINVAL; - - le = kzalloc(sizeof(*le), GFP_KERNEL); - if (!le) - return -ENOMEM; - le->gdev = gdev; - get_device(&gdev->dev); - - /* Make sure this is terminated */ - eventreq.consumer_label[sizeof(eventreq.consumer_label)-1] = '\0'; - if (strlen(eventreq.consumer_label)) { - le->label = kstrdup(eventreq.consumer_label, - GFP_KERNEL); - if (!le->label) { - ret = -ENOMEM; - goto out_free_le; - } - } - - ret = gpiod_request(desc, le->label); - if (ret) - goto out_free_label; - le->desc = desc; - le->eflags = eflags; - - if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW) - set_bit(FLAG_ACTIVE_LOW, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_BIAS_DISABLE) - set_bit(FLAG_BIAS_DISABLE, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_BIAS_PULL_DOWN) - set_bit(FLAG_PULL_DOWN, &desc->flags); - if (lflags & GPIOHANDLE_REQUEST_BIAS_PULL_UP) - set_bit(FLAG_PULL_UP, &desc->flags); - - ret = gpiod_direction_input(desc); - if (ret) - goto out_free_desc; - - atomic_notifier_call_chain(&desc->gdev->notifier, - GPIOLINE_CHANGED_REQUESTED, desc); - - le->irq = gpiod_to_irq(desc); - if (le->irq <= 0) { - ret = -ENODEV; - goto out_free_desc; - } - - if (eflags & GPIOEVENT_REQUEST_RISING_EDGE) - irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? - IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING; - if (eflags & GPIOEVENT_REQUEST_FALLING_EDGE) - irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? - IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; - irqflags |= IRQF_ONESHOT; - - INIT_KFIFO(le->events); - init_waitqueue_head(&le->wait); - - /* Request a thread to read the events */ - ret = request_threaded_irq(le->irq, - lineevent_irq_handler, - lineevent_irq_thread, - irqflags, - le->label, - le); - if (ret) - goto out_free_desc; - - fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC); - if (fd < 0) { - ret = fd; - goto out_free_irq; - } - - file = anon_inode_getfile("gpio-event", - &lineevent_fileops, - le, - O_RDONLY | O_CLOEXEC); - if (IS_ERR(file)) { - ret = PTR_ERR(file); - goto out_put_unused_fd; - } - - eventreq.fd = fd; - if (copy_to_user(ip, &eventreq, sizeof(eventreq))) { - /* - * fput() will trigger the release() callback, so do not go onto - * the regular error cleanup path here. - */ - fput(file); - put_unused_fd(fd); - return -EFAULT; - } - - fd_install(fd, file); - - return 0; - -out_put_unused_fd: - put_unused_fd(fd); -out_free_irq: - free_irq(le->irq, le); -out_free_desc: - gpiod_free(le->desc); -out_free_label: - kfree(le->label); -out_free_le: - kfree(le); - put_device(&gdev->dev); - return ret; -} - -static void gpio_desc_to_lineinfo(struct gpio_desc *desc, - struct gpioline_info *info) -{ - struct gpio_chip *gc = desc->gdev->chip; - bool ok_for_pinctrl; - unsigned long flags; - - /* - * This function takes a mutex so we must check this before taking - * the spinlock. - * - * FIXME: find a non-racy way to retrieve this information. Maybe a - * lock common to both frameworks? - */ - ok_for_pinctrl = - pinctrl_gpio_can_use_line(gc->base + info->line_offset); - - spin_lock_irqsave(&gpio_lock, flags); - - if (desc->name) { - strncpy(info->name, desc->name, sizeof(info->name)); - info->name[sizeof(info->name) - 1] = '\0'; - } else { - info->name[0] = '\0'; - } - - if (desc->label) { - strncpy(info->consumer, desc->label, sizeof(info->consumer)); - info->consumer[sizeof(info->consumer) - 1] = '\0'; - } else { - info->consumer[0] = '\0'; - } - - /* - * Userspace only need to know that the kernel is using this GPIO so - * it can't use it. - */ - info->flags = 0; - if (test_bit(FLAG_REQUESTED, &desc->flags) || - test_bit(FLAG_IS_HOGGED, &desc->flags) || - test_bit(FLAG_USED_AS_IRQ, &desc->flags) || - test_bit(FLAG_EXPORT, &desc->flags) || - test_bit(FLAG_SYSFS, &desc->flags) || - !ok_for_pinctrl) - info->flags |= GPIOLINE_FLAG_KERNEL; - if (test_bit(FLAG_IS_OUT, &desc->flags)) - info->flags |= GPIOLINE_FLAG_IS_OUT; - if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) - info->flags |= GPIOLINE_FLAG_ACTIVE_LOW; - if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) - info->flags |= (GPIOLINE_FLAG_OPEN_DRAIN | - GPIOLINE_FLAG_IS_OUT); - if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) - info->flags |= (GPIOLINE_FLAG_OPEN_SOURCE | - GPIOLINE_FLAG_IS_OUT); - if (test_bit(FLAG_BIAS_DISABLE, &desc->flags)) - info->flags |= GPIOLINE_FLAG_BIAS_DISABLE; - if (test_bit(FLAG_PULL_DOWN, &desc->flags)) - info->flags |= GPIOLINE_FLAG_BIAS_PULL_DOWN; - if (test_bit(FLAG_PULL_UP, &desc->flags)) - info->flags |= GPIOLINE_FLAG_BIAS_PULL_UP; - - spin_unlock_irqrestore(&gpio_lock, flags); -} - -struct gpio_chardev_data { - struct gpio_device *gdev; - wait_queue_head_t wait; - DECLARE_KFIFO(events, struct gpioline_info_changed, 32); - struct notifier_block lineinfo_changed_nb; - unsigned long *watched_lines; -}; - -/* - * gpio_ioctl() - ioctl handler for the GPIO chardev - */ -static long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - struct gpio_chardev_data *priv = filp->private_data; - struct gpio_device *gdev = priv->gdev; - struct gpio_chip *gc = gdev->chip; - void __user *ip = (void __user *)arg; - struct gpio_desc *desc; - __u32 offset; - int hwgpio; - - /* We fail any subsequent ioctl():s when the chip is gone */ - if (!gc) - return -ENODEV; - - /* Fill in the struct and pass to userspace */ - if (cmd == GPIO_GET_CHIPINFO_IOCTL) { - struct gpiochip_info chipinfo; - - memset(&chipinfo, 0, sizeof(chipinfo)); - - strncpy(chipinfo.name, dev_name(&gdev->dev), - sizeof(chipinfo.name)); - chipinfo.name[sizeof(chipinfo.name)-1] = '\0'; - strncpy(chipinfo.label, gdev->label, - sizeof(chipinfo.label)); - chipinfo.label[sizeof(chipinfo.label)-1] = '\0'; - chipinfo.lines = gdev->ngpio; - if (copy_to_user(ip, &chipinfo, sizeof(chipinfo))) - return -EFAULT; - return 0; - } else if (cmd == GPIO_GET_LINEINFO_IOCTL) { - struct gpioline_info lineinfo; - - if (copy_from_user(&lineinfo, ip, sizeof(lineinfo))) - return -EFAULT; - - desc = gpiochip_get_desc(gc, lineinfo.line_offset); - if (IS_ERR(desc)) - return PTR_ERR(desc); - - hwgpio = gpio_chip_hwgpio(desc); - - gpio_desc_to_lineinfo(desc, &lineinfo); - - if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) - return -EFAULT; - return 0; - } else if (cmd == GPIO_GET_LINEHANDLE_IOCTL) { - return linehandle_create(gdev, ip); - } else if (cmd == GPIO_GET_LINEEVENT_IOCTL) { - return lineevent_create(gdev, ip); - } else if (cmd == GPIO_GET_LINEINFO_WATCH_IOCTL) { - struct gpioline_info lineinfo; - - if (copy_from_user(&lineinfo, ip, sizeof(lineinfo))) - return -EFAULT; - - desc = gpiochip_get_desc(gc, lineinfo.line_offset); - if (IS_ERR(desc)) - return PTR_ERR(desc); - - hwgpio = gpio_chip_hwgpio(desc); - - if (test_bit(hwgpio, priv->watched_lines)) - return -EBUSY; - - gpio_desc_to_lineinfo(desc, &lineinfo); - - if (copy_to_user(ip, &lineinfo, sizeof(lineinfo))) - return -EFAULT; - - set_bit(hwgpio, priv->watched_lines); - return 0; - } else if (cmd == GPIO_GET_LINEINFO_UNWATCH_IOCTL) { - if (copy_from_user(&offset, ip, sizeof(offset))) - return -EFAULT; - - desc = gpiochip_get_desc(gc, offset); - if (IS_ERR(desc)) - return PTR_ERR(desc); - - hwgpio = gpio_chip_hwgpio(desc); - - if (!test_bit(hwgpio, priv->watched_lines)) - return -EBUSY; - - clear_bit(hwgpio, priv->watched_lines); - return 0; - } - return -EINVAL; -} - -#ifdef CONFIG_COMPAT -static long gpio_ioctl_compat(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - return gpio_ioctl(filp, cmd, (unsigned long)compat_ptr(arg)); -} -#endif - -static struct gpio_chardev_data * -to_gpio_chardev_data(struct notifier_block *nb) -{ - return container_of(nb, struct gpio_chardev_data, lineinfo_changed_nb); -} - -static int lineinfo_changed_notify(struct notifier_block *nb, - unsigned long action, void *data) -{ - struct gpio_chardev_data *priv = to_gpio_chardev_data(nb); - struct gpioline_info_changed chg; - struct gpio_desc *desc = data; - int ret; - - if (!test_bit(gpio_chip_hwgpio(desc), priv->watched_lines)) - return NOTIFY_DONE; - - memset(&chg, 0, sizeof(chg)); - chg.info.line_offset = gpio_chip_hwgpio(desc); - chg.event_type = action; - chg.timestamp = ktime_get_ns(); - gpio_desc_to_lineinfo(desc, &chg.info); - - ret = kfifo_in_spinlocked(&priv->events, &chg, 1, &priv->wait.lock); - if (ret) - wake_up_poll(&priv->wait, EPOLLIN); - else - pr_debug_ratelimited("lineinfo event FIFO is full - event dropped\n"); - - return NOTIFY_OK; -} - -static __poll_t lineinfo_watch_poll(struct file *filep, - struct poll_table_struct *pollt) -{ - struct gpio_chardev_data *priv = filep->private_data; - __poll_t events = 0; - - poll_wait(filep, &priv->wait, pollt); - - if (!kfifo_is_empty_spinlocked_noirqsave(&priv->events, - &priv->wait.lock)) - events = EPOLLIN | EPOLLRDNORM; - - return events; -} - -static ssize_t lineinfo_watch_read(struct file *filep, char __user *buf, - size_t count, loff_t *off) -{ - struct gpio_chardev_data *priv = filep->private_data; - struct gpioline_info_changed event; - ssize_t bytes_read = 0; - int ret; - - if (count < sizeof(event)) - return -EINVAL; - - do { - spin_lock(&priv->wait.lock); - if (kfifo_is_empty(&priv->events)) { - if (bytes_read) { - spin_unlock(&priv->wait.lock); - return bytes_read; - } - - if (filep->f_flags & O_NONBLOCK) { - spin_unlock(&priv->wait.lock); - return -EAGAIN; - } - - ret = wait_event_interruptible_locked(priv->wait, - !kfifo_is_empty(&priv->events)); - if (ret) { - spin_unlock(&priv->wait.lock); - return ret; - } - } - - ret = kfifo_out(&priv->events, &event, 1); - spin_unlock(&priv->wait.lock); - if (ret != 1) { - ret = -EIO; - break; - /* We should never get here. See lineevent_read(). */ - } - - if (copy_to_user(buf + bytes_read, &event, sizeof(event))) - return -EFAULT; - bytes_read += sizeof(event); - } while (count >= bytes_read + sizeof(event)); - - return bytes_read; -} - -/** - * gpio_chrdev_open() - open the chardev for ioctl operations - * @inode: inode for this chardev - * @filp: file struct for storing private data - * Returns 0 on success - */ -static int gpio_chrdev_open(struct inode *inode, struct file *filp) -{ - struct gpio_device *gdev = container_of(inode->i_cdev, - struct gpio_device, chrdev); - struct gpio_chardev_data *priv; - int ret = -ENOMEM; - - /* Fail on open if the backing gpiochip is gone */ - if (!gdev->chip) - return -ENODEV; - - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->watched_lines = bitmap_zalloc(gdev->chip->ngpio, GFP_KERNEL); - if (!priv->watched_lines) - goto out_free_priv; - - init_waitqueue_head(&priv->wait); - INIT_KFIFO(priv->events); - priv->gdev = gdev; - - priv->lineinfo_changed_nb.notifier_call = lineinfo_changed_notify; - ret = atomic_notifier_chain_register(&gdev->notifier, - &priv->lineinfo_changed_nb); - if (ret) - goto out_free_bitmap; - - get_device(&gdev->dev); - filp->private_data = priv; - - ret = nonseekable_open(inode, filp); - if (ret) - goto out_unregister_notifier; - - return ret; - -out_unregister_notifier: - atomic_notifier_chain_unregister(&gdev->notifier, - &priv->lineinfo_changed_nb); -out_free_bitmap: - bitmap_free(priv->watched_lines); -out_free_priv: - kfree(priv); - return ret; -} - -/** - * gpio_chrdev_release() - close chardev after ioctl operations - * @inode: inode for this chardev - * @filp: file struct for storing private data - * Returns 0 on success - */ -static int gpio_chrdev_release(struct inode *inode, struct file *filp) -{ - struct gpio_chardev_data *priv = filp->private_data; - struct gpio_device *gdev = priv->gdev; - - bitmap_free(priv->watched_lines); - atomic_notifier_chain_unregister(&gdev->notifier, - &priv->lineinfo_changed_nb); - put_device(&gdev->dev); - kfree(priv); - - return 0; -} - -static const struct file_operations gpio_fileops = { - .release = gpio_chrdev_release, - .open = gpio_chrdev_open, - .poll = lineinfo_watch_poll, - .read = lineinfo_watch_read, - .owner = THIS_MODULE, - .llseek = no_llseek, - .unlocked_ioctl = gpio_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = gpio_ioctl_compat, -#endif -}; - static void gpiodevice_release(struct device *dev) { struct gpio_device *gdev = dev_get_drvdata(dev); @@@ -436,10 -1539,17 +436,10 @@@ static int gpiochip_setup_dev(struct gp { int ret;
- cdev_init(&gdev->chrdev, &gpio_fileops); - gdev->chrdev.owner = THIS_MODULE; - gdev->dev.devt = MKDEV(MAJOR(gpio_devt), gdev->id); - - ret = cdev_device_add(&gdev->chrdev, &gdev->dev); + ret = gpiolib_cdev_register(gdev, gpio_devt); if (ret) return ret;
- chip_dbg(gdev->chip, "added GPIO chardev (%d:%d)\n", - MAJOR(gpio_devt), gdev->id); - ret = gpiochip_sysfs_register(gdev); if (ret) goto err_remove_device; @@@ -452,7 -1562,7 +452,7 @@@ return 0;
err_remove_device: - cdev_device_del(&gdev->chrdev, &gdev->dev); + gpiolib_cdev_unregister(gdev); return ret; }
@@@ -615,7 -1725,7 +615,7 @@@ int gpiochip_add_data_with_key(struct g
spin_unlock_irqrestore(&gpio_lock, flags);
- ATOMIC_INIT_NOTIFIER_HEAD(&gdev->notifier); + BLOCKING_INIT_NOTIFIER_HEAD(&gdev->notifier);
#ifdef CONFIG_PINCTRL INIT_LIST_HEAD(&gdev->pin_ranges); @@@ -774,7 -1884,7 +774,7 @@@ void gpiochip_remove(struct gpio_chip * * be removed, else it will be dangling until the last user is * gone. */ - cdev_device_del(&gdev->chrdev, &gdev->dev); + gpiolib_cdev_unregister(gdev); put_device(&gdev->dev); } EXPORT_SYMBOL_GPL(gpiochip_remove); @@@ -2049,8 -3159,8 +2049,8 @@@ static bool gpiod_free_commit(struct gp }
spin_unlock_irqrestore(&gpio_lock, flags); - atomic_notifier_call_chain(&desc->gdev->notifier, - GPIOLINE_CHANGED_RELEASED, desc); + blocking_notifier_call_chain(&desc->gdev->notifier, + GPIOLINE_CHANGED_RELEASED, desc);
return ret; } @@@ -2595,9 -3705,10 +2595,9 @@@ int gpiod_get_array_value_complex(bool bitmap_xor(value_bitmap, value_bitmap, array_info->invert_mask, array_size);
- if (bitmap_full(array_info->get_mask, array_size)) - return 0; - i = find_first_zero_bit(array_info->get_mask, array_size); + if (i == array_size) + return 0; } else { array_info = NULL; } @@@ -2878,9 -3989,10 +2878,9 @@@ int gpiod_set_array_value_complex(bool gpio_chip_set_multiple(array_info->chip, array_info->set_mask, value_bitmap);
- if (bitmap_full(array_info->set_mask, array_size)) - return 0; - i = find_first_zero_bit(array_info->set_mask, array_size); + if (i == array_size) + return 0; } else { array_info = NULL; } @@@ -3927,8 -5039,8 +3927,8 @@@ struct gpio_desc *__must_check gpiod_ge return ERR_PTR(ret); }
- atomic_notifier_call_chain(&desc->gdev->notifier, - GPIOLINE_CHANGED_REQUESTED, desc); + blocking_notifier_call_chain(&desc->gdev->notifier, + GPIOLINE_CHANGED_REQUESTED, desc);
return desc; } @@@ -3995,8 -5107,8 +3995,8 @@@ struct gpio_desc *fwnode_get_named_gpio return ERR_PTR(ret); }
- atomic_notifier_call_chain(&desc->gdev->notifier, - GPIOLINE_CHANGED_REQUESTED, desc); + blocking_notifier_call_chain(&desc->gdev->notifier, + GPIOLINE_CHANGED_REQUESTED, desc);
return desc; } @@@ -4417,7 -5529,7 +4417,7 @@@ static int gpiolib_open(struct inode *i static const struct file_operations gpiolib_operations = { .owner = THIS_MODULE, .open = gpiolib_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; diff --combined drivers/gpu/drm/arm/malidp_drv.c index 69fee05c256c,029a26def9f7..c9e18eeddf2e --- a/drivers/gpu/drm/arm/malidp_drv.c +++ b/drivers/gpu/drm/arm/malidp_drv.c @@@ -349,11 -349,11 +349,11 @@@ malidp_verify_afbc_framebuffer_size(str if (objs->size < afbc_size) { DRM_DEBUG_KMS("buffer size (%zu) too small for AFBC buffer size = %u\n", objs->size, afbc_size); - drm_gem_object_put_unlocked(objs); + drm_gem_object_put(objs); return false; }
- drm_gem_object_put_unlocked(objs); + drm_gem_object_put(objs);
return true; } @@@ -542,7 -542,7 +542,7 @@@ static ssize_t malidp_debugfs_write(str static const struct file_operations malidp_debugfs_fops = { .owner = THIS_MODULE, .open = malidp_debugfs_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = malidp_debugfs_write, .llseek = seq_lseek, .release = single_release, @@@ -563,7 -563,16 +563,7 @@@ static void malidp_debugfs_init(struct
static struct drm_driver malidp_driver = { .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, - .gem_free_object_unlocked = drm_gem_cma_free_object, - .gem_vm_ops = &drm_gem_cma_vm_ops, - .dumb_create = malidp_dumb_create, - .prime_handle_to_fd = drm_gem_prime_handle_to_fd, - .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, - .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, + DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(malidp_dumb_create), #ifdef CONFIG_DEBUG_FS .debugfs_init = malidp_debugfs_init, #endif @@@ -657,11 -666,20 +657,11 @@@ static ssize_t core_id_show(struct devi
static DEVICE_ATTR_RO(core_id);
-static int malidp_init_sysfs(struct device *dev) -{ - int ret = device_create_file(dev, &dev_attr_core_id); - - if (ret) - DRM_ERROR("failed to create device file for core_id\n"); - - return ret; -} - -static void malidp_fini_sysfs(struct device *dev) -{ - device_remove_file(dev, &dev_attr_core_id); -} +static struct attribute *mali_dp_attrs[] = { + &dev_attr_core_id.attr, + NULL, +}; +ATTRIBUTE_GROUPS(mali_dp);
#define MAX_OUTPUT_CHANNELS 3
@@@ -823,6 -841,10 +823,6 @@@ static int malidp_bind(struct device *d if (ret < 0) goto query_hw_fail;
- ret = malidp_init_sysfs(dev); - if (ret) - goto init_fail; - /* Set the CRTC's port so that the encoder component can find it */ malidp->crtc.port = of_graph_get_port_by_id(dev->of_node, 0);
@@@ -848,6 -870,7 +848,6 @@@ drm->irq_enabled = true;
ret = drm_vblank_init(drm, drm->mode_config.num_crtc); - drm_crtc_vblank_reset(&malidp->crtc); if (ret < 0) { DRM_ERROR("failed to initialise vblank\n"); goto vblank_fail; @@@ -879,6 -902,8 +879,6 @@@ irq_init_fail bind_fail: of_node_put(malidp->crtc.port); malidp->crtc.port = NULL; -init_fail: - malidp_fini_sysfs(dev); malidp_fini(drm); query_hw_fail: pm_runtime_put(dev); @@@ -904,13 -929,15 +904,13 @@@ static void malidp_unbind(struct devic drm_dev_unregister(drm); drm_kms_helper_poll_fini(drm); pm_runtime_get_sync(dev); - drm_crtc_vblank_off(&malidp->crtc); + drm_atomic_helper_shutdown(drm); malidp_se_irq_fini(hwdev); malidp_de_irq_fini(hwdev); drm->irq_enabled = false; - drm_atomic_helper_shutdown(drm); component_unbind_all(dev, drm); of_node_put(malidp->crtc.port); malidp->crtc.port = NULL; - malidp_fini_sysfs(dev); malidp_fini(drm); pm_runtime_put(dev); if (pm_runtime_enabled(dev)) @@@ -1006,7 -1033,6 +1006,7 @@@ static struct platform_driver malidp_pl .name = "mali-dp", .pm = &malidp_pm_ops, .of_match_table = malidp_drm_of_match, + .dev_groups = mali_dp_groups, }, };
diff --combined drivers/gpu/drm/drm_debugfs.c index 3d7182001004,a0a1a598826f..c4b2c861101f --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@@ -154,7 -154,7 +154,7 @@@ static int drm_debugfs_open(struct inod static const struct file_operations drm_debugfs_fops = { .owner = THIS_MODULE, .open = drm_debugfs_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -311,13 -311,13 +311,13 @@@ static ssize_t connector_write(struct f
buf[len] = '\0';
- if (!strcmp(buf, "on")) + if (sysfs_streq(buf, "on")) connector->force = DRM_FORCE_ON; - else if (!strcmp(buf, "digital")) + else if (sysfs_streq(buf, "digital")) connector->force = DRM_FORCE_ON_DIGITAL; - else if (!strcmp(buf, "off")) + else if (sysfs_streq(buf, "off")) connector->force = DRM_FORCE_OFF; - else if (!strcmp(buf, "unspecified")) + else if (sysfs_streq(buf, "unspecified")) connector->force = DRM_FORCE_UNSPECIFIED; else return -EINVAL; @@@ -376,28 -376,10 +376,28 @@@ static ssize_t edid_write(struct file * return (ret) ? ret : len; }
+/* + * Returns the min and max vrr vfreq through the connector's debugfs file. + * Example usage: cat /sys/kernel/debug/dri/0/DP-1/vrr_range + */ +static int vrr_range_show(struct seq_file *m, void *data) +{ + struct drm_connector *connector = m->private; + + if (connector->status != connector_status_connected) + return -ENODEV; + + seq_printf(m, "Min: %u\n", (u8)connector->display_info.monitor_range.min_vfreq); + seq_printf(m, "Max: %u\n", (u8)connector->display_info.monitor_range.max_vfreq); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(vrr_range); + static const struct file_operations drm_edid_fops = { .owner = THIS_MODULE, .open = edid_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = edid_write @@@ -407,7 -389,7 +407,7 @@@ static const struct file_operations drm_connector_fops = { .owner = THIS_MODULE, .open = connector_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = connector_write @@@ -431,10 -413,6 +431,10 @@@ void drm_debugfs_connector_add(struct d /* edid */ debugfs_create_file("edid_override", S_IRUGO | S_IWUSR, root, connector, &drm_edid_fops); + + /* vrr range */ + debugfs_create_file("vrr_range", S_IRUGO, root, connector, + &vrr_range_fops); }
void drm_debugfs_connector_remove(struct drm_connector *connector) diff --combined drivers/gpu/drm/drm_mipi_dbi.c index 79532b9a324a,d0298376d28a..0e55d8716e3d --- a/drivers/gpu/drm/drm_mipi_dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@@ -217,7 -217,7 +217,7 @@@ int mipi_dbi_buf_copy(void *dst, struc switch (fb->format->format) { case DRM_FORMAT_RGB565: if (swap) - drm_fb_swab16(dst, src, fb, clip); + drm_fb_swab(dst, src, fb, clip, !import_attach); else drm_fb_memcpy(dst, src, fb, clip); break; @@@ -268,7 -268,7 +268,7 @@@ static void mipi_dbi_fb_dirty(struct dr bool full; void *tr;
- if (!dbidev->enabled) + if (WARN_ON(!fb)) return;
if (!drm_dev_enter(fb->dev, &idx)) @@@ -314,9 -314,6 +314,9 @@@ void mipi_dbi_pipe_update(struct drm_si struct drm_plane_state *state = pipe->plane.state; struct drm_rect rect;
+ if (!pipe->crtc.state->active) + return; + if (drm_atomic_helper_damage_merged(old_state, state, &rect)) mipi_dbi_fb_dirty(state->fb, &rect); } @@@ -328,8 -325,9 +328,8 @@@ EXPORT_SYMBOL(mipi_dbi_pipe_update) * @crtc_state: CRTC state * @plane_state: Plane state * - * This function sets &mipi_dbi->enabled, flushes the whole framebuffer and - * enables the backlight. Drivers can use this in their - * &drm_simple_display_pipe_funcs->enable callback. + * Flushes the whole framebuffer and enables the backlight. Drivers can use this + * in their &drm_simple_display_pipe_funcs->enable callback. * * Note: Drivers which don't use mipi_dbi_pipe_update() because they have custom * framebuffer flushing, can't use this function since they both use the same @@@ -351,6 -349,7 +351,6 @@@ void mipi_dbi_enable_flush(struct mipi_ if (!drm_dev_enter(&dbidev->drm, &idx)) return;
- dbidev->enabled = true; mipi_dbi_fb_dirty(fb, &rect); backlight_enable(dbidev->backlight);
@@@ -391,8 -390,13 +391,8 @@@ void mipi_dbi_pipe_disable(struct drm_s { struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);
- if (!dbidev->enabled) - return; - DRM_DEBUG_KMS("\n");
- dbidev->enabled = false; - if (dbidev->backlight) backlight_disable(dbidev->backlight); else @@@ -1275,7 -1279,7 +1275,7 @@@ static int mipi_dbi_debugfs_command_ope static const struct file_operations mipi_dbi_debugfs_command_fops = { .owner = THIS_MODULE, .open = mipi_dbi_debugfs_command_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = mipi_dbi_debugfs_command_write, diff --combined drivers/gpu/drm/i915/display/intel_display_debugfs.c index 3644752cc5ec,147448e6f750..067f24c47513 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@@ -125,7 -125,7 +125,7 @@@ static int i915_ips_status(struct seq_f wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
seq_printf(m, "Enabled by kernel parameter: %s\n", - yesno(i915_modparams.enable_ips)); + yesno(dev_priv->params.enable_ips));
if (INTEL_GEN(dev_priv) >= 8) { seq_puts(m, "Currently: unknown\n"); @@@ -1009,7 -1009,7 +1009,7 @@@ static ssize_t i915_ipc_status_write(st static const struct file_operations i915_ipc_status_fops = { .owner = THIS_MODULE, .open = i915_ipc_status_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = i915_ipc_status_write @@@ -1099,10 -1099,10 +1099,10 @@@ static void drrs_status_per_crtc(struc seq_puts(m, "\n\t\t"); if (drrs->refresh_rate_type == DRRS_HIGH_RR) { seq_puts(m, "DRRS_State: DRRS_HIGH_RR\n"); - vrefresh = panel->fixed_mode->vrefresh; + vrefresh = drm_mode_vrefresh(panel->fixed_mode); } else if (drrs->refresh_rate_type == DRRS_LOW_RR) { seq_puts(m, "DRRS_State: DRRS_LOW_RR\n"); - vrefresh = panel->downclock_mode->vrefresh; + vrefresh = drm_mode_vrefresh(panel->downclock_mode); } else { seq_printf(m, "DRRS_State: Unknown(%d)\n", drrs->refresh_rate_type); @@@ -1194,7 -1194,7 +1194,7 @@@ static int i915_dp_mst_info(struct seq_ struct drm_i915_private *dev_priv = node_to_i915(m->private); struct drm_device *dev = &dev_priv->drm; struct intel_encoder *intel_encoder; - struct intel_digital_port *intel_dig_port; + struct intel_digital_port *dig_port; struct drm_connector *connector; struct drm_connector_list_iter conn_iter;
@@@ -1207,14 -1207,14 +1207,14 @@@ if (!intel_encoder || intel_encoder->type == INTEL_OUTPUT_DP_MST) continue;
- intel_dig_port = enc_to_dig_port(intel_encoder); - if (!intel_dig_port->dp.can_mst) + dig_port = enc_to_dig_port(intel_encoder); + if (!dig_port->dp.can_mst) continue;
seq_printf(m, "MST Source Port [ENCODER:%d:%s]\n", - intel_dig_port->base.base.base.id, - intel_dig_port->base.base.name); - drm_dp_mst_dump_topology(m, &intel_dig_port->dp.mst_mgr); + dig_port->base.base.base.id, + dig_port->base.base.name); + drm_dp_mst_dump_topology(m, &dig_port->dp.mst_mgr); } drm_connector_list_iter_end(&conn_iter);
@@@ -1326,7 -1326,7 +1326,7 @@@ static int i915_displayport_test_active static const struct file_operations i915_displayport_test_active_fops = { .owner = THIS_MODULE, .open = i915_displayport_test_active_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = i915_displayport_test_active_write @@@ -1627,7 -1627,7 +1627,7 @@@ static ssize_t cur_wm_latency_write(str static const struct file_operations i915_pri_wm_latency_fops = { .owner = THIS_MODULE, .open = pri_wm_latency_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = pri_wm_latency_write @@@ -1636,7 -1636,7 +1636,7 @@@ static const struct file_operations i915_spr_wm_latency_fops = { .owner = THIS_MODULE, .open = spr_wm_latency_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = spr_wm_latency_write @@@ -1645,7 -1645,7 +1645,7 @@@ static const struct file_operations i915_cur_wm_latency_fops = { .owner = THIS_MODULE, .open = cur_wm_latency_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = cur_wm_latency_write @@@ -1728,7 -1728,7 +1728,7 @@@ static int i915_hpd_storm_ctl_open(stru static const struct file_operations i915_hpd_storm_ctl_fops = { .owner = THIS_MODULE, .open = i915_hpd_storm_ctl_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = i915_hpd_storm_ctl_write @@@ -1801,7 -1801,7 +1801,7 @@@ static ssize_t i915_hpd_short_storm_ctl static const struct file_operations i915_hpd_short_storm_ctl_fops = { .owner = THIS_MODULE, .open = i915_hpd_short_storm_ctl_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = i915_hpd_short_storm_ctl_write, @@@ -2179,7 -2179,7 +2179,7 @@@ static int i915_dsc_fec_support_open(st static const struct file_operations i915_dsc_fec_support_fops = { .owner = THIS_MODULE, .open = i915_dsc_fec_support_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = i915_dsc_fec_support_write @@@ -2218,8 -2218,7 +2218,8 @@@ int intel_connector_debugfs_add(struct }
if (INTEL_GEN(dev_priv) >= 10 && - (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort || + ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort && + !to_intel_connector(connector)->mst_port) || connector->connector_type == DRM_MODE_CONNECTOR_eDP)) debugfs_create_file("i915_dsc_fec_support", S_IRUGO, root, connector, &i915_dsc_fec_support_fops); diff --combined drivers/gpu/drm/i915/i915_debugfs_params.c index 4e2b077692cb,58ef14b028ea..19518e805bd6 --- a/drivers/gpu/drm/i915/i915_debugfs_params.c +++ b/drivers/gpu/drm/i915/i915_debugfs_params.c @@@ -48,7 -48,7 +48,7 @@@ static ssize_t i915_param_int_write(str static const struct file_operations i915_param_int_fops = { .owner = THIS_MODULE, .open = i915_param_int_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = i915_param_int_write, .llseek = default_llseek, .release = single_release, @@@ -57,7 -57,7 +57,7 @@@ static const struct file_operations i915_param_int_fops_ro = { .owner = THIS_MODULE, .open = i915_param_int_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = default_llseek, .release = single_release, }; @@@ -101,7 -101,7 +101,7 @@@ static ssize_t i915_param_uint_write(st static const struct file_operations i915_param_uint_fops = { .owner = THIS_MODULE, .open = i915_param_uint_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = i915_param_uint_write, .llseek = default_llseek, .release = single_release, @@@ -110,7 -110,7 +110,7 @@@ static const struct file_operations i915_param_uint_fops_ro = { .owner = THIS_MODULE, .open = i915_param_uint_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = default_llseek, .release = single_release, }; @@@ -138,6 -138,9 +138,6 @@@ static ssize_t i915_param_charp_write(s char **s = m->private; char *new, *old;
- /* FIXME: remove locking after params aren't the module params */ - kernel_param_lock(THIS_MODULE); - old = *s; new = strndup_user(ubuf, PAGE_SIZE); if (IS_ERR(new)) { @@@ -149,13 -152,15 +149,13 @@@
kfree(old); out: - kernel_param_unlock(THIS_MODULE); - return len; }
static const struct file_operations i915_param_charp_fops = { .owner = THIS_MODULE, .open = i915_param_charp_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = i915_param_charp_write, .llseek = default_llseek, .release = single_release, @@@ -164,7 -169,7 +164,7 @@@ static const struct file_operations i915_param_charp_fops_ro = { .owner = THIS_MODULE, .open = i915_param_charp_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = default_llseek, .release = single_release, }; @@@ -224,7 -229,7 +224,7 @@@ _i915_param_create_file(struct dentry * struct dentry *i915_debugfs_params(struct drm_i915_private *i915) { struct drm_minor *minor = i915->drm.primary; - struct i915_params *params = &i915_modparams; + struct i915_params *params = &i915->params; struct dentry *dir;
dir = debugfs_create_dir("i915_params", minor->debugfs_root); diff --combined drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index b0b264e30ce5,40a7ce44f717..7d603784a1a1 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@@ -499,6 -499,23 +499,6 @@@ void dpu_encoder_helper_split_config } }
-static void _dpu_encoder_adjust_mode(struct drm_connector *connector, - struct drm_display_mode *adj_mode) -{ - struct drm_display_mode *cur_mode; - - if (!connector || !adj_mode) - return; - - list_for_each_entry(cur_mode, &connector->modes, head) { - if (cur_mode->vdisplay == adj_mode->vdisplay && - cur_mode->hdisplay == adj_mode->hdisplay && - drm_mode_vrefresh(cur_mode) == drm_mode_vrefresh(adj_mode)) { - adj_mode->private_flags |= cur_mode->private_flags; - } - } -} - static struct msm_display_topology dpu_encoder_get_topology( struct dpu_encoder_virt *dpu_enc, struct dpu_kms *dpu_kms, @@@ -572,6 -589,15 +572,6 @@@ static int dpu_encoder_virt_atomic_chec global_state = dpu_kms_get_existing_global_state(dpu_kms); trace_dpu_enc_atomic_check(DRMID(drm_enc));
- /* - * display drivers may populate private fields of the drm display mode - * structure while registering possible modes of a connector with DRM. - * These private fields are not populated back while DRM invokes - * the mode_set callbacks. This module retrieves and populates the - * private fields of the given mode. - */ - _dpu_encoder_adjust_mode(conn_state->connector, adj_mode); - /* perform atomic check on the first physical encoder (master) */ for (i = 0; i < dpu_enc->num_phys_encs; i++) { struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; @@@ -604,7 -630,8 +604,7 @@@ } }
- trace_dpu_enc_atomic_check_flags(DRMID(drm_enc), adj_mode->flags, - adj_mode->private_flags); + trace_dpu_enc_atomic_check_flags(DRMID(drm_enc), adj_mode->flags);
return ret; } @@@ -1858,7 -1885,7 +1858,7 @@@ static int _dpu_encoder_init_debugfs(st
static const struct file_operations debugfs_status_fops = { .open = _dpu_encoder_debugfs_status_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/hwmon/dell-smm-hwmon.c index ec448f5f2dc3,29ac38842962..976acbbe8ce9 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@@ -597,7 -597,7 +597,7 @@@ static int i8k_open_fs(struct inode *in
static const struct proc_ops i8k_proc_ops = { .proc_open = i8k_open_fs, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = single_release, .proc_ioctl = i8k_ioctl, @@@ -1187,14 -1187,6 +1187,14 @@@ static struct dmi_system_id i8k_whiteli }, .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3], }, + { + .ident = "Dell Latitude 5480", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Latitude 5480"), + }, + .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3], + }, { .ident = "Dell Latitude E6440", .matches = { diff --combined drivers/md/md.c index 96b28f6d025c,0bae6c1523ce..9a9f135770b4 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@@ -199,7 -199,7 +199,7 @@@ static int rdevs_init_serial(struct mdd static int rdev_need_serial(struct md_rdev *rdev) { return (rdev && rdev->mddev->bitmap_info.max_write_behind > 0 && - rdev->bdev->bd_queue->nr_hw_queues != 1 && + rdev->bdev->bd_disk->queue->nr_hw_queues != 1 && test_bit(WriteMostly, &rdev->flags)); }
@@@ -463,7 -463,7 +463,7 @@@ check_suspended } EXPORT_SYMBOL(md_handle_request);
-static blk_qc_t md_make_request(struct request_queue *q, struct bio *bio) +static blk_qc_t md_submit_bio(struct bio *bio) { const int rw = bio_data_dir(bio); const int sgrp = op_stat_group(bio_op(bio)); @@@ -475,7 -475,7 +475,7 @@@ return BLK_QC_T_NONE; }
- blk_queue_split(q, &bio); + blk_queue_split(&bio);
if (mddev == NULL || mddev->pers == NULL) { bio_io_error(bio); @@@ -549,6 -549,26 +549,6 @@@ void mddev_resume(struct mddev *mddev } EXPORT_SYMBOL_GPL(mddev_resume);
-int mddev_congested(struct mddev *mddev, int bits) -{ - struct md_personality *pers = mddev->pers; - int ret = 0; - - rcu_read_lock(); - if (mddev->suspended) - ret = 1; - else if (pers && pers->congested) - ret = pers->congested(mddev, bits); - rcu_read_unlock(); - return ret; -} -EXPORT_SYMBOL_GPL(mddev_congested); -static int md_congested(void *data, int bits) -{ - struct mddev *mddev = data; - return mddev_congested(mddev, bits); -} - /* * Generic flush handling for md */ @@@ -5621,7 -5641,7 +5621,7 @@@ static int md_alloc(dev_t dev, char *na mddev->hold_active = UNTIL_STOP;
error = -ENOMEM; - mddev->queue = blk_alloc_queue(md_make_request, NUMA_NO_NODE); + mddev->queue = blk_alloc_queue(NUMA_NO_NODE); if (!mddev->queue) goto abort;
@@@ -5650,7 -5670,6 +5650,7 @@@ * remove it now. */ disk->flags |= GENHD_FL_EXT_DEVT; + disk->events |= DISK_EVENT_MEDIA_CHANGE; mddev->gendisk = disk; /* As soon as we call add_disk(), another thread could get * through to md_open, so make sure it doesn't get too far @@@ -5945,6 -5964,8 +5945,6 @@@ int md_run(struct mddev *mddev blk_queue_flag_set(QUEUE_FLAG_NONROT, mddev->queue); else blk_queue_flag_clear(QUEUE_FLAG_NONROT, mddev->queue); - mddev->queue->backing_dev_info->congested_data = mddev; - mddev->queue->backing_dev_info->congested_fn = md_congested; } if (pers->sync_request) { if (mddev->kobj.sd && @@@ -6329,6 -6350,7 +6329,6 @@@ static int do_md_stop(struct mddev *mdd
__md_stop_writes(mddev); __md_stop(mddev); - mddev->queue->backing_dev_info->congested_fn = NULL;
/* tell userspace to handle 'inactive' */ sysfs_notify_dirent_safe(mddev->sysfs_state); @@@ -7784,21 -7806,23 +7784,21 @@@ static void md_release(struct gendisk * mddev_put(mddev); }
-static int md_media_changed(struct gendisk *disk) -{ - struct mddev *mddev = disk->private_data; - - return mddev->changed; -} - -static int md_revalidate(struct gendisk *disk) +static unsigned int md_check_events(struct gendisk *disk, unsigned int clearing) { struct mddev *mddev = disk->private_data; + unsigned int ret = 0;
+ if (mddev->changed) + ret = DISK_EVENT_MEDIA_CHANGE; mddev->changed = 0; - return 0; + return ret; } + static const struct block_device_operations md_fops = { .owner = THIS_MODULE, + .submit_bio = md_submit_bio, .open = md_open, .release = md_release, .ioctl = md_ioctl, @@@ -7806,7 -7830,8 +7806,7 @@@ .compat_ioctl = md_compat_ioctl, #endif .getgeo = md_getgeo, - .media_changed = md_media_changed, - .revalidate_disk= md_revalidate, + .check_events = md_check_events, };
static int md_thread(void *arg) @@@ -8276,7 -8301,7 +8276,7 @@@ static __poll_t mdstat_poll(struct fil
static const struct proc_ops mdstat_proc_ops = { .proc_open = md_seq_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = seq_release, .proc_poll = mdstat_poll, diff --combined drivers/media/cec/core/cec-core.c index c599cd94dd62,87e856788e0b..6edb1e09f9fa --- a/drivers/media/cec/core/cec-core.c +++ b/drivers/media/cec/core/cec-core.c @@@ -226,7 -226,7 +226,7 @@@ static int cec_error_inj_open(struct in static const struct file_operations cec_error_inj_fops = { .open = cec_error_inj_open, .write = cec_error_inj_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -265,6 -265,7 +265,6 @@@ struct cec_adapter *cec_allocate_adapte adap->sequence = 0; adap->ops = ops; adap->priv = priv; - memset(adap->phys_addrs, 0xff, sizeof(adap->phys_addrs)); mutex_init(&adap->lock); INIT_LIST_HEAD(&adap->transmit_queue); INIT_LIST_HEAD(&adap->wait_queue); diff --combined drivers/memory/tegra/tegra124-emc.c index d19fb7ae230d,794431b2102c..23c44429e009 --- a/drivers/memory/tegra/tegra124-emc.c +++ b/drivers/memory/tegra/tegra124-emc.c @@@ -1068,7 -1068,7 +1068,7 @@@ static int tegra_emc_debug_available_ra
static const struct file_operations tegra_emc_debug_available_rates_fops = { .open = tegra_emc_debug_available_rates_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -1178,11 -1178,11 +1178,11 @@@ static void emc_debugfs_init(struct dev return; }
- debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root, emc, + debugfs_create_file("available_rates", 0444, emc->debugfs.root, emc, &tegra_emc_debug_available_rates_fops); - debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, + debugfs_create_file("min_rate", 0644, emc->debugfs.root, emc, &tegra_emc_debug_min_rate_fops); - debugfs_create_file("max_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, + debugfs_create_file("max_rate", 0644, emc->debugfs.root, emc, &tegra_emc_debug_max_rate_fops); }
diff --combined drivers/memory/tegra/tegra186-emc.c index f27dd39377e6,1445ab51af6a..9333ebe4c918 --- a/drivers/memory/tegra/tegra186-emc.c +++ b/drivers/memory/tegra/tegra186-emc.c @@@ -94,7 -94,7 +94,7 @@@ static int tegra186_emc_debug_available
static const struct file_operations tegra186_emc_debug_available_rates_fops = { .open = tegra186_emc_debug_available_rates_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -185,7 -185,7 +185,7 @@@ static int tegra186_emc_probe(struct pl if (IS_ERR(emc->clk)) { err = PTR_ERR(emc->clk); dev_err(&pdev->dev, "failed to get EMC clock: %d\n", err); - return err; + goto put_bpmp; }
platform_set_drvdata(pdev, emc); @@@ -201,7 -201,7 +201,7 @@@ err = tegra_bpmp_transfer(emc->bpmp, &msg); if (err < 0) { dev_err(&pdev->dev, "failed to EMC DVFS pairs: %d\n", err); - return err; + goto put_bpmp; }
emc->debugfs.min_rate = ULONG_MAX; @@@ -211,10 -211,8 +211,10 @@@
emc->dvfs = devm_kmalloc_array(&pdev->dev, emc->num_dvfs, sizeof(*emc->dvfs), GFP_KERNEL); - if (!emc->dvfs) - return -ENOMEM; + if (!emc->dvfs) { + err = -ENOMEM; + goto put_bpmp; + }
dev_dbg(&pdev->dev, "%u DVFS pairs:\n", emc->num_dvfs);
@@@ -239,10 -237,15 +239,10 @@@ "failed to set rate range [%lu-%lu] for %pC\n", emc->debugfs.min_rate, emc->debugfs.max_rate, emc->clk); - return err; + goto put_bpmp; }
emc->debugfs.root = debugfs_create_dir("emc", NULL); - if (!emc->debugfs.root) { - dev_err(&pdev->dev, "failed to create debugfs directory\n"); - return 0; - } - debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root, emc, &tegra186_emc_debug_available_rates_fops); debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, @@@ -251,10 -254,6 +251,10 @@@ emc, &tegra186_emc_debug_max_rate_fops);
return 0; + +put_bpmp: + tegra_bpmp_put(emc->bpmp); + return err; }
static int tegra186_emc_remove(struct platform_device *pdev) diff --combined drivers/memory/tegra/tegra20-emc.c index 027f46287dbf,c63b14f7b356..83ca46345aba --- a/drivers/memory/tegra/tegra20-emc.c +++ b/drivers/memory/tegra/tegra20-emc.c @@@ -7,11 -7,11 +7,11 @@@
#include <linux/clk.h> #include <linux/clk/tegra.h> -#include <linux/completion.h> #include <linux/debugfs.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/of.h> @@@ -144,6 -144,7 +144,6 @@@ struct emc_timing
struct tegra_emc { struct device *dev; - struct completion clk_handshake_complete; struct notifier_block clk_nb; struct clk *clk; void __iomem *regs; @@@ -161,13 -162,17 +161,13 @@@ static irqreturn_t tegra_emc_isr(int irq, void *data) { struct tegra_emc *emc = data; - u32 intmask = EMC_REFRESH_OVERFLOW_INT | EMC_CLKCHANGE_COMPLETE_INT; + u32 intmask = EMC_REFRESH_OVERFLOW_INT; u32 status;
status = readl_relaxed(emc->regs + EMC_INTSTATUS) & intmask; if (!status) return IRQ_NONE;
- /* notify about EMC-CAR handshake completion */ - if (status & EMC_CLKCHANGE_COMPLETE_INT) - complete(&emc->clk_handshake_complete); - /* notify about HW problem */ if (status & EMC_REFRESH_OVERFLOW_INT) dev_err_ratelimited(emc->dev, @@@ -219,13 -224,14 +219,13 @@@ static int emc_prepare_timing_change(st /* wait until programming has settled */ readl_relaxed(emc->regs + emc_timing_registers[i - 1]);
- reinit_completion(&emc->clk_handshake_complete); - return 0; }
static int emc_complete_timing_change(struct tegra_emc *emc, bool flush) { - unsigned long timeout; + int err; + u32 v;
dev_dbg(emc->dev, "%s: flush %d\n", __func__, flush);
@@@ -236,12 -242,11 +236,12 @@@ return 0; }
- timeout = wait_for_completion_timeout(&emc->clk_handshake_complete, - msecs_to_jiffies(100)); - if (timeout == 0) { - dev_err(emc->dev, "EMC-CAR handshake failed\n"); - return -EIO; + err = readl_relaxed_poll_timeout_atomic(emc->regs + EMC_INTSTATUS, v, + v & EMC_CLKCHANGE_COMPLETE_INT, + 1, 100); + if (err) { + dev_err(emc->dev, "emc-car handshake timeout: %d\n", err); + return err; }
return 0; @@@ -407,7 -412,7 +407,7 @@@ tegra_emc_find_node_by_ram_code(struct
static int emc_setup_hw(struct tegra_emc *emc) { - u32 intmask = EMC_REFRESH_OVERFLOW_INT | EMC_CLKCHANGE_COMPLETE_INT; + u32 intmask = EMC_REFRESH_OVERFLOW_INT; u32 emc_cfg, emc_dbg;
emc_cfg = readl_relaxed(emc->regs + EMC_CFG_2); @@@ -541,7 -546,7 +541,7 @@@ static int tegra_emc_debug_available_ra
static const struct file_operations tegra_emc_debug_available_rates_fops = { .open = tegra_emc_debug_available_rates_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -642,11 -647,11 +642,11 @@@ static void tegra_emc_debugfs_init(stru return; }
- debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root, + debugfs_create_file("available_rates", 0444, emc->debugfs.root, emc, &tegra_emc_debug_available_rates_fops); - debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, + debugfs_create_file("min_rate", 0644, emc->debugfs.root, emc, &tegra_emc_debug_min_rate_fops); - debugfs_create_file("max_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, + debugfs_create_file("max_rate", 0644, emc->debugfs.root, emc, &tegra_emc_debug_max_rate_fops); }
@@@ -681,6 -686,7 +681,6 @@@ static int tegra_emc_probe(struct platf return -ENOMEM; }
- init_completion(&emc->clk_handshake_complete); emc->clk_nb.notifier_call = tegra_emc_clk_change_notify; emc->dev = &pdev->dev;
diff --combined drivers/memory/tegra/tegra30-emc.c index 055af0e08a2e,2ed027408af2..e448a55cb812 --- a/drivers/memory/tegra/tegra30-emc.c +++ b/drivers/memory/tegra/tegra30-emc.c @@@ -11,6 -11,7 +11,6 @@@
#include <linux/clk.h> #include <linux/clk/tegra.h> -#include <linux/completion.h> #include <linux/debugfs.h> #include <linux/delay.h> #include <linux/err.h> @@@ -326,6 -327,7 +326,6 @@@ struct emc_timing struct tegra_emc { struct device *dev; struct tegra_mc *mc; - struct completion clk_handshake_complete; struct notifier_block clk_nb; struct clk *clk; void __iomem *regs; @@@ -372,10 -374,52 +372,10 @@@ static int emc_seq_update_timing(struc return 0; }
-static void emc_complete_clk_change(struct tegra_emc *emc) -{ - struct emc_timing *timing = emc->new_timing; - unsigned int dram_num; - bool failed = false; - int err; - - /* re-enable auto-refresh */ - dram_num = tegra_mc_get_emem_device_count(emc->mc); - writel_relaxed(EMC_REFCTRL_ENABLE_ALL(dram_num), - emc->regs + EMC_REFCTRL); - - /* restore auto-calibration */ - if (emc->vref_cal_toggle) - writel_relaxed(timing->emc_auto_cal_interval, - emc->regs + EMC_AUTO_CAL_INTERVAL); - - /* restore dynamic self-refresh */ - if (timing->emc_cfg_dyn_self_ref) { - emc->emc_cfg |= EMC_CFG_DYN_SREF_ENABLE; - writel_relaxed(emc->emc_cfg, emc->regs + EMC_CFG); - } - - /* set number of clocks to wait after each ZQ command */ - if (emc->zcal_long) - writel_relaxed(timing->emc_zcal_cnt_long, - emc->regs + EMC_ZCAL_WAIT_CNT); - - /* wait for writes to settle */ - udelay(2); - - /* update restored timing */ - err = emc_seq_update_timing(emc); - if (err) - failed = true; - - /* restore early ACK */ - mc_writel(emc->mc, emc->mc_override, MC_EMEM_ARB_OVERRIDE); - - WRITE_ONCE(emc->bad_state, failed); -} - static irqreturn_t tegra_emc_isr(int irq, void *data) { struct tegra_emc *emc = data; - u32 intmask = EMC_REFRESH_OVERFLOW_INT | EMC_CLKCHANGE_COMPLETE_INT; + u32 intmask = EMC_REFRESH_OVERFLOW_INT; u32 status;
status = readl_relaxed(emc->regs + EMC_INTSTATUS) & intmask; @@@ -390,6 -434,18 +390,6 @@@ /* clear interrupts */ writel_relaxed(status, emc->regs + EMC_INTSTATUS);
- /* notify about EMC-CAR handshake completion */ - if (status & EMC_CLKCHANGE_COMPLETE_INT) { - if (completion_done(&emc->clk_handshake_complete)) { - dev_err_ratelimited(emc->dev, - "bogus handshake interrupt\n"); - return IRQ_NONE; - } - - emc_complete_clk_change(emc); - complete(&emc->clk_handshake_complete); - } - return IRQ_HANDLED; }
@@@ -745,58 -801,29 +745,58 @@@ static int emc_prepare_timing_change(st */ mc_readl(emc->mc, MC_EMEM_ARB_OVERRIDE);
- reinit_completion(&emc->clk_handshake_complete); - - emc->new_timing = timing; - return 0; }
static int emc_complete_timing_change(struct tegra_emc *emc, unsigned long rate) { - unsigned long timeout; + struct emc_timing *timing = emc_find_timing(emc, rate); + unsigned int dram_num; + int err; + u32 v;
- timeout = wait_for_completion_timeout(&emc->clk_handshake_complete, - msecs_to_jiffies(100)); - if (timeout == 0) { - dev_err(emc->dev, "emc-car handshake failed\n"); - return -EIO; + err = readl_relaxed_poll_timeout_atomic(emc->regs + EMC_INTSTATUS, v, + v & EMC_CLKCHANGE_COMPLETE_INT, + 1, 100); + if (err) { + dev_err(emc->dev, "emc-car handshake timeout: %d\n", err); + return err; }
- if (READ_ONCE(emc->bad_state)) - return -EIO; + /* re-enable auto-refresh */ + dram_num = tegra_mc_get_emem_device_count(emc->mc); + writel_relaxed(EMC_REFCTRL_ENABLE_ALL(dram_num), + emc->regs + EMC_REFCTRL); + + /* restore auto-calibration */ + if (emc->vref_cal_toggle) + writel_relaxed(timing->emc_auto_cal_interval, + emc->regs + EMC_AUTO_CAL_INTERVAL);
- return 0; + /* restore dynamic self-refresh */ + if (timing->emc_cfg_dyn_self_ref) { + emc->emc_cfg |= EMC_CFG_DYN_SREF_ENABLE; + writel_relaxed(emc->emc_cfg, emc->regs + EMC_CFG); + } + + /* set number of clocks to wait after each ZQ command */ + if (emc->zcal_long) + writel_relaxed(timing->emc_zcal_cnt_long, + emc->regs + EMC_ZCAL_WAIT_CNT); + + /* wait for writes to settle */ + udelay(2); + + /* update restored timing */ + err = emc_seq_update_timing(emc); + if (!err) + emc->bad_state = false; + + /* restore early ACK */ + mc_writel(emc->mc, emc->mc_override, MC_EMEM_ARB_OVERRIDE); + + return err; }
static int emc_unprepare_timing_change(struct tegra_emc *emc, @@@ -1006,7 -1033,7 +1006,7 @@@ static struct device_node *emc_find_nod
static int emc_setup_hw(struct tegra_emc *emc) { - u32 intmask = EMC_REFRESH_OVERFLOW_INT | EMC_CLKCHANGE_COMPLETE_INT; + u32 intmask = EMC_REFRESH_OVERFLOW_INT; u32 fbio_cfg5, emc_cfg, emc_dbg; enum emc_dram_type dram_type;
@@@ -1147,7 -1174,7 +1147,7 @@@ static int tegra_emc_debug_available_ra
static const struct file_operations tegra_emc_debug_available_rates_fops = { .open = tegra_emc_debug_available_rates_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -1248,11 -1275,11 +1248,11 @@@ static void tegra_emc_debugfs_init(stru return; }
- debugfs_create_file("available_rates", S_IRUGO, emc->debugfs.root, + debugfs_create_file("available_rates", 0444, emc->debugfs.root, emc, &tegra_emc_debug_available_rates_fops); - debugfs_create_file("min_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, + debugfs_create_file("min_rate", 0644, emc->debugfs.root, emc, &tegra_emc_debug_min_rate_fops); - debugfs_create_file("max_rate", S_IRUGO | S_IWUSR, emc->debugfs.root, + debugfs_create_file("max_rate", 0644, emc->debugfs.root, emc, &tegra_emc_debug_max_rate_fops); }
@@@ -1294,6 -1321,7 +1294,6 @@@ static int tegra_emc_probe(struct platf if (!emc->mc) return -EPROBE_DEFER;
- init_completion(&emc->clk_handshake_complete); emc->clk_nb.notifier_call = emc_clk_change_notify; emc->dev = &pdev->dev;
diff --combined drivers/mfd/ab3100-core.c index ee71ae04b5e6,0f461180d29f..092c78b5e26f --- a/drivers/mfd/ab3100-core.c +++ b/drivers/mfd/ab3100-core.c @@@ -473,7 -473,7 +473,7 @@@ static int ab3100_registers_open(struc
static const struct file_operations ab3100_registers_fops = { .open = ab3100_registers_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -498,7 -498,7 +498,7 @@@ static ssize_t ab3100_get_set_reg(struc int i = 0;
/* Get userspace string and assure termination */ - buf_size = min(count, (sizeof(buf)-1)); + buf_size = min((ssize_t)count, (ssize_t)(sizeof(buf)-1)); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; buf[buf_size] = 0; diff --combined drivers/mfd/ab3100-otp.c index c393102e3a39,3667fa4c9fed..3c1157e7a0c1 --- a/drivers/mfd/ab3100-otp.c +++ b/drivers/mfd/ab3100-otp.c @@@ -29,22 -29,22 +29,22 @@@
/** * struct ab3100_otp - * @dev containing device - * @locked whether the OTP is locked, after locking, no more bits + * @dev: containing device + * @locked: whether the OTP is locked, after locking, no more bits * can be changed but before locking it is still possible * to change bits from 1->0. - * @freq clocking frequency for the OTP, this frequency is either + * @freq: clocking frequency for the OTP, this frequency is either * 32768Hz or 1MHz/30 - * @paf product activation flag, indicates whether this is a real + * @paf: product activation flag, indicates whether this is a real * product (paf true) or a lab board etc (paf false) - * @imeich if this is set it is possible to override the + * @imeich: if this is set it is possible to override the * IMEI number found in the tac, fac and svn fields with * (secured) software - * @cid customer ID - * @tac type allocation code of the IMEI - * @fac final assembly code of the IMEI - * @svn software version number of the IMEI - * @debugfs a debugfs file used when dumping to file + * @cid: customer ID + * @tac: type allocation code of the IMEI + * @fac: final assembly code of the IMEI + * @svn: software version number of the IMEI + * @debugfs: a debugfs file used when dumping to file */ struct ab3100_otp { struct device *dev; @@@ -117,7 -117,7 +117,7 @@@ static int ab3100_otp_open(struct inod
static const struct file_operations ab3100_otp_operations = { .open = ab3100_otp_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/mfd/ab8500-debugfs.c index 6d1bf7c3ca3b,fcdb618fe2db..838798c98d0f --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@@ -1376,7 -1376,7 +1376,7 @@@ static int ab8500_all_banks_open(struc
static const struct file_operations ab8500_all_banks_fops = { .open = ab8500_all_banks_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -1801,7 -1801,7 +1801,7 @@@ static ssize_t ab8500_hwreg_write(struc int buf_size, ret;
/* Get userspace string and assure termination */ - buf_size = min(count, (sizeof(buf)-1)); + buf_size = min((int)count, (int)(sizeof(buf)-1)); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; buf[buf_size] = 0; @@@ -1959,7 -1959,7 +1959,7 @@@ static ssize_t ab8500_unsubscribe_write static const struct file_operations ab8500_bank_fops = { .open = ab8500_bank_open, .write = ab8500_bank_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -1968,7 -1968,7 +1968,7 @@@ static const struct file_operations ab8500_address_fops = { .open = ab8500_address_open, .write = ab8500_address_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -1977,7 -1977,7 +1977,7 @@@ static const struct file_operations ab8500_val_fops = { .open = ab8500_val_open, .write = ab8500_val_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -1986,7 -1986,7 +1986,7 @@@ static const struct file_operations ab8500_subscribe_fops = { .open = ab8500_subscribe_unsubscribe_open, .write = ab8500_subscribe_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -1995,7 -1995,7 +1995,7 @@@ static const struct file_operations ab8500_unsubscribe_fops = { .open = ab8500_subscribe_unsubscribe_open, .write = ab8500_unsubscribe_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, @@@ -2004,7 -2004,7 +2004,7 @@@ static const struct file_operations ab8500_hwreg_fops = { .open = ab8500_hwreg_open, .write = ab8500_hwreg_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .owner = THIS_MODULE, diff --combined drivers/mfd/tps65010.c index 7e7dbee58ca9,19ed0a372389..31259867f637 --- a/drivers/mfd/tps65010.c +++ b/drivers/mfd/tps65010.c @@@ -290,7 -290,7 +290,7 @@@ static int dbg_tps_open(struct inode *i
static const struct file_operations debug_fops = { .open = dbg_tps_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -404,6 -404,7 +404,6 @@@ static void tps65010_work(struct work_s tps65010_interrupt(tps);
if (test_and_clear_bit(FLAG_VBUS_CHANGED, &tps->flags)) { - int status; u8 chgconfig, tmp;
chgconfig = i2c_smbus_read_byte_data(tps->client, @@@ -414,8 -415,8 +414,8 @@@ else if (tps->vbus >= 100) chgconfig |= TPS_VBUS_CHARGING;
- status = i2c_smbus_write_byte_data(tps->client, - TPS_CHGCONFIG, chgconfig); + i2c_smbus_write_byte_data(tps->client, + TPS_CHGCONFIG, chgconfig);
/* vbus update fails unless VBUS is connected! */ tmp = i2c_smbus_read_byte_data(tps->client, TPS_CHGCONFIG); diff --combined drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 05f33b7e3677,3891fb39a889..424026da73cc --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c @@@ -229,7 -229,7 +229,7 @@@ static int cim_la_open(struct inode *in static const struct file_operations cim_la_fops = { .owner = THIS_MODULE, .open = cim_la_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -272,7 -272,7 +272,7 @@@ static int cim_pif_la_open(struct inod static const struct file_operations cim_pif_la_fops = { .owner = THIS_MODULE, .open = cim_pif_la_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -318,7 -318,7 +318,7 @@@ static int cim_ma_la_open(struct inode static const struct file_operations cim_ma_la_fops = { .owner = THIS_MODULE, .open = cim_ma_la_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -411,7 -411,7 +411,7 @@@ static int cim_ibq_open(struct inode *i static const struct file_operations cim_ibq_fops = { .owner = THIS_MODULE, .open = cim_ibq_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -440,7 -440,7 +440,7 @@@ static int cim_obq_open(struct inode *i static const struct file_operations cim_obq_fops = { .owner = THIS_MODULE, .open = cim_obq_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -686,7 -686,7 +686,7 @@@ static ssize_t tp_la_write(struct file static const struct file_operations tp_la_fops = { .owner = THIS_MODULE, .open = tp_la_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private, .write = tp_la_write @@@ -722,7 -722,7 +722,7 @@@ static int ulprx_la_open(struct inode * static const struct file_operations ulprx_la_fops = { .owner = THIS_MODULE, .open = ulprx_la_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -812,7 -812,7 +812,7 @@@ static ssize_t pm_stats_clear(struct fi static const struct file_operations pm_stats_debugfs_fops = { .owner = THIS_MODULE, .open = pm_stats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = pm_stats_clear @@@ -1136,7 -1136,7 +1136,7 @@@ static int devlog_open(struct inode *in static const struct file_operations devlog_fops = { .owner = THIS_MODULE, .open = devlog_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -1234,7 -1234,7 +1234,7 @@@ static int mboxlog_open(struct inode *i static const struct file_operations mboxlog_fops = { .owner = THIS_MODULE, .open = mboxlog_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -1317,7 -1317,7 +1317,7 @@@ static ssize_t mbox_write(struct file * static const struct file_operations mbox_debugfs_fops = { .owner = THIS_MODULE, .open = mbox_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = mbox_write @@@ -1610,7 -1610,7 +1610,7 @@@ out static const struct file_operations mps_trc_debugfs_fops = { .owner = THIS_MODULE, .open = mps_trc_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = mps_trc_write @@@ -1930,7 -1930,7 +1930,7 @@@ static int mps_tcam_open(struct inode * static const struct file_operations mps_tcam_debugfs_fops = { .owner = THIS_MODULE, .open = mps_tcam_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -2007,7 -2007,7 +2007,7 @@@ static int rss_open(struct inode *inode static const struct file_operations rss_debugfs_fops = { .owner = THIS_MODULE, .open = rss_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -2226,7 -2226,7 +2226,7 @@@ static ssize_t rss_key_write(struct fil static const struct file_operations rss_key_debugfs_fops = { .owner = THIS_MODULE, .open = rss_key_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = rss_key_write @@@ -2310,7 -2310,7 +2310,7 @@@ static int rss_pf_config_open(struct in static const struct file_operations rss_pf_config_debugfs_fops = { .owner = THIS_MODULE, .open = rss_pf_config_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -2373,7 -2373,7 +2373,7 @@@ static int rss_vf_config_open(struct in static const struct file_operations rss_vf_config_debugfs_fops = { .owner = THIS_MODULE, .open = rss_vf_config_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private }; @@@ -2561,7 -2561,7 +2561,7 @@@ static int dcb_info_open(struct inode * static const struct file_operations dcb_info_debugfs_fops = { .owner = THIS_MODULE, .open = dcb_info_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -2742,58 -2742,6 +2742,58 @@@ do { }
r -= eth_entries; + for_each_port(adap, j) { + struct port_info *pi = adap2pinfo(adap, j); + const struct sge_eth_rxq *rx; + + mutex_lock(&pi->vi_mirror_mutex); + if (!pi->vi_mirror_count) { + mutex_unlock(&pi->vi_mirror_mutex); + continue; + } + + if (r >= DIV_ROUND_UP(pi->nmirrorqsets, 4)) { + r -= DIV_ROUND_UP(pi->nmirrorqsets, 4); + mutex_unlock(&pi->vi_mirror_mutex); + continue; + } + + rx = &s->mirror_rxq[j][r * 4]; + n = min(4, pi->nmirrorqsets - 4 * r); + + S("QType:", "Mirror-Rxq"); + S("Interface:", + rx[i].rspq.netdev ? rx[i].rspq.netdev->name : "N/A"); + R("RspQ ID:", rspq.abs_id); + R("RspQ size:", rspq.size); + R("RspQE size:", rspq.iqe_len); + R("RspQ CIDX:", rspq.cidx); + R("RspQ Gen:", rspq.gen); + S3("u", "Intr delay:", qtimer_val(adap, &rx[i].rspq)); + S3("u", "Intr pktcnt:", s->counter_val[rx[i].rspq.pktcnt_idx]); + R("FL ID:", fl.cntxt_id); + R("FL size:", fl.size - 8); + R("FL pend:", fl.pend_cred); + R("FL avail:", fl.avail); + R("FL PIDX:", fl.pidx); + R("FL CIDX:", fl.cidx); + RL("RxPackets:", stats.pkts); + RL("RxCSO:", stats.rx_cso); + RL("VLANxtract:", stats.vlan_ex); + RL("LROmerged:", stats.lro_merged); + RL("LROpackets:", stats.lro_pkts); + RL("RxDrops:", stats.rx_drops); + RL("RxBadPkts:", stats.bad_rx_pkts); + RL("FLAllocErr:", fl.alloc_failed); + RL("FLLrgAlcErr:", fl.large_alloc_failed); + RL("FLMapErr:", fl.mapping_err); + RL("FLLow:", fl.low); + RL("FLStarving:", fl.starving); + + mutex_unlock(&pi->vi_mirror_mutex); + goto out; + } + if (!adap->tc_mqprio) goto skip_mqprio;
@@@ -3150,10 -3098,9 +3150,10 @@@ unlock return 0; }
-static int sge_queue_entries(const struct adapter *adap) +static int sge_queue_entries(struct adapter *adap) { int i, tot_uld_entries = 0, eohw_entries = 0, eosw_entries = 0; + int mirror_rxq_entries = 0;
if (adap->tc_mqprio) { struct cxgb4_tc_port_mqprio *port_mqprio; @@@ -3176,15 -3123,6 +3176,15 @@@ mutex_unlock(&adap->tc_mqprio->mqprio_mutex); }
+ for_each_port(adap, i) { + struct port_info *pi = adap2pinfo(adap, i); + + mutex_lock(&pi->vi_mirror_mutex); + if (pi->vi_mirror_count) + mirror_rxq_entries += DIV_ROUND_UP(pi->nmirrorqsets, 4); + mutex_unlock(&pi->vi_mirror_mutex); + } + if (!is_uld(adap)) goto lld_only;
@@@ -3199,7 -3137,7 +3199,7 @@@ mutex_unlock(&uld_mutex);
lld_only: - return DIV_ROUND_UP(adap->sge.ethqsets, 4) + + return DIV_ROUND_UP(adap->sge.ethqsets, 4) + mirror_rxq_entries + eohw_entries + eosw_entries + tot_uld_entries + DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1; } @@@ -3245,7 -3183,7 +3245,7 @@@ static int sge_qinfo_open(struct inode static const struct file_operations sge_qinfo_debugfs_fops = { .owner = THIS_MODULE, .open = sge_qinfo_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; diff --combined drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c index dbe8ee7e0e21,20e74d5e837f..6983e3d55e22 --- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c @@@ -2039,7 -2039,7 +2039,7 @@@ static int mboxlog_open(struct inode *i static const struct file_operations mboxlog_fops = { .owner = THIS_MODULE, .open = mboxlog_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -2192,7 -2192,7 +2192,7 @@@ static int sge_qinfo_open(struct inode static const struct file_operations sge_qinfo_debugfs_fops = { .owner = THIS_MODULE, .open = sge_qinfo_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -2338,7 -2338,7 +2338,7 @@@ static int sge_qstats_open(struct inod static const struct file_operations sge_qstats_proc_fops = { .owner = THIS_MODULE, .open = sge_qstats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -2436,7 -2436,7 +2436,7 @@@ static int interfaces_open(struct inod static const struct file_operations interfaces_proc_fops = { .owner = THIS_MODULE, .open = interfaces_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -2916,39 -2916,6 +2916,39 @@@ static const struct net_device_ops cxgb #endif };
+/** + * cxgb4vf_get_port_mask - Get port mask for the VF based on mac + * address stored on the adapter + * @adapter: The adapter + * + * Find the the port mask for the VF based on the index of mac + * address stored in the adapter. If no mac address is stored on + * the adapter for the VF, use the port mask received from the + * firmware. + */ +static unsigned int cxgb4vf_get_port_mask(struct adapter *adapter) +{ + unsigned int naddr = 1, pidx = 0; + unsigned int pmask, rmask = 0; + u8 mac[ETH_ALEN]; + int err; + + pmask = adapter->params.vfres.pmask; + while (pmask) { + if (pmask & 1) { + err = t4vf_get_vf_mac_acl(adapter, pidx, &naddr, mac); + if (!err && !is_zero_ether_addr(mac)) + rmask |= (1 << pidx); + } + pmask >>= 1; + pidx++; + } + if (!rmask) + rmask = adapter->params.vfres.pmask; + + return rmask; +} + /* * "Probe" a device: initialize a device and construct all kernel and driver * state needed to manage the device. This routine is called "init_one" in @@@ -2957,12 -2924,13 +2957,12 @@@ static int cxgb4vf_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - int pci_using_dac; - int err, pidx; - unsigned int pmask; struct adapter *adapter; - struct port_info *pi; struct net_device *netdev; - unsigned int pf; + struct port_info *pi; + unsigned int pmask; + int pci_using_dac; + int err, pidx;
/* * Initialize generic PCI device state. @@@ -3105,7 -3073,8 +3105,7 @@@ /* * Allocate our "adapter ports" and stitch everything together. */ - pmask = adapter->params.vfres.pmask; - pf = t4vf_get_pf_from_vf(adapter); + pmask = cxgb4vf_get_port_mask(adapter); for_each_port(adapter, pidx) { int port_id, viid; u8 mac[ETH_ALEN]; @@@ -3188,7 -3157,7 +3188,7 @@@ goto err_free_dev; }
- err = t4vf_get_vf_mac_acl(adapter, pf, &naddr, mac); + err = t4vf_get_vf_mac_acl(adapter, port_id, &naddr, mac); if (err) { dev_err(&pdev->dev, "unable to determine MAC ACL address, " diff --combined drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c index 56d9927fbfda,bc99fe0aabf0..f80f94e1e10a --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c @@@ -21,7 -21,7 +21,7 @@@ static int dpaa2_dbg_cpu_show(struct se seq_printf(file, "Per-CPU stats for %s\n", priv->net_dev->name); seq_printf(file, "%s%16s%16s%16s%16s%16s%16s%16s%16s%16s\n", "CPU", "Rx", "Rx Err", "Rx SG", "Tx", "Tx Err", "Tx conf", - "Tx SG", "Tx realloc", "Enq busy"); + "Tx SG", "Tx converted to SG", "Enq busy");
for_each_online_cpu(i) { stats = per_cpu_ptr(priv->percpu_stats, i); @@@ -35,7 -35,7 +35,7 @@@ stats->tx_errors, extras->tx_conf_frames, extras->tx_sg_frames, - extras->tx_reallocs, + extras->tx_converted_sg_frames, extras->tx_portal_busy); }
@@@ -56,7 -56,7 +56,7 @@@ static int dpaa2_dbg_cpu_open(struct in
static const struct file_operations dpaa2_dbg_cpu_ops = { .open = dpaa2_dbg_cpu_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -90,10 -90,6 +90,10 @@@ static int dpaa2_dbg_fqs_show(struct se if (err) fcnt = 0;
+ /* Skip FQs with no traffic */ + if (!fq->stats.frames && !fcnt) + continue; + seq_printf(file, "%5d%16d%16d%16s%16llu%16u\n", fq->fqid, fq->target_cpu, @@@ -120,7 -116,7 +120,7 @@@ static int dpaa2_dbg_fqs_open(struct in
static const struct file_operations dpaa2_dbg_fq_ops = { .open = dpaa2_dbg_fqs_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -165,7 -161,7 +165,7 @@@ static int dpaa2_dbg_ch_open(struct ino
static const struct file_operations dpaa2_dbg_ch_ops = { .open = dpaa2_dbg_ch_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/net/wireless/intel/iwlwifi/fw/debugfs.c index 267ad4eddb5c,cf3b7ec4db73..a3a1691e5ed9 --- a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.c @@@ -260,7 -260,7 +260,7 @@@ struct hcmd_write_data __be32 cmd_id; __be32 flags; __be16 length; - u8 data[0]; + u8 data[]; } __packed;
static ssize_t iwl_dbgfs_send_hcmd_write(struct iwl_fw_runtime *fwrt, char *buf, @@@ -419,7 -419,7 +419,7 @@@ static int iwl_dbgfs_fw_info_open(struc static const struct file_operations iwl_dbgfs_fw_info_ops = { .owner = THIS_MODULE, .open = iwl_dbgfs_fw_info_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private, }; diff --combined drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c index d06afcf46d67,c61bd9803078..e356d9ec5957 --- a/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c @@@ -181,7 -181,7 +181,7 @@@ mt7615_ampdu_stat_open(struct inode *in
static const struct file_operations fops_ampdu_stat = { .open = mt7615_ampdu_stat_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -234,11 -234,10 +234,11 @@@ mt7615_queues_acq(struct seq_file *s, v int i;
for (i = 0; i < 16; i++) { - int j, acs = i / 4, index = i % 4; + int j, wmm_idx = i % MT7615_MAX_WMM_SETS; + int acs = i / MT7615_MAX_WMM_SETS; u32 ctrl, val, qlen = 0;
- val = mt76_rr(dev, MT_PLE_AC_QEMPTY(acs, index)); + val = mt76_rr(dev, MT_PLE_AC_QEMPTY(acs, wmm_idx)); ctrl = BIT(31) | BIT(15) | (acs << 8);
for (j = 0; j < 32; j++) { @@@ -246,11 -245,11 +246,11 @@@ continue;
mt76_wr(dev, MT_PLE_FL_Q0_CTRL, - ctrl | (j + (index << 5))); + ctrl | (j + (wmm_idx << 5))); qlen += mt76_get_field(dev, MT_PLE_FL_Q3_CTRL, GENMASK(11, 0)); } - seq_printf(s, "AC%d%d: queued=%d\n", acs, index, qlen); + seq_printf(s, "AC%d%d: queued=%d\n", wmm_idx, acs, qlen); }
return 0; diff --combined drivers/net/xen-netback/xenbus.c index 7e62a6ee7622,06b253eba25d..aad7e526eb5f --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c @@@ -152,7 -152,7 +152,7 @@@ static int xenvif_io_ring_open(struct i static const struct file_operations xenvif_dbg_io_ring_ops_fops = { .owner = THIS_MODULE, .open = xenvif_io_ring_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = xenvif_write_io_ring, @@@ -393,24 -393,6 +393,24 @@@ static void set_backend_state(struct ba } }
+static void read_xenbus_frontend_xdp(struct backend_info *be, + struct xenbus_device *dev) +{ + struct xenvif *vif = be->vif; + u16 headroom; + int err; + + err = xenbus_scanf(XBT_NIL, dev->otherend, + "xdp-headroom", "%hu", &headroom); + if (err != 1) { + vif->xdp_headroom = 0; + return; + } + if (headroom > XEN_NETIF_MAX_XDP_HEADROOM) + headroom = XEN_NETIF_MAX_XDP_HEADROOM; + vif->xdp_headroom = headroom; +} + /** * Callback received when the frontend's state changes. */ @@@ -435,11 -417,6 +435,11 @@@ static void frontend_changed(struct xen set_backend_state(be, XenbusStateConnected); break;
+ case XenbusStateReconfiguring: + read_xenbus_frontend_xdp(be, dev); + xenbus_switch_state(dev, XenbusStateReconfigured); + break; + case XenbusStateClosing: set_backend_state(be, XenbusStateClosing); break; @@@ -970,8 -947,6 +970,8 @@@ static int read_xenbus_vif_flags(struc vif->ipv6_csum = !!xenbus_read_unsigned(dev->otherend, "feature-ipv6-csum-offload", 0);
+ read_xenbus_frontend_xdp(be, dev); + return 0; }
@@@ -1061,15 -1036,6 +1061,15 @@@ static int netback_probe(struct xenbus_ goto abort_transaction; }
+ /* we can adjust a headroom for netfront XDP processing */ + err = xenbus_printf(xbt, dev->nodename, + "feature-xdp-headroom", "%d", + provides_xdp_headroom); + if (err) { + message = "writing feature-xdp-headroom"; + goto abort_transaction; + } + /* We don't support rx-flip path (except old guests who * don't grok this feature flag). */ diff --combined drivers/pci/controller/pci-tegra.c index 71bf4b2684ac,bfb8dbc2d0ea..66386f742bd7 --- a/drivers/pci/controller/pci-tegra.c +++ b/drivers/pci/controller/pci-tegra.c @@@ -1462,7 -1462,7 +1462,7 @@@ static int tegra_pcie_get_resources(str { struct device *dev = pcie->dev; struct platform_device *pdev = to_platform_device(dev); - struct resource *pads, *afi, *res; + struct resource *res; const struct tegra_pcie_soc *soc = pcie->soc; int err;
@@@ -1486,13 -1486,15 +1486,13 @@@ } }
- pads = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pads"); - pcie->pads = devm_ioremap_resource(dev, pads); + pcie->pads = devm_platform_ioremap_resource_byname(pdev, "pads"); if (IS_ERR(pcie->pads)) { err = PTR_ERR(pcie->pads); goto phys_put; }
- afi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "afi"); - pcie->afi = devm_ioremap_resource(dev, afi); + pcie->afi = devm_platform_ioremap_resource_byname(pdev, "afi"); if (IS_ERR(pcie->afi)) { err = PTR_ERR(pcie->afi); goto phys_put; @@@ -2632,7 -2634,7 +2632,7 @@@ static int tegra_pcie_ports_open(struc static const struct file_operations tegra_pcie_ports_ops = { .owner = THIS_MODULE, .open = tegra_pcie_ports_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -2668,6 -2670,7 +2668,6 @@@ static int tegra_pcie_probe(struct plat struct device *dev = &pdev->dev; struct pci_host_bridge *host; struct tegra_pcie *pcie; - struct pci_bus *child; struct resource *bus; int err;
@@@ -2718,12 -2721,20 +2718,12 @@@ host->map_irq = tegra_pcie_map_irq; host->swizzle_irq = pci_common_swizzle;
- err = pci_scan_root_bus_bridge(host); + err = pci_host_probe(host); if (err < 0) { dev_err(dev, "failed to register host: %d\n", err); goto pm_runtime_put; }
- pci_bus_size_bridges(host->bus); - pci_bus_assign_resources(host->bus); - - list_for_each_entry(child, &host->bus->children, node) - pcie_bus_configure_settings(child); - - pci_bus_add_devices(host->bus); - if (IS_ENABLED(CONFIG_DEBUG_FS)) { err = tegra_pcie_debugfs_init(pcie); if (err < 0) diff --combined drivers/platform/x86/asus-wmi.c index 8f4acdc06b13,9efa854fff13..13f7d1bf076b --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@@ -441,7 -441,6 +441,7 @@@ static int asus_wmi_battery_add(struct * battery is named BATT. */ if (strcmp(battery->desc->name, "BAT0") != 0 && + strcmp(battery->desc->name, "BAT1") != 0 && strcmp(battery->desc->name, "BATT") != 0) return -ENODEV;
@@@ -2503,7 -2502,7 +2503,7 @@@ static int asus_wmi_debugfs_open(struc static const struct file_operations asus_wmi_debugfs_io_ops = { .owner = THIS_MODULE, .open = asus_wmi_debugfs_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/platform/x86/intel_pmc_core.c index 338ea5222555,4941349004f6..e0bee021d044 --- a/drivers/platform/x86/intel_pmc_core.c +++ b/drivers/platform/x86/intel_pmc_core.c @@@ -415,7 -415,7 +415,7 @@@ static const struct pmc_bit_map tgl_lpm {"PCIe_Gen3PLL_OFF_STS", BIT(20)}, {"OPIOPLL_OFF_STS", BIT(21)}, {"OCPLL_OFF_STS", BIT(22)}, - {"AudioPLL_OFF_STS", BIT(23)}, + {"MainPLL_OFF_STS", BIT(23)}, {"MIPIPLL_OFF_STS", BIT(24)}, {"Fast_XTAL_Osc_OFF_STS", BIT(25)}, {"AC_Ring_Osc_OFF_STS", BIT(26)}, @@@ -795,7 -795,7 +795,7 @@@ static int pmc_core_mphy_pg_show(struc msleep(10); val_high = pmc_core_reg_read(pmcdev, SPT_PMC_MFPMC_OFFSET);
- for (index = 0; map[index].name && index < 8; index++) { + for (index = 0; index < 8 && map[index].name; index++) { seq_printf(s, "%-32s\tState: %s\n", map[index].name, map[index].bit_mask & val_low ? "Not power gated" : @@@ -894,7 -894,7 +894,7 @@@ static int pmc_core_ltr_ignore_open(str
static const struct file_operations pmc_core_ltr_ignore_ops = { .open = pmc_core_ltr_ignore_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = pmc_core_ltr_ignore_write, .llseek = seq_lseek, .release = single_release, diff --combined drivers/pwm/core.c index 276e939a5684,ad39b0bb0b03..a7037136d49f --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@@ -510,12 -510,12 +510,12 @@@ static void pwm_apply_state_debug(struc last->period > s2.period && last->period <= state->period) dev_warn(chip->dev, - ".apply didn't pick the best available period (requested: %u, applied: %u, possible: %u)\n", + ".apply didn't pick the best available period (requested: %llu, applied: %llu, possible: %llu)\n", state->period, s2.period, last->period);
if (state->enabled && state->period < s2.period) dev_warn(chip->dev, - ".apply is supposed to round down period (requested: %u, applied: %u)\n", + ".apply is supposed to round down period (requested: %llu, applied: %llu)\n", state->period, s2.period);
if (state->enabled && @@@ -524,14 -524,14 +524,14 @@@ last->duty_cycle > s2.duty_cycle && last->duty_cycle <= state->duty_cycle) dev_warn(chip->dev, - ".apply didn't pick the best available duty cycle (requested: %u/%u, applied: %u/%u, possible: %u/%u)\n", + ".apply didn't pick the best available duty cycle (requested: %llu/%llu, applied: %llu/%llu, possible: %llu/%llu)\n", state->duty_cycle, state->period, s2.duty_cycle, s2.period, last->duty_cycle, last->period);
if (state->enabled && state->duty_cycle < s2.duty_cycle) dev_warn(chip->dev, - ".apply is supposed to round down duty_cycle (requested: %u/%u, applied: %u/%u)\n", + ".apply is supposed to round down duty_cycle (requested: %llu/%llu, applied: %llu/%llu)\n", state->duty_cycle, state->period, s2.duty_cycle, s2.period);
@@@ -558,7 -558,7 +558,7 @@@ (s1.enabled && s1.period != last->period) || (s1.enabled && s1.duty_cycle != last->duty_cycle)) { dev_err(chip->dev, - ".apply is not idempotent (ena=%d pol=%d %u/%u) -> (ena=%d pol=%d %u/%u)\n", + ".apply is not idempotent (ena=%d pol=%d %llu/%llu) -> (ena=%d pol=%d %llu/%llu)\n", s1.enabled, s1.polarity, s1.duty_cycle, s1.period, last->enabled, last->polarity, last->duty_cycle, last->period); @@@ -1284,8 -1284,8 +1284,8 @@@ static void pwm_dbg_show(struct pwm_chi if (state.enabled) seq_puts(s, " enabled");
- seq_printf(s, " period: %u ns", state.period); - seq_printf(s, " duty: %u ns", state.duty_cycle); + seq_printf(s, " period: %llu ns", state.period); + seq_printf(s, " duty: %llu ns", state.duty_cycle); seq_printf(s, " polarity: %s", state.polarity ? "inverse" : "normal");
@@@ -1342,7 -1342,7 +1342,7 @@@ static int pwm_seq_open(struct inode *i static const struct file_operations pwm_debugfs_ops = { .owner = THIS_MODULE, .open = pwm_seq_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; diff --combined drivers/s390/block/dasd.c index eb17fea8075c,17a9a35e9aed..20f256e6d38b --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@@ -1089,7 -1089,7 +1089,7 @@@ static int dasd_stats_open(struct inod static const struct file_operations dasd_stats_raw_fops = { .owner = THIS_MODULE, .open = dasd_stats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, .write = dasd_stats_write, @@@ -2802,7 -2802,7 +2802,7 @@@ static void __dasd_cleanup_cqr(struct d blk_update_request(req, BLK_STS_OK, blk_rq_bytes(req) - proc_bytes); blk_mq_requeue_request(req, true); - } else { + } else if (likely(!blk_should_fake_timeout(req->q))) { blk_mq_complete_request(req); } } diff --combined drivers/scsi/scsi_devinfo.c index ba84244c1b4f,87fb440ddfc5..f2e42862e27f --- a/drivers/scsi/scsi_devinfo.c +++ b/drivers/scsi/scsi_devinfo.c @@@ -239,7 -239,6 +239,7 @@@ static struct {"LSI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, {"ENGENIO", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, {"LENOVO", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, + {"FUJITSU", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, {"SanDisk", "Cruzer Blade", NULL, BLIST_TRY_VPD_PAGES | BLIST_INQUIRY_36}, {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36}, @@@ -739,7 -738,7 +739,7 @@@ out
static const struct proc_ops scsi_devinfo_proc_ops = { .proc_open = proc_scsi_devinfo_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_write = proc_scsi_devinfo_write, .proc_lseek = seq_lseek, .proc_release = seq_release, diff --combined drivers/soc/qcom/socinfo.c index e19102f46302,ab2a56c75f13..d9c64a78e49c --- a/drivers/soc/qcom/socinfo.c +++ b/drivers/soc/qcom/socinfo.c @@@ -24,7 -24,6 +24,7 @@@ #define SOCINFO_VERSION(maj, min) ((((maj) & 0xffff) << 16)|((min) & 0xffff))
#define SMEM_SOCINFO_BUILD_ID_LENGTH 32 +#define SMEM_SOCINFO_CHIP_ID_LENGTH 32
/* * SMEM item id, used to acquire handles to respective @@@ -122,16 -121,6 +122,16 @@@ struct socinfo __le32 chip_family; __le32 raw_device_family; __le32 raw_device_num; + /* Version 13 */ + __le32 nproduct_id; + char chip_id[SMEM_SOCINFO_CHIP_ID_LENGTH]; + /* Version 14 */ + __le32 num_clusters; + __le32 ncluster_array_offset; + __le32 num_defective_parts; + __le32 ndefective_parts_array_offset; + /* Version 15 */ + __le32 nmodem_supported; };
#ifdef CONFIG_DEBUG_FS @@@ -146,12 -135,6 +146,12 @@@ struct socinfo_params u32 raw_ver; u32 hw_plat; u32 fmt; + u32 nproduct_id; + u32 num_clusters; + u32 ncluster_array_offset; + u32 num_defective_parts; + u32 ndefective_parts_array_offset; + u32 nmodem_supported; };
struct smem_image_version { @@@ -219,10 -202,8 +219,10 @@@ static const struct soc_id soc_id[] = { 310, "MSM8996AU" }, { 311, "APQ8096AU" }, { 312, "APQ8096SG" }, + { 318, "SDM630" }, { 321, "SDM845" }, { 341, "SDA845" }, + { 356, "SM8250" }, };
static const char *socinfo_machine(struct device *dev, unsigned int id) @@@ -247,7 -228,7 +247,7 @@@ static int qcom_open_##name(struct inod \ static const struct file_operations qcom_ ##name## _ops = { \ .open = qcom_open_##name, \ - .read = seq_read, \ + .read_iter = seq_read_iter, \ .llseek = seq_lseek, \ .release = single_release, \ } @@@ -275,10 -256,7 +275,10 @@@ static int qcom_show_pmic_model(struct if (model < 0) return -EINVAL;
- seq_printf(seq, "%s\n", pmic_models[model]); + if (model <= ARRAY_SIZE(pmic_models) && pmic_models[model]) + seq_printf(seq, "%s\n", pmic_models[model]); + else + seq_printf(seq, "unknown (%d)\n", model);
return 0; } @@@ -294,19 -272,9 +294,19 @@@ static int qcom_show_pmic_die_revision( return 0; }
+static int qcom_show_chip_id(struct seq_file *seq, void *p) +{ + struct socinfo *socinfo = seq->private; + + seq_printf(seq, "%s\n", socinfo->chip_id); + + return 0; +} + QCOM_OPEN(build_id, qcom_show_build_id); QCOM_OPEN(pmic_model, qcom_show_pmic_model); QCOM_OPEN(pmic_die_rev, qcom_show_pmic_die_revision); +QCOM_OPEN(chip_id, qcom_show_chip_id);
#define DEFINE_IMAGE_OPS(type) \ static int show_image_##type(struct seq_file *seq, void *p) \ @@@ -323,7 -291,7 +323,7 @@@ static int open_image_##type(struct ino \ static const struct file_operations qcom_image_##type##_ops = { \ .open = open_image_##type, \ - .read = seq_read, \ + .read_iter = seq_read_iter, \ .llseek = seq_lseek, \ .release = single_release, \ } @@@ -344,38 -312,7 +344,38 @@@ static void socinfo_debugfs_init(struc
qcom_socinfo->info.fmt = __le32_to_cpu(info->fmt);
+ debugfs_create_x32("info_fmt", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.fmt); + switch (qcom_socinfo->info.fmt) { + case SOCINFO_VERSION(0, 15): + qcom_socinfo->info.nmodem_supported = __le32_to_cpu(info->nmodem_supported); + + debugfs_create_u32("nmodem_supported", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.nmodem_supported); + /* Fall through */ + case SOCINFO_VERSION(0, 14): + qcom_socinfo->info.num_clusters = __le32_to_cpu(info->num_clusters); + qcom_socinfo->info.ncluster_array_offset = __le32_to_cpu(info->ncluster_array_offset); + qcom_socinfo->info.num_defective_parts = __le32_to_cpu(info->num_defective_parts); + qcom_socinfo->info.ndefective_parts_array_offset = __le32_to_cpu(info->ndefective_parts_array_offset); + + debugfs_create_u32("num_clusters", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.num_clusters); + debugfs_create_u32("ncluster_array_offset", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.ncluster_array_offset); + debugfs_create_u32("num_defective_parts", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.num_defective_parts); + debugfs_create_u32("ndefective_parts_array_offset", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.ndefective_parts_array_offset); + /* Fall through */ + case SOCINFO_VERSION(0, 13): + qcom_socinfo->info.nproduct_id = __le32_to_cpu(info->nproduct_id); + + debugfs_create_u32("nproduct_id", 0400, qcom_socinfo->dbg_root, + &qcom_socinfo->info.nproduct_id); + DEBUGFS_ADD(info, chip_id); + /* Fall through */ case SOCINFO_VERSION(0, 12): qcom_socinfo->info.chip_family = __le32_to_cpu(info->chip_family); diff --combined drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index c52540b734fd,e198779db6fc..a47d32a2166f --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@@ -9,6 -9,22 +9,6 @@@ * jkmaline@cc.hut.fi * Copyright (c) 2002-2003, Jouni Malinen jkmaline@cc.hut.fi * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * * Contact Information: * James P. Ketrenos ipw2100-admin@linux.intel.com * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 @@@ -249,7 -265,7 +249,7 @@@ static int open_debug_level(struct inod
static const struct proc_ops debug_level_proc_ops = { .proc_open = open_debug_level, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_write = write_debug_level, .proc_release = single_release, diff --combined drivers/usb/chipidea/debug.c index da5d18cf6840,d734b97a7327..31a6fdcb7620 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c @@@ -18,7 -18,7 +18,7 @@@ #include "bits.h" #include "otg.h"
-/** +/* * ci_device_show: prints information about device capabilities and status */ static int ci_device_show(struct seq_file *s, void *data) @@@ -47,7 -47,7 +47,7 @@@ } DEFINE_SHOW_ATTRIBUTE(ci_device);
-/** +/* * ci_port_test_show: reads port test mode */ static int ci_port_test_show(struct seq_file *s, void *data) @@@ -67,7 -67,7 +67,7 @@@ return 0; }
-/** +/* * ci_port_test_write: writes port test mode */ static ssize_t ci_port_test_write(struct file *file, const char __user *ubuf, @@@ -110,12 -110,12 +110,12 @@@ static int ci_port_test_open(struct ino static const struct file_operations ci_port_test_fops = { .open = ci_port_test_open, .write = ci_port_test_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, };
-/** +/* * ci_qheads_show: DMA contents of all queue heads */ static int ci_qheads_show(struct seq_file *s, void *data) @@@ -147,7 -147,7 +147,7 @@@ } DEFINE_SHOW_ATTRIBUTE(ci_qheads);
-/** +/* * ci_requests_show: DMA contents of all requests currently queued (all endpts) */ static int ci_requests_show(struct seq_file *s, void *data) @@@ -296,7 -296,7 +296,7 @@@ static int ci_role_open(struct inode *i static const struct file_operations ci_role_fops = { .open = ci_role_open, .write = ci_role_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/usb/dwc2/debugfs.c index aaafd463d72a,19a083e4f396..5a9586a6432f --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@@ -37,15 -37,15 +37,15 @@@ static ssize_t testmode_write(struct fi return -EFAULT;
if (!strncmp(buf, "test_j", 6)) - testmode = TEST_J; + testmode = USB_TEST_J; else if (!strncmp(buf, "test_k", 6)) - testmode = TEST_K; + testmode = USB_TEST_K; else if (!strncmp(buf, "test_se0_nak", 12)) - testmode = TEST_SE0_NAK; + testmode = USB_TEST_SE0_NAK; else if (!strncmp(buf, "test_packet", 11)) - testmode = TEST_PACKET; + testmode = USB_TEST_PACKET; else if (!strncmp(buf, "test_force_enable", 17)) - testmode = TEST_FORCE_EN; + testmode = USB_TEST_FORCE_ENABLE; else testmode = 0;
@@@ -78,19 -78,19 +78,19 @@@ static int testmode_show(struct seq_fil case 0: seq_puts(s, "no test\n"); break; - case TEST_J: + case USB_TEST_J: seq_puts(s, "test_j\n"); break; - case TEST_K: + case USB_TEST_K: seq_puts(s, "test_k\n"); break; - case TEST_SE0_NAK: + case USB_TEST_SE0_NAK: seq_puts(s, "test_se0_nak\n"); break; - case TEST_PACKET: + case USB_TEST_PACKET: seq_puts(s, "test_packet\n"); break; - case TEST_FORCE_EN: + case USB_TEST_FORCE_ENABLE: seq_puts(s, "test_force_enable\n"); break; default: @@@ -109,7 -109,7 +109,7 @@@ static const struct file_operations tes .owner = THIS_MODULE, .open = testmode_open, .write = testmode_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/usb/dwc3/debugfs.c index 14dc6a37305d,14c075ad29f9..22706bb23e04 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@@ -380,7 -380,7 +380,7 @@@ static ssize_t dwc3_lsp_write(struct fi static const struct file_operations dwc3_lsp_fops = { .open = dwc3_lsp_open, .write = dwc3_lsp_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -445,7 -445,7 +445,7 @@@ static ssize_t dwc3_mode_write(struct f static const struct file_operations dwc3_mode_fops = { .open = dwc3_mode_open, .write = dwc3_mode_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -466,19 -466,19 +466,19 @@@ static int dwc3_testmode_show(struct se case 0: seq_printf(s, "no test\n"); break; - case TEST_J: + case USB_TEST_J: seq_printf(s, "test_j\n"); break; - case TEST_K: + case USB_TEST_K: seq_printf(s, "test_k\n"); break; - case TEST_SE0_NAK: + case USB_TEST_SE0_NAK: seq_printf(s, "test_se0_nak\n"); break; - case TEST_PACKET: + case USB_TEST_PACKET: seq_printf(s, "test_packet\n"); break; - case TEST_FORCE_EN: + case USB_TEST_FORCE_ENABLE: seq_printf(s, "test_force_enable\n"); break; default: @@@ -506,15 -506,15 +506,15 @@@ static ssize_t dwc3_testmode_write(stru return -EFAULT;
if (!strncmp(buf, "test_j", 6)) - testmode = TEST_J; + testmode = USB_TEST_J; else if (!strncmp(buf, "test_k", 6)) - testmode = TEST_K; + testmode = USB_TEST_K; else if (!strncmp(buf, "test_se0_nak", 12)) - testmode = TEST_SE0_NAK; + testmode = USB_TEST_SE0_NAK; else if (!strncmp(buf, "test_packet", 11)) - testmode = TEST_PACKET; + testmode = USB_TEST_PACKET; else if (!strncmp(buf, "test_force_enable", 17)) - testmode = TEST_FORCE_EN; + testmode = USB_TEST_FORCE_ENABLE; else testmode = 0;
@@@ -528,7 -528,7 +528,7 @@@ static const struct file_operations dwc3_testmode_fops = { .open = dwc3_testmode_open, .write = dwc3_testmode_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -620,7 -620,7 +620,7 @@@ static ssize_t dwc3_link_state_write(st static const struct file_operations dwc3_link_state_fops = { .open = dwc3_link_state_open, .write = dwc3_link_state_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined drivers/usb/gadget/udc/lpc32xx_udc.c index e8a4637a9a17,bac74bb67290..e79f5f286cbb --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c @@@ -532,7 -532,7 +532,7 @@@ static int proc_udc_open(struct inode * static const struct file_operations proc_ops = { .owner = THIS_MODULE, .open = proc_udc_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -1926,7 -1926,7 +1926,7 @@@ static const struct usb_ep_ops lpc32xx_ };
/* Send a ZLP on a non-0 IN EP */ -void udc_send_in_zlp(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) +static void udc_send_in_zlp(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) { /* Clear EP status */ udc_clearep_getsts(udc, ep->hwep_num); @@@ -1940,7 -1940,7 +1940,7 @@@ * This function will only be called when a delayed ZLP needs to be sent out * after a DMA transfer has filled both buffers. */ -void udc_handle_eps(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) +static void udc_handle_eps(struct lpc32xx_udc *udc, struct lpc32xx_ep *ep) { u32 epstatus; struct lpc32xx_request *req; @@@ -2986,7 -2986,7 +2986,7 @@@ static void lpc32xx_rmwkup_chg(int remo /* Enable or disable USB remote wakeup */ }
-struct lpc32xx_usbd_cfg lpc32xx_usbddata = { +static struct lpc32xx_usbd_cfg lpc32xx_usbddata = { .vbus_drv_pol = 0, .conn_chgb = &lpc32xx_usbd_conn_chg, .susp_chgb = &lpc32xx_usbd_susp_chg, diff --combined drivers/usb/host/xhci-debugfs.c index 92e25a62fdb5,4a640031d944..8b6747b53434 --- a/drivers/usb/host/xhci-debugfs.c +++ b/drivers/usb/host/xhci-debugfs.c @@@ -110,7 -110,6 +110,7 @@@ static void xhci_debugfs_free_regset(st kfree(regset); }
+__printf(6, 7) static void xhci_debugfs_regset(struct xhci_hcd *xhci, u32 base, const struct debugfs_reg32 *regs, size_t nregs, struct dentry *parent, @@@ -249,7 -248,7 +249,7 @@@ static int xhci_ring_open(struct inode
static const struct file_operations xhci_ring_fops = { .open = xhci_ring_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -330,7 -329,7 +330,7 @@@ static int xhci_context_open(struct ino
static const struct file_operations xhci_context_fops = { .open = xhci_context_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -391,7 -390,7 +391,7 @@@ static ssize_t xhci_port_write(struct f static const struct file_operations port_fops = { .open = xhci_port_open, .write = xhci_port_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; diff --combined fs/affs/file.c index a26a0f96c119,7d51cc2e3dab..87d23705135b --- a/fs/affs/file.c +++ b/fs/affs/file.c @@@ -14,7 -14,6 +14,7 @@@ */
#include <linux/uio.h> +#include <linux/blkdev.h> #include "affs.h"
static struct buffer_head *affs_get_extblock_slow(struct inode *inode, u32 ext); @@@ -976,7 -975,6 +976,6 @@@ const struct file_operations affs_file_ .open = affs_file_open, .release = affs_file_release, .fsync = affs_file_fsync, - .splice_read = generic_file_splice_read, };
const struct inode_operations affs_file_inode_operations = { diff --combined fs/block_dev.c index 1a84168f7cf3,0aa66a6075eb..64c4fe8181f2 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@@ -105,7 -105,16 +105,7 @@@ EXPORT_SYMBOL(invalidate_bdev)
static void set_init_blocksize(struct block_device *bdev) { - unsigned bsize = bdev_logical_block_size(bdev); - loff_t size = i_size_read(bdev->bd_inode); - - while (bsize < PAGE_SIZE) { - if (size & bsize) - break; - bsize <<= 1; - } - bdev->bd_block_size = bsize; - bdev->bd_inode->i_blkbits = blksize_bits(bsize); + bdev->bd_inode->i_blkbits = blksize_bits(bdev_logical_block_size(bdev)); }
int set_blocksize(struct block_device *bdev, int size) @@@ -119,8 -128,9 +119,8 @@@ return -EINVAL;
/* Don't change the size if it is same as current */ - if (bdev->bd_block_size != size) { + if (bdev->bd_inode->i_blkbits != blksize_bits(size)) { sync_blockdev(bdev); - bdev->bd_block_size = size; bdev->bd_inode->i_blkbits = blksize_bits(size); kill_bdev(bdev); } @@@ -693,12 -703,12 +693,12 @@@ int bdev_read_page(struct block_device if (!ops->rw_page || bdev_get_integrity(bdev)) return result;
- result = blk_queue_enter(bdev->bd_queue, 0); + result = blk_queue_enter(bdev->bd_disk->queue, 0); if (result) return result; result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, REQ_OP_READ); - blk_queue_exit(bdev->bd_queue); + blk_queue_exit(bdev->bd_disk->queue); return result; }
@@@ -729,7 -739,7 +729,7 @@@ int bdev_write_page(struct block_devic
if (!ops->rw_page || bdev_get_integrity(bdev)) return -EOPNOTSUPP; - result = blk_queue_enter(bdev->bd_queue, 0); + result = blk_queue_enter(bdev->bd_disk->queue, 0); if (result) return result;
@@@ -742,7 -752,7 +742,7 @@@ clean_page_buffers(page); unlock_page(page); } - blk_queue_exit(bdev->bd_queue); + blk_queue_exit(bdev->bd_disk->queue); return result; }
@@@ -773,6 -783,7 +773,6 @@@ static void init_once(void *foo
memset(bdev, 0, sizeof(*bdev)); mutex_init(&bdev->bd_mutex); - INIT_LIST_HEAD(&bdev->bd_list); #ifdef CONFIG_SYSFS INIT_LIST_HEAD(&bdev->bd_holder_disks); #endif @@@ -788,6 -799,9 +788,6 @@@ static void bdev_evict_inode(struct ino truncate_inode_pages_final(&inode->i_data); invalidate_inode_buffers(inode); /* is it needed here? */ clear_inode(inode); - spin_lock(&bdev_lock); - list_del_init(&bdev->bd_list); - spin_unlock(&bdev_lock); /* Detach inode from wb early as bdi_put() may free bdi->wb */ inode_detach_wb(inode); if (bdev->bd_bdi != &noop_backing_dev_info) { @@@ -862,6 -876,8 +862,6 @@@ static int bdev_set(struct inode *inode return 0; }
-static LIST_HEAD(all_bdevs); - struct block_device *bdget(dev_t dev) { struct block_device *bdev; @@@ -879,6 -895,7 +879,6 @@@ bdev->bd_contains = NULL; bdev->bd_super = NULL; bdev->bd_inode = inode; - bdev->bd_block_size = i_blocksize(inode); bdev->bd_part_count = 0; bdev->bd_invalidated = 0; inode->i_mode = S_IFBLK; @@@ -886,6 -903,9 +886,6 @@@ inode->i_bdev = bdev; inode->i_data.a_ops = &def_blk_aops; mapping_set_gfp_mask(&inode->i_data, GFP_USER); - spin_lock(&bdev_lock); - list_add(&bdev->bd_list, &all_bdevs); - spin_unlock(&bdev_lock); unlock_new_inode(inode); } return bdev; @@@ -906,14 -926,13 +906,14 @@@ EXPORT_SYMBOL(bdgrab)
long nr_blockdev_pages(void) { - struct block_device *bdev; + struct inode *inode; long ret = 0; - spin_lock(&bdev_lock); - list_for_each_entry(bdev, &all_bdevs, bd_list) { - ret += bdev->bd_inode->i_mapping->nrpages; - } - spin_unlock(&bdev_lock); + + spin_lock(&blockdev_superblock->s_inode_list_lock); + list_for_each_entry(inode, &blockdev_superblock->s_inodes, i_sb_list) + ret += inode->i_mapping->nrpages; + spin_unlock(&blockdev_superblock->s_inode_list_lock); + return ret; }
@@@ -1168,8 -1187,8 +1168,8 @@@ static void bd_clear_claiming(struct bl * Finish exclusive open of a block device. Mark the device as exlusively * open by the holder and wake up all waiters for exclusive open to finish. */ -void bd_finish_claiming(struct block_device *bdev, struct block_device *whole, - void *holder) +static void bd_finish_claiming(struct block_device *bdev, + struct block_device *whole, void *holder) { spin_lock(&bdev_lock); BUG_ON(!bd_may_claim(bdev, whole, holder)); @@@ -1184,6 -1203,7 +1184,6 @@@ bd_clear_claiming(whole, holder); spin_unlock(&bdev_lock); } -EXPORT_SYMBOL(bd_finish_claiming);
/** * bd_abort_claiming - abort claiming of a block device @@@ -1347,6 -1367,26 +1347,6 @@@ void bd_unlink_disk_holder(struct block EXPORT_SYMBOL_GPL(bd_unlink_disk_holder); #endif
-/** - * flush_disk - invalidates all buffer-cache entries on a disk - * - * @bdev: struct block device to be flushed - * @kill_dirty: flag to guide handling of dirty inodes - * - * Invalidates all buffer-cache entries on a disk. It should be called - * when a disk has been changed -- either by a media change or online - * resize. - */ -static void flush_disk(struct block_device *bdev, bool kill_dirty) -{ - if (__invalidate_device(bdev, kill_dirty)) { - printk(KERN_WARNING "VFS: busy inodes on changed media or " - "resized disk %s\n", - bdev->bd_disk ? bdev->bd_disk->disk_name : ""); - } - bdev->bd_invalidated = 1; -} - /** * check_disk_size_change - checks for disk size change and adjusts bdev size. * @disk: struct gendisk to check @@@ -1371,9 -1411,8 +1371,9 @@@ static void check_disk_size_change(stru disk->disk_name, bdev_size, disk_size); } i_size_write(bdev->bd_inode, disk_size); - if (bdev_size > disk_size) - flush_disk(bdev, false); + if (bdev_size > disk_size && __invalidate_device(bdev, false)) + pr_warn("VFS: busy inodes on resized disk %s\n", + disk->disk_name); } bdev->bd_invalidated = 0; } @@@ -1432,10 -1471,7 +1432,10 @@@ int check_disk_change(struct block_devi if (!(events & DISK_EVENT_MEDIA_CHANGE)) return 0;
- flush_disk(bdev, true); + if (__invalidate_device(bdev, true)) + pr_warn("VFS: busy inodes on changed media %s\n", + disk->disk_name); + bdev->bd_invalidated = 1; if (bdops->revalidate_disk) bdops->revalidate_disk(bdev->bd_disk); return 1; @@@ -1544,6 -1580,7 +1544,6 @@@ static int __blkdev_get(struct block_de if (!bdev->bd_openers) { first_open = true; bdev->bd_disk = disk; - bdev->bd_queue = disk->queue; bdev->bd_contains = bdev; bdev->bd_partno = partno;
@@@ -1564,6 -1601,7 +1564,6 @@@ disk_put_part(bdev->bd_part); bdev->bd_part = NULL; bdev->bd_disk = NULL; - bdev->bd_queue = NULL; mutex_unlock(&bdev->bd_mutex); disk_unblock_events(disk); put_disk_and_module(disk); @@@ -1640,6 -1678,7 +1640,6 @@@ disk_put_part(bdev->bd_part); bdev->bd_disk = NULL; bdev->bd_part = NULL; - bdev->bd_queue = NULL; if (bdev != bdev->bd_contains) __blkdev_put(bdev->bd_contains, mode, 1); bdev->bd_contains = NULL; @@@ -1812,7 -1851,7 +1812,7 @@@ static int blkdev_open(struct inode * i */ filp->f_flags |= O_LARGEFILE;
- filp->f_mode |= FMODE_NOWAIT; + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
if (filp->f_flags & O_NDELAY) filp->f_mode |= FMODE_NDELAY; @@@ -2121,7 -2160,6 +2121,6 @@@ const struct file_operations def_blk_fo #ifdef CONFIG_COMPAT .compat_ioctl = compat_blkdev_ioctl, #endif - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = blkdev_fallocate, }; diff --combined fs/btrfs/file.c index e050bd96e6c6,322cc65902d1..b4ec68cc8ea1 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@@ -500,18 -500,18 +500,18 @@@ next * this also makes the decision about creating an inline extent vs * doing real data extents, marking pages dirty and delalloc as required. */ -int btrfs_dirty_pages(struct inode *inode, struct page **pages, +int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages, size_t num_pages, loff_t pos, size_t write_bytes, struct extent_state **cached) { - struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); + struct btrfs_fs_info *fs_info = inode->root->fs_info; int err = 0; int i; u64 num_bytes; u64 start_pos; u64 end_of_last_block; u64 end_pos = pos + write_bytes; - loff_t isize = i_size_read(inode); + loff_t isize = i_size_read(&inode->vfs_inode); unsigned int extra_bits = 0;
start_pos = pos & ~((u64) fs_info->sectorsize - 1); @@@ -524,13 -524,13 +524,13 @@@ * The pages may have already been dirty, clear out old accounting so * we can set things up properly */ - clear_extent_bit(&BTRFS_I(inode)->io_tree, start_pos, end_of_last_block, + clear_extent_bit(&inode->io_tree, start_pos, end_of_last_block, EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 0, 0, cached);
- if (!btrfs_is_free_space_inode(BTRFS_I(inode))) { + if (!btrfs_is_free_space_inode(inode)) { if (start_pos >= isize && - !(BTRFS_I(inode)->flags & BTRFS_INODE_PREALLOC)) { + !(inode->flags & BTRFS_INODE_PREALLOC)) { /* * There can't be any extents following eof in this case * so just set the delalloc new bit for the range @@@ -538,7 -538,8 +538,7 @@@ */ extra_bits |= EXTENT_DELALLOC_NEW; } else { - err = btrfs_find_new_delalloc_bytes(BTRFS_I(inode), - start_pos, + err = btrfs_find_new_delalloc_bytes(inode, start_pos, num_bytes, cached); if (err) return err; @@@ -563,7 -564,7 +563,7 @@@ * at this time. */ if (end_pos > isize) - i_size_write(inode, end_pos); + i_size_write(&inode->vfs_inode, end_pos); return 0; }
@@@ -730,7 -731,7 +730,7 @@@ next * is deleted from the tree. */ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct inode *inode, + struct btrfs_root *root, struct btrfs_inode *inode, struct btrfs_path *path, u64 start, u64 end, u64 *drop_end, int drop_cache, int replace_extent, @@@ -743,8 -744,7 +743,8 @@@ struct btrfs_ref ref = { 0 }; struct btrfs_key key; struct btrfs_key new_key; - u64 ino = btrfs_ino(BTRFS_I(inode)); + struct inode *vfs_inode = &inode->vfs_inode; + u64 ino = btrfs_ino(inode); u64 search_start = start; u64 disk_bytenr = 0; u64 num_bytes = 0; @@@ -762,9 -762,9 +762,9 @@@ int leafs_visited = 0;
if (drop_cache) - btrfs_drop_extent_cache(BTRFS_I(inode), start, end - 1, 0); + btrfs_drop_extent_cache(inode, start, end - 1, 0);
- if (start >= BTRFS_I(inode)->disk_i_size && !replace_extent) + if (start >= inode->disk_i_size && !replace_extent) modify_tree = 0;
update_refs = (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || @@@ -935,7 -935,7 +935,7 @@@ next_slot extent_end - end); btrfs_mark_buffer_dirty(leaf); if (update_refs && disk_bytenr > 0) - inode_sub_bytes(inode, end - key.offset); + inode_sub_bytes(vfs_inode, end - key.offset); break; }
@@@ -955,7 -955,7 +955,7 @@@ start - key.offset); btrfs_mark_buffer_dirty(leaf); if (update_refs && disk_bytenr > 0) - inode_sub_bytes(inode, extent_end - start); + inode_sub_bytes(vfs_inode, extent_end - start); if (end == extent_end) break;
@@@ -979,7 -979,7 +979,7 @@@ delete_extent_item
if (update_refs && extent_type == BTRFS_FILE_EXTENT_INLINE) { - inode_sub_bytes(inode, + inode_sub_bytes(vfs_inode, extent_end - key.offset); extent_end = ALIGN(extent_end, fs_info->sectorsize); @@@ -993,7 -993,7 +993,7 @@@ key.offset - extent_offset); ret = btrfs_free_extent(trans, &ref); BUG_ON(ret); /* -ENOMEM */ - inode_sub_bytes(inode, + inode_sub_bytes(vfs_inode, extent_end - key.offset); }
@@@ -1082,8 -1082,8 +1082,8 @@@ int btrfs_drop_extents(struct btrfs_tra path = btrfs_alloc_path(); if (!path) return -ENOMEM; - ret = __btrfs_drop_extents(trans, root, inode, path, start, end, NULL, - drop_cache, 0, 0, NULL); + ret = __btrfs_drop_extents(trans, root, BTRFS_I(inode), path, start, + end, NULL, drop_cache, 0, 0, NULL); btrfs_free_path(path); return ret; } @@@ -1532,8 -1532,8 +1532,8 @@@ lock_and_cleanup_extent_if_need(struct return ret; }
-static noinline int check_can_nocow(struct btrfs_inode *inode, loff_t pos, - size_t *write_bytes, bool nowait) +static int check_can_nocow(struct btrfs_inode *inode, loff_t pos, + size_t *write_bytes, bool nowait) { struct btrfs_fs_info *fs_info = inode->root->fs_info; struct btrfs_root *root = inode->root; @@@ -1541,9 -1541,6 +1541,9 @@@ u64 num_bytes; int ret;
+ if (!(inode->flags & (BTRFS_INODE_NODATACOW | BTRFS_INODE_PREALLOC))) + return 0; + if (!nowait && !btrfs_drew_try_write_lock(&root->snapshot_lock)) return -EAGAIN;
@@@ -1586,42 -1583,6 +1586,42 @@@ out_unlock return ret; }
+static int check_nocow_nolock(struct btrfs_inode *inode, loff_t pos, + size_t *write_bytes) +{ + return check_can_nocow(inode, pos, write_bytes, true); +} + +/* + * Check if we can do nocow write into the range [@pos, @pos + @write_bytes) + * + * @pos: File offset + * @write_bytes: The length to write, will be updated to the nocow writeable + * range + * + * This function will flush ordered extents in the range to ensure proper + * nocow checks. + * + * Return: + * >0 and update @write_bytes if we can do nocow write + * 0 if we can't do nocow write + * -EAGAIN if we can't get the needed lock or there are ordered extents + * for * (nowait == true) case + * <0 if other error happened + * + * NOTE: Callers need to release the lock by btrfs_check_nocow_unlock(). + */ +int btrfs_check_nocow_lock(struct btrfs_inode *inode, loff_t pos, + size_t *write_bytes) +{ + return check_can_nocow(inode, pos, write_bytes, false); +} + +void btrfs_check_nocow_unlock(struct btrfs_inode *inode) +{ + btrfs_drew_write_unlock(&inode->root->snapshot_lock); +} + static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, struct iov_iter *i) { @@@ -1629,6 -1590,7 +1629,6 @@@ loff_t pos = iocb->ki_pos; struct inode *inode = file_inode(file); struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); - struct btrfs_root *root = BTRFS_I(inode)->root; struct page **pages = NULL; struct extent_changeset *data_reserved = NULL; u64 release_bytes = 0; @@@ -1681,12 -1643,13 +1681,12 @@@ fs_info->sectorsize);
extent_changeset_release(data_reserved); - ret = btrfs_check_data_free_space(inode, &data_reserved, pos, + ret = btrfs_check_data_free_space(BTRFS_I(inode), + &data_reserved, pos, write_bytes); if (ret < 0) { - if ((BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | - BTRFS_INODE_PREALLOC)) && - check_can_nocow(BTRFS_I(inode), pos, - &write_bytes, false) > 0) { + if (btrfs_check_nocow_lock(BTRFS_I(inode), pos, + &write_bytes) > 0) { /* * For nodata cow case, no need to reserve * data space. @@@ -1711,11 -1674,11 +1711,11 @@@ reserve_bytes); if (ret) { if (!only_release_metadata) - btrfs_free_reserved_data_space(inode, + btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved, pos, write_bytes); else - btrfs_drew_write_unlock(&root->snapshot_lock); + btrfs_check_nocow_unlock(BTRFS_I(inode)); break; }
@@@ -1785,7 -1748,7 +1785,7 @@@ again __pos = round_down(pos, fs_info->sectorsize) + (dirty_pages << PAGE_SHIFT); - btrfs_delalloc_release_space(inode, + btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved, __pos, release_bytes, true); } @@@ -1795,9 -1758,8 +1795,9 @@@ fs_info->sectorsize);
if (copied > 0) - ret = btrfs_dirty_pages(inode, pages, dirty_pages, - pos, copied, &cached_state); + ret = btrfs_dirty_pages(BTRFS_I(inode), pages, + dirty_pages, pos, copied, + &cached_state);
/* * If we have not locked the extent range, because the range's @@@ -1820,7 -1782,7 +1820,7 @@@
release_bytes = 0; if (only_release_metadata) - btrfs_drew_write_unlock(&root->snapshot_lock); + btrfs_check_nocow_unlock(BTRFS_I(inode));
if (only_release_metadata && copied > 0) { lockstart = round_down(pos, @@@ -1838,6 -1800,8 +1838,6 @@@ cond_resched();
balance_dirty_pages_ratelimited(inode->i_mapping); - if (dirty_pages < (fs_info->nodesize >> PAGE_SHIFT) + 1) - btrfs_btree_balance_dirty(fs_info);
pos += copied; num_written += copied; @@@ -1847,12 -1811,11 +1847,12 @@@
if (release_bytes) { if (only_release_metadata) { - btrfs_drew_write_unlock(&root->snapshot_lock); + btrfs_check_nocow_unlock(BTRFS_I(inode)); btrfs_delalloc_release_metadata(BTRFS_I(inode), release_bytes, true); } else { - btrfs_delalloc_release_space(inode, data_reserved, + btrfs_delalloc_release_space(BTRFS_I(inode), + data_reserved, round_down(pos, fs_info->sectorsize), release_bytes, true); } @@@ -1872,7 -1835,7 +1872,7 @@@ static ssize_t __btrfs_direct_write(str loff_t endbyte; int err;
- written = generic_file_direct_write(iocb, from); + written = btrfs_direct_IO(iocb, from);
if (written < 0 || !iov_iter_count(from)) return written; @@@ -1963,8 -1926,10 +1963,8 @@@ static ssize_t btrfs_file_write_iter(st * We will allocate space in case nodatacow is not set, * so bail */ - if (!(BTRFS_I(inode)->flags & (BTRFS_INODE_NODATACOW | - BTRFS_INODE_PREALLOC)) || - check_can_nocow(BTRFS_I(inode), pos, &nocow_bytes, - true) <= 0) { + if (check_nocow_nolock(BTRFS_I(inode), pos, &nocow_bytes) + <= 0) { inode_unlock(inode); return -EAGAIN; } @@@ -2633,7 -2598,7 +2633,7 @@@ int btrfs_punch_hole_range(struct inod
cur_offset = start; while (cur_offset < end) { - ret = __btrfs_drop_extents(trans, root, inode, path, + ret = __btrfs_drop_extents(trans, root, BTRFS_I(inode), path, cur_offset, end + 1, &drop_end, 1, 0, 0, NULL); if (ret != -ENOSPC) { @@@ -3211,14 -3176,14 +3211,14 @@@ reserve_space if (ret < 0) goto out; space_reserved = true; - ret = btrfs_qgroup_reserve_data(inode, &data_reserved, - alloc_start, bytes_to_reserve); - if (ret) - goto out; ret = btrfs_punch_hole_lock_range(inode, lockstart, lockend, &cached_state); if (ret) goto out; + ret = btrfs_qgroup_reserve_data(BTRFS_I(inode), &data_reserved, + alloc_start, bytes_to_reserve); + if (ret) + goto out; ret = btrfs_prealloc_file_range(inode, mode, alloc_start, alloc_end - alloc_start, i_blocksize(inode), @@@ -3234,7 -3199,7 +3234,7 @@@ ret = btrfs_fallocate_update_isize(inode, offset + len, mode); out: if (ret && space_reserved) - btrfs_free_reserved_data_space(inode, data_reserved, + btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved, alloc_start, bytes_to_reserve); extent_changeset_free(data_reserved);
@@@ -3385,9 -3350,8 +3385,9 @@@ static long btrfs_fallocate(struct fil free_extent_map(em); break; } - ret = btrfs_qgroup_reserve_data(inode, &data_reserved, - cur_offset, last_byte - cur_offset); + ret = btrfs_qgroup_reserve_data(BTRFS_I(inode), + &data_reserved, cur_offset, + last_byte - cur_offset); if (ret < 0) { cur_offset = last_byte; free_extent_map(em); @@@ -3399,9 -3363,8 +3399,9 @@@ * range, free reserved data space first, otherwise * it'll result in false ENOSPC error. */ - btrfs_free_reserved_data_space(inode, data_reserved, - cur_offset, last_byte - cur_offset); + btrfs_free_reserved_data_space(BTRFS_I(inode), + data_reserved, cur_offset, + last_byte - cur_offset); } free_extent_map(em); cur_offset = last_byte; @@@ -3418,7 -3381,7 +3418,7 @@@ range->len, i_blocksize(inode), offset + len, &alloc_hint); else - btrfs_free_reserved_data_space(inode, + btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved, range->start, range->len); list_del(&range->list); @@@ -3439,7 -3402,7 +3439,7 @@@ out inode_unlock(inode); /* Let go of our reservation. */ if (ret != 0 && !(mode & FALLOC_FL_ZERO_RANGE)) - btrfs_free_reserved_data_space(inode, data_reserved, + btrfs_free_reserved_data_space(BTRFS_I(inode), data_reserved, cur_offset, alloc_end - cur_offset); extent_changeset_free(data_reserved); return ret; @@@ -3537,33 -3500,14 +3537,32 @@@ static loff_t btrfs_file_llseek(struct
static int btrfs_file_open(struct inode *inode, struct file *filp) { - filp->f_mode |= FMODE_NOWAIT; + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; return generic_file_open(inode, filp); }
+static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + ssize_t ret = 0; + + if (iocb->ki_flags & IOCB_DIRECT) { + struct inode *inode = file_inode(iocb->ki_filp); + + inode_lock_shared(inode); + ret = btrfs_direct_IO(iocb, to); + inode_unlock_shared(inode); + if (ret < 0) + return ret; + } + + return generic_file_buffered_read(iocb, to, ret); +} + const struct file_operations btrfs_file_operations = { .llseek = btrfs_file_llseek, - .read_iter = generic_file_read_iter, + .read_iter = btrfs_file_read_iter, - .splice_read = generic_file_splice_read, .write_iter = btrfs_file_write_iter, + .splice_write = iter_file_splice_write, .mmap = btrfs_file_mmap, .open = btrfs_file_open, .release = btrfs_release_file, diff --combined fs/debugfs/file.c index b167d2d02148,8ba32c2feb1b..ce825d328c4d --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@@ -273,7 -273,7 +273,7 @@@ static int full_proxy_release(struct in r = real_fops->release(inode, filp);
replace_fops(filp, d_inode(dentry)->i_fop); - kfree((void *)proxy_fops); + kfree(proxy_fops); fops_put(real_fops); return r; } @@@ -918,6 -918,11 +918,6 @@@ struct dentry *debugfs_create_blob(cons } EXPORT_SYMBOL_GPL(debugfs_create_blob);
-struct array_data { - void *array; - u32 elements; -}; - static size_t u32_format_array(char *buf, size_t bufsize, u32 *array, int array_size) { @@@ -938,8 -943,8 +938,8 @@@
static int u32_array_open(struct inode *inode, struct file *file) { - struct array_data *data = inode->i_private; - int size, elements = data->elements; + struct debugfs_u32_array *data = inode->i_private; + int size, elements = data->n_elements; char *buf;
/* @@@ -954,7 -959,7 +954,7 @@@ buf[size] = 0;
file->private_data = buf; - u32_format_array(buf, size, data->array, data->elements); + u32_format_array(buf, size, data->array, data->n_elements);
return nonseekable_open(inode, file); } @@@ -991,7 -996,8 +991,7 @@@ static const struct file_operations u32 * @parent: a pointer to the parent dentry for this file. This should be a * directory dentry if set. If this parameter is %NULL, then the * file will be created in the root of the debugfs filesystem. - * @array: u32 array that provides data. - * @elements: total number of elements in the array. + * @array: wrapper struct containing data pointer and size of the array. * * This function creates a file in debugfs with the given name that exports * @array as data. If the @mode variable is so set it can be read from. @@@ -999,10 -1005,17 +999,10 @@@ * Once array is created its size can not be changed. */ void debugfs_create_u32_array(const char *name, umode_t mode, - struct dentry *parent, u32 *array, u32 elements) + struct dentry *parent, + struct debugfs_u32_array *array) { - struct array_data *data = kmalloc(sizeof(*data), GFP_KERNEL); - - if (data == NULL) - return; - - data->array = array; - data->elements = elements; - - debugfs_create_file_unsafe(name, mode, parent, data, &u32_array_fops); + debugfs_create_file_unsafe(name, mode, parent, array, &u32_array_fops); } EXPORT_SYMBOL_GPL(debugfs_create_u32_array);
@@@ -1067,7 -1080,7 +1067,7 @@@ static int debugfs_open_regset32(struc
static const struct file_operations fops_regset32 = { .open = debugfs_open_regset32, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -1113,7 -1126,7 +1113,7 @@@ static const struct file_operations deb .owner = THIS_MODULE, .open = debugfs_devm_entry_open, .release = single_release, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek };
diff --combined fs/exfat/file.c index 6bdabfd4b134,8fe5df8a9ccb..f71b599f9bfe --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@@ -154,7 -154,6 +154,7 @@@ int __exfat_truncate(struct inode *inod struct timespec64 ts; struct exfat_dentry *ep, *ep2; struct exfat_entry_set_cache *es; + int err;
es = exfat_get_dentry_set(sb, &(ei->dir), ei->entry, ES_ALL_ENTRIES); @@@ -177,7 -176,7 +177,7 @@@ ep2->dentry.stream.size = 0; } else { ep2->dentry.stream.valid_size = cpu_to_le64(new_size); - ep2->dentry.stream.size = ep->dentry.stream.valid_size; + ep2->dentry.stream.size = ep2->dentry.stream.valid_size; }
if (new_size == 0) { @@@ -189,9 -188,7 +189,9 @@@ }
exfat_update_dir_chksum_with_entry_set(es); - exfat_free_dentry_set(es, inode_needs_sync(inode)); + err = exfat_free_dentry_set(es, inode_needs_sync(inode)); + if (err) + return err; }
/* cut off from the FAT chain */ @@@ -372,7 -369,6 +372,6 @@@ const struct file_operations exfat_file .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = exfat_file_fsync, - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, };
diff --combined fs/ext4/file.c index 8f6324eb6b27,f5dc9a4e0937..cdfc8c6919c5 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@@ -53,7 -53,6 +53,7 @@@ static ssize_t ext4_dio_read_iter(struc { ssize_t ret; struct inode *inode = file_inode(iocb->ki_filp); + unsigned int flags = 0;
if (iocb->ki_flags & IOCB_NOWAIT) { if (!inode_trylock_shared(inode)) @@@ -75,11 -74,8 +75,11 @@@ return generic_file_read_iter(iocb, to); }
+ if (is_sync_kiocb(iocb)) + flags |= IOMAP_DIO_RWF_SYNCIO; + ret = iomap_dio_rw(iocb, to, &ext4_iomap_ops, NULL, - is_sync_kiocb(iocb)); + flags); inode_unlock_shared(inode);
file_accessed(iocb->ki_filp); @@@ -461,7 -457,6 +461,7 @@@ static ssize_t ext4_dio_write_iter(stru const struct iomap_ops *iomap_ops = &ext4_iomap_ops; bool extend = false, unaligned_io = false; bool ilock_shared = true; + unsigned int flags = 0;
/* * We initially start with shared inode lock unless it is @@@ -545,12 -540,10 +545,12 @@@ ext4_journal_stop(handle); }
+ if (is_sync_kiocb(iocb) || unaligned_io || extend) + flags |= IOMAP_DIO_RWF_SYNCIO; if (ilock_shared) iomap_ops = &ext4_iomap_overwrite_ops; ret = iomap_dio_rw(iocb, from, iomap_ops, &ext4_dio_write_ops, - is_sync_kiocb(iocb) || unaligned_io || extend); + flags);
if (extend) ret = ext4_handle_inode_extension(inode, offset, ret, count); @@@ -903,7 -896,6 +903,6 @@@ const struct file_operations ext4_file_ .release = ext4_release_file, .fsync = ext4_sync_file, .get_unmapped_area = thp_get_unmapped_area, - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ext4_fallocate, }; diff --combined fs/f2fs/file.c index 368c80f8e2a1,6b34caf13b56..bdc1726af2d3 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@@ -21,7 -21,6 +21,7 @@@ #include <linux/uuid.h> #include <linux/file.h> #include <linux/nls.h> +#include <linux/sched/signal.h>
#include "f2fs.h" #include "node.h" @@@ -106,11 -105,11 +106,11 @@@ static vm_fault_t f2fs_vm_page_mkwrite(
if (need_alloc) { /* block allocation */ - __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, true); + f2fs_do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, true); set_new_dnode(&dn, inode, NULL, NULL, 0); err = f2fs_get_block(&dn, page->index); f2fs_put_dnode(&dn); - __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false); + f2fs_do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false); }
#ifdef CONFIG_F2FS_FS_COMPRESSION @@@ -1374,6 -1373,8 +1374,6 @@@ static int f2fs_collapse_range(struct i truncate_pagecache(inode, offset);
new_size = i_size_read(inode) - len; - truncate_pagecache(inode, new_size); - ret = f2fs_truncate_blocks(inode, new_size, true); up_write(&F2FS_I(inode)->i_mmap_sem); if (!ret) @@@ -1659,7 -1660,7 +1659,7 @@@ next_alloc map.m_seg_type = CURSEG_COLD_DATA_PINNED;
f2fs_lock_op(sbi); - f2fs_allocate_new_segments(sbi, CURSEG_COLD_DATA); + f2fs_allocate_new_segment(sbi, CURSEG_COLD_DATA); f2fs_unlock_op(sbi);
err = f2fs_map_blocks(inode, &map, 1, F2FS_GET_BLOCK_PRE_DIO); @@@ -2526,11 -2527,6 +2526,11 @@@ do_more }
ret = f2fs_gc(sbi, range.sync, true, GET_SEGNO(sbi, range.start)); + if (ret) { + if (ret == -EBUSY) + ret = -EAGAIN; + goto out; + } range.start += BLKS_PER_SEC(sbi); if (range.start <= end) goto do_more; @@@ -3760,183 -3756,6 +3760,183 @@@ out return ret; }
+static int f2fs_secure_erase(struct block_device *bdev, block_t block, + block_t len, u32 flags) +{ + struct request_queue *q = bdev_get_queue(bdev); + sector_t sector = SECTOR_FROM_BLOCK(block); + sector_t nr_sects = SECTOR_FROM_BLOCK(len); + int ret = 0; + + if (!q) + return -ENXIO; + + if (flags & F2FS_TRIM_FILE_DISCARD) + ret = blkdev_issue_discard(bdev, sector, nr_sects, GFP_NOFS, + blk_queue_secure_erase(q) ? + BLKDEV_DISCARD_SECURE : 0); + + if (!ret && (flags & F2FS_TRIM_FILE_ZEROOUT)) + ret = blkdev_issue_zeroout(bdev, sector, nr_sects, GFP_NOFS, 0); + + return ret; +} + +static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) +{ + struct inode *inode = file_inode(filp); + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + struct address_space *mapping = inode->i_mapping; + struct block_device *prev_bdev = NULL; + struct f2fs_sectrim_range range; + pgoff_t index, pg_end; + block_t prev_block = 0, len = 0; + loff_t end_addr; + bool to_end; + int ret = 0; + + if (!(filp->f_mode & FMODE_WRITE)) + return -EBADF; + + if (copy_from_user(&range, (struct f2fs_sectrim_range __user *)arg, + sizeof(range))) + return -EFAULT; + + if (range.flags == 0 || (range.flags & ~F2FS_TRIM_FILE_MASK) || + !S_ISREG(inode->i_mode)) + return -EINVAL; + + if ((range.flags & F2FS_TRIM_FILE_DISCARD) && + !f2fs_hw_support_discard(sbi)) + return -EOPNOTSUPP; + + file_start_write(filp); + inode_lock(inode); + + if (f2fs_is_atomic_file(inode) || f2fs_compressed_file(inode)) { + ret = -EINVAL; + goto err; + } + + if (range.start >= inode->i_size) { + ret = -EINVAL; + goto err; + } + + if (inode->i_size - range.start < range.len) { + ret = -E2BIG; + goto err; + } + end_addr = range.start + range.len; + + to_end = (end_addr == inode->i_size); + if (!IS_ALIGNED(range.start, F2FS_BLKSIZE) || + (!to_end && !IS_ALIGNED(end_addr, F2FS_BLKSIZE))) { + ret = -EINVAL; + goto err; + } + + index = F2FS_BYTES_TO_BLK(range.start); + pg_end = DIV_ROUND_UP(end_addr, F2FS_BLKSIZE); + + ret = f2fs_convert_inline_inode(inode); + if (ret) + goto err; + + down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); + down_write(&F2FS_I(inode)->i_mmap_sem); + + ret = filemap_write_and_wait_range(mapping, range.start, end_addr - 1); + if (ret) + goto out; + + truncate_inode_pages_range(mapping, range.start, + to_end ? -1 : end_addr - 1); + + while (index < pg_end) { + struct dnode_of_data dn; + pgoff_t end_offset, count; + int i; + + set_new_dnode(&dn, inode, NULL, NULL, 0); + ret = f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE); + if (ret) { + if (ret == -ENOENT) { + index = f2fs_get_next_page_offset(&dn, index); + continue; + } + goto out; + } + + end_offset = ADDRS_PER_PAGE(dn.node_page, inode); + count = min(end_offset - dn.ofs_in_node, pg_end - index); + for (i = 0; i < count; i++, dn.ofs_in_node++) { + struct block_device *cur_bdev; + block_t blkaddr = f2fs_data_blkaddr(&dn); + + if (!__is_valid_data_blkaddr(blkaddr)) + continue; + + if (!f2fs_is_valid_blkaddr(sbi, blkaddr, + DATA_GENERIC_ENHANCE)) { + ret = -EFSCORRUPTED; + f2fs_put_dnode(&dn); + goto out; + } + + cur_bdev = f2fs_target_device(sbi, blkaddr, NULL); + if (f2fs_is_multi_device(sbi)) { + int di = f2fs_target_device_index(sbi, blkaddr); + + blkaddr -= FDEV(di).start_blk; + } + + if (len) { + if (prev_bdev == cur_bdev && + blkaddr == prev_block + len) { + len++; + } else { + ret = f2fs_secure_erase(prev_bdev, + prev_block, len, range.flags); + if (ret) { + f2fs_put_dnode(&dn); + goto out; + } + + len = 0; + } + } + + if (!len) { + prev_bdev = cur_bdev; + prev_block = blkaddr; + len = 1; + } + } + + f2fs_put_dnode(&dn); + index += count; + + if (fatal_signal_pending(current)) { + ret = -EINTR; + goto out; + } + cond_resched(); + } + + if (len) + ret = f2fs_secure_erase(prev_bdev, prev_block, len, + range.flags); +out: + up_write(&F2FS_I(inode)->i_mmap_sem); + up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); +err: + inode_unlock(inode); + file_end_write(filp); + + return ret; +} + long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { if (unlikely(f2fs_cp_error(F2FS_I_SB(file_inode(filp))))) @@@ -4023,8 -3842,6 +4023,8 @@@ return f2fs_release_compress_blocks(filp, arg); case F2FS_IOC_RESERVE_COMPRESS_BLOCKS: return f2fs_reserve_compress_blocks(filp, arg); + case F2FS_IOC_SEC_TRIM_FILE: + return f2fs_sec_trim_file(filp, arg); default: return -ENOTTY; } @@@ -4194,7 -4011,6 +4194,7 @@@ long f2fs_compat_ioctl(struct file *fil case F2FS_IOC_GET_COMPRESS_BLOCKS: case F2FS_IOC_RELEASE_COMPRESS_BLOCKS: case F2FS_IOC_RESERVE_COMPRESS_BLOCKS: + case F2FS_IOC_SEC_TRIM_FILE: break; default: return -ENOIOCTLCMD; @@@ -4217,6 -4033,5 +4217,5 @@@ const struct file_operations f2fs_file_ #ifdef CONFIG_COMPAT .compat_ioctl = f2fs_compat_ioctl, #endif - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, }; diff --combined fs/fuse/file.c index 32301fe626ba,a404e147bb2c..d87d7120f71d --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@@ -2963,7 -2963,7 +2963,7 @@@ static void fuse_register_polled_file(s { spin_lock(&fc->lock); if (RB_EMPTY_NODE(&ff->polled_node)) { - struct rb_node **link, *uninitialized_var(parent); + struct rb_node **link, *parent;
link = fuse_find_polled_node(fc, ff->kh, &parent); BUG_ON(*link); @@@ -3382,7 -3382,6 +3382,6 @@@ static const struct file_operations fus .fsync = fuse_fsync, .lock = fuse_file_lock, .flock = fuse_file_flock, - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .unlocked_ioctl = fuse_file_ioctl, .compat_ioctl = fuse_file_compat_ioctl, diff --combined fs/gfs2/file.c index 973cac25e781,3e0f0435c96a..8f172bbf5996 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@@ -781,44 -781,40 +781,44 @@@ static int gfs2_fsync(struct file *file return ret ? ret : ret1; }
-static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to) +static ssize_t gfs2_file_direct_read(struct kiocb *iocb, struct iov_iter *to, + struct gfs2_holder *gh) { struct file *file = iocb->ki_filp; struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); size_t count = iov_iter_count(to); - struct gfs2_holder gh; ssize_t ret; + unsigned int flags = 0;
if (!count) return 0; /* skip atime */
- gfs2_holder_init(ip->i_gl, LM_ST_DEFERRED, 0, &gh); - ret = gfs2_glock_nq(&gh); + gfs2_holder_init(ip->i_gl, LM_ST_DEFERRED, 0, gh); + ret = gfs2_glock_nq(gh); if (ret) goto out_uninit;
- ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL, - is_sync_kiocb(iocb)); + if (is_sync_kiocb(iocb)) + flags |= IOMAP_DIO_RWF_SYNCIO;
- gfs2_glock_dq(&gh); + ret = iomap_dio_rw(iocb, to, &gfs2_iomap_ops, NULL, flags); + + gfs2_glock_dq(gh); out_uninit: - gfs2_holder_uninit(&gh); + gfs2_holder_uninit(gh); return ret; }
-static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from) +static ssize_t gfs2_file_direct_write(struct kiocb *iocb, struct iov_iter *from, + struct gfs2_holder *gh) { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; struct gfs2_inode *ip = GFS2_I(inode); size_t len = iov_iter_count(from); loff_t offset = iocb->ki_pos; - struct gfs2_holder gh; ssize_t ret; + unsigned int flags = 0;
/* * Deferred lock, even if its a write, since we do no allocation on @@@ -828,8 -824,8 +828,8 @@@ * unfortunately, have the option of only flushing a range like the * VFS does. */ - gfs2_holder_init(ip->i_gl, LM_ST_DEFERRED, 0, &gh); - ret = gfs2_glock_nq(&gh); + gfs2_holder_init(ip->i_gl, LM_ST_DEFERRED, 0, gh); + ret = gfs2_glock_nq(gh); if (ret) goto out_uninit;
@@@ -837,15 -833,13 +837,15 @@@ if (offset + len > i_size_read(&ip->i_inode)) goto out;
- ret = iomap_dio_rw(iocb, from, &gfs2_iomap_ops, NULL, - is_sync_kiocb(iocb)); + if (is_sync_kiocb(iocb)) + flags |= IOMAP_DIO_RWF_SYNCIO; + + ret = iomap_dio_rw(iocb, from, &gfs2_iomap_ops, NULL, flags);
out: - gfs2_glock_dq(&gh); + gfs2_glock_dq(gh); out_uninit: - gfs2_holder_uninit(&gh); + gfs2_holder_uninit(gh); return ret; }
@@@ -857,7 -851,7 +857,7 @@@ static ssize_t gfs2_file_read_iter(stru ssize_t ret;
if (iocb->ki_flags & IOCB_DIRECT) { - ret = gfs2_file_direct_read(iocb, to); + ret = gfs2_file_direct_read(iocb, to, &gh); if (likely(ret != -ENOTBLK)) return ret; iocb->ki_flags &= ~IOCB_DIRECT; @@@ -906,12 -900,13 +906,12 @@@ static ssize_t gfs2_file_write_iter(str struct file *file = iocb->ki_filp; struct inode *inode = file_inode(file); struct gfs2_inode *ip = GFS2_I(inode); + struct gfs2_holder gh; ssize_t ret;
gfs2_size_hint(file, iocb->ki_pos, iov_iter_count(from));
if (iocb->ki_flags & IOCB_APPEND) { - struct gfs2_holder gh; - ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &gh); if (ret) return ret; @@@ -935,7 -930,7 +935,7 @@@ struct address_space *mapping = file->f_mapping; ssize_t buffered, ret2;
- ret = gfs2_file_direct_write(iocb, from); + ret = gfs2_file_direct_write(iocb, from, &gh); if (ret < 0 || !iov_iter_count(from)) goto out_unlock;
@@@ -1376,7 -1371,6 +1376,6 @@@ const struct file_operations gfs2_file_ .fsync = gfs2_fsync, .lock = gfs2_lock, .flock = gfs2_flock, - .splice_read = generic_file_splice_read, .splice_write = gfs2_file_splice_write, .setlease = simple_nosetlease, .fallocate = gfs2_fallocate, @@@ -1407,7 -1401,6 +1406,6 @@@ const struct file_operations gfs2_file_ .open = gfs2_open, .release = gfs2_release, .fsync = gfs2_fsync, - .splice_read = generic_file_splice_read, .splice_write = gfs2_file_splice_write, .setlease = generic_setlease, .fallocate = gfs2_fallocate, diff --combined fs/gfs2/glock.c index 57134d326cfa,ffc9e4273a23..63a6c3e391e9 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@@ -2106,12 -2106,6 +2106,12 @@@ static const char *gflags2str(char *buf *p++ = 'o'; if (test_bit(GLF_BLOCKING, gflags)) *p++ = 'b'; + if (test_bit(GLF_INODE_CREATING, gflags)) + *p++ = 'c'; + if (test_bit(GLF_PENDING_DELETE, gflags)) + *p++ = 'P'; + if (test_bit(GLF_FREEING, gflags)) + *p++ = 'x'; *p = 0; return buf; } @@@ -2479,7 -2473,7 +2479,7 @@@ static int gfs2_sbstats_open(struct ino static const struct file_operations gfs2_glocks_fops = { .owner = THIS_MODULE, .open = gfs2_glocks_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = gfs2_glocks_release, }; @@@ -2487,7 -2481,7 +2487,7 @@@ static const struct file_operations gfs2_glstats_fops = { .owner = THIS_MODULE, .open = gfs2_glstats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = gfs2_glocks_release, }; @@@ -2495,7 -2489,7 +2495,7 @@@ static const struct file_operations gfs2_sbstats_fops = { .owner = THIS_MODULE, .open = gfs2_sbstats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; diff --combined fs/hfs/inode.c index f35a37c65e5f,6181d3818e17..8d78da646f74 --- a/fs/hfs/inode.c +++ b/fs/hfs/inode.c @@@ -17,7 -17,6 +17,7 @@@ #include <linux/cred.h> #include <linux/uio.h> #include <linux/xattr.h> +#include <linux/blkdev.h>
#include "hfs_fs.h" #include "btree.h" @@@ -683,7 -682,6 +683,6 @@@ static const struct file_operations hfs .read_iter = generic_file_read_iter, .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, - .splice_read = generic_file_splice_read, .fsync = hfs_file_fsync, .open = hfs_file_open, .release = hfs_file_release, diff --combined fs/nfsd/nfsctl.c index 7ae236113040,c6f2faa759d1..b36911385f5d --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@@ -159,7 -159,7 +159,7 @@@ static int exports_proc_open(struct ino
static const struct proc_ops exports_proc_ops = { .proc_open = exports_proc_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = seq_release, }; @@@ -171,7 -171,7 +171,7 @@@ static int exports_nfsd_open(struct ino
static const struct file_operations exports_nfsd_operations = { .open = exports_nfsd_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -189,7 -189,7 +189,7 @@@ static int export_features_open(struct
static const struct file_operations export_features_operations = { .open = export_features_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -208,7 -208,7 +208,7 @@@ static int supported_enctypes_open(stru
static const struct file_operations supported_enctypes_ops = { .open = supported_enctypes_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -216,14 -216,14 +216,14 @@@
static const struct file_operations pool_stats_operations = { .open = nfsd_pool_stats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = nfsd_pool_stats_release, };
static const struct file_operations reply_cache_stats_operations = { .open = nfsd_reply_cache_stats_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = single_release, }; @@@ -351,7 -351,7 +351,7 @@@ static ssize_t write_unlock_fs(struct f static ssize_t write_filehandle(struct file *file, char *buf, size_t size) { char *dname, *path; - int uninitialized_var(maxsize); + int maxsize; char *mesg = buf; int len; struct auth_domain *dom; diff --combined fs/omfs/file.c index 2c7b70ee1388,0dddc6c644c1..cae3f4dcae54 --- a/fs/omfs/file.c +++ b/fs/omfs/file.c @@@ -220,7 -220,7 +220,7 @@@ static int omfs_get_block(struct inode struct buffer_head *bh; sector_t next, offset; int ret; - u64 uninitialized_var(new_block); + u64 new_block; u32 max_extents; int extent_count; struct omfs_extent *oe; @@@ -340,7 -340,6 +340,6 @@@ const struct file_operations omfs_file_ .write_iter = generic_file_write_iter, .mmap = generic_file_mmap, .fsync = generic_file_fsync, - .splice_read = generic_file_splice_read, };
static int omfs_setattr(struct dentry *dentry, struct iattr *attr) diff --combined fs/proc/array.c index 65ec2029fa80,49456efa31e3..5f6c8a8cb701 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@@ -341,8 -341,6 +341,8 @@@ static inline void task_seccomp(struct seq_put_decimal_ull(m, "NoNewPrivs:\t", task_no_new_privs(p)); #ifdef CONFIG_SECCOMP seq_put_decimal_ull(m, "\nSeccomp:\t", p->seccomp.mode); + seq_put_decimal_ull(m, "\nSeccomp_filters:\t", + atomic_read(&p->seccomp.filter_count)); #endif seq_puts(m, "\nSpeculation_Store_Bypass:\t"); switch (arch_prctl_spec_ctrl_get(p, PR_SPEC_STORE_BYPASS)) { @@@ -768,7 -766,7 +768,7 @@@ static int children_seq_open(struct ino
const struct file_operations proc_tid_children_operations = { .open = children_seq_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; diff --combined fs/proc/task_mmu.c index 4f8ae353a8c5,df2f0f05f5ba..3465973308b7 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@@ -351,7 -351,7 +351,7 @@@ static int pid_maps_open(struct inode *
const struct file_operations proc_pid_maps_operations = { .open = pid_maps_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = proc_map_release, }; @@@ -653,10 -653,6 +653,10 @@@ static void show_smap_vma_flags(struct [ilog2(VM_MERGEABLE)] = "mg", [ilog2(VM_UFFD_MISSING)]= "um", [ilog2(VM_UFFD_WP)] = "uw", +#ifdef CONFIG_ARM64_MTE + [ilog2(VM_MTE)] = "mt", + [ilog2(VM_MTE_ALLOWED)] = "", +#endif #ifdef CONFIG_ARCH_HAS_PKEYS /* These come out via ProtectionKey: */ [ilog2(VM_PKEY_BIT0)] = "", @@@ -937,14 -933,14 +937,14 @@@ static int smaps_rollup_release(struct
const struct file_operations proc_pid_smaps_operations = { .open = pid_smaps_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = proc_map_release, };
const struct file_operations proc_pid_smaps_rollup_operations = { .open = smaps_rollup_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = smaps_rollup_release, }; @@@ -1883,7 -1879,7 +1883,7 @@@ static int pid_numa_maps_open(struct in
const struct file_operations proc_pid_numa_maps_operations = { .open = pid_numa_maps_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = proc_map_release, }; diff --combined fs/ubifs/file.c index b77d1637bbbc,a3af46b39508..fb41c77cae1e --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@@ -222,7 -222,7 +222,7 @@@ static int write_begin_slow(struct addr struct ubifs_info *c = inode->i_sb->s_fs_info; pgoff_t index = pos >> PAGE_SHIFT; struct ubifs_budget_req req = { .new_page = 1 }; - int uninitialized_var(err), appending = !!(pos + len > inode->i_size); + int err, appending = !!(pos + len > inode->i_size); struct page *page;
dbg_gen("ino %lu, pos %llu, len %u, i_size %lld", @@@ -426,7 -426,7 +426,7 @@@ static int ubifs_write_begin(struct fil struct ubifs_info *c = inode->i_sb->s_fs_info; struct ubifs_inode *ui = ubifs_inode(inode); pgoff_t index = pos >> PAGE_SHIFT; - int uninitialized_var(err), appending = !!(pos + len > inode->i_size); + int err, appending = !!(pos + len > inode->i_size); int skipped_read = 0; struct page *page;
@@@ -1668,7 -1668,6 +1668,6 @@@ const struct file_operations ubifs_file .mmap = ubifs_file_mmap, .fsync = ubifs_fsync, .unlocked_ioctl = ubifs_ioctl, - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .open = fscrypt_file_open, #ifdef CONFIG_COMPAT diff --combined fs/xfs/xfs_file.c index 781f72b06af0,964bc733e765..36ba167f0e80 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@@ -94,7 -94,6 +94,7 @@@ xfs_file_fsync { struct inode *inode = file->f_mapping->host; struct xfs_inode *ip = XFS_I(inode); + struct xfs_inode_log_item *iip = ip->i_itemp; struct xfs_mount *mp = ip->i_mount; int error = 0; int log_flushed = 0; @@@ -138,15 -137,13 +138,15 @@@ xfs_ilock(ip, XFS_ILOCK_SHARED); if (xfs_ipincount(ip)) { if (!datasync || - (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) - lsn = ip->i_itemp->ili_last_lsn; + (iip->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) + lsn = iip->ili_last_lsn; }
if (lsn) { error = xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, &log_flushed); - ip->i_itemp->ili_fsync_fields = 0; + spin_lock(&iip->ili_lock); + iip->ili_fsync_fields = 0; + spin_unlock(&iip->ili_lock); } xfs_iunlock(ip, XFS_ILOCK_SHARED);
@@@ -172,8 -169,6 +172,8 @@@ xfs_file_dio_aio_read struct xfs_inode *ip = XFS_I(file_inode(iocb->ki_filp)); size_t count = iov_iter_count(to); ssize_t ret; + unsigned int flags = 0; +
trace_xfs_file_direct_read(ip, count, iocb->ki_pos);
@@@ -188,11 -183,8 +188,11 @@@ } else { xfs_ilock(ip, XFS_IOLOCK_SHARED); } - ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL, - is_sync_kiocb(iocb)); + + if (is_sync_kiocb(iocb)) + flags |= IOMAP_DIO_RWF_SYNCIO; + + ret = iomap_dio_rw(iocb, to, &xfs_read_iomap_ops, NULL, flags); xfs_iunlock(ip, XFS_IOLOCK_SHARED);
return ret; @@@ -491,7 -483,6 +491,7 @@@ xfs_file_dio_aio_write int iolock; size_t count = iov_iter_count(from); struct xfs_buftarg *target = xfs_inode_buftarg(ip); + unsigned int flags = 0;
/* DIO must be aligned to device logical sector size */ if ((iocb->ki_pos | count) & target->bt_logical_sectormask) @@@ -555,10 -546,9 +555,10 @@@ * If unaligned, this is the only IO in-flight. Wait on it before we * release the iolock to prevent subsequent overlapping IO. */ + if (is_sync_kiocb(iocb) || unaligned_io) + flags |= IOMAP_DIO_RWF_SYNCIO; ret = iomap_dio_rw(iocb, from, &xfs_direct_write_iomap_ops, - &xfs_dio_write_ops, - is_sync_kiocb(iocb) || unaligned_io); + &xfs_dio_write_ops, flags); out: xfs_iunlock(ip, iolock);
@@@ -1045,7 -1035,7 +1045,7 @@@ xfs_file_remap_range /* Prepare and then clone file data. */ ret = xfs_reflink_remap_prep(file_in, pos_in, file_out, pos_out, &len, remap_flags); - if (ret < 0 || len == 0) + if (ret || len == 0) return ret;
trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); @@@ -1075,7 -1065,7 +1075,7 @@@ if (mp->m_flags & XFS_MOUNT_WSYNC) xfs_log_force_inode(dest); out_unlock: - xfs_reflink_remap_unlock(file_in, file_out); + xfs_iunlock2_io_mmap(src, dest); if (ret) trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); return remapped > 0 ? remapped : ret; @@@ -1090,7 -1080,7 +1090,7 @@@ xfs_file_open return -EFBIG; if (XFS_FORCED_SHUTDOWN(XFS_M(inode->i_sb))) return -EIO; - file->f_mode |= FMODE_NOWAIT; + file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; return 0; }
@@@ -1273,23 -1263,10 +1273,23 @@@ xfs_filemap_pfn_mkwrite return __xfs_filemap_fault(vmf, PE_SIZE_PTE, true); }
+static void +xfs_filemap_map_pages( + struct vm_fault *vmf, + pgoff_t start_pgoff, + pgoff_t end_pgoff) +{ + struct inode *inode = file_inode(vmf->vma->vm_file); + + xfs_ilock(XFS_I(inode), XFS_MMAPLOCK_SHARED); + filemap_map_pages(vmf, start_pgoff, end_pgoff); + xfs_iunlock(XFS_I(inode), XFS_MMAPLOCK_SHARED); +} + static const struct vm_operations_struct xfs_file_vm_ops = { .fault = xfs_filemap_fault, .huge_fault = xfs_filemap_huge_fault, - .map_pages = filemap_map_pages, + .map_pages = xfs_filemap_map_pages, .page_mkwrite = xfs_filemap_page_mkwrite, .pfn_mkwrite = xfs_filemap_pfn_mkwrite, }; @@@ -1320,7 -1297,6 +1320,6 @@@ const struct file_operations xfs_file_o .llseek = xfs_file_llseek, .read_iter = xfs_file_read_iter, .write_iter = xfs_file_write_iter, - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .iopoll = iomap_dio_iopoll, .unlocked_ioctl = xfs_file_ioctl, diff --combined fs/zonefs/super.c index 798e2e636887,d9f5fbeb5506..0d59e3fff1a7 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@@ -670,7 -670,6 +670,7 @@@ static ssize_t zonefs_file_dio_write(st bool append = false; size_t count; ssize_t ret; + int flags = 0;
/* * For async direct IOs to sequential zone files, refuse IOCB_NOWAIT @@@ -712,15 -711,11 +712,15 @@@ append = sync; }
- if (append) + if (append) { ret = zonefs_file_dio_append(iocb, from); - else + } else { + if (is_sync_kiocb(iocb)) + flags |= IOMAP_DIO_RWF_SYNCIO; + ret = iomap_dio_rw(iocb, from, &zonefs_iomap_ops, - &zonefs_write_dio_ops, sync); + &zonefs_write_dio_ops, flags); + } if (zi->i_ztype == ZONEFS_ZTYPE_SEQ && (ret > 0 || ret == -EIOCBQUEUED)) { if (ret > 0) @@@ -819,7 -814,6 +819,7 @@@ static ssize_t zonefs_file_read_iter(st struct super_block *sb = inode->i_sb; loff_t isize; ssize_t ret; + int flags = 0;
/* Offline zones cannot be read */ if (unlikely(IS_IMMUTABLE(inode) && !(inode->i_mode & 0777))) @@@ -854,10 -848,8 +854,10 @@@ goto inode_unlock; } file_accessed(iocb->ki_filp); + if (is_sync_kiocb(iocb)) + flags |= IOMAP_DIO_RWF_SYNCIO; ret = iomap_dio_rw(iocb, to, &zonefs_iomap_ops, - &zonefs_read_dio_ops, is_sync_kiocb(iocb)); + &zonefs_read_dio_ops, flags); } else { ret = generic_file_read_iter(iocb, to); if (ret == -EIO) @@@ -877,7 -869,6 +877,6 @@@ static const struct file_operations zon .llseek = zonefs_file_llseek, .read_iter = zonefs_file_read_iter, .write_iter = zonefs_file_write_iter, - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .iopoll = iomap_dio_iopoll, }; diff --combined include/linux/bpf-cgroup.h index 2c6f26670acc,f81d3b3752f9..a4079965c98e --- a/include/linux/bpf-cgroup.h +++ b/include/linux/bpf-cgroup.h @@@ -132,7 -132,7 +132,7 @@@ int __cgroup_bpf_check_dev_permission(s
int __cgroup_bpf_run_filter_sysctl(struct ctl_table_header *head, struct ctl_table *table, int write, - void **buf, size_t *pcount, loff_t *ppos, + char **buf, size_t *pcount, loff_t *ppos, enum bpf_attach_type type);
int __cgroup_bpf_run_filter_setsockopt(struct sock *sock, int *level, @@@ -210,9 -210,6 +210,9 @@@ int bpf_percpu_cgroup_storage_update(st #define BPF_CGROUP_RUN_PROG_INET_SOCK(sk) \ BPF_CGROUP_RUN_SK_PROG(sk, BPF_CGROUP_INET_SOCK_CREATE)
+#define BPF_CGROUP_RUN_PROG_INET_SOCK_RELEASE(sk) \ + BPF_CGROUP_RUN_SK_PROG(sk, BPF_CGROUP_INET_SOCK_RELEASE) + #define BPF_CGROUP_RUN_PROG_INET4_POST_BIND(sk) \ BPF_CGROUP_RUN_SK_PROG(sk, BPF_CGROUP_INET4_POST_BIND)
@@@ -404,7 -401,6 +404,7 @@@ static inline int bpf_percpu_cgroup_sto #define BPF_CGROUP_RUN_PROG_INET_INGRESS(sk,skb) ({ 0; }) #define BPF_CGROUP_RUN_PROG_INET_EGRESS(sk,skb) ({ 0; }) #define BPF_CGROUP_RUN_PROG_INET_SOCK(sk) ({ 0; }) +#define BPF_CGROUP_RUN_PROG_INET_SOCK_RELEASE(sk) ({ 0; }) #define BPF_CGROUP_RUN_PROG_INET4_BIND(sk, uaddr) ({ 0; }) #define BPF_CGROUP_RUN_PROG_INET6_BIND(sk, uaddr) ({ 0; }) #define BPF_CGROUP_RUN_PROG_INET4_POST_BIND(sk) ({ 0; }) diff --combined include/linux/fs.h index a771d4f2e41d,7680752cff24..166ae3eafb58 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@@ -39,7 -39,6 +39,7 @@@ #include <linux/fs_types.h> #include <linux/build_bug.h> #include <linux/stddef.h> +#include <linux/watch_queue.h>
#include <asm/byteorder.h> #include <uapi/linux/fs.h> @@@ -69,7 -68,6 +69,7 @@@ struct fsverity_info struct fsverity_operations; struct fs_context; struct fs_parameter_spec; +struct fsinfo_context;
extern void __init inode_init(void); extern void __init inode_init_early(void); @@@ -177,9 -175,6 +177,9 @@@ typedef int (dio_iodone_t)(struct kioc /* File does not contribute to nr_files count */ #define FMODE_NOACCOUNT ((__force fmode_t)0x20000000)
+/* File supports async buffered reads */ +#define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000) + /* * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector * that indicates that they should check the contents of the iovec are @@@ -320,8 -315,6 +320,8 @@@ enum rw_hint #define IOCB_SYNC (1 << 5) #define IOCB_WRITE (1 << 6) #define IOCB_NOWAIT (1 << 7) +/* iocb->ki_waitq is valid */ +#define IOCB_WAITQ (1 << 8) #define IOCB_NOIO (1 << 9)
struct kiocb { @@@ -336,10 -329,7 +336,10 @@@ int ki_flags; u16 ki_hint; u16 ki_ioprio; /* See linux/ioprio.h */ - unsigned int ki_cookie; /* for ->iopoll */ + union { + unsigned int ki_cookie; /* for ->iopoll */ + struct wait_page_queue *ki_waitq; /* for async buffered IO */ + };
randomized_struct_fields_end }; @@@ -481,6 -471,45 +481,6 @@@ struct address_space * must be enforced here for CRIS, to let the least significant bit * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. */ -struct request_queue; - -struct block_device { - dev_t bd_dev; /* not a kdev_t - it's a search key */ - int bd_openers; - struct inode * bd_inode; /* will die */ - struct super_block * bd_super; - struct mutex bd_mutex; /* open/close mutex */ - void * bd_claiming; - void * bd_holder; - int bd_holders; - bool bd_write_holder; -#ifdef CONFIG_SYSFS - struct list_head bd_holder_disks; -#endif - struct block_device * bd_contains; - unsigned bd_block_size; - u8 bd_partno; - struct hd_struct * bd_part; - /* number of times partitions within this device have been opened. */ - unsigned bd_part_count; - int bd_invalidated; - struct gendisk * bd_disk; - struct request_queue * bd_queue; - struct backing_dev_info *bd_bdi; - struct list_head bd_list; - /* - * Private data. You must have bd_claim'ed the block_device - * to use this. NOTE: bd_claim allows an owner to claim - * the same device multiple times, the owner must take special - * care to not mess up bd_private for that case. - */ - unsigned long bd_private; - - /* The counter of freeze processes */ - int bd_fsfreeze_count; - /* Mutex for freeze */ - struct mutex bd_fsfreeze_mutex; -} __randomize_layout;
/* XArray tags, for tagging dirty and writeback pages in the pagecache. */ #define PAGECACHE_TAG_DIRTY XA_MARK_0 @@@ -879,6 -908,8 +879,6 @@@ static inline unsigned imajor(const str return MAJOR(inode->i_rdev); }
-extern struct block_device *I_BDEV(struct inode *inode); - struct fown_struct { rwlock_t lock; /* protects pid, uid, euid fields */ struct pid *pid; /* pid or -pgrp where SIGIO should be sent */ @@@ -1350,7 -1381,6 +1350,7 @@@ extern int send_sigurg(struct fown_stru #define SB_NODIRATIME 2048 /* Do not update directory access times */ #define SB_SILENT 32768 #define SB_POSIXACL (1<<16) /* VFS does not apply the umask */ +#define SB_INLINECRYPT (1<<17) /* Use blk-crypto for encrypted files */ #define SB_KERNMOUNT (1<<22) /* this is a kern_mount call */ #define SB_I_VERSION (1<<23) /* Update inode I_version field */ #define SB_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ @@@ -1534,15 -1564,6 +1534,15 @@@ struct super_block
spinlock_t s_inode_wblist_lock; struct list_head s_inodes_wb; /* writeback inodes */ + + /* Superblock event notifications */ + u64 s_unique_id; + +#ifdef CONFIG_SB_NOTIFICATIONS + struct watch_list *s_watchers; +#endif + atomic_t s_change_counter; /* Count of config change notifications */ + atomic_t s_notify_counter; /* Count of other notifications */ } __randomize_layout;
/* Helper functions so that in most cases filesystems will @@@ -1754,6 -1775,14 +1754,6 @@@ struct dir_context loff_t pos; };
-struct block_device_operations; - -/* These macros are for out of kernel modules to test that - * the kernel supports the unlocked_ioctl and compat_ioctl - * fields in struct file_operations. */ -#define HAVE_COMPAT_IOCTL 1 -#define HAVE_UNLOCKED_IOCTL 1 - /* * These flags let !MMU mmap() govern direct device mapping vs immediate * copying more easily for MAP_PRIVATE, especially for ROM filesystems. @@@ -1891,8 -1920,6 +1891,6 @@@ ssize_t rw_copy_check_uvector(int type
extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); - extern ssize_t vfs_readv(struct file *, const struct iovec __user *, - unsigned long, loff_t *, rwf_t); extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); extern ssize_t generic_copy_file_range(struct file *file_in, loff_t pos_in, @@@ -1931,9 -1958,6 +1929,9 @@@ struct super_operations int (*thaw_super) (struct super_block *); int (*unfreeze_fs) (struct super_block *); int (*statfs) (struct dentry *, struct kstatfs *); +#ifdef CONFIG_FSINFO + int (*fsinfo)(struct path *, struct fsinfo_context *); +#endif int (*remount_fs) (struct super_block *, int *, char *); void (*umount_begin) (struct super_block *);
@@@ -2132,10 -2156,6 +2130,10 @@@ static inline void kiocb_clone(struct k * * I_DONTCACHE Evict inode as soon as it is not used anymore. * + * I_SYNC_QUEUED Inode is queued in b_io or b_more_io writeback lists. + * Used to detect that mark_inode_dirty() should not move + * inode between dirty lists. + * * Q: What is the difference between I_WILL_FREE and I_FREEING? */ #define I_DIRTY_SYNC (1 << 0) @@@ -2153,11 -2173,12 +2151,11 @@@ #define I_DIO_WAKEUP (1 << __I_DIO_WAKEUP) #define I_LINKABLE (1 << 10) #define I_DIRTY_TIME (1 << 11) -#define __I_DIRTY_TIME_EXPIRED 12 -#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) #define I_WB_SWITCH (1 << 13) #define I_OVL_INUSE (1 << 14) #define I_CREATING (1 << 15) #define I_DONTCACHE (1 << 16) +#define I_SYNC_QUEUED (1 << 17)
#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC) #define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES) @@@ -2241,9 -2262,18 +2239,9 @@@ struct file_system_type
#define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME)
-#ifdef CONFIG_BLOCK extern struct dentry *mount_bdev(struct file_system_type *fs_type, int flags, const char *dev_name, void *data, int (*fill_super)(struct super_block *, void *, int)); -#else -static inline struct dentry *mount_bdev(struct file_system_type *fs_type, - int flags, const char *dev_name, void *data, - int (*fill_super)(struct super_block *, void *, int)) -{ - return ERR_PTR(-ENODEV); -} -#endif extern struct dentry *mount_single(struct file_system_type *fs_type, int flags, void *data, int (*fill_super)(struct super_block *, void *, int)); @@@ -2252,7 -2282,14 +2250,7 @@@ extern struct dentry *mount_nodev(struc int (*fill_super)(struct super_block *, void *, int)); extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path); void generic_shutdown_super(struct super_block *sb); -#ifdef CONFIG_BLOCK void kill_block_super(struct super_block *sb); -#else -static inline void kill_block_super(struct super_block *sb) -{ - BUG(); -} -#endif void kill_anon_super(struct super_block *sb); void kill_litter_super(struct super_block *sb); void deactivate_super(struct super_block *sb); @@@ -2542,16 -2579,93 +2540,16 @@@ extern struct kmem_cache *names_cachep #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) #define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
-#ifdef CONFIG_BLOCK -extern int register_blkdev(unsigned int, const char *); -extern void unregister_blkdev(unsigned int, const char *); -extern struct block_device *bdget(dev_t); -extern struct block_device *bdgrab(struct block_device *bdev); -extern void bd_set_size(struct block_device *, loff_t size); -extern void bd_forget(struct inode *inode); -extern void bdput(struct block_device *); -extern void invalidate_bdev(struct block_device *); -extern void iterate_bdevs(void (*)(struct block_device *, void *), void *); -extern int sync_blockdev(struct block_device *bdev); -extern struct super_block *freeze_bdev(struct block_device *); -extern void emergency_thaw_all(void); -extern void emergency_thaw_bdev(struct super_block *sb); -extern int thaw_bdev(struct block_device *bdev, struct super_block *sb); -extern int fsync_bdev(struct block_device *); - extern struct super_block *blockdev_superblock; - static inline bool sb_is_blkdev_sb(struct super_block *sb) { - return sb == blockdev_superblock; -} -#else -static inline void bd_forget(struct inode *inode) {} -static inline int sync_blockdev(struct block_device *bdev) { return 0; } -static inline void invalidate_bdev(struct block_device *bdev) {} - -static inline struct super_block *freeze_bdev(struct block_device *sb) -{ - return NULL; -} - -static inline int thaw_bdev(struct block_device *bdev, struct super_block *sb) -{ - return 0; -} - -static inline int emergency_thaw_bdev(struct super_block *sb) -{ - return 0; -} - -static inline void iterate_bdevs(void (*f)(struct block_device *, void *), void *arg) -{ + return IS_ENABLED(CONFIG_BLOCK) && sb == blockdev_superblock; }
-static inline bool sb_is_blkdev_sb(struct super_block *sb) -{ - return false; -} -#endif +void emergency_thaw_all(void); extern int sync_filesystem(struct super_block *); extern const struct file_operations def_blk_fops; extern const struct file_operations def_chr_fops; -#ifdef CONFIG_BLOCK -extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); -extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); -extern int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder); -extern struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, - void *holder); -extern struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, - void *holder); -extern struct block_device *bd_start_claiming(struct block_device *bdev, - void *holder); -extern void bd_finish_claiming(struct block_device *bdev, - struct block_device *whole, void *holder); -extern void bd_abort_claiming(struct block_device *bdev, - struct block_device *whole, void *holder); -extern void blkdev_put(struct block_device *bdev, fmode_t mode); - -#ifdef CONFIG_SYSFS -extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk); -extern void bd_unlink_disk_holder(struct block_device *bdev, - struct gendisk *disk); -#else -static inline int bd_link_disk_holder(struct block_device *bdev, - struct gendisk *disk) -{ - return 0; -} -static inline void bd_unlink_disk_holder(struct block_device *bdev, - struct gendisk *disk) -{ -} -#endif -#endif
/* fs/char_dev.c */ #define CHRDEV_MAJOR_MAX 512 @@@ -2582,12 -2696,31 +2580,12 @@@ static inline void unregister_chrdev(un __unregister_chrdev(major, 0, 256, name); }
-/* fs/block_dev.c */ -#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ -#define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */ - -#ifdef CONFIG_BLOCK -#define BLKDEV_MAJOR_MAX 512 -extern const char *bdevname(struct block_device *bdev, char *buffer); -extern struct block_device *lookup_bdev(const char *); -extern void blkdev_show(struct seq_file *,off_t); - -#else -#define BLKDEV_MAJOR_MAX 0 -#endif - extern void init_special_inode(struct inode *, umode_t, dev_t);
/* Invalid inode operations -- fs/bad_inode.c */ extern void make_bad_inode(struct inode *); extern bool is_bad_inode(struct inode *);
-#ifdef CONFIG_BLOCK -extern int revalidate_disk(struct gendisk *); -extern int check_disk_change(struct block_device *); -extern int __invalidate_device(struct block_device *, bool); -#endif unsigned long invalidate_mapping_pages(struct address_space *mapping, pgoff_t start, pgoff_t end);
@@@ -2692,7 -2825,7 +2690,7 @@@ static inline errseq_t filemap_sample_w
/** * file_sample_sb_err - sample the current errseq_t to test for later errors - * @mapping: mapping to be sampled + * @file: file pointer to be sampled * * Grab the most current superblock-level errseq_t value for the given * struct file. @@@ -2988,6 -3121,10 +2986,6 @@@ static inline void remove_inode_hash(st
extern void inode_sb_list_add(struct inode *inode);
-#ifdef CONFIG_BLOCK -extern int bdev_read_only(struct block_device *); -#endif -extern int set_blocksize(struct block_device *, int); extern int sb_set_blocksize(struct super_block *, int); extern int sb_min_blocksize(struct super_block *, int);
@@@ -3525,56 -3662,4 +3523,56 @@@ static inline int inode_drain_writes(st return filemap_write_and_wait(inode->i_mapping); }
+extern void __notify_sb(struct super_block *s, + enum superblock_notification_type subtype, + u32 info); +extern void __notify_sb_error(struct super_block *s, int error); +extern void __notify_sb_EQDUOT(struct super_block *s); + +/** + * notify_sb: Post simple superblock notification. + * @s: The superblock the notification is about. + * @subtype: The type of notification. + * @info: WATCH_INFO_FLAG_* flags to be set in the record. + */ +static inline void notify_sb(struct super_block *s, + enum superblock_notification_type subtype, + u32 info) +{ +#ifdef CONFIG_SB_NOTIFICATIONS + atomic_inc(&s->s_change_counter); + if (unlikely(READ_ONCE(s->s_watchers))) + __notify_sb(s, subtype, info); +#endif +} + +/** + * notify_sb_error: Post superblock error notification. + * @s: The superblock the notification is about. + * @error: The error number to be recorded. + */ +static inline int notify_sb_error(struct super_block *s, int error) +{ +#ifdef CONFIG_SB_NOTIFICATIONS + atomic_inc(&s->s_notify_counter); + if (unlikely(READ_ONCE(s->s_watchers))) + __notify_sb_error(s, error); +#endif + return error; +} + +/** + * notify_sb_EDQUOT: Post superblock quota overrun notification. + * @s: The superblock the notification is about. + */ +static inline int notify_sb_EQDUOT(struct super_block *s) +{ +#ifdef CONFIG_SB_NOTIFICATIONS + atomic_inc(&s->s_notify_counter); + if (unlikely(READ_ONCE(s->s_watchers))) + __notify_sb_EQDUOT(s); +#endif + return -EDQUOT; +} + #endif /* _LINUX_FS_H */ diff --combined kernel/kallsyms.c index 95cb74f73292,1c46a1f2e9f9..ad0646efe554 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@@ -24,7 -24,6 +24,7 @@@ #include <linux/slab.h> #include <linux/filter.h> #include <linux/ftrace.h> +#include <linux/kprobes.h> #include <linux/compiler.h>
/* @@@ -438,7 -437,6 +438,7 @@@ struct kallsym_iter loff_t pos_arch_end; loff_t pos_mod_end; loff_t pos_ftrace_mod_end; + loff_t pos_bpf_end; unsigned long value; unsigned int nameoff; /* If iterating in core kernel symbols. */ char type; @@@ -482,11 -480,6 +482,11 @@@ static int get_ksymbol_mod(struct kalls return 1; }
+/* + * ftrace_mod_get_kallsym() may also get symbols for pages allocated for ftrace + * purposes. In that case "__builtin__ftrace" is used as a module name, even + * though "__builtin__ftrace" is not a module. + */ static int get_ksymbol_ftrace_mod(struct kallsym_iter *iter) { int ret = ftrace_mod_get_kallsym(iter->pos - iter->pos_mod_end, @@@ -503,33 -496,11 +503,33 @@@
static int get_ksymbol_bpf(struct kallsym_iter *iter) { + int ret; + strlcpy(iter->module_name, "bpf", MODULE_NAME_LEN); iter->exported = 0; - return bpf_get_kallsym(iter->pos - iter->pos_ftrace_mod_end, - &iter->value, &iter->type, - iter->name) < 0 ? 0 : 1; + ret = bpf_get_kallsym(iter->pos - iter->pos_ftrace_mod_end, + &iter->value, &iter->type, + iter->name); + if (ret < 0) { + iter->pos_bpf_end = iter->pos; + return 0; + } + + return 1; +} + +/* + * This uses "__builtin__kprobes" as a module name for symbols for pages + * allocated for kprobes' purposes, even though "__builtin__kprobes" is not a + * module. + */ +static int get_ksymbol_kprobe(struct kallsym_iter *iter) +{ + strlcpy(iter->module_name, "__builtin__kprobes", MODULE_NAME_LEN); + iter->exported = 0; + return kprobe_get_kallsym(iter->pos - iter->pos_bpf_end, + &iter->value, &iter->type, + iter->name) < 0 ? 0 : 1; }
/* Returns space to next name. */ @@@ -556,7 -527,6 +556,7 @@@ static void reset_iter(struct kallsym_i iter->pos_arch_end = 0; iter->pos_mod_end = 0; iter->pos_ftrace_mod_end = 0; + iter->pos_bpf_end = 0; } }
@@@ -581,11 -551,7 +581,11 @@@ static int update_iter_mod(struct kalls get_ksymbol_ftrace_mod(iter)) return 1;
- return get_ksymbol_bpf(iter); + if ((!iter->pos_bpf_end || iter->pos_bpf_end > pos) && + get_ksymbol_bpf(iter)) + return 1; + + return get_ksymbol_kprobe(iter); }
/* Returns false if pos at or past end of file. */ @@@ -738,7 -704,7 +738,7 @@@ const char *kdb_walk_kallsyms(loff_t *p
static const struct proc_ops kallsyms_proc_ops = { .proc_open = kallsyms_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = seq_release_private, }; diff --combined kernel/sched/psi.c index 967732c0766c,6795170140a0..4c084d66746a --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@@ -190,6 -190,7 +190,6 @@@ static void group_init(struct psi_grou INIT_DELAYED_WORK(&group->avgs_work, psi_avgs_work); mutex_init(&group->avgs_lock); /* Init trigger-related members */ - atomic_set(&group->poll_scheduled, 0); mutex_init(&group->trigger_lock); INIT_LIST_HEAD(&group->triggers); memset(group->nr_triggers, 0, sizeof(group->nr_triggers)); @@@ -198,7 -199,7 +198,7 @@@ memset(group->polling_total, 0, sizeof(group->polling_total)); group->polling_next_update = ULLONG_MAX; group->polling_until = 0; - rcu_assign_pointer(group->poll_kworker, NULL); + rcu_assign_pointer(group->poll_task, NULL); }
void __init psi_init(void) @@@ -546,38 -547,47 +546,38 @@@ static u64 update_triggers(struct psi_g return now + group->poll_min_period; }
-/* - * Schedule polling if it's not already scheduled. It's safe to call even from - * hotpath because even though kthread_queue_delayed_work takes worker->lock - * spinlock that spinlock is never contended due to poll_scheduled atomic - * preventing such competition. - */ +/* Schedule polling if it's not already scheduled. */ static void psi_schedule_poll_work(struct psi_group *group, unsigned long delay) { - struct kthread_worker *kworker; + struct task_struct *task;
- /* Do not reschedule if already scheduled */ - if (atomic_cmpxchg(&group->poll_scheduled, 0, 1) != 0) + /* + * Do not reschedule if already scheduled. + * Possible race with a timer scheduled after this check but before + * mod_timer below can be tolerated because group->polling_next_update + * will keep updates on schedule. + */ + if (timer_pending(&group->poll_timer)) return;
rcu_read_lock();
- kworker = rcu_dereference(group->poll_kworker); + task = rcu_dereference(group->poll_task); /* * kworker might be NULL in case psi_trigger_destroy races with * psi_task_change (hotpath) which can't use locks */ - if (likely(kworker)) - kthread_queue_delayed_work(kworker, &group->poll_work, delay); - else - atomic_set(&group->poll_scheduled, 0); + if (likely(task)) + mod_timer(&group->poll_timer, jiffies + delay);
rcu_read_unlock(); }
-static void psi_poll_work(struct kthread_work *work) +static void psi_poll_work(struct psi_group *group) { - struct kthread_delayed_work *dwork; - struct psi_group *group; u32 changed_states; u64 now;
- dwork = container_of(work, struct kthread_delayed_work, work); - group = container_of(dwork, struct psi_group, poll_work); - - atomic_set(&group->poll_scheduled, 0); - mutex_lock(&group->trigger_lock);
now = sched_clock(); @@@ -613,32 -623,6 +613,32 @@@ out mutex_unlock(&group->trigger_lock); }
+static int psi_poll_worker(void *data) +{ + struct psi_group *group = (struct psi_group *)data; + + sched_set_fifo_low(current); + + while (true) { + wait_event_interruptible(group->poll_wait, + atomic_cmpxchg(&group->poll_wakeup, 1, 0) || + kthread_should_stop()); + if (kthread_should_stop()) + break; + + psi_poll_work(group); + } + return 0; +} + +static void poll_timer_fn(struct timer_list *t) +{ + struct psi_group *group = from_timer(group, t, poll_timer); + + atomic_set(&group->poll_wakeup, 1); + wake_up_interruptible(&group->poll_wait); +} + static void record_times(struct psi_group_cpu *groupc, int cpu, bool memstall_tick) { @@@ -1115,20 -1099,22 +1115,20 @@@ struct psi_trigger *psi_trigger_create(
mutex_lock(&group->trigger_lock);
- if (!rcu_access_pointer(group->poll_kworker)) { - struct sched_param param = { - .sched_priority = 1, - }; - struct kthread_worker *kworker; + if (!rcu_access_pointer(group->poll_task)) { + struct task_struct *task;
- kworker = kthread_create_worker(0, "psimon"); - if (IS_ERR(kworker)) { + task = kthread_create(psi_poll_worker, group, "psimon"); + if (IS_ERR(task)) { kfree(t); mutex_unlock(&group->trigger_lock); - return ERR_CAST(kworker); + return ERR_CAST(task); } - sched_setscheduler_nocheck(kworker->task, SCHED_FIFO, ¶m); - kthread_init_delayed_work(&group->poll_work, - psi_poll_work); - rcu_assign_pointer(group->poll_kworker, kworker); + atomic_set(&group->poll_wakeup, 0); + init_waitqueue_head(&group->poll_wait); + wake_up_process(task); + timer_setup(&group->poll_timer, poll_timer_fn, 0); + rcu_assign_pointer(group->poll_task, task); }
list_add(&t->node, &group->triggers); @@@ -1146,7 -1132,7 +1146,7 @@@ static void psi_trigger_destroy(struct { struct psi_trigger *t = container_of(ref, struct psi_trigger, refcount); struct psi_group *group = t->group; - struct kthread_worker *kworker_to_destroy = NULL; + struct task_struct *task_to_destroy = NULL;
if (static_branch_likely(&psi_disabled)) return; @@@ -1172,13 -1158,13 +1172,13 @@@ period = min(period, div_u64(tmp->win.size, UPDATES_PER_WINDOW)); group->poll_min_period = period; - /* Destroy poll_kworker when the last trigger is destroyed */ + /* Destroy poll_task when the last trigger is destroyed */ if (group->poll_states == 0) { group->polling_until = 0; - kworker_to_destroy = rcu_dereference_protected( - group->poll_kworker, + task_to_destroy = rcu_dereference_protected( + group->poll_task, lockdep_is_held(&group->trigger_lock)); - rcu_assign_pointer(group->poll_kworker, NULL); + rcu_assign_pointer(group->poll_task, NULL); } }
@@@ -1186,23 -1172,25 +1186,23 @@@
/* * Wait for both *trigger_ptr from psi_trigger_replace and - * poll_kworker RCUs to complete their read-side critical sections - * before destroying the trigger and optionally the poll_kworker + * poll_task RCUs to complete their read-side critical sections + * before destroying the trigger and optionally the poll_task */ synchronize_rcu(); /* * Destroy the kworker after releasing trigger_lock to prevent a * deadlock while waiting for psi_poll_work to acquire trigger_lock */ - if (kworker_to_destroy) { + if (task_to_destroy) { /* * After the RCU grace period has expired, the worker - * can no longer be found through group->poll_kworker. + * can no longer be found through group->poll_task. * But it might have been already scheduled before * that - deschedule it cleanly before destroying it. */ - kthread_cancel_delayed_work_sync(&group->poll_work); - atomic_set(&group->poll_scheduled, 0); - - kthread_destroy_worker(kworker_to_destroy); + del_timer_sync(&group->poll_timer); + kthread_stop(task_to_destroy); } kfree(t); } @@@ -1317,7 -1305,7 +1317,7 @@@ static int psi_fop_release(struct inod
static const struct proc_ops psi_io_proc_ops = { .proc_open = psi_io_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_write = psi_io_write, .proc_poll = psi_fop_poll, @@@ -1326,7 -1314,7 +1326,7 @@@
static const struct proc_ops psi_memory_proc_ops = { .proc_open = psi_memory_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_write = psi_memory_write, .proc_poll = psi_fop_poll, @@@ -1335,7 -1323,7 +1335,7 @@@
static const struct proc_ops psi_cpu_proc_ops = { .proc_open = psi_cpu_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_write = psi_cpu_write, .proc_poll = psi_fop_poll, diff --combined kernel/trace/ftrace.c index 62e9b93d5fee,6a645f2ebf47..a3093a84bae3 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@@ -2388,14 -2388,6 +2388,14 @@@ struct ftrace_ops direct_ops = .flags = FTRACE_OPS_FL_IPMODIFY | FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_DIRECT | FTRACE_OPS_FL_SAVE_REGS | FTRACE_OPS_FL_PERMANENT, + /* + * By declaring the main trampoline as this trampoline + * it will never have one allocated for it. Allocated + * trampolines should not call direct functions. + * The direct_ops should only be called by the builtin + * ftrace_regs_caller trampoline. + */ + .trampoline = FTRACE_REGS_ADDR, }; #endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */
@@@ -2772,50 -2764,6 +2772,50 @@@ void __weak arch_ftrace_trampoline_free { }
+/* List of trace_ops that have allocated trampolines */ +static LIST_HEAD(ftrace_ops_trampoline_list); + +static void ftrace_add_trampoline_to_kallsyms(struct ftrace_ops *ops) +{ + lockdep_assert_held(&ftrace_lock); + list_add_rcu(&ops->list, &ftrace_ops_trampoline_list); +} + +static void ftrace_remove_trampoline_from_kallsyms(struct ftrace_ops *ops) +{ + lockdep_assert_held(&ftrace_lock); + list_del_rcu(&ops->list); +} + +/* + * "__builtin__ftrace" is used as a module name in /proc/kallsyms for symbols + * for pages allocated for ftrace purposes, even though "__builtin__ftrace" is + * not a module. + */ +#define FTRACE_TRAMPOLINE_MOD "__builtin__ftrace" +#define FTRACE_TRAMPOLINE_SYM "ftrace_trampoline" + +static void ftrace_trampoline_free(struct ftrace_ops *ops) +{ + if (ops && (ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP) && + ops->trampoline) { + /* + * Record the text poke event before the ksymbol unregister + * event. + */ + perf_event_text_poke((void *)ops->trampoline, + (void *)ops->trampoline, + ops->trampoline_size, NULL, 0); + perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_OOL, + ops->trampoline, ops->trampoline_size, + true, FTRACE_TRAMPOLINE_SYM); + /* Remove from kallsyms after the perf events */ + ftrace_remove_trampoline_from_kallsyms(ops); + } + + arch_ftrace_trampoline_free(ops); +} + static void ftrace_startup_enable(int command) { if (saved_ftrace_func != ftrace_trace_function) { @@@ -2986,7 -2934,7 +2986,7 @@@ int ftrace_shutdown(struct ftrace_ops * synchronize_rcu_tasks();
free_ops: - arch_ftrace_trampoline_free(ops); + ftrace_trampoline_free(ops); }
return 0; @@@ -5613,21 -5561,21 +5613,21 @@@ int ftrace_regex_release(struct inode *
static const struct file_operations ftrace_avail_fops = { .open = ftrace_avail_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private, };
static const struct file_operations ftrace_enabled_fops = { .open = ftrace_enabled_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release_private, };
static const struct file_operations ftrace_filter_fops = { .open = ftrace_filter_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = ftrace_filter_write, .llseek = tracing_lseek, .release = ftrace_regex_release, @@@ -5635,7 -5583,7 +5635,7 @@@
static const struct file_operations ftrace_notrace_fops = { .open = ftrace_notrace_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = ftrace_notrace_write, .llseek = tracing_lseek, .release = ftrace_regex_release, @@@ -6033,7 -5981,7 +6033,7 @@@ ftrace_graph_write(struct file *file, c
static const struct file_operations ftrace_graph_fops = { .open = ftrace_graph_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = ftrace_graph_write, .llseek = tracing_lseek, .release = ftrace_graph_release, @@@ -6041,7 -5989,7 +6041,7 @@@
static const struct file_operations ftrace_graph_notrace_fops = { .open = ftrace_graph_notrace_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = ftrace_graph_write, .llseek = tracing_lseek, .release = ftrace_graph_release, @@@ -6230,27 -6178,6 +6230,27 @@@ struct ftrace_mod_map unsigned int num_funcs; };
+static int ftrace_get_trampoline_kallsym(unsigned int symnum, + unsigned long *value, char *type, + char *name, char *module_name, + int *exported) +{ + struct ftrace_ops *op; + + list_for_each_entry_rcu(op, &ftrace_ops_trampoline_list, list) { + if (!op->trampoline || symnum--) + continue; + *value = op->trampoline; + *type = 't'; + strlcpy(name, FTRACE_TRAMPOLINE_SYM, KSYM_NAME_LEN); + strlcpy(module_name, FTRACE_TRAMPOLINE_MOD, MODULE_NAME_LEN); + *exported = 0; + return 0; + } + + return -ERANGE; +} + #ifdef CONFIG_MODULES
#define next_to_ftrace_page(p) container_of(p, struct ftrace_page, next) @@@ -6587,7 -6514,6 +6587,7 @@@ int ftrace_mod_get_kallsym(unsigned in { struct ftrace_mod_map *mod_map; struct ftrace_mod_func *mod_func; + int ret;
preempt_disable(); list_for_each_entry_rcu(mod_map, &ftrace_mod_maps, list) { @@@ -6614,10 -6540,8 +6614,10 @@@ WARN_ON(1); break; } + ret = ftrace_get_trampoline_kallsym(symnum, value, type, name, + module_name, exported); preempt_enable(); - return -ERANGE; + return ret; }
#else @@@ -6629,18 -6553,6 +6629,18 @@@ allocate_ftrace_mod_map(struct module * { return NULL; } +int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value, + char *type, char *name, char *module_name, + int *exported) +{ + int ret; + + preempt_disable(); + ret = ftrace_get_trampoline_kallsym(symnum, value, type, name, + module_name, exported); + preempt_enable(); + return ret; +} #endif /* CONFIG_MODULES */
struct ftrace_init_func { @@@ -6821,24 -6733,7 +6821,24 @@@ void __weak arch_ftrace_update_trampoli
static void ftrace_update_trampoline(struct ftrace_ops *ops) { + unsigned long trampoline = ops->trampoline; + arch_ftrace_update_trampoline(ops); + if (ops->trampoline && ops->trampoline != trampoline && + (ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP)) { + /* Add to kallsyms before the perf events */ + ftrace_add_trampoline_to_kallsyms(ops); + perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_OOL, + ops->trampoline, ops->trampoline_size, false, + FTRACE_TRAMPOLINE_SYM); + /* + * Record the perf text poke event after the ksymbol register + * event. + */ + perf_event_text_poke((void *)ops->trampoline, NULL, 0, + (void *)ops->trampoline, + ops->trampoline_size); + } }
void ftrace_init_trace_array(struct trace_array *tr) @@@ -7411,7 -7306,7 +7411,7 @@@ ftrace_pid_release(struct inode *inode static const struct file_operations ftrace_pid_fops = { .open = ftrace_pid_open, .write = ftrace_pid_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = tracing_lseek, .release = ftrace_pid_release, }; @@@ -7419,7 -7314,7 +7419,7 @@@ static const struct file_operations ftrace_no_pid_fops = { .open = ftrace_no_pid_open, .write = ftrace_no_pid_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = tracing_lseek, .release = ftrace_pid_release, }; diff --combined kernel/trace/trace.c index 4aab712f9567,36dbb58680fc..5aa5c01e2fed --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@@ -2003,6 -2003,7 +2003,6 @@@ static void tracing_reset_cpu(struct ar void tracing_reset_online_cpus(struct array_buffer *buf) { struct trace_buffer *buffer = buf->buffer; - int cpu;
if (!buffer) return; @@@ -2014,7 -2015,8 +2014,7 @@@
buf->time_start = buffer_ftrace_now(buf, buf->cpu);
- for_each_online_cpu(cpu) - ring_buffer_reset_cpu(buffer, cpu); + ring_buffer_reset_online_cpus(buffer);
ring_buffer_record_enable(buffer); } @@@ -3344,16 -3346,12 +3344,16 @@@ int trace_array_printk(struct trace_arr int ret; va_list ap;
- if (!(global_trace.trace_flags & TRACE_ITER_PRINTK)) - return 0; - if (!tr) return -ENOENT;
+ /* This is only allowed for created instances */ + if (tr == &global_trace) + return 0; + + if (!(tr->trace_flags & TRACE_ITER_PRINTK)) + return 0; + va_start(ap, fmt); ret = trace_array_vprintk(tr, ip, fmt, ap); va_end(ap); @@@ -4613,7 -4611,7 +4613,7 @@@ loff_t tracing_lseek(struct file *file
static const struct file_operations tracing_fops = { .open = tracing_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = tracing_write_stub, .llseek = tracing_lseek, .release = tracing_release, @@@ -4621,7 -4619,7 +4621,7 @@@
static const struct file_operations show_traces_fops = { .open = show_traces_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = show_traces_release, }; @@@ -4959,7 -4957,7 +4959,7 @@@ static int tracing_trace_options_open(s
static const struct file_operations tracing_iter_fops = { .open = tracing_trace_options_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = tracing_single_release_tr, .write = tracing_trace_options_write, @@@ -5299,7 -5297,7 +5299,7 @@@ static int tracing_saved_tgids_open(str
static const struct file_operations tracing_saved_tgids_fops = { .open = tracing_saved_tgids_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -5378,7 -5376,7 +5378,7 @@@ static int tracing_saved_cmdlines_open(
static const struct file_operations tracing_saved_cmdlines_fops = { .open = tracing_saved_cmdlines_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -5544,7 -5542,7 +5544,7 @@@ static int tracing_eval_map_open(struc
static const struct file_operations tracing_eval_map_fops = { .open = tracing_eval_map_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = seq_release, }; @@@ -5889,7 -5887,7 +5889,7 @@@ int tracing_set_tracer(struct trace_arr }
/* If trace pipe files are being read, we can't change the tracer */ - if (tr->current_trace->ref) { + if (tr->trace_ref) { ret = -EBUSY; goto out; } @@@ -6105,7 -6103,7 +6105,7 @@@ static int tracing_open_pipe(struct ino
nonseekable_open(inode, filp);
- tr->current_trace->ref++; + tr->trace_ref++; out: mutex_unlock(&trace_types_lock); return ret; @@@ -6124,7 -6122,7 +6124,7 @@@ static int tracing_release_pipe(struct
mutex_lock(&trace_types_lock);
- tr->current_trace->ref--; + tr->trace_ref--;
if (iter->trace->pipe_close) iter->trace->pipe_close(iter); @@@ -7121,7 -7119,7 +7121,7 @@@ static const struct file_operations tra
static const struct file_operations trace_clock_fops = { .open = tracing_clock_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = tracing_single_release_tr, .write = tracing_clock_write, @@@ -7129,7 -7127,7 +7129,7 @@@
static const struct file_operations trace_time_stamp_mode_fops = { .open = tracing_time_stamp_mode_open, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = tracing_single_release_tr, }; @@@ -7137,7 -7135,7 +7137,7 @@@ #ifdef CONFIG_TRACER_SNAPSHOT static const struct file_operations snapshot_fops = { .open = tracing_snapshot_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = tracing_snapshot_write, .llseek = tracing_lseek, .release = tracing_snapshot_release, @@@ -7393,7 -7391,7 +7393,7 @@@ static int tracing_err_log_release(stru static const struct file_operations tracing_err_log_fops = { .open = tracing_err_log_open, .write = tracing_err_log_write, - .read = seq_read, + .read_iter = seq_read_iter, .llseek = seq_lseek, .release = tracing_err_log_release, }; @@@ -7426,7 -7424,7 +7426,7 @@@ static int tracing_buffers_open(struct
filp->private_data = info;
- tr->current_trace->ref++; + tr->trace_ref++;
mutex_unlock(&trace_types_lock);
@@@ -7527,7 -7525,7 +7527,7 @@@ static int tracing_buffers_release(stru
mutex_lock(&trace_types_lock);
- iter->tr->current_trace->ref--; + iter->tr->trace_ref--;
__trace_array_put(iter->tr);
@@@ -8735,7 -8733,7 +8735,7 @@@ static int __remove_instance(struct tra int i;
/* Reference counter for a newly created trace array = 1. */ - if (tr->ref > 1 || (tr->current_trace && tr->current_trace->ref)) + if (tr->ref > 1 || (tr->current_trace && tr->trace_ref)) return -EBUSY;
list_del(&tr->list); diff --combined mm/shmem.c index 66024b1884c1,f019ff500844..d08fa0f4eb9b --- a/mm/shmem.c +++ b/mm/shmem.c @@@ -1673,12 -1673,6 +1673,12 @@@ static int shmem_swapin_page(struct ino } wait_on_page_writeback(page);
+ /* + * Some architectures may have to restore extra metadata to the + * physical page after reading from swap. + */ + arch_swap_restore(swap, page); + if (shmem_should_replace_page(page, gfp)) { error = shmem_replace_page(&page, gfp, info, index); if (error) @@@ -2212,9 -2206,6 +2212,9 @@@ static int shmem_mmap(struct file *file vma->vm_flags &= ~(VM_MAYWRITE); }
+ /* arm64 - allow memory tagging on RAM-based files */ + vma->vm_flags |= VM_MTE_ALLOWED; + file_accessed(file); vma->vm_ops = &shmem_vm_ops; if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && @@@ -3765,7 -3756,6 +3765,6 @@@ static const struct file_operations shm .read_iter = shmem_file_read_iter, .write_iter = generic_file_write_iter, .fsync = noop_fsync, - .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = shmem_fallocate, #endif diff --combined mm/swapfile.c index 1d9fb474dada,2e50f52a14c7..7f1587b223ed --- a/mm/swapfile.c +++ b/mm/swapfile.c @@@ -716,7 -716,6 +716,7 @@@ static void swap_range_free(struct swap else swap_slot_free_notify = NULL; while (offset <= end) { + arch_swap_invalidate_page(si->type, offset); frontswap_invalidate_page(si->type, offset); if (swap_slot_free_notify) swap_slot_free_notify(si->bdev, offset); @@@ -2676,7 -2675,6 +2676,7 @@@ SYSCALL_DEFINE1(swapoff, const char __u frontswap_map = frontswap_map_get(p); spin_unlock(&p->lock); spin_unlock(&swap_lock); + arch_swap_invalidate_area(p->type); frontswap_invalidate_area(p->type); frontswap_map_set(p, NULL); mutex_unlock(&swapon_mutex); @@@ -2837,7 -2835,7 +2837,7 @@@ static int swaps_open(struct inode *ino static const struct proc_ops swaps_proc_ops = { .proc_flags = PROC_ENTRY_PERMANENT, .proc_open = swaps_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = seq_release, .proc_poll = swaps_poll, @@@ -2931,7 -2929,7 +2931,7 @@@ static int claim_swapfile(struct swap_i * write only restriction. Hence zoned block devices are not * suitable for swapping. Disallow them here. */ - if (blk_queue_is_zoned(p->bdev->bd_queue)) + if (blk_queue_is_zoned(p->bdev->bd_disk->queue)) return -EINVAL; p->flags |= SWP_BLKDEV; } else if (S_ISREG(inode->i_mode)) { diff --combined net/bluetooth/6lowpan.c index cff4944d5b66,573ef0c80521..7c492105b8c8 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@@ -50,7 -50,6 +50,7 @@@ static bool enable_6lowpan /* We are listening incoming connections via this channel */ static struct l2cap_chan *listen_chan; +static DEFINE_MUTEX(set_lock);
struct lowpan_peer { struct list_head list; @@@ -1079,14 -1078,12 +1079,14 @@@ static void do_enable_set(struct work_s
enable_6lowpan = set_enable->flag;
+ mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); }
listen_chan = bt_6lowpan_listen(); + mutex_unlock(&set_lock);
kfree(set_enable); } @@@ -1138,13 -1135,11 +1138,13 @@@ static ssize_t lowpan_control_write(str if (ret == -EINVAL) return ret;
+ mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); listen_chan = NULL; } + mutex_unlock(&set_lock);
if (conn) { struct lowpan_peer *peer; @@@ -1210,7 -1205,7 +1210,7 @@@ static int lowpan_control_open(struct i
static const struct file_operations lowpan_control_fops = { .open = lowpan_control_open, - .read = seq_read, + .read_iter = seq_read_iter, .write = lowpan_control_write, .llseek = seq_lseek, .release = single_release, diff --combined net/ipv4/netfilter/ipt_CLUSTERIP.c index a8b980ad11d4,67472389c9c3..40af4bbf4519 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c @@@ -3,7 -3,7 +3,7 @@@ * (C) 2003-2004 by Harald Welte laforge@netfilter.org * based on ideas of Fabio Olive Leite olive@unixforge.org * - * Development of this code funded by SuSE Linux AG, http://www.suse.com/ + * Development of this code funded by SuSE Linux AG, https://www.suse.com/ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/module.h> @@@ -806,7 -806,7 +806,7 @@@ static ssize_t clusterip_proc_write(str
static const struct proc_ops clusterip_proc_ops = { .proc_open = clusterip_proc_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_write = clusterip_proc_write, .proc_lseek = seq_lseek, .proc_release = clusterip_proc_release, diff --combined net/ipv4/route.c index a01efa062f6b,4d5f26478f10..90cdf46eae85 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@@ -239,7 -239,7 +239,7 @@@ static int rt_cache_seq_open(struct ino
static const struct proc_ops rt_cache_proc_ops = { .proc_open = rt_cache_seq_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = seq_release, }; @@@ -330,7 -330,7 +330,7 @@@ static int rt_cpu_seq_open(struct inod
static const struct proc_ops rt_cpu_proc_ops = { .proc_open = rt_cpu_seq_open, - .proc_read = seq_read, + .proc_read_iter = seq_read_iter, .proc_lseek = seq_lseek, .proc_release = seq_release, }; @@@ -2027,7 -2027,7 +2027,7 @@@ int ip_route_use_hint(struct sk_buff *s const struct sk_buff *hint) { struct in_device *in_dev = __in_dev_get_rcu(dev); - struct rtable *rt = (struct rtable *)hint; + struct rtable *rt = skb_rtable(hint); struct net *net = dev_net(dev); int err = -EINVAL; u32 tag = 0;