···2424For more information on this wrapper (also called kunit_tool) checkout the2525:doc:`kunit-tool` page.26262727-Creating a kunitconfig2828-======================2727+Creating a .kunitconfig2828+=======================2929The Python script is a thin wrapper around Kbuild. As such, it needs to be3030-configured with a ``kunitconfig`` file. This file essentially contains the3030+configured with a ``.kunitconfig`` file. This file essentially contains the3131regular Kernel config, with the specific test targets as well.32323333.. code-block:: bash34343535- git clone -b master https://kunit.googlesource.com/kunitconfig $PATH_TO_KUNITCONFIG_REPO3635 cd $PATH_TO_LINUX_REPO3737- ln -s $PATH_TO_KUNIT_CONFIG_REPO/kunitconfig kunitconfig3838-3939-You may want to add kunitconfig to your local gitignore.3636+ cp arch/um/configs/kunit_defconfig .kunitconfig40374138Verifying KUnit Works4239---------------------···148151149152 obj-$(CONFIG_MISC_EXAMPLE_TEST) += example-test.o150153151151-Now add it to your ``kunitconfig``:154154+Now add it to your ``.kunitconfig``:152155153156.. code-block:: none154157
-6
Documentation/networking/dsa/sja1105.rst
···230230against this restriction and errors out when appropriate. Schedule analysis is231231needed to avoid this, which is outside the scope of the document.232232233233-At the moment, the time-aware scheduler can only be triggered based on a234234-standalone clock and not based on PTP time. This means the base-time argument235235-from tc-taprio is ignored and the schedule starts right away. It also means it236236-is more difficult to phase-align the scheduler with the other devices in the237237-network.238238-239233Device Tree bindings and board design240234=====================================241235
+3
MAINTAINERS
···771771772772AMAZON ETHERNET DRIVERS773773M: Netanel Belgazal <netanel@amazon.com>774774+M: Arthur Kiyanovski <akiyano@amazon.com>775775+R: Guy Tzalik <gtzalik@amazon.com>774776R: Saeed Bishara <saeedb@amazon.com>775777R: Zorik Machulsky <zorik@amazon.com>776778L: netdev@vger.kernel.org···70367034S: Maintained70377035F: Documentation/firmware-guide/acpi/gpio-properties.rst70387036F: drivers/gpio/gpiolib-acpi.c70377037+F: drivers/gpio/gpiolib-acpi.h7039703870407039GPIO IR Transmitter70417040M: Sean Young <sean@mess.org>
···99/*1010 * Assembly functions that may be used (directly or indirectly) by modules1111 */1212-EXPORT_SYMBOL(__clear_user);1313-EXPORT_SYMBOL(__asm_copy_to_user);1414-EXPORT_SYMBOL(__asm_copy_from_user);1512EXPORT_SYMBOL(memset);1613EXPORT_SYMBOL(memcpy);
···2222 else2323 on_each_cpu(ipi_remote_fence_i, NULL, 1);2424}2525+EXPORT_SYMBOL(flush_icache_all);25262627/*2728 * Performs an icache flush for the given MM context. RISC-V has no direct
+16
block/compat_ioctl.c
···66#include <linux/compat.h>77#include <linux/elevator.h>88#include <linux/hdreg.h>99+#include <linux/pr.h>910#include <linux/slab.h>1011#include <linux/syscalls.h>1112#include <linux/types.h>···355354 * but we call blkdev_ioctl, which gets the lock for us356355 */357356 case BLKRRPART:357357+ case BLKREPORTZONE:358358+ case BLKRESETZONE:359359+ case BLKOPENZONE:360360+ case BLKCLOSEZONE:361361+ case BLKFINISHZONE:362362+ case BLKGETZONESZ:363363+ case BLKGETNRZONES:358364 return blkdev_ioctl(bdev, mode, cmd,359365 (unsigned long)compat_ptr(arg));360366 case BLKBSZSET_32:···409401 case BLKTRACETEARDOWN: /* compatible */410402 ret = blk_trace_ioctl(bdev, cmd, compat_ptr(arg));411403 return ret;404404+ case IOC_PR_REGISTER:405405+ case IOC_PR_RESERVE:406406+ case IOC_PR_RELEASE:407407+ case IOC_PR_PREEMPT:408408+ case IOC_PR_PREEMPT_ABORT:409409+ case IOC_PR_CLEAR:410410+ return blkdev_ioctl(bdev, mode, cmd,411411+ (unsigned long)compat_ptr(arg));412412 default:413413 if (disk->fops->compat_ioctl)414414 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg);
+95-40
drivers/ata/ahci_brcm.c
···7676};77777878enum brcm_ahci_quirks {7979- BRCM_AHCI_QUIRK_NO_NCQ = BIT(0),8080- BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1),7979+ BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(0),8180};82818382struct brcm_ahci_priv {···212213 brcm_sata_phy_disable(priv, i);213214}214215215215-static u32 brcm_ahci_get_portmask(struct platform_device *pdev,216216+static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv,216217 struct brcm_ahci_priv *priv)217218{218218- void __iomem *ahci;219219- struct resource *res;220219 u32 impl;221220222222- res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ahci");223223- ahci = devm_ioremap_resource(&pdev->dev, res);224224- if (IS_ERR(ahci))225225- return 0;226226-227227- impl = readl(ahci + HOST_PORTS_IMPL);221221+ impl = readl(hpriv->mmio + HOST_PORTS_IMPL);228222229223 if (fls(impl) > SATA_TOP_MAX_PHYS)230224 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n",231225 impl);232226 else if (!impl)233227 dev_info(priv->dev, "no ports found\n");234234-235235- devm_iounmap(&pdev->dev, ahci);236236- devm_release_mem_region(&pdev->dev, res->start, resource_size(res));237228238229 return impl;239230}···273284274285 /* Perform the SATA PHY reset sequence */275286 brcm_sata_phy_disable(priv, ap->port_no);287287+288288+ /* Reset the SATA clock */289289+ ahci_platform_disable_clks(hpriv);290290+ msleep(10);291291+292292+ ahci_platform_enable_clks(hpriv);293293+ msleep(10);276294277295 /* Bring the PHY back on */278296 brcm_sata_phy_enable(priv, ap->port_no);···343347 struct ata_host *host = dev_get_drvdata(dev);344348 struct ahci_host_priv *hpriv = host->private_data;345349 struct brcm_ahci_priv *priv = hpriv->plat_data;346346- int ret;347350348348- ret = ahci_platform_suspend(dev);349351 brcm_sata_phys_disable(priv);350350- return ret;352352+353353+ return ahci_platform_suspend(dev);351354}352355353356static int brcm_ahci_resume(struct device *dev)···354359 struct ata_host *host = dev_get_drvdata(dev);355360 struct ahci_host_priv *hpriv = host->private_data;356361 struct brcm_ahci_priv *priv = hpriv->plat_data;362362+ int ret;363363+364364+ /* Make sure clocks are turned on before re-configuration */365365+ ret = ahci_platform_enable_clks(hpriv);366366+ if (ret)367367+ return ret;357368358369 brcm_sata_init(priv);359370 brcm_sata_phys_enable(priv);360371 brcm_sata_alpm_init(hpriv);361361- return ahci_platform_resume(dev);372372+373373+ /* Since we had to enable clocks earlier on, we cannot use374374+ * ahci_platform_resume() as-is since a second call to375375+ * ahci_platform_enable_resources() would bump up the resources376376+ * (regulators, clocks, PHYs) count artificially so we copy the part377377+ * after ahci_platform_enable_resources().378378+ */379379+ ret = ahci_platform_enable_phys(hpriv);380380+ if (ret)381381+ goto out_disable_phys;382382+383383+ ret = ahci_platform_resume_host(dev);384384+ if (ret)385385+ goto out_disable_platform_phys;386386+387387+ /* We resumed so update PM runtime state */388388+ pm_runtime_disable(dev);389389+ pm_runtime_set_active(dev);390390+ pm_runtime_enable(dev);391391+392392+ return 0;393393+394394+out_disable_platform_phys:395395+ ahci_platform_disable_phys(hpriv);396396+out_disable_phys:397397+ brcm_sata_phys_disable(priv);398398+ ahci_platform_disable_clks(hpriv);399399+ return ret;362400}363401#endif364402···438410 if (!IS_ERR_OR_NULL(priv->rcdev))439411 reset_control_deassert(priv->rcdev);440412441441- if ((priv->version == BRCM_SATA_BCM7425) ||442442- (priv->version == BRCM_SATA_NSP)) {443443- priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ;444444- priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;413413+ hpriv = ahci_platform_get_resources(pdev, 0);414414+ if (IS_ERR(hpriv)) {415415+ ret = PTR_ERR(hpriv);416416+ goto out_reset;445417 }446418419419+ hpriv->plat_data = priv;420420+ hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP | AHCI_HFLAG_NO_WRITE_TO_RO;421421+422422+ switch (priv->version) {423423+ case BRCM_SATA_BCM7425:424424+ hpriv->flags |= AHCI_HFLAG_DELAY_ENGINE;425425+ /* fall through */426426+ case BRCM_SATA_NSP:427427+ hpriv->flags |= AHCI_HFLAG_NO_NCQ;428428+ priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;429429+ break;430430+ default:431431+ break;432432+ }433433+434434+ ret = ahci_platform_enable_clks(hpriv);435435+ if (ret)436436+ goto out_reset;437437+438438+ /* Must be first so as to configure endianness including that439439+ * of the standard AHCI register space.440440+ */447441 brcm_sata_init(priv);448442449449- priv->port_mask = brcm_ahci_get_portmask(pdev, priv);450450- if (!priv->port_mask)451451- return -ENODEV;443443+ /* Initializes priv->port_mask which is used below */444444+ priv->port_mask = brcm_ahci_get_portmask(hpriv, priv);445445+ if (!priv->port_mask) {446446+ ret = -ENODEV;447447+ goto out_disable_clks;448448+ }452449450450+ /* Must be done before ahci_platform_enable_phys() */453451 brcm_sata_phys_enable(priv);454454-455455- hpriv = ahci_platform_get_resources(pdev, 0);456456- if (IS_ERR(hpriv))457457- return PTR_ERR(hpriv);458458- hpriv->plat_data = priv;459459- hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP;460452461453 brcm_sata_alpm_init(hpriv);462454463463- ret = ahci_platform_enable_resources(hpriv);455455+ ret = ahci_platform_enable_phys(hpriv);464456 if (ret)465465- return ret;466466-467467- if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ)468468- hpriv->flags |= AHCI_HFLAG_NO_NCQ;469469- hpriv->flags |= AHCI_HFLAG_NO_WRITE_TO_RO;457457+ goto out_disable_phys;470458471459 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info,472460 &ahci_platform_sht);473461 if (ret)474474- return ret;462462+ goto out_disable_platform_phys;475463476464 dev_info(dev, "Broadcom AHCI SATA3 registered\n");477465478466 return 0;467467+468468+out_disable_platform_phys:469469+ ahci_platform_disable_phys(hpriv);470470+out_disable_phys:471471+ brcm_sata_phys_disable(priv);472472+out_disable_clks:473473+ ahci_platform_disable_clks(hpriv);474474+out_reset:475475+ if (!IS_ERR_OR_NULL(priv->rcdev))476476+ reset_control_assert(priv->rcdev);477477+ return ret;479478}480479481480static int brcm_ahci_remove(struct platform_device *pdev)···512457 struct brcm_ahci_priv *priv = hpriv->plat_data;513458 int ret;514459460460+ brcm_sata_phys_disable(priv);461461+515462 ret = ata_platform_remove_one(pdev);516463 if (ret)517464 return ret;518518-519519- brcm_sata_phys_disable(priv);520465521466 return 0;522467}
+4-2
drivers/ata/libahci_platform.c
···4343 * RETURNS:4444 * 0 on success otherwise a negative error code4545 */4646-static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)4646+int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)4747{4848 int rc, i;4949···7474 }7575 return rc;7676}7777+EXPORT_SYMBOL_GPL(ahci_platform_enable_phys);77787879/**7980 * ahci_platform_disable_phys - Disable PHYs···8281 *8382 * This function disables all PHYs found in hpriv->phys.8483 */8585-static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)8484+void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)8685{8786 int i;8887···9190 phy_exit(hpriv->phys[i]);9291 }9392}9393+EXPORT_SYMBOL_GPL(ahci_platform_disable_phys);94949595/**9696 * ahci_platform_enable_clks - Enable platform clocks
+24
drivers/ata/libata-core.c
···53295329}5330533053315331/**53325332+ * ata_qc_get_active - get bitmask of active qcs53335333+ * @ap: port in question53345334+ *53355335+ * LOCKING:53365336+ * spin_lock_irqsave(host lock)53375337+ *53385338+ * RETURNS:53395339+ * Bitmask of active qcs53405340+ */53415341+u64 ata_qc_get_active(struct ata_port *ap)53425342+{53435343+ u64 qc_active = ap->qc_active;53445344+53455345+ /* ATA_TAG_INTERNAL is sent to hw as tag 0 */53465346+ if (qc_active & (1ULL << ATA_TAG_INTERNAL)) {53475347+ qc_active |= (1 << 0);53485348+ qc_active &= ~(1ULL << ATA_TAG_INTERNAL);53495349+ }53505350+53515351+ return qc_active;53525352+}53535353+EXPORT_SYMBOL_GPL(ata_qc_get_active);53545354+53555355+/**53325356 * ata_qc_complete_multiple - Complete multiple qcs successfully53335357 * @ap: port in question53345358 * @qc_active: new qc_active mask
···8383 select DEVFREQ_GOV_PASSIVE8484 select DEVFREQ_EVENT_EXYNOS_PPMU8585 select PM_DEVFREQ_EVENT8686- select PM_OPP8786 help8887 This adds the common DEVFREQ driver for Exynos Memory bus. Exynos8988 Memory bus has one more group of memory bus (e.g, MIF and INT block).···9798 ARCH_TEGRA_132_SOC || ARCH_TEGRA_124_SOC || \9899 ARCH_TEGRA_210_SOC || \99100 COMPILE_TEST100100- select PM_OPP101101+ depends on COMMON_CLK101102 help102103 This adds the DEVFREQ driver for the Tegra family of SoCs.103104 It reads ACTMON counters of memory controllers and adjusts the···108109 depends on (TEGRA_MC && TEGRA20_EMC) || COMPILE_TEST109110 depends on COMMON_CLK110111 select DEVFREQ_GOV_SIMPLE_ONDEMAND111111- select PM_OPP112112 help113113 This adds the DEVFREQ driver for the Tegra20 family of SoCs.114114 It reads Memory Controller counters and adjusts the operating···119121 select DEVFREQ_EVENT_ROCKCHIP_DFI120122 select DEVFREQ_GOV_SIMPLE_ONDEMAND121123 select PM_DEVFREQ_EVENT122122- select PM_OPP123124 help124125 This adds the DEVFREQ driver for the RK3399 DMC(Dynamic Memory Controller).125126 It sets the frequency for the memory controller and reads the usage counts
···280280 return 0;281281}282282283283-static int __exit iproc_gpio_remove(struct platform_device *pdev)283283+static int iproc_gpio_remove(struct platform_device *pdev)284284{285285 struct iproc_gpio_chip *chip;286286
+3-4
drivers/gpio/gpio-xtensa.c
···4444 unsigned long flags;45454646 local_irq_save(flags);4747- RSR_CPENABLE(*cpenable);4848- WSR_CPENABLE(*cpenable | BIT(XCHAL_CP_ID_XTIOP));4949-4747+ *cpenable = xtensa_get_sr(cpenable);4848+ xtensa_set_sr(*cpenable | BIT(XCHAL_CP_ID_XTIOP), cpenable);5049 return flags;5150}52515352static inline void disable_cp(unsigned long flags, unsigned long cpenable)5453{5555- WSR_CPENABLE(cpenable);5454+ xtensa_set_sr(cpenable, cpenable);5655 local_irq_restore(flags);5756}5857
+11-2
drivers/gpio/gpiolib.c
···220220 chip = gpiod_to_chip(desc);221221 offset = gpio_chip_hwgpio(desc);222222223223+ /*224224+ * Open drain emulation using input mode may incorrectly report225225+ * input here, fix that up.226226+ */227227+ if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) &&228228+ test_bit(FLAG_IS_OUT, &desc->flags))229229+ return 0;230230+223231 if (!chip->get_direction)224232 return -ENOTSUPP;225233···4480447244814473 if (chip->ngpio <= p->chip_hwnum) {44824474 dev_err(dev,44834483- "requested GPIO %d is out of range [0..%d] for chip %s\n",44844484- idx, chip->ngpio, chip->label);44754475+ "requested GPIO %u (%u) is out of range [0..%u] for chip %s\n",44764476+ idx, p->chip_hwnum, chip->ngpio - 1,44774477+ chip->label);44854478 return ERR_PTR(-EINVAL);44864479 }44874480
···150150 */151151 u16 write_domain;152152153153- struct intel_frontbuffer *frontbuffer;153153+ struct intel_frontbuffer __rcu *frontbuffer;154154155155 /** Current tiling stride for the object, if it's tiled. */156156 unsigned int tiling_and_stride;
+2-1
drivers/gpu/drm/i915/gt/intel_gt_pm.c
···9494 intel_uncore_forcewake_put(&i915->uncore, FORCEWAKE_ALL);9595 }96969797+ /* Defer dropping the display power well for 100ms, it's slow! */9798 GEM_BUG_ON(!wakeref);9898- intel_display_power_put(i915, POWER_DOMAIN_GT_IRQ, wakeref);9999+ intel_display_power_put_async(i915, POWER_DOMAIN_GT_IRQ, wakeref);99100100101 i915_globals_park();101102
+5-5
drivers/gpu/drm/i915/i915_gem.c
···161161 * We manually control the domain here and pretend that it162162 * remains coherent i.e. in the GTT domain, like shmem_pwrite.163163 */164164- intel_frontbuffer_invalidate(obj->frontbuffer, ORIGIN_CPU);164164+ i915_gem_object_invalidate_frontbuffer(obj, ORIGIN_CPU);165165166166 if (copy_from_user(vaddr, user_data, args->size))167167 return -EFAULT;···169169 drm_clflush_virt_range(vaddr, args->size);170170 intel_gt_chipset_flush(&to_i915(obj->base.dev)->gt);171171172172- intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU);172172+ i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU);173173 return 0;174174}175175···589589 goto out_unpin;590590 }591591592592- intel_frontbuffer_invalidate(obj->frontbuffer, ORIGIN_CPU);592592+ i915_gem_object_invalidate_frontbuffer(obj, ORIGIN_CPU);593593594594 user_data = u64_to_user_ptr(args->data_ptr);595595 offset = args->offset;···631631 user_data += page_length;632632 offset += page_length;633633 }634634- intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU);634634+ i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU);635635636636 i915_gem_object_unlock_fence(obj, fence);637637out_unpin:···721721 offset = 0;722722 }723723724724- intel_frontbuffer_flush(obj->frontbuffer, ORIGIN_CPU);724724+ i915_gem_object_flush_frontbuffer(obj, ORIGIN_CPU);725725 i915_gem_object_unlock_fence(obj, fence);726726727727 return ret;
+20-53
drivers/gpu/drm/i915/i915_pmu.c
···144144 return ktime_to_ns(ktime_sub(ktime_get(), kt));145145}146146147147-static u64 __pmu_estimate_rc6(struct i915_pmu *pmu)148148-{149149- u64 val;150150-151151- /*152152- * We think we are runtime suspended.153153- *154154- * Report the delta from when the device was suspended to now,155155- * on top of the last known real value, as the approximated RC6156156- * counter value.157157- */158158- val = ktime_since(pmu->sleep_last);159159- val += pmu->sample[__I915_SAMPLE_RC6].cur;160160-161161- pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur = val;162162-163163- return val;164164-}165165-166166-static u64 __pmu_update_rc6(struct i915_pmu *pmu, u64 val)167167-{168168- /*169169- * If we are coming back from being runtime suspended we must170170- * be careful not to report a larger value than returned171171- * previously.172172- */173173- if (val >= pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur) {174174- pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur = 0;175175- pmu->sample[__I915_SAMPLE_RC6].cur = val;176176- } else {177177- val = pmu->sample[__I915_SAMPLE_RC6_ESTIMATED].cur;178178- }179179-180180- return val;181181-}182182-183147static u64 get_rc6(struct intel_gt *gt)184148{185149 struct drm_i915_private *i915 = gt->i915;186150 struct i915_pmu *pmu = &i915->pmu;187151 unsigned long flags;152152+ bool awake = false;188153 u64 val;189154190190- val = 0;191155 if (intel_gt_pm_get_if_awake(gt)) {192156 val = __get_rc6(gt);193157 intel_gt_pm_put_async(gt);158158+ awake = true;194159 }195160196161 spin_lock_irqsave(&pmu->lock, flags);197162198198- if (val)199199- val = __pmu_update_rc6(pmu, val);163163+ if (awake) {164164+ pmu->sample[__I915_SAMPLE_RC6].cur = val;165165+ } else {166166+ /*167167+ * We think we are runtime suspended.168168+ *169169+ * Report the delta from when the device was suspended to now,170170+ * on top of the last known real value, as the approximated RC6171171+ * counter value.172172+ */173173+ val = ktime_since(pmu->sleep_last);174174+ val += pmu->sample[__I915_SAMPLE_RC6].cur;175175+ }176176+177177+ if (val < pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur)178178+ val = pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur;200179 else201201- val = __pmu_estimate_rc6(pmu);180180+ pmu->sample[__I915_SAMPLE_RC6_LAST_REPORTED].cur = val;202181203182 spin_unlock_irqrestore(&pmu->lock, flags);204183···189210 struct i915_pmu *pmu = &i915->pmu;190211191212 if (pmu->enable & config_enabled_mask(I915_PMU_RC6_RESIDENCY))192192- __pmu_update_rc6(pmu, __get_rc6(&i915->gt));213213+ pmu->sample[__I915_SAMPLE_RC6].cur = __get_rc6(&i915->gt);193214194215 pmu->sleep_last = ktime_get();195195-}196196-197197-static void unpark_rc6(struct drm_i915_private *i915)198198-{199199- struct i915_pmu *pmu = &i915->pmu;200200-201201- /* Estimate how long we slept and accumulate that into rc6 counters */202202- if (pmu->enable & config_enabled_mask(I915_PMU_RC6_RESIDENCY))203203- __pmu_estimate_rc6(pmu);204216}205217206218#else···202232}203233204234static void park_rc6(struct drm_i915_private *i915) {}205205-static void unpark_rc6(struct drm_i915_private *i915) {}206235207236#endif208237···249280 * Re-enable sampling timer when GPU goes active.250281 */251282 __i915_pmu_maybe_start_timer(pmu);252252-253253- unpark_rc6(i915);254283255284 spin_unlock_irq(&pmu->lock);256285}
···477477 if (admin->cycle_time_extension)478478 return -ENOTSUPP;479479480480- if (!ns_to_sja1105_delta(admin->base_time)) {481481- dev_err(ds->dev, "A base time of zero is not hardware-allowed\n");482482- return -ERANGE;483483- }484484-485480 for (i = 0; i < admin->num_entries; i++) {486481 s64 delta_ns = admin->entries[i].interval;487482 s64 delta_cycles = ns_to_sja1105_delta(delta_ns);
···515515516516 enum cc_pause requested_fc; /* flow control user has requested */517517 enum cc_pause fc; /* actual link flow control */518518+ enum cc_pause advertised_fc; /* actual advertised flow control */518519519520 enum cc_fec requested_fec; /* Forward Error Correction: */520521 enum cc_fec fec; /* requested and actual in use */
···287287 card->state = CARD_STATE_HARDSETUP;288288 }289289 if (card->state == CARD_STATE_HARDSETUP) {290290- qeth_qdio_clear_card(card, 0);291290 qeth_drain_output_queues(card);292291 qeth_clear_working_pool_list(card);293292 card->state = CARD_STATE_DOWN;294293 }295294295295+ qeth_qdio_clear_card(card, 0);296296 flush_workqueue(card->event_wq);297297 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;298298 card->info.promisc_mode = 0;···19121912/* check if VNICC is currently enabled */19131913bool qeth_l2_vnicc_is_in_use(struct qeth_card *card)19141914{19151915- /* if everything is turned off, VNICC is not active */19161916- if (!card->options.vnicc.cur_chars)19151915+ if (!card->options.vnicc.sup_chars)19171916 return false;19181917 /* default values are only OK if rx_bcast was not enabled by user19191918 * or the card is offline.···19992000 /* enforce assumed default values and recover settings, if changed */20002001 error |= qeth_l2_vnicc_recover_timeout(card, QETH_VNICC_LEARNING,20012002 timeout);20022002- chars_tmp = card->options.vnicc.wanted_chars ^ QETH_VNICC_DEFAULT;20032003- chars_tmp |= QETH_VNICC_BRIDGE_INVISIBLE;20032003+ /* Change chars, if necessary */20042004+ chars_tmp = card->options.vnicc.wanted_chars ^20052005+ card->options.vnicc.cur_chars;20042006 chars_len = sizeof(card->options.vnicc.wanted_chars) * BITS_PER_BYTE;20052007 for_each_set_bit(i, &chars_tmp, chars_len) {20062008 vnicc = BIT(i);
···85558555 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK;85568556 spin_unlock_irq(&phba->hbalock);8557855785588558- /* wake up worker thread to post asynchronlous mailbox command */85588558+ /* wake up worker thread to post asynchronous mailbox command */85598559 lpfc_worker_wake_up(phba);85608560}85618561···88238823 return rc;88248824 }8825882588268826- /* Now, interrupt mode asynchrous mailbox command */88268826+ /* Now, interrupt mode asynchronous mailbox command */88278827 rc = lpfc_mbox_cmd_check(phba, mboxq);88288828 if (rc) {88298829 lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_SLI,···1311213112}13113131131311413114/**1311513115- * lpfc_sli4_sp_handle_async_event - Handle an asynchroous event1311513115+ * lpfc_sli4_sp_handle_async_event - Handle an asynchronous event1311613116 * @phba: Pointer to HBA context object.1311713117 * @cqe: Pointer to mailbox completion queue entry.1311813118 *1311913119- * This routine process a mailbox completion queue entry with asynchrous1311913119+ * This routine process a mailbox completion queue entry with asynchronous1312013120 * event.1312113121 *1312213122 * Return: true if work posted to worker thread, otherwise false.···1327013270 * @cqe: Pointer to mailbox completion queue entry.1327113271 *1327213272 * This routine process a mailbox completion queue entry, it invokes the1327313273- * proper mailbox complete handling or asynchrous event handling routine1327313273+ * proper mailbox complete handling or asynchronous event handling routine1327413274 * according to the MCQE's async bit.1327513275 *1327613276 * Return: true if work posted to worker thread, otherwise false.
···9292 struct io_wqe_acct acct[2];93939494 struct hlist_nulls_head free_list;9595- struct hlist_nulls_head busy_list;9695 struct list_head all_list;97969897 struct io_wq *wq;···326327 if (worker->flags & IO_WORKER_F_FREE) {327328 worker->flags &= ~IO_WORKER_F_FREE;328329 hlist_nulls_del_init_rcu(&worker->nulls_node);329329- hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->busy_list);330330 }331331332332 /*···363365{364366 if (!(worker->flags & IO_WORKER_F_FREE)) {365367 worker->flags |= IO_WORKER_F_FREE;366366- hlist_nulls_del_init_rcu(&worker->nulls_node);367368 hlist_nulls_add_head_rcu(&worker->nulls_node, &wqe->free_list);368369 }369370···428431 /* flush any pending signals before assigning new work */429432 if (signal_pending(current))430433 flush_signals(current);434434+435435+ cond_resched();431436432437 spin_lock_irq(&worker->lock);433438 worker->cur_work = work;···797798798799 set_bit(IO_WQ_BIT_CANCEL, &wq->state);799800800800- /*801801- * Browse both lists, as there's a gap between handing work off802802- * to a worker and the worker putting itself on the busy_list803803- */804801 rcu_read_lock();805802 for_each_node(node) {806803 struct io_wqe *wqe = wq->wqes[node];···10441049 spin_lock_init(&wqe->lock);10451050 INIT_WQ_LIST(&wqe->work_list);10461051 INIT_HLIST_NULLS_HEAD(&wqe->free_list, 0);10471047- INIT_HLIST_NULLS_HEAD(&wqe->busy_list, 1);10481052 INIT_LIST_HEAD(&wqe->all_list);10491053 }10501054
+355-335
fs/io_uring.c
···330330 struct file *file;331331 u64 addr;332332 int flags;333333+ unsigned count;334334+};335335+336336+struct io_rw {337337+ /* NOTE: kiocb has the file as the first member, so don't do it here */338338+ struct kiocb kiocb;339339+ u64 addr;340340+ u64 len;341341+};342342+343343+struct io_connect {344344+ struct file *file;345345+ struct sockaddr __user *addr;346346+ int addr_len;347347+};348348+349349+struct io_sr_msg {350350+ struct file *file;351351+ struct user_msghdr __user *msg;352352+ int msg_flags;333353};334354335355struct io_async_connect {···371351};372352373353struct io_async_ctx {374374- struct io_uring_sqe sqe;375354 union {376355 struct io_async_rw rw;377356 struct io_async_msghdr msg;···388369struct io_kiocb {389370 union {390371 struct file *file;391391- struct kiocb rw;372372+ struct io_rw rw;392373 struct io_poll_iocb poll;393374 struct io_accept accept;394375 struct io_sync sync;395376 struct io_cancel cancel;396377 struct io_timeout timeout;378378+ struct io_connect connect;379379+ struct io_sr_msg sr_msg;397380 };398381399399- const struct io_uring_sqe *sqe;400382 struct io_async_ctx *io;401383 struct file *ring_file;402384 int ring_fd;···431411#define REQ_F_INFLIGHT 16384 /* on inflight list */432412#define REQ_F_COMP_LOCKED 32768 /* completion under lock */433413#define REQ_F_HARDLINK 65536 /* doesn't sever on completion < 0 */434434-#define REQ_F_PREPPED 131072 /* request already opcode prepared */435414 u64 user_data;436415 u32 result;437416 u32 sequence;···628609{629610 bool do_hashed = false;630611631631- if (req->sqe) {632632- switch (req->opcode) {633633- case IORING_OP_WRITEV:634634- case IORING_OP_WRITE_FIXED:635635- /* only regular files should be hashed for writes */636636- if (req->flags & REQ_F_ISREG)637637- do_hashed = true;638638- /* fall-through */639639- case IORING_OP_READV:640640- case IORING_OP_READ_FIXED:641641- case IORING_OP_SENDMSG:642642- case IORING_OP_RECVMSG:643643- case IORING_OP_ACCEPT:644644- case IORING_OP_POLL_ADD:645645- case IORING_OP_CONNECT:646646- /*647647- * We know REQ_F_ISREG is not set on some of these648648- * opcodes, but this enables us to keep the check in649649- * just one place.650650- */651651- if (!(req->flags & REQ_F_ISREG))652652- req->work.flags |= IO_WQ_WORK_UNBOUND;653653- break;654654- }655655- if (io_req_needs_user(req))656656- req->work.flags |= IO_WQ_WORK_NEEDS_USER;612612+ switch (req->opcode) {613613+ case IORING_OP_WRITEV:614614+ case IORING_OP_WRITE_FIXED:615615+ /* only regular files should be hashed for writes */616616+ if (req->flags & REQ_F_ISREG)617617+ do_hashed = true;618618+ /* fall-through */619619+ case IORING_OP_READV:620620+ case IORING_OP_READ_FIXED:621621+ case IORING_OP_SENDMSG:622622+ case IORING_OP_RECVMSG:623623+ case IORING_OP_ACCEPT:624624+ case IORING_OP_POLL_ADD:625625+ case IORING_OP_CONNECT:626626+ /*627627+ * We know REQ_F_ISREG is not set on some of these628628+ * opcodes, but this enables us to keep the check in629629+ * just one place.630630+ */631631+ if (!(req->flags & REQ_F_ISREG))632632+ req->work.flags |= IO_WQ_WORK_UNBOUND;633633+ break;657634 }635635+ if (io_req_needs_user(req))636636+ req->work.flags |= IO_WQ_WORK_NEEDS_USER;658637659638 *link = io_prep_linked_timeout(req);660639 return do_hashed;···1197118011981181 ret = 0;11991182 list_for_each_entry_safe(req, tmp, &ctx->poll_list, list) {12001200- struct kiocb *kiocb = &req->rw;11831183+ struct kiocb *kiocb = &req->rw.kiocb;1201118412021185 /*12031186 * Move completed entries to our local list. If we find a···1352133513531336static void io_complete_rw_common(struct kiocb *kiocb, long res)13541337{13551355- struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw);13381338+ struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);1356133913571340 if (kiocb->ki_flags & IOCB_WRITE)13581341 kiocb_end_write(req);···1364134713651348static void io_complete_rw(struct kiocb *kiocb, long res, long res2)13661349{13671367- struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw);13501350+ struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);1368135113691352 io_complete_rw_common(kiocb, res);13701353 io_put_req(req);···1372135513731356static struct io_kiocb *__io_complete_rw(struct kiocb *kiocb, long res)13741357{13751375- struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw);13581358+ struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);13761359 struct io_kiocb *nxt = NULL;1377136013781361 io_complete_rw_common(kiocb, res);···1383136613841367static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2)13851368{13861386- struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw);13691369+ struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb);1387137013881371 if (kiocb->ki_flags & IOCB_WRITE)13891372 kiocb_end_write(req);···1417140014181401 list_req = list_first_entry(&ctx->poll_list, struct io_kiocb,14191402 list);14201420- if (list_req->rw.ki_filp != req->rw.ki_filp)14031403+ if (list_req->file != req->file)14211404 ctx->poll_multi_file = true;14221405 }14231406···14881471 return false;14891472}1490147314911491-static int io_prep_rw(struct io_kiocb *req, bool force_nonblock)14741474+static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe,14751475+ bool force_nonblock)14921476{14931493- const struct io_uring_sqe *sqe = req->sqe;14941477 struct io_ring_ctx *ctx = req->ctx;14951495- struct kiocb *kiocb = &req->rw;14781478+ struct kiocb *kiocb = &req->rw.kiocb;14961479 unsigned ioprio;14971480 int ret;14981481···15411524 return -EINVAL;15421525 kiocb->ki_complete = io_complete_rw;15431526 }15271527+15281528+ req->rw.addr = READ_ONCE(sqe->addr);15291529+ req->rw.len = READ_ONCE(sqe->len);15301530+ /* we own ->private, reuse it for the buffer index */15311531+ req->rw.kiocb.private = (void *) (unsigned long)15321532+ READ_ONCE(sqe->buf_index);15441533 return 0;15451534}15461535···15801557 io_rw_done(kiocb, ret);15811558}1582155915831583-static ssize_t io_import_fixed(struct io_ring_ctx *ctx, int rw,15841584- const struct io_uring_sqe *sqe,15601560+static ssize_t io_import_fixed(struct io_kiocb *req, int rw,15851561 struct iov_iter *iter)15861562{15871587- size_t len = READ_ONCE(sqe->len);15631563+ struct io_ring_ctx *ctx = req->ctx;15641564+ size_t len = req->rw.len;15881565 struct io_mapped_ubuf *imu;15891566 unsigned index, buf_index;15901567 size_t offset;···15941571 if (unlikely(!ctx->user_bufs))15951572 return -EFAULT;1596157315971597- buf_index = READ_ONCE(sqe->buf_index);15741574+ buf_index = (unsigned long) req->rw.kiocb.private;15981575 if (unlikely(buf_index >= ctx->nr_user_bufs))15991576 return -EFAULT;1600157716011578 index = array_index_nospec(buf_index, ctx->nr_user_bufs);16021579 imu = &ctx->user_bufs[index];16031603- buf_addr = READ_ONCE(sqe->addr);15801580+ buf_addr = req->rw.addr;1604158116051582 /* overflow */16061583 if (buf_addr + len < buf_addr)···16571634static ssize_t io_import_iovec(int rw, struct io_kiocb *req,16581635 struct iovec **iovec, struct iov_iter *iter)16591636{16601660- const struct io_uring_sqe *sqe = req->sqe;16611661- void __user *buf = u64_to_user_ptr(READ_ONCE(sqe->addr));16621662- size_t sqe_len = READ_ONCE(sqe->len);16371637+ void __user *buf = u64_to_user_ptr(req->rw.addr);16381638+ size_t sqe_len = req->rw.len;16631639 u8 opcode;1664164016651665- /*16661666- * We're reading ->opcode for the second time, but the first read16671667- * doesn't care whether it's _FIXED or not, so it doesn't matter16681668- * whether ->opcode changes concurrently. The first read does care16691669- * about whether it is a READ or a WRITE, so we don't trust this read16701670- * for that purpose and instead let the caller pass in the read/write16711671- * flag.16721672- */16731641 opcode = req->opcode;16741642 if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) {16751643 *iovec = NULL;16761676- return io_import_fixed(req->ctx, rw, sqe, iter);16441644+ return io_import_fixed(req, rw, iter);16771645 }16461646+16471647+ /* buffer index only valid with fixed read/write */16481648+ if (req->rw.kiocb.private)16491649+ return -EINVAL;1678165016791651 if (req->io) {16801652 struct io_async_rw *iorw = &req->io->rw;···17681750static int io_alloc_async_ctx(struct io_kiocb *req)17691751{17701752 req->io = kmalloc(sizeof(*req->io), GFP_KERNEL);17711771- if (req->io) {17721772- memcpy(&req->io->sqe, req->sqe, sizeof(req->io->sqe));17731773- req->sqe = &req->io->sqe;17741774- return 0;17751775- }17761776-17771777- return 1;17531753+ return req->io == NULL;17781754}1779175517801756static void io_rw_async(struct io_wq_work **workptr)···17941782 return 0;17951783}1796178417971797-static int io_read_prep(struct io_kiocb *req, struct iovec **iovec,17981798- struct iov_iter *iter, bool force_nonblock)17851785+static int io_read_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,17861786+ bool force_nonblock)17991787{17881788+ struct io_async_ctx *io;17891789+ struct iov_iter iter;18001790 ssize_t ret;1801179118021802- ret = io_prep_rw(req, force_nonblock);17921792+ ret = io_prep_rw(req, sqe, force_nonblock);18031793 if (ret)18041794 return ret;1805179518061796 if (unlikely(!(req->file->f_mode & FMODE_READ)))18071797 return -EBADF;1808179818091809- return io_import_iovec(READ, req, iovec, iter);17991799+ if (!req->io)18001800+ return 0;18011801+18021802+ io = req->io;18031803+ io->rw.iov = io->rw.fast_iov;18041804+ req->io = NULL;18051805+ ret = io_import_iovec(READ, req, &io->rw.iov, &iter);18061806+ req->io = io;18071807+ if (ret < 0)18081808+ return ret;18091809+18101810+ io_req_map_rw(req, ret, io->rw.iov, io->rw.fast_iov, &iter);18111811+ return 0;18101812}1811181318121814static int io_read(struct io_kiocb *req, struct io_kiocb **nxt,18131815 bool force_nonblock)18141816{18151817 struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;18161816- struct kiocb *kiocb = &req->rw;18181818+ struct kiocb *kiocb = &req->rw.kiocb;18171819 struct iov_iter iter;18181818- struct file *file;18191820 size_t iov_count;18201821 ssize_t io_size, ret;1821182218221822- if (!req->io) {18231823- ret = io_read_prep(req, &iovec, &iter, force_nonblock);18241824- if (ret < 0)18251825- return ret;18261826- } else {18271827- ret = io_import_iovec(READ, req, &iovec, &iter);18281828- if (ret < 0)18291829- return ret;18301830- }18231823+ ret = io_import_iovec(READ, req, &iovec, &iter);18241824+ if (ret < 0)18251825+ return ret;1831182618321827 /* Ensure we clear previously set non-block flag */18331828 if (!force_nonblock)18341834- req->rw.ki_flags &= ~IOCB_NOWAIT;18291829+ req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;1835183018361836- file = req->file;18371831 io_size = ret;18381832 if (req->flags & REQ_F_LINK)18391833 req->result = io_size;···18481830 * If the file doesn't support async, mark it as REQ_F_MUST_PUNT so18491831 * we know to async punt it even if it was opened O_NONBLOCK18501832 */18511851- if (force_nonblock && !io_file_supports_async(file)) {18331833+ if (force_nonblock && !io_file_supports_async(req->file)) {18521834 req->flags |= REQ_F_MUST_PUNT;18531835 goto copy_iov;18541836 }1855183718561838 iov_count = iov_iter_count(&iter);18571857- ret = rw_verify_area(READ, file, &kiocb->ki_pos, iov_count);18391839+ ret = rw_verify_area(READ, req->file, &kiocb->ki_pos, iov_count);18581840 if (!ret) {18591841 ssize_t ret2;1860184218611861- if (file->f_op->read_iter)18621862- ret2 = call_read_iter(file, kiocb, &iter);18431843+ if (req->file->f_op->read_iter)18441844+ ret2 = call_read_iter(req->file, kiocb, &iter);18631845 else18641864- ret2 = loop_rw_iter(READ, file, kiocb, &iter);18461846+ ret2 = loop_rw_iter(READ, req->file, kiocb, &iter);1865184718661848 /*18671849 * In case of a short read, punt to async. This can happen···18931875 return ret;18941876}1895187718961896-static int io_write_prep(struct io_kiocb *req, struct iovec **iovec,18971897- struct iov_iter *iter, bool force_nonblock)18781878+static int io_write_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,18791879+ bool force_nonblock)18981880{18811881+ struct io_async_ctx *io;18821882+ struct iov_iter iter;18991883 ssize_t ret;1900188419011901- ret = io_prep_rw(req, force_nonblock);18851885+ ret = io_prep_rw(req, sqe, force_nonblock);19021886 if (ret)19031887 return ret;1904188819051889 if (unlikely(!(req->file->f_mode & FMODE_WRITE)))19061890 return -EBADF;1907189119081908- return io_import_iovec(WRITE, req, iovec, iter);18921892+ if (!req->io)18931893+ return 0;18941894+18951895+ io = req->io;18961896+ io->rw.iov = io->rw.fast_iov;18971897+ req->io = NULL;18981898+ ret = io_import_iovec(WRITE, req, &io->rw.iov, &iter);18991899+ req->io = io;19001900+ if (ret < 0)19011901+ return ret;19021902+19031903+ io_req_map_rw(req, ret, io->rw.iov, io->rw.fast_iov, &iter);19041904+ return 0;19091905}1910190619111907static int io_write(struct io_kiocb *req, struct io_kiocb **nxt,19121908 bool force_nonblock)19131909{19141910 struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;19151915- struct kiocb *kiocb = &req->rw;19111911+ struct kiocb *kiocb = &req->rw.kiocb;19161912 struct iov_iter iter;19171917- struct file *file;19181913 size_t iov_count;19191914 ssize_t ret, io_size;1920191519211921- if (!req->io) {19221922- ret = io_write_prep(req, &iovec, &iter, force_nonblock);19231923- if (ret < 0)19241924- return ret;19251925- } else {19261926- ret = io_import_iovec(WRITE, req, &iovec, &iter);19271927- if (ret < 0)19281928- return ret;19291929- }19161916+ ret = io_import_iovec(WRITE, req, &iovec, &iter);19171917+ if (ret < 0)19181918+ return ret;1930191919311920 /* Ensure we clear previously set non-block flag */19321921 if (!force_nonblock)19331933- req->rw.ki_flags &= ~IOCB_NOWAIT;19221922+ req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT;1934192319351935- file = kiocb->ki_filp;19361924 io_size = ret;19371925 if (req->flags & REQ_F_LINK)19381926 req->result = io_size;···19581934 goto copy_iov;1959193519601936 iov_count = iov_iter_count(&iter);19611961- ret = rw_verify_area(WRITE, file, &kiocb->ki_pos, iov_count);19371937+ ret = rw_verify_area(WRITE, req->file, &kiocb->ki_pos, iov_count);19621938 if (!ret) {19631939 ssize_t ret2;19641940···19701946 * we return to userspace.19711947 */19721948 if (req->flags & REQ_F_ISREG) {19731973- __sb_start_write(file_inode(file)->i_sb,19491949+ __sb_start_write(file_inode(req->file)->i_sb,19741950 SB_FREEZE_WRITE, true);19751975- __sb_writers_release(file_inode(file)->i_sb,19511951+ __sb_writers_release(file_inode(req->file)->i_sb,19761952 SB_FREEZE_WRITE);19771953 }19781954 kiocb->ki_flags |= IOCB_WRITE;1979195519801980- if (file->f_op->write_iter)19811981- ret2 = call_write_iter(file, kiocb, &iter);19561956+ if (req->file->f_op->write_iter)19571957+ ret2 = call_write_iter(req->file, kiocb, &iter);19821958 else19831983- ret2 = loop_rw_iter(WRITE, file, kiocb, &iter);19591959+ ret2 = loop_rw_iter(WRITE, req->file, kiocb, &iter);19841960 if (!force_nonblock || ret2 != -EAGAIN) {19851961 kiocb_done(kiocb, ret2, nxt, req->in_async);19861962 } else {···20131989 return 0;20141990}2015199120162016-static int io_prep_fsync(struct io_kiocb *req)19921992+static int io_prep_fsync(struct io_kiocb *req, const struct io_uring_sqe *sqe)20171993{20182018- const struct io_uring_sqe *sqe = req->sqe;20191994 struct io_ring_ctx *ctx = req->ctx;2020199520212021- if (req->flags & REQ_F_PREPPED)20222022- return 0;20231996 if (!req->file)20241997 return -EBADF;20251998···2031201020322011 req->sync.off = READ_ONCE(sqe->off);20332012 req->sync.len = READ_ONCE(sqe->len);20342034- req->flags |= REQ_F_PREPPED;20352013 return 0;20362014}20372015···20562036 if (io_req_cancelled(req))20572037 return;2058203820592059- ret = vfs_fsync_range(req->rw.ki_filp, req->sync.off,20392039+ ret = vfs_fsync_range(req->file, req->sync.off,20602040 end > 0 ? end : LLONG_MAX,20612041 req->sync.flags & IORING_FSYNC_DATASYNC);20622042 if (ret < 0)···20712051 bool force_nonblock)20722052{20732053 struct io_wq_work *work, *old_work;20742074- int ret;20752075-20762076- ret = io_prep_fsync(req);20772077- if (ret)20782078- return ret;2079205420802055 /* fsync always requires a blocking context */20812056 if (force_nonblock) {···20862071 return 0;20872072}2088207320892089-static int io_prep_sfr(struct io_kiocb *req)20742074+static int io_prep_sfr(struct io_kiocb *req, const struct io_uring_sqe *sqe)20902075{20912091- const struct io_uring_sqe *sqe = req->sqe;20922076 struct io_ring_ctx *ctx = req->ctx;2093207720942094- if (req->flags & REQ_F_PREPPED)20952095- return 0;20962078 if (!req->file)20972079 return -EBADF;20982080···21012089 req->sync.off = READ_ONCE(sqe->off);21022090 req->sync.len = READ_ONCE(sqe->len);21032091 req->sync.flags = READ_ONCE(sqe->sync_range_flags);21042104- req->flags |= REQ_F_PREPPED;21052092 return 0;21062093}21072094···21132102 if (io_req_cancelled(req))21142103 return;2115210421162116- ret = sync_file_range(req->rw.ki_filp, req->sync.off, req->sync.len,21052105+ ret = sync_file_range(req->file, req->sync.off, req->sync.len,21172106 req->sync.flags);21182107 if (ret < 0)21192108 req_set_fail_links(req);···21272116 bool force_nonblock)21282117{21292118 struct io_wq_work *work, *old_work;21302130- int ret;21312131-21322132- ret = io_prep_sfr(req);21332133- if (ret)21342134- return ret;2135211921362120 /* sync_file_range always requires a blocking context */21372121 if (force_nonblock) {···21552149}21562150#endif2157215121582158-static int io_sendmsg_prep(struct io_kiocb *req, struct io_async_ctx *io)21522152+static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)21592153{21602154#if defined(CONFIG_NET)21612161- const struct io_uring_sqe *sqe = req->sqe;21622162- struct user_msghdr __user *msg;21632163- unsigned flags;21552155+ struct io_sr_msg *sr = &req->sr_msg;21562156+ struct io_async_ctx *io = req->io;2164215721652165- flags = READ_ONCE(sqe->msg_flags);21662166- msg = (struct user_msghdr __user *)(unsigned long) READ_ONCE(sqe->addr);21582158+ sr->msg_flags = READ_ONCE(sqe->msg_flags);21592159+ sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));21602160+21612161+ if (!io)21622162+ return 0;21632163+21672164 io->msg.iov = io->msg.fast_iov;21682168- return sendmsg_copy_msghdr(&io->msg.msg, msg, flags, &io->msg.iov);21652165+ return sendmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags,21662166+ &io->msg.iov);21692167#else21702170- return 0;21682168+ return -EOPNOTSUPP;21712169#endif21722170}21732171···21792169 bool force_nonblock)21802170{21812171#if defined(CONFIG_NET)21822182- const struct io_uring_sqe *sqe = req->sqe;21832172 struct io_async_msghdr *kmsg = NULL;21842173 struct socket *sock;21852174 int ret;···21922183 struct sockaddr_storage addr;21932184 unsigned flags;2194218521952195- flags = READ_ONCE(sqe->msg_flags);21962196- if (flags & MSG_DONTWAIT)21972197- req->flags |= REQ_F_NOWAIT;21982198- else if (force_nonblock)21992199- flags |= MSG_DONTWAIT;22002200-22012186 if (req->io) {22022187 kmsg = &req->io->msg;22032188 kmsg->msg.msg_name = &addr;···22002197 kmsg->iov = kmsg->fast_iov;22012198 kmsg->msg.msg_iter.iov = kmsg->iov;22022199 } else {22002200+ struct io_sr_msg *sr = &req->sr_msg;22012201+22032202 kmsg = &io.msg;22042203 kmsg->msg.msg_name = &addr;22052205- ret = io_sendmsg_prep(req, &io);22042204+22052205+ io.msg.iov = io.msg.fast_iov;22062206+ ret = sendmsg_copy_msghdr(&io.msg.msg, sr->msg,22072207+ sr->msg_flags, &io.msg.iov);22062208 if (ret)22072207- goto out;22092209+ return ret;22082210 }22112211+22122212+ flags = req->sr_msg.msg_flags;22132213+ if (flags & MSG_DONTWAIT)22142214+ req->flags |= REQ_F_NOWAIT;22152215+ else if (force_nonblock)22162216+ flags |= MSG_DONTWAIT;2209221722102218 ret = __sys_sendmsg_sock(sock, &kmsg->msg, flags);22112219 if (force_nonblock && ret == -EAGAIN) {···22322218 ret = -EINTR;22332219 }2234222022352235-out:22362221 if (!io_wq_current_is_worker() && kmsg && kmsg->iov != kmsg->fast_iov)22372222 kfree(kmsg->iov);22382223 io_cqring_add_event(req, ret);···22442231#endif22452232}2246223322472247-static int io_recvmsg_prep(struct io_kiocb *req, struct io_async_ctx *io)22342234+static int io_recvmsg_prep(struct io_kiocb *req,22352235+ const struct io_uring_sqe *sqe)22482236{22492237#if defined(CONFIG_NET)22502250- const struct io_uring_sqe *sqe = req->sqe;22512251- struct user_msghdr __user *msg;22522252- unsigned flags;22382238+ struct io_sr_msg *sr = &req->sr_msg;22392239+ struct io_async_ctx *io = req->io;2253224022542254- flags = READ_ONCE(sqe->msg_flags);22552255- msg = (struct user_msghdr __user *)(unsigned long) READ_ONCE(sqe->addr);22412241+ sr->msg_flags = READ_ONCE(sqe->msg_flags);22422242+ sr->msg = u64_to_user_ptr(READ_ONCE(sqe->addr));22432243+22442244+ if (!io)22452245+ return 0;22462246+22562247 io->msg.iov = io->msg.fast_iov;22572257- return recvmsg_copy_msghdr(&io->msg.msg, msg, flags, &io->msg.uaddr,22582258- &io->msg.iov);22482248+ return recvmsg_copy_msghdr(&io->msg.msg, sr->msg, sr->msg_flags,22492249+ &io->msg.uaddr, &io->msg.iov);22592250#else22602260- return 0;22512251+ return -EOPNOTSUPP;22612252#endif22622253}22632254···22692252 bool force_nonblock)22702253{22712254#if defined(CONFIG_NET)22722272- const struct io_uring_sqe *sqe = req->sqe;22732255 struct io_async_msghdr *kmsg = NULL;22742256 struct socket *sock;22752257 int ret;···2278226222792263 sock = sock_from_file(req->file, &ret);22802264 if (sock) {22812281- struct user_msghdr __user *msg;22822265 struct io_async_ctx io;22832266 struct sockaddr_storage addr;22842267 unsigned flags;2285226822862286- flags = READ_ONCE(sqe->msg_flags);22872287- if (flags & MSG_DONTWAIT)22882288- req->flags |= REQ_F_NOWAIT;22892289- else if (force_nonblock)22902290- flags |= MSG_DONTWAIT;22912291-22922292- msg = (struct user_msghdr __user *) (unsigned long)22932293- READ_ONCE(sqe->addr);22942269 if (req->io) {22952270 kmsg = &req->io->msg;22962271 kmsg->msg.msg_name = &addr;···22902283 kmsg->iov = kmsg->fast_iov;22912284 kmsg->msg.msg_iter.iov = kmsg->iov;22922285 } else {22862286+ struct io_sr_msg *sr = &req->sr_msg;22872287+22932288 kmsg = &io.msg;22942289 kmsg->msg.msg_name = &addr;22952295- ret = io_recvmsg_prep(req, &io);22902290+22912291+ io.msg.iov = io.msg.fast_iov;22922292+ ret = recvmsg_copy_msghdr(&io.msg.msg, sr->msg,22932293+ sr->msg_flags, &io.msg.uaddr,22942294+ &io.msg.iov);22962295 if (ret)22972297- goto out;22962296+ return ret;22982297 }2299229823002300- ret = __sys_recvmsg_sock(sock, &kmsg->msg, msg, kmsg->uaddr, flags);22992299+ flags = req->sr_msg.msg_flags;23002300+ if (flags & MSG_DONTWAIT)23012301+ req->flags |= REQ_F_NOWAIT;23022302+ else if (force_nonblock)23032303+ flags |= MSG_DONTWAIT;23042304+23052305+ ret = __sys_recvmsg_sock(sock, &kmsg->msg, req->sr_msg.msg,23062306+ kmsg->uaddr, flags);23012307 if (force_nonblock && ret == -EAGAIN) {23022308 if (req->io)23032309 return -EAGAIN;···23242304 ret = -EINTR;23252305 }2326230623272327-out:23282307 if (!io_wq_current_is_worker() && kmsg && kmsg->iov != kmsg->fast_iov)23292308 kfree(kmsg->iov);23302309 io_cqring_add_event(req, ret);···23362317#endif23372318}2338231923392339-static int io_accept_prep(struct io_kiocb *req)23202320+static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)23402321{23412322#if defined(CONFIG_NET)23422342- const struct io_uring_sqe *sqe = req->sqe;23432323 struct io_accept *accept = &req->accept;23442344-23452345- if (req->flags & REQ_F_PREPPED)23462346- return 0;2347232423482325 if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))23492326 return -EINVAL;23502327 if (sqe->ioprio || sqe->len || sqe->buf_index)23512328 return -EINVAL;2352232923532353- accept->addr = (struct sockaddr __user *)23542354- (unsigned long) READ_ONCE(sqe->addr);23552355- accept->addr_len = (int __user *) (unsigned long) READ_ONCE(sqe->addr2);23302330+ accept->addr = u64_to_user_ptr(READ_ONCE(sqe->addr));23312331+ accept->addr_len = u64_to_user_ptr(READ_ONCE(sqe->addr2));23562332 accept->flags = READ_ONCE(sqe->accept_flags);23572357- req->flags |= REQ_F_PREPPED;23582333 return 0;23592334#else23602335 return -EOPNOTSUPP;···23962383#if defined(CONFIG_NET)23972384 int ret;2398238523992399- ret = io_accept_prep(req);24002400- if (ret)24012401- return ret;24022402-24032386 ret = __io_accept(req, nxt, force_nonblock);24042387 if (ret == -EAGAIN && force_nonblock) {24052388 req->work.func = io_accept_finish;···24092400#endif24102401}2411240224122412-static int io_connect_prep(struct io_kiocb *req, struct io_async_ctx *io)24032403+static int io_connect_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)24132404{24142405#if defined(CONFIG_NET)24152415- const struct io_uring_sqe *sqe = req->sqe;24162416- struct sockaddr __user *addr;24172417- int addr_len;24062406+ struct io_connect *conn = &req->connect;24072407+ struct io_async_ctx *io = req->io;2418240824192419- addr = (struct sockaddr __user *) (unsigned long) READ_ONCE(sqe->addr);24202420- addr_len = READ_ONCE(sqe->addr2);24212421- return move_addr_to_kernel(addr, addr_len, &io->connect.address);24092409+ if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))24102410+ return -EINVAL;24112411+ if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags)24122412+ return -EINVAL;24132413+24142414+ conn->addr = u64_to_user_ptr(READ_ONCE(sqe->addr));24152415+ conn->addr_len = READ_ONCE(sqe->addr2);24162416+24172417+ if (!io)24182418+ return 0;24192419+24202420+ return move_addr_to_kernel(conn->addr, conn->addr_len,24212421+ &io->connect.address);24222422#else24232423- return 0;24232423+ return -EOPNOTSUPP;24242424#endif24252425}24262426···24372419 bool force_nonblock)24382420{24392421#if defined(CONFIG_NET)24402440- const struct io_uring_sqe *sqe = req->sqe;24412422 struct io_async_ctx __io, *io;24422423 unsigned file_flags;24432443- int addr_len, ret;24442444-24452445- if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))24462446- return -EINVAL;24472447- if (sqe->ioprio || sqe->len || sqe->buf_index || sqe->rw_flags)24482448- return -EINVAL;24492449-24502450- addr_len = READ_ONCE(sqe->addr2);24512451- file_flags = force_nonblock ? O_NONBLOCK : 0;24242424+ int ret;2452242524532426 if (req->io) {24542427 io = req->io;24552428 } else {24562456- ret = io_connect_prep(req, &__io);24292429+ ret = move_addr_to_kernel(req->connect.addr,24302430+ req->connect.addr_len,24312431+ &__io.connect.address);24572432 if (ret)24582433 goto out;24592434 io = &__io;24602435 }2461243624622462- ret = __sys_connect_file(req->file, &io->connect.address, addr_len,24632463- file_flags);24372437+ file_flags = force_nonblock ? O_NONBLOCK : 0;24382438+24392439+ ret = __sys_connect_file(req->file, &io->connect.address,24402440+ req->connect.addr_len, file_flags);24642441 if ((ret == -EAGAIN || ret == -EINPROGRESS) && force_nonblock) {24652442 if (req->io)24662443 return -EAGAIN;···25262513 return -ENOENT;25272514}2528251525292529-static int io_poll_remove_prep(struct io_kiocb *req)25162516+static int io_poll_remove_prep(struct io_kiocb *req,25172517+ const struct io_uring_sqe *sqe)25302518{25312531- const struct io_uring_sqe *sqe = req->sqe;25322532-25332533- if (req->flags & REQ_F_PREPPED)25342534- return 0;25352519 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))25362520 return -EINVAL;25372521 if (sqe->ioprio || sqe->off || sqe->len || sqe->buf_index ||···25362526 return -EINVAL;2537252725382528 req->poll.addr = READ_ONCE(sqe->addr);25392539- req->flags |= REQ_F_PREPPED;25402529 return 0;25412530}25422531···25482539 struct io_ring_ctx *ctx = req->ctx;25492540 u64 addr;25502541 int ret;25512551-25522552- ret = io_poll_remove_prep(req);25532553- if (ret)25542554- return ret;2555254225562543 addr = req->poll.addr;25572544 spin_lock_irq(&ctx->completion_lock);···26862681 hlist_add_head(&req->hash_node, list);26872682}2688268326892689-static int io_poll_add_prep(struct io_kiocb *req)26842684+static int io_poll_add_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)26902685{26912691- const struct io_uring_sqe *sqe = req->sqe;26922686 struct io_poll_iocb *poll = &req->poll;26932687 u16 events;2694268826952695- if (req->flags & REQ_F_PREPPED)26962696- return 0;26972689 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))26982690 return -EINVAL;26992691 if (sqe->addr || sqe->ioprio || sqe->off || sqe->len || sqe->buf_index)···26982696 if (!poll->file)26992697 return -EBADF;2700269827012701- req->flags |= REQ_F_PREPPED;27022699 events = READ_ONCE(sqe->poll_events);27032700 poll->events = demangle_poll(events) | EPOLLERR | EPOLLHUP;27042701 return 0;···27102709 struct io_poll_table ipt;27112710 bool cancel = false;27122711 __poll_t mask;27132713- int ret;27142714-27152715- ret = io_poll_add_prep(req);27162716- if (ret)27172717- return ret;2718271227192713 INIT_IO_WORK(&req->work, io_poll_complete_work);27202714 INIT_HLIST_NODE(&req->hash_node);···28282832 return 0;28292833}2830283428312831-static int io_timeout_remove_prep(struct io_kiocb *req)28352835+static int io_timeout_remove_prep(struct io_kiocb *req,28362836+ const struct io_uring_sqe *sqe)28322837{28332833- const struct io_uring_sqe *sqe = req->sqe;28342834-28352835- if (req->flags & REQ_F_PREPPED)28362836- return 0;28372838 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))28382839 return -EINVAL;28392840 if (sqe->flags || sqe->ioprio || sqe->buf_index || sqe->len)···28412848 if (req->timeout.flags)28422849 return -EINVAL;2843285028442844- req->flags |= REQ_F_PREPPED;28452851 return 0;28462852}28472853···28512859{28522860 struct io_ring_ctx *ctx = req->ctx;28532861 int ret;28542854-28552855- ret = io_timeout_remove_prep(req);28562856- if (ret)28572857- return ret;2858286228592863 spin_lock_irq(&ctx->completion_lock);28602864 ret = io_timeout_cancel(ctx, req->timeout.addr);···28652877 return 0;28662878}2867287928682868-static int io_timeout_prep(struct io_kiocb *req, struct io_async_ctx *io,28802880+static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,28692881 bool is_timeout_link)28702882{28712871- const struct io_uring_sqe *sqe = req->sqe;28722883 struct io_timeout_data *data;28732884 unsigned flags;28742885···28812894 if (flags & ~IORING_TIMEOUT_ABS)28822895 return -EINVAL;2883289628842884- data = &io->timeout;28972897+ req->timeout.count = READ_ONCE(sqe->off);28982898+28992899+ if (!req->io && io_alloc_async_ctx(req))29002900+ return -ENOMEM;29012901+29022902+ data = &req->io->timeout;28852903 data->req = req;28862904 req->flags |= REQ_F_TIMEOUT;28872905···2904291229052913static int io_timeout(struct io_kiocb *req)29062914{29072907- const struct io_uring_sqe *sqe = req->sqe;29082915 unsigned count;29092916 struct io_ring_ctx *ctx = req->ctx;29102917 struct io_timeout_data *data;29112918 struct list_head *entry;29122919 unsigned span = 0;29132913- int ret;2914292029152915- if (!req->io) {29162916- if (io_alloc_async_ctx(req))29172917- return -ENOMEM;29182918- ret = io_timeout_prep(req, req->io, false);29192919- if (ret)29202920- return ret;29212921- }29222921 data = &req->io->timeout;2923292229242923 /*···29172934 * timeout event to be satisfied. If it isn't set, then this is29182935 * a pure timeout request, sequence isn't used.29192936 */29202920- count = READ_ONCE(sqe->off);29372937+ count = req->timeout.count;29212938 if (!count) {29222939 req->flags |= REQ_F_TIMEOUT_NOSEQ;29232940 spin_lock_irq(&ctx->completion_lock);···30353052 io_put_req_find_next(req, nxt);30363053}3037305430383038-static int io_async_cancel_prep(struct io_kiocb *req)30553055+static int io_async_cancel_prep(struct io_kiocb *req,30563056+ const struct io_uring_sqe *sqe)30393057{30403040- const struct io_uring_sqe *sqe = req->sqe;30413041-30423042- if (req->flags & REQ_F_PREPPED)30433043- return 0;30443058 if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))30453059 return -EINVAL;30463060 if (sqe->flags || sqe->ioprio || sqe->off || sqe->len ||30473061 sqe->cancel_flags)30483062 return -EINVAL;3049306330503050- req->flags |= REQ_F_PREPPED;30513064 req->cancel.addr = READ_ONCE(sqe->addr);30523065 return 0;30533066}···30513072static int io_async_cancel(struct io_kiocb *req, struct io_kiocb **nxt)30523073{30533074 struct io_ring_ctx *ctx = req->ctx;30543054- int ret;30553055-30563056- ret = io_async_cancel_prep(req);30573057- if (ret)30583058- return ret;3059307530603076 io_async_find_and_cancel(ctx, req, req->cancel.addr, nxt, 0);30613077 return 0;30623078}3063307930643064-static int io_req_defer_prep(struct io_kiocb *req)30803080+static int io_req_defer_prep(struct io_kiocb *req,30813081+ const struct io_uring_sqe *sqe)30653082{30663066- struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs;30673067- struct io_async_ctx *io = req->io;30683068- struct iov_iter iter;30693083 ssize_t ret = 0;3070308430713085 switch (req->opcode) {···30663094 break;30673095 case IORING_OP_READV:30683096 case IORING_OP_READ_FIXED:30693069- /* ensure prep does right import */30703070- req->io = NULL;30713071- ret = io_read_prep(req, &iovec, &iter, true);30723072- req->io = io;30733073- if (ret < 0)30743074- break;30753075- io_req_map_rw(req, ret, iovec, inline_vecs, &iter);30763076- ret = 0;30973097+ ret = io_read_prep(req, sqe, true);30773098 break;30783099 case IORING_OP_WRITEV:30793100 case IORING_OP_WRITE_FIXED:30803080- /* ensure prep does right import */30813081- req->io = NULL;30823082- ret = io_write_prep(req, &iovec, &iter, true);30833083- req->io = io;30843084- if (ret < 0)30853085- break;30863086- io_req_map_rw(req, ret, iovec, inline_vecs, &iter);30873087- ret = 0;31013101+ ret = io_write_prep(req, sqe, true);30883102 break;30893103 case IORING_OP_POLL_ADD:30903090- ret = io_poll_add_prep(req);31043104+ ret = io_poll_add_prep(req, sqe);30913105 break;30923106 case IORING_OP_POLL_REMOVE:30933093- ret = io_poll_remove_prep(req);31073107+ ret = io_poll_remove_prep(req, sqe);30943108 break;30953109 case IORING_OP_FSYNC:30963096- ret = io_prep_fsync(req);31103110+ ret = io_prep_fsync(req, sqe);30973111 break;30983112 case IORING_OP_SYNC_FILE_RANGE:30993099- ret = io_prep_sfr(req);31133113+ ret = io_prep_sfr(req, sqe);31003114 break;31013115 case IORING_OP_SENDMSG:31023102- ret = io_sendmsg_prep(req, io);31163116+ ret = io_sendmsg_prep(req, sqe);31033117 break;31043118 case IORING_OP_RECVMSG:31053105- ret = io_recvmsg_prep(req, io);31193119+ ret = io_recvmsg_prep(req, sqe);31063120 break;31073121 case IORING_OP_CONNECT:31083108- ret = io_connect_prep(req, io);31223122+ ret = io_connect_prep(req, sqe);31093123 break;31103124 case IORING_OP_TIMEOUT:31113111- ret = io_timeout_prep(req, io, false);31253125+ ret = io_timeout_prep(req, sqe, false);31123126 break;31133127 case IORING_OP_TIMEOUT_REMOVE:31143114- ret = io_timeout_remove_prep(req);31283128+ ret = io_timeout_remove_prep(req, sqe);31153129 break;31163130 case IORING_OP_ASYNC_CANCEL:31173117- ret = io_async_cancel_prep(req);31313131+ ret = io_async_cancel_prep(req, sqe);31183132 break;31193133 case IORING_OP_LINK_TIMEOUT:31203120- ret = io_timeout_prep(req, io, true);31343134+ ret = io_timeout_prep(req, sqe, true);31213135 break;31223136 case IORING_OP_ACCEPT:31233123- ret = io_accept_prep(req);31373137+ ret = io_accept_prep(req, sqe);31243138 break;31253139 default:31263140 printk_once(KERN_WARNING "io_uring: unhandled opcode %d\n",···31183160 return ret;31193161}3120316231213121-static int io_req_defer(struct io_kiocb *req)31633163+static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)31223164{31233165 struct io_ring_ctx *ctx = req->ctx;31243166 int ret;···31273169 if (!req_need_defer(req) && list_empty(&ctx->defer_list))31283170 return 0;3129317131303130- if (io_alloc_async_ctx(req))31723172+ if (!req->io && io_alloc_async_ctx(req))31313173 return -EAGAIN;3132317431333133- ret = io_req_defer_prep(req);31753175+ ret = io_req_defer_prep(req, sqe);31343176 if (ret < 0)31353177 return ret;31363178···31463188 return -EIOCBQUEUED;31473189}3148319031493149-__attribute__((nonnull))31503150-static int io_issue_sqe(struct io_kiocb *req, struct io_kiocb **nxt,31513151- bool force_nonblock)31913191+static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,31923192+ struct io_kiocb **nxt, bool force_nonblock)31523193{31533194 struct io_ring_ctx *ctx = req->ctx;31543195 int ret;···31573200 ret = io_nop(req);31583201 break;31593202 case IORING_OP_READV:31603160- if (unlikely(req->sqe->buf_index))31613161- return -EINVAL;32033203+ case IORING_OP_READ_FIXED:32043204+ if (sqe) {32053205+ ret = io_read_prep(req, sqe, force_nonblock);32063206+ if (ret < 0)32073207+ break;32083208+ }31623209 ret = io_read(req, nxt, force_nonblock);31633210 break;31643211 case IORING_OP_WRITEV:31653165- if (unlikely(req->sqe->buf_index))31663166- return -EINVAL;31673167- ret = io_write(req, nxt, force_nonblock);31683168- break;31693169- case IORING_OP_READ_FIXED:31703170- ret = io_read(req, nxt, force_nonblock);31713171- break;31723212 case IORING_OP_WRITE_FIXED:32133213+ if (sqe) {32143214+ ret = io_write_prep(req, sqe, force_nonblock);32153215+ if (ret < 0)32163216+ break;32173217+ }31733218 ret = io_write(req, nxt, force_nonblock);31743219 break;31753220 case IORING_OP_FSYNC:32213221+ if (sqe) {32223222+ ret = io_prep_fsync(req, sqe);32233223+ if (ret < 0)32243224+ break;32253225+ }31763226 ret = io_fsync(req, nxt, force_nonblock);31773227 break;31783228 case IORING_OP_POLL_ADD:32293229+ if (sqe) {32303230+ ret = io_poll_add_prep(req, sqe);32313231+ if (ret)32323232+ break;32333233+ }31793234 ret = io_poll_add(req, nxt);31803235 break;31813236 case IORING_OP_POLL_REMOVE:32373237+ if (sqe) {32383238+ ret = io_poll_remove_prep(req, sqe);32393239+ if (ret < 0)32403240+ break;32413241+ }31823242 ret = io_poll_remove(req);31833243 break;31843244 case IORING_OP_SYNC_FILE_RANGE:32453245+ if (sqe) {32463246+ ret = io_prep_sfr(req, sqe);32473247+ if (ret < 0)32483248+ break;32493249+ }31853250 ret = io_sync_file_range(req, nxt, force_nonblock);31863251 break;31873252 case IORING_OP_SENDMSG:32533253+ if (sqe) {32543254+ ret = io_sendmsg_prep(req, sqe);32553255+ if (ret < 0)32563256+ break;32573257+ }31883258 ret = io_sendmsg(req, nxt, force_nonblock);31893259 break;31903260 case IORING_OP_RECVMSG:32613261+ if (sqe) {32623262+ ret = io_recvmsg_prep(req, sqe);32633263+ if (ret)32643264+ break;32653265+ }31913266 ret = io_recvmsg(req, nxt, force_nonblock);31923267 break;31933268 case IORING_OP_TIMEOUT:32693269+ if (sqe) {32703270+ ret = io_timeout_prep(req, sqe, false);32713271+ if (ret)32723272+ break;32733273+ }31943274 ret = io_timeout(req);31953275 break;31963276 case IORING_OP_TIMEOUT_REMOVE:32773277+ if (sqe) {32783278+ ret = io_timeout_remove_prep(req, sqe);32793279+ if (ret)32803280+ break;32813281+ }31973282 ret = io_timeout_remove(req);31983283 break;31993284 case IORING_OP_ACCEPT:32853285+ if (sqe) {32863286+ ret = io_accept_prep(req, sqe);32873287+ if (ret)32883288+ break;32893289+ }32003290 ret = io_accept(req, nxt, force_nonblock);32013291 break;32023292 case IORING_OP_CONNECT:32933293+ if (sqe) {32943294+ ret = io_connect_prep(req, sqe);32953295+ if (ret)32963296+ break;32973297+ }32033298 ret = io_connect(req, nxt, force_nonblock);32043299 break;32053300 case IORING_OP_ASYNC_CANCEL:33013301+ if (sqe) {33023302+ ret = io_async_cancel_prep(req, sqe);33033303+ if (ret)33043304+ break;33053305+ }32063306 ret = io_async_cancel(req, nxt);32073307 break;32083308 default:···33033289 req->has_user = (work->flags & IO_WQ_WORK_HAS_MM) != 0;33043290 req->in_async = true;33053291 do {33063306- ret = io_issue_sqe(req, &nxt, false);32923292+ ret = io_issue_sqe(req, NULL, &nxt, false);33073293 /*33083294 * We can get EAGAIN for polled IO even though we're33093295 * forcing a sync submission from here, since we can't···33693355 return table->files[index & IORING_FILE_TABLE_MASK];33703356}3371335733723372-static int io_req_set_file(struct io_submit_state *state, struct io_kiocb *req)33583358+static int io_req_set_file(struct io_submit_state *state, struct io_kiocb *req,33593359+ const struct io_uring_sqe *sqe)33733360{33743361 struct io_ring_ctx *ctx = req->ctx;33753362 unsigned flags;33763363 int fd, ret;3377336433783378- flags = READ_ONCE(req->sqe->flags);33793379- fd = READ_ONCE(req->sqe->fd);33653365+ flags = READ_ONCE(sqe->flags);33663366+ fd = READ_ONCE(sqe->fd);3380336733813368 if (flags & IOSQE_IO_DRAIN)33823369 req->flags |= REQ_F_IO_DRAIN;···35093494 return nxt;35103495}3511349635123512-static void __io_queue_sqe(struct io_kiocb *req)34973497+static void __io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe)35133498{35143499 struct io_kiocb *linked_timeout;35153500 struct io_kiocb *nxt = NULL;···35183503again:35193504 linked_timeout = io_prep_linked_timeout(req);3520350535213521- ret = io_issue_sqe(req, &nxt, true);35063506+ ret = io_issue_sqe(req, sqe, &nxt, true);3522350735233508 /*35243509 * We async punt it if the file wasn't marked NOWAIT, or if the file···35653550 }35663551}3567355235683568-static void io_queue_sqe(struct io_kiocb *req)35533553+static void io_queue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe)35693554{35703555 int ret;35713556···35753560 }35763561 req->ctx->drain_next = (req->flags & REQ_F_DRAIN_LINK);3577356235783578- ret = io_req_defer(req);35633563+ ret = io_req_defer(req, sqe);35793564 if (ret) {35803565 if (ret != -EIOCBQUEUED) {35813566 io_cqring_add_event(req, ret);···35833568 io_double_put_req(req);35843569 }35853570 } else35863586- __io_queue_sqe(req);35713571+ __io_queue_sqe(req, sqe);35873572}3588357335893574static inline void io_queue_link_head(struct io_kiocb *req)···35923577 io_cqring_add_event(req, -ECANCELED);35933578 io_double_put_req(req);35943579 } else35953595- io_queue_sqe(req);35803580+ io_queue_sqe(req, NULL);35963581}3597358235983583#define SQE_VALID_FLAGS (IOSQE_FIXED_FILE|IOSQE_IO_DRAIN|IOSQE_IO_LINK| \35993584 IOSQE_IO_HARDLINK)3600358536013601-static bool io_submit_sqe(struct io_kiocb *req, struct io_submit_state *state,36023602- struct io_kiocb **link)35863586+static bool io_submit_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,35873587+ struct io_submit_state *state, struct io_kiocb **link)36033588{36043589 struct io_ring_ctx *ctx = req->ctx;36053590 int ret;3606359136073592 /* enforce forwards compatibility on users */36083608- if (unlikely(req->sqe->flags & ~SQE_VALID_FLAGS)) {35933593+ if (unlikely(sqe->flags & ~SQE_VALID_FLAGS)) {36093594 ret = -EINVAL;36103595 goto err_req;36113596 }3612359736133613- ret = io_req_set_file(state, req);35983598+ ret = io_req_set_file(state, req, sqe);36143599 if (unlikely(ret)) {36153600err_req:36163601 io_cqring_add_event(req, ret);···36283613 if (*link) {36293614 struct io_kiocb *prev = *link;3630361536313631- if (req->sqe->flags & IOSQE_IO_DRAIN)36163616+ if (sqe->flags & IOSQE_IO_DRAIN)36323617 (*link)->flags |= REQ_F_DRAIN_LINK | REQ_F_IO_DRAIN;3633361836343634- if (req->sqe->flags & IOSQE_IO_HARDLINK)36193619+ if (sqe->flags & IOSQE_IO_HARDLINK)36353620 req->flags |= REQ_F_HARDLINK;3636362136373622 if (io_alloc_async_ctx(req)) {···36393624 goto err_req;36403625 }3641362636423642- ret = io_req_defer_prep(req);36273627+ ret = io_req_defer_prep(req, sqe);36433628 if (ret) {36443629 /* fail even hard links since we don't submit */36453630 prev->flags |= REQ_F_FAIL_LINK;···36473632 }36483633 trace_io_uring_link(ctx, req, prev);36493634 list_add_tail(&req->link_list, &prev->link_list);36503650- } else if (req->sqe->flags & (IOSQE_IO_LINK|IOSQE_IO_HARDLINK)) {36353635+ } else if (sqe->flags & (IOSQE_IO_LINK|IOSQE_IO_HARDLINK)) {36513636 req->flags |= REQ_F_LINK;36523652- if (req->sqe->flags & IOSQE_IO_HARDLINK)36373637+ if (sqe->flags & IOSQE_IO_HARDLINK)36533638 req->flags |= REQ_F_HARDLINK;3654363936553640 INIT_LIST_HEAD(&req->link_list);36413641+ ret = io_req_defer_prep(req, sqe);36423642+ if (ret)36433643+ req->flags |= REQ_F_FAIL_LINK;36563644 *link = req;36573645 } else {36583658- io_queue_sqe(req);36463646+ io_queue_sqe(req, sqe);36593647 }3660364836613649 return true;···37033685}3704368637053687/*37063706- * Fetch an sqe, if one is available. Note that req->sqe will point to memory36883688+ * Fetch an sqe, if one is available. Note that sqe_ptr will point to memory37073689 * that is mapped by userspace. This means that care needs to be taken to37083690 * ensure that reads are stable, as we cannot rely on userspace always37093691 * being a good citizen. If members of the sqe are validated and then later37103692 * used, it's important that those reads are done through READ_ONCE() to37113693 * prevent a re-load down the line.37123694 */37133713-static bool io_get_sqring(struct io_ring_ctx *ctx, struct io_kiocb *req)36953695+static bool io_get_sqring(struct io_ring_ctx *ctx, struct io_kiocb *req,36963696+ const struct io_uring_sqe **sqe_ptr)37143697{37153698 struct io_rings *rings = ctx->rings;37163699 u32 *sq_array = ctx->sq_array;···37383719 * link list.37393720 */37403721 req->sequence = ctx->cached_sq_head;37413741- req->sqe = &ctx->sq_sqes[head];37423742- req->opcode = READ_ONCE(req->sqe->opcode);37433743- req->user_data = READ_ONCE(req->sqe->user_data);37223722+ *sqe_ptr = &ctx->sq_sqes[head];37233723+ req->opcode = READ_ONCE((*sqe_ptr)->opcode);37243724+ req->user_data = READ_ONCE((*sqe_ptr)->user_data);37443725 ctx->cached_sq_head++;37453726 return true;37463727 }···37723753 }3773375437743755 for (i = 0; i < nr; i++) {37563756+ const struct io_uring_sqe *sqe;37753757 struct io_kiocb *req;37763758 unsigned int sqe_flags;37773759···37823762 submitted = -EAGAIN;37833763 break;37843764 }37853785- if (!io_get_sqring(ctx, req)) {37653765+ if (!io_get_sqring(ctx, req, &sqe)) {37863766 __io_free_req(req);37873767 break;37883768 }···37963776 }3797377737983778 submitted++;37993799- sqe_flags = req->sqe->flags;37793779+ sqe_flags = sqe->flags;3800378038013781 req->ring_file = ring_file;38023782 req->ring_fd = ring_fd;···38043784 req->in_async = async;38053785 req->needs_fixed_file = async;38063786 trace_io_uring_submit_sqe(ctx, req->user_data, true, async);38073807- if (!io_submit_sqe(req, statep, &link))37873787+ if (!io_submit_sqe(req, sqe, statep, &link))38083788 break;38093789 /*38103790 * If previous wasn't linked and we have a linked command,···47224702 if (copy_from_user(&ciov, &ciovs[index], sizeof(ciov)))47234703 return -EFAULT;4724470447254725- dst->iov_base = (void __user *) (unsigned long) ciov.iov_base;47054705+ dst->iov_base = u64_to_user_ptr((u64)ciov.iov_base);47264706 dst->iov_len = ciov.iov_len;47274707 return 0;47284708 }
+1-1
fs/locks.c
···28532853 }28542854 if (inode) {28552855 /* userspace relies on this representation of dev_t */28562856- seq_printf(f, "%d %02x:%02x:%ld ", fl_pid,28562856+ seq_printf(f, "%d %02x:%02x:%lu ", fl_pid,28572857 MAJOR(inode->i_sb->s_dev),28582858 MINOR(inode->i_sb->s_dev), inode->i_ino);28592859 } else {
+4
fs/notify/fsnotify.c
···5757 * doing an __iget/iput with SB_ACTIVE clear would actually5858 * evict all inodes with zero i_count from icache which is5959 * unnecessarily violent and may in fact be illegal to do.6060+ * However, we should have been called /after/ evict_inodes6161+ * removed all zero refcount inodes, in any case. Test to6262+ * be sure.6063 */6164 if (!atomic_read(&inode->i_count)) {6265 spin_unlock(&inode->i_lock);···80778178 iput_inode = inode;82798080+ cond_resched();8381 spin_lock(&sb->s_inode_list_lock);8482 }8583 spin_unlock(&sb->s_inode_list_lock);
···448448 sync_filesystem(sb);449449 sb->s_flags &= ~SB_ACTIVE;450450451451- fsnotify_sb_delete(sb);452451 cgroup_writeback_umount();453452453453+ /* evict all inodes with zero refcount */454454 evict_inodes(sb);455455+ /* only nonzero refcount inodes can have marks */456456+ fsnotify_sb_delete(sb);455457456458 if (sb->s_dio_done_wq) {457459 destroy_workqueue(sb->s_dio_done_wq);
···6969 *7070 * @ops: Functional interface to the clock7171 * @cdev: Character device instance for this clock7272- * @kref: Reference count.7272+ * @dev: Pointer to the clock's device.7373 * @rwsem: Protects the 'zombie' field from concurrent access.7474 * @zombie: If 'zombie' is true, then the hardware has disappeared.7575- * @release: A function to free the structure when the reference count reaches7676- * zero. May be NULL if structure is statically allocated.7775 *7876 * Drivers should embed their struct posix_clock within a private7977 * structure, obtaining a reference to it during callbacks using8078 * container_of().7979+ *8080+ * Drivers should supply an initialized but not exposed struct device8181+ * to posix_clock_register(). It is used to manage lifetime of the8282+ * driver's private structure. It's 'release' field should be set to8383+ * a release function for this private structure.8184 */8285struct posix_clock {8386 struct posix_clock_operations ops;8487 struct cdev cdev;8585- struct kref kref;8888+ struct device *dev;8689 struct rw_semaphore rwsem;8790 bool zombie;8888- void (*release)(struct posix_clock *clk);8991};90929193/**9294 * posix_clock_register() - register a new clock9393- * @clk: Pointer to the clock. Caller must provide 'ops' and 'release'9494- * @devid: Allocated device id9595+ * @clk: Pointer to the clock. Caller must provide 'ops' field9696+ * @dev: Pointer to the initialized device. Caller must provide9797+ * 'release' field9598 *9699 * A clock driver calls this function to register itself with the97100 * clock device subsystem. If 'clk' points to dynamically allocated···103100 *104101 * Returns zero on success, non-zero otherwise.105102 */106106-int posix_clock_register(struct posix_clock *clk, dev_t devid);103103+int posix_clock_register(struct posix_clock *clk, struct device *dev);107104108105/**109106 * posix_clock_unregister() - unregister a clock
···4545 case NETDEV_CHANGE: /* Link (carrier) state changes */4646 hsr_check_carrier_and_operstate(hsr);4747 break;4848+ case NETDEV_CHANGENAME:4949+ if (is_hsr_master(dev))5050+ hsr_debugfs_rename(dev);5151+ break;4852 case NETDEV_CHANGEADDR:4953 if (port->type == HSR_PT_MASTER) {5054 /* This should not happen since there's no···68646965 /* Make sure we recognize frames from ourselves in hsr_rcv() */7066 port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);7171- res = hsr_create_self_node(&hsr->self_node_db,6767+ res = hsr_create_self_node(hsr,7268 master->dev->dev_addr,7369 port ?7470 port->dev->dev_addr :···127123{128124 unregister_netdevice_notifier(&hsr_nb);129125 hsr_netlink_exit();126126+ hsr_debugfs_remove_root();130127}131128132129module_init(hsr_init);
+15-7
net/hsr/hsr_main.h
···160160 int announce_count;161161 u16 sequence_nr;162162 u16 sup_sequence_nr; /* For HSRv1 separate seq_nr for supervision */163163- u8 prot_version; /* Indicate if HSRv0 or HSRv1. */164164- spinlock_t seqnr_lock; /* locking for sequence_nr */163163+ u8 prot_version; /* Indicate if HSRv0 or HSRv1. */164164+ spinlock_t seqnr_lock; /* locking for sequence_nr */165165+ spinlock_t list_lock; /* locking for node list */165166 unsigned char sup_multicast_addr[ETH_ALEN];166167#ifdef CONFIG_DEBUG_FS167168 struct dentry *node_tbl_root;···185184}186185187186#if IS_ENABLED(CONFIG_DEBUG_FS)188188-int hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev);187187+void hsr_debugfs_rename(struct net_device *dev);188188+void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev);189189void hsr_debugfs_term(struct hsr_priv *priv);190190+void hsr_debugfs_create_root(void);191191+void hsr_debugfs_remove_root(void);190192#else191191-static inline int hsr_debugfs_init(struct hsr_priv *priv,192192- struct net_device *hsr_dev)193193+static inline void void hsr_debugfs_rename(struct net_device *dev)193194{194194- return 0;195195}196196-196196+static inline void hsr_debugfs_init(struct hsr_priv *priv,197197+ struct net_device *hsr_dev)198198+{}197199static inline void hsr_debugfs_term(struct hsr_priv *priv)200200+{}201201+static inline void hsr_debugfs_create_root(void)202202+{}203203+static inline void hsr_debugfs_remove_root(void)198204{}199205#endif200206
···193193}194194195195/*196196- * Ping the other end to fill our RTT cache and to retrieve the rwind197197- * and MTU parameters.198198- */199199-static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb)200200-{201201- struct rxrpc_skb_priv *sp = rxrpc_skb(skb);202202- ktime_t now = skb->tstamp;203203-204204- if (call->peer->rtt_usage < 3 ||205205- ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now))206206- rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,207207- true, true,208208- rxrpc_propose_ack_ping_for_params);209209-}210210-211211-/*212196 * Apply a hard ACK by advancing the Tx window.213197 */214198static bool rxrpc_rotate_tx_window(struct rxrpc_call *call, rxrpc_seq_t to,···13801396 call = rxrpc_new_incoming_call(local, rx, skb);13811397 if (!call)13821398 goto reject_packet;13831383- rxrpc_send_ping(call, skb);13841384- mutex_unlock(&call->user_mutex);13851399 }1386140013871401 /* Process a call packet; this either discards or passes on the ref
···11081108 return err;11091109}1110111011111111-static bool u32_hnode_empty(struct tc_u_hnode *ht, bool *non_root_ht)11121112-{11131113- int i;11141114-11151115- if (!ht)11161116- return true;11171117- if (!ht->is_root) {11181118- *non_root_ht = true;11191119- return false;11201120- }11211121- if (*non_root_ht)11221122- return false;11231123- if (ht->refcnt < 2)11241124- return true;11251125-11261126- for (i = 0; i <= ht->divisor; i++) {11271127- if (rtnl_dereference(ht->ht[i]))11281128- return false;11291129- }11301130- return true;11311131-}11321132-11331111static void u32_walk(struct tcf_proto *tp, struct tcf_walker *arg,11341112 bool rtnl_held)11351113{11361114 struct tc_u_common *tp_c = tp->data;11371137- bool non_root_ht = false;11381115 struct tc_u_hnode *ht;11391116 struct tc_u_knode *n;11401117 unsigned int h;···11241147 ht = rtnl_dereference(ht->next)) {11251148 if (ht->prio != tp->prio)11261149 continue;11271127- if (u32_hnode_empty(ht, &non_root_ht))11281128- return;11291150 if (arg->count >= arg->skip) {11301151 if (arg->fn(tp, ht, arg) < 0) {11311152 arg->stop = 1;
+8-9
net/sched/sch_fq.c
···301301 f->socket_hash != sk->sk_hash)) {302302 f->credit = q->initial_quantum;303303 f->socket_hash = sk->sk_hash;304304+ if (q->rate_enable)305305+ smp_store_release(&sk->sk_pacing_status,306306+ SK_PACING_FQ);304307 if (fq_flow_is_throttled(f))305308 fq_flow_unset_throttled(q, f);306309 f->time_next_packet = 0ULL;···325322326323 fq_flow_set_detached(f);327324 f->sk = sk;328328- if (skb->sk == sk)325325+ if (skb->sk == sk) {329326 f->socket_hash = sk->sk_hash;327327+ if (q->rate_enable)328328+ smp_store_release(&sk->sk_pacing_status,329329+ SK_PACING_FQ);330330+ }330331 f->credit = q->initial_quantum;331332332333 rb_link_node(&f->fq_node, parent, p);···435428 f->qlen++;436429 qdisc_qstats_backlog_inc(sch, skb);437430 if (fq_flow_is_detached(f)) {438438- struct sock *sk = skb->sk;439439-440431 fq_flow_add_tail(&q->new_flows, f);441432 if (time_after(jiffies, f->age + q->flow_refill_delay))442433 f->credit = max_t(u32, f->credit, q->quantum);443443- if (sk && q->rate_enable) {444444- if (unlikely(smp_load_acquire(&sk->sk_pacing_status) !=445445- SK_PACING_FQ))446446- smp_store_release(&sk->sk_pacing_status,447447- SK_PACING_FQ);448448- }449434 q->inactive_flows--;450435 }451436
+15-15
net/sctp/stream.c
···8484 return 0;85858686 ret = genradix_prealloc(&stream->out, outcnt, gfp);8787- if (ret) {8888- genradix_free(&stream->out);8787+ if (ret)8988 return ret;9090- }91899290 stream->outcnt = outcnt;9391 return 0;···100102 return 0;101103102104 ret = genradix_prealloc(&stream->in, incnt, gfp);103103- if (ret) {104104- genradix_free(&stream->in);105105+ if (ret)105106 return ret;106106- }107107108108 stream->incnt = incnt;109109 return 0;···119123 * a new one with new outcnt to save memory if needed.120124 */121125 if (outcnt == stream->outcnt)122122- goto in;126126+ goto handle_in;123127124128 /* Filter out chunks queued on streams that won't exist anymore */125129 sched->unsched_all(stream);···128132129133 ret = sctp_stream_alloc_out(stream, outcnt, gfp);130134 if (ret)131131- goto out;135135+ goto out_err;132136133137 for (i = 0; i < stream->outcnt; i++)134138 SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;135139136136-in:140140+handle_in:137141 sctp_stream_interleave_init(stream);138142 if (!incnt)139143 goto out;140144141145 ret = sctp_stream_alloc_in(stream, incnt, gfp);142142- if (ret) {143143- sched->free(stream);144144- genradix_free(&stream->out);145145- stream->outcnt = 0;146146- goto out;147147- }146146+ if (ret)147147+ goto in_err;148148149149+ goto out;150150+151151+in_err:152152+ sched->free(stream);153153+ genradix_free(&stream->in);154154+out_err:155155+ genradix_free(&stream->out);156156+ stream->outcnt = 0;149157out:150158 return ret;151159}
···3131 TEST_FAILURE = auto()32323333def create_default_kunitconfig():3434- if not os.path.exists(kunit_kernel.KUNITCONFIG_PATH):3434+ if not os.path.exists(kunit_kernel.kunitconfig_path):3535 shutil.copyfile('arch/um/configs/kunit_defconfig',3636- kunit_kernel.KUNITCONFIG_PATH)3636+ kunit_kernel.kunitconfig_path)37373838def run_tests(linux: kunit_kernel.LinuxSourceTree,3939 request: KunitRequest) -> KunitResult:4040- if request.defconfig:4141- create_default_kunitconfig()4242-4340 config_start = time.time()4441 success = linux.build_reconfig(request.build_dir)4542 config_end = time.time()···105108 run_parser.add_argument('--build_dir',106109 help='As in the make command, it specifies the build '107110 'directory.',108108- type=str, default=None, metavar='build_dir')111111+ type=str, default='', metavar='build_dir')109112110113 run_parser.add_argument('--defconfig',111111- help='Uses a default kunitconfig.',114114+ help='Uses a default .kunitconfig.',112115 action='store_true')113116114117 cli_args = parser.parse_args(argv)115118116119 if cli_args.subcommand == 'run':120120+ if cli_args.build_dir:121121+ if not os.path.exists(cli_args.build_dir):122122+ os.mkdir(cli_args.build_dir)123123+ kunit_kernel.kunitconfig_path = os.path.join(124124+ cli_args.build_dir,125125+ kunit_kernel.kunitconfig_path)126126+117127 if cli_args.defconfig:118128 create_default_kunitconfig()119129
+5-5
tools/testing/kunit/kunit_kernel.py
···1414import kunit_config15151616KCONFIG_PATH = '.config'1717-KUNITCONFIG_PATH = 'kunitconfig'1717+kunitconfig_path = '.kunitconfig'18181919class ConfigError(Exception):2020 """Represents an error trying to configure the Linux kernel."""···82828383 def __init__(self):8484 self._kconfig = kunit_config.Kconfig()8585- self._kconfig.read_from_file(KUNITCONFIG_PATH)8585+ self._kconfig.read_from_file(kunitconfig_path)8686 self._ops = LinuxSourceTreeOperations()87878888 def clean(self):···111111 return True112112113113 def build_reconfig(self, build_dir):114114- """Creates a new .config if it is not a subset of the kunitconfig."""114114+ """Creates a new .config if it is not a subset of the .kunitconfig."""115115 kconfig_path = get_kconfig_path(build_dir)116116 if os.path.exists(kconfig_path):117117 existing_kconfig = kunit_config.Kconfig()···140140 return False141141 return True142142143143- def run_kernel(self, args=[], timeout=None, build_dir=None):143143+ def run_kernel(self, args=[], timeout=None, build_dir=''):144144 args.extend(['mem=256M'])145145 process = self._ops.linux_bin(args, timeout, build_dir)146146- with open('test.log', 'w') as f:146146+ with open(os.path.join(build_dir, 'test.log'), 'w') as f:147147 for line in process.stdout:148148 f.write(line.rstrip().decode('ascii') + '\n')149149 yield line.rstrip().decode('ascii')
···151151$(BPFOBJ): force152152 $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/153153154154-BPF_HELPERS := $(BPFDIR)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h)155155-$(BPFDIR)/bpf_helper_defs.h:156156- $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ bpf_helper_defs.h154154+BPF_HELPERS := $(OUTPUT)/bpf_helper_defs.h $(wildcard $(BPFDIR)/bpf_*.h)155155+$(OUTPUT)/bpf_helper_defs.h:156156+ $(MAKE) -C $(BPFDIR) OUTPUT=$(OUTPUT)/ $(OUTPUT)/bpf_helper_defs.h157157158158# Get Clang's default includes on this system, as opposed to those seen by159159# '-target bpf'. This fixes "missing" files on some architectures/distros,
···34343535check_mods()3636{3737+ local uid=$(id -u)3838+ if [ $uid -ne 0 ]; then3939+ echo "skip all tests: must be run as root" >&24040+ exit $ksft_skip4141+ fi4242+3743 trap "test_modprobe" EXIT3844 if [ ! -d $DIR ]; then3945 modprobe test_firmware
+14-1
tools/testing/selftests/livepatch/functions.sh
···77MAX_RETRIES=60088RETRY_INTERVAL=".1" # seconds991010+# Kselftest framework requirement - SKIP code is 41111+ksft_skip=41212+1013# log(msg) - write message to kernel log1114# msg - insightful words1215function log() {···2118function skip() {2219 log "SKIP: $1"2320 echo "SKIP: $1" >&22424- exit 42121+ exit $ksft_skip2222+}2323+2424+# root test2525+function is_root() {2626+ uid=$(id -u)2727+ if [ $uid -ne 0 ]; then2828+ echo "skip all tests: must be run as root" >&22929+ exit $ksft_skip3030+ fi2531}26322733# die(msg) - game over, man···7462# for verbose livepatching output and turn on7563# the ftrace_enabled sysctl.7664function setup_config() {6565+ is_root7766 push_config7867 set_dynamic_debug7968 set_ftrace_enabled 1
+1-2
tools/testing/selftests/livepatch/test-state.sh
···88MOD_LIVEPATCH2=test_klp_state299MOD_LIVEPATCH3=test_klp_state310101111-set_dynamic_debug1212-1111+setup_config13121413# TEST: Loading and removing a module that modifies the system state1514
···226226 return 0227227}228228229229-test_tcp_forwarding()229229+test_tcp_forwarding_ip()230230{231231 local nsa=$1232232 local nsb=$2233233+ local dstip=$3234234+ local dstport=$4233235 local lret=0234236235237 ip netns exec $nsb nc -w 5 -l -p 12345 < "$ns2in" > "$ns2out" &236238 lpid=$!237239238240 sleep 1239239- ip netns exec $nsa nc -w 4 10.0.2.99 12345 < "$ns1in" > "$ns1out" &241241+ ip netns exec $nsa nc -w 4 "$dstip" "$dstport" < "$ns1in" > "$ns1out" &240242 cpid=$!241243242244 sleep 3···255253 check_transfer "$ns2in" "$ns1out" "ns1 <- ns2"256254 if [ $? -ne 0 ];then257255 lret=1256256+ fi257257+258258+ return $lret259259+}260260+261261+test_tcp_forwarding()262262+{263263+ test_tcp_forwarding_ip "$1" "$2" 10.0.2.99 12345264264+265265+ return $?266266+}267267+268268+test_tcp_forwarding_nat()269269+{270270+ local lret271271+272272+ test_tcp_forwarding_ip "$1" "$2" 10.0.2.99 12345273273+ lret=$?274274+275275+ if [ $lret -eq 0 ] ; then276276+ test_tcp_forwarding_ip "$1" "$2" 10.6.6.6 1666277277+ lret=$?258278 fi259279260280 return $lret···307283# Same, but with NAT enabled.308284ip netns exec nsr1 nft -f - <<EOF309285table ip nat {286286+ chain prerouting {287287+ type nat hook prerouting priority 0; policy accept;288288+ meta iif "veth0" ip daddr 10.6.6.6 tcp dport 1666 counter dnat ip to 10.0.2.99:12345289289+ }290290+310291 chain postrouting {311292 type nat hook postrouting priority 0; policy accept;312312- meta oifname "veth1" masquerade293293+ meta oifname "veth1" counter masquerade313294 }314295}315296EOF316297317317-test_tcp_forwarding ns1 ns2298298+test_tcp_forwarding_nat ns1 ns2318299319300if [ $? -eq 0 ] ;then320301 echo "PASS: flow offloaded for ns1/ns2 with NAT"···342313ip netns exec ns1 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null343314ip netns exec ns2 sysctl net.ipv4.ip_no_pmtu_disc=0 > /dev/null344315345345-test_tcp_forwarding ns1 ns2316316+test_tcp_forwarding_nat ns1 ns2346317if [ $? -eq 0 ] ;then347318 echo "PASS: flow offloaded for ns1/ns2 with NAT and pmtu discovery"348319else
+10-8
tools/testing/selftests/rseq/param_test.c
···1515#include <errno.h>1616#include <stddef.h>17171818-static inline pid_t gettid(void)1818+static inline pid_t rseq_gettid(void)1919{2020 return syscall(__NR_gettid);2121}···373373 rseq_percpu_unlock(&data->lock, cpu);374374#ifndef BENCHMARK375375 if (i != 0 && !(i % (reps / 10)))376376- printf_verbose("tid %d: count %lld\n", (int) gettid(), i);376376+ printf_verbose("tid %d: count %lld\n",377377+ (int) rseq_gettid(), i);377378#endif378379 }379380 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",380380- (int) gettid(), nr_abort, signals_delivered);381381+ (int) rseq_gettid(), nr_abort, signals_delivered);381382 if (!opt_disable_rseq && thread_data->reg &&382383 rseq_unregister_current_thread())383384 abort();···455454 } while (rseq_unlikely(ret));456455#ifndef BENCHMARK457456 if (i != 0 && !(i % (reps / 10)))458458- printf_verbose("tid %d: count %lld\n", (int) gettid(), i);457457+ printf_verbose("tid %d: count %lld\n",458458+ (int) rseq_gettid(), i);459459#endif460460 }461461 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",462462- (int) gettid(), nr_abort, signals_delivered);462462+ (int) rseq_gettid(), nr_abort, signals_delivered);463463 if (!opt_disable_rseq && thread_data->reg &&464464 rseq_unregister_current_thread())465465 abort();···607605 }608606609607 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",610610- (int) gettid(), nr_abort, signals_delivered);608608+ (int) rseq_gettid(), nr_abort, signals_delivered);611609 if (!opt_disable_rseq && rseq_unregister_current_thread())612610 abort();613611···798796 }799797800798 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",801801- (int) gettid(), nr_abort, signals_delivered);799799+ (int) rseq_gettid(), nr_abort, signals_delivered);802800 if (!opt_disable_rseq && rseq_unregister_current_thread())803801 abort();804802···10131011 }1014101210151013 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n",10161016- (int) gettid(), nr_abort, signals_delivered);10141014+ (int) rseq_gettid(), nr_abort, signals_delivered);10171015 if (!opt_disable_rseq && rseq_unregister_current_thread())10181016 abort();10191017
+7-5
tools/testing/selftests/rseq/rseq.h
···149149/*150150 * rseq_prepare_unload() should be invoked by each thread executing a rseq151151 * critical section at least once between their last critical section and152152- * library unload of the library defining the rseq critical section153153- * (struct rseq_cs). This also applies to use of rseq in code generated by154154- * JIT: rseq_prepare_unload() should be invoked at least once by each155155- * thread executing a rseq critical section before reclaim of the memory156156- * holding the struct rseq_cs.152152+ * library unload of the library defining the rseq critical section (struct153153+ * rseq_cs) or the code referred to by the struct rseq_cs start_ip and154154+ * post_commit_offset fields. This also applies to use of rseq in code155155+ * generated by JIT: rseq_prepare_unload() should be invoked at least once by156156+ * each thread executing a rseq critical section before reclaim of the memory157157+ * holding the struct rseq_cs or reclaim of the code pointed to by struct158158+ * rseq_cs start_ip and post_commit_offset fields.157159 */158160static inline void rseq_prepare_unload(void)159161{