···1111and so are not advertised as being I2C but come under different names,1212e.g. TWI (Two Wire Interface), IIC.13131414-The official I2C specification is the `"I2C-bus specification and user1515-manual" (UM10204) <https://www.nxp.com/docs/en/user-guide/UM10204.pdf>`_1616-published by NXP Semiconductors.1414+The latest official I2C specification is the `"I2C-bus specification and user1515+manual" (UM10204) <https://www.nxp.com/webapp/Download?colCode=UM10204>`_1616+published by NXP Semiconductors. However, you need to log-in to the site to1717+access the PDF. An older version of the specification (revision 6) is archived1818+`here <https://web.archive.org/web/20210813122132/https://www.nxp.com/docs/en/user-guide/UM10204.pdf>`_.17191820SMBus (System Management Bus) is based on the I2C protocol, and is mostly1921a subset of I2C protocols and signaling. Many I2C devices will work on an
···395395 reg = ioread32(bank_reg(data, bank, reg_irq_status));396396397397 for_each_set_bit(p, ®, 32)398398- generic_handle_domain_irq(gc->irq.domain, i * 32 + p * 2);398398+ generic_handle_domain_irq(gc->irq.domain, (i * 32 + p) * 2);399399 }400400401401 chained_irq_exit(ic, desc);
+8-9
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
···31663166bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type)31673167{31683168 switch (asic_type) {31693169+#ifdef CONFIG_DRM_AMDGPU_SI31703170+ case CHIP_HAINAN:31713171+#endif31723172+ case CHIP_TOPAZ:31733173+ /* chips with no display hardware */31743174+ return false;31693175#if defined(CONFIG_DRM_AMD_DC)31703176 case CHIP_TAHITI:31713177 case CHIP_PITCAIRN:···44674461int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,44684462 struct amdgpu_reset_context *reset_context)44694463{44704470- int i, j, r = 0;44644464+ int i, r = 0;44714465 struct amdgpu_job *job = NULL;44724466 bool need_full_reset =44734467 test_bit(AMDGPU_NEED_FULL_RESET, &reset_context->flags);···4489448344904484 /*clear job fence from fence drv to avoid force_completion44914485 *leave NULL and vm flush fence in fence drv */44924492- for (j = 0; j <= ring->fence_drv.num_fences_mask; j++) {44934493- struct dma_fence *old, **ptr;44864486+ amdgpu_fence_driver_clear_job_fences(ring);4494448744954495- ptr = &ring->fence_drv.fences[j];44964496- old = rcu_dereference_protected(*ptr, 1);44974497- if (old && test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &old->flags)) {44984498- RCU_INIT_POINTER(*ptr, NULL);44994499- }45004500- }45014488 /* after all hw jobs are reset, hw fence is meaningless, so force_completion */45024489 amdgpu_fence_driver_force_completion(ring);45034490 }
···384384 struct amdgpu_vm_bo_base *bo_base;385385 int r;386386387387- if (bo->tbo.resource->mem_type == TTM_PL_SYSTEM)387387+ if (!bo->tbo.resource || bo->tbo.resource->mem_type == TTM_PL_SYSTEM)388388 return;389389390390 r = ttm_bo_validate(&bo->tbo, &placement, &ctx);
+23-4
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
···328328329329/**330330 * DOC: runpm (int)331331- * Override for runtime power management control for dGPUs in PX/HG laptops. The amdgpu driver can dynamically power down332332- * the dGPU on PX/HG laptops when it is idle. The default is -1 (auto enable). Setting the value to 0 disables this functionality.331331+ * Override for runtime power management control for dGPUs. The amdgpu driver can dynamically power down332332+ * the dGPUs when they are idle if supported. The default is -1 (auto enable).333333+ * Setting the value to 0 disables this functionality.333334 */334334-MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = force enable with BACO, 0 = disable, -1 = PX only default)");335335+MODULE_PARM_DESC(runpm, "PX runtime pm (2 = force enable with BAMACO, 1 = force enable with BACO, 0 = disable, -1 = auto)");335336module_param_named(runpm, amdgpu_runtime_pm, int, 0444);336337337338/**···21542153 adev->in_s3 = true;21552154 r = amdgpu_device_suspend(drm_dev, true);21562155 adev->in_s3 = false;21572157-21562156+ if (r)21572157+ return r;21582158+ if (!adev->in_s0ix)21592159+ r = amdgpu_asic_reset(adev);21582160 return r;21592161}21602162···22382234 if (amdgpu_device_supports_px(drm_dev))22392235 drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;2240223622372237+ /*22382238+ * By setting mp1_state as PP_MP1_STATE_UNLOAD, MP1 will do some22392239+ * proper cleanups and put itself into a state ready for PNP. That22402240+ * can address some random resuming failure observed on BOCO capable22412241+ * platforms.22422242+ * TODO: this may be also needed for PX capable platform.22432243+ */22442244+ if (amdgpu_device_supports_boco(drm_dev))22452245+ adev->mp1_state = PP_MP1_STATE_UNLOAD;22462246+22412247 ret = amdgpu_device_suspend(drm_dev, false);22422248 if (ret) {22432249 adev->in_runpm = false;22502250+ if (amdgpu_device_supports_boco(drm_dev))22512251+ adev->mp1_state = PP_MP1_STATE_NONE;22442252 return ret;22452253 }22542254+22552255+ if (amdgpu_device_supports_boco(drm_dev))22562256+ adev->mp1_state = PP_MP1_STATE_NONE;2246225722472258 if (amdgpu_device_supports_px(drm_dev)) {22482259 /* Only need to handle PCI state in the driver for ATPX
+87-39
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
···7777 * Cast helper7878 */7979static const struct dma_fence_ops amdgpu_fence_ops;8080+static const struct dma_fence_ops amdgpu_job_fence_ops;8081static inline struct amdgpu_fence *to_amdgpu_fence(struct dma_fence *f)8182{8283 struct amdgpu_fence *__f = container_of(f, struct amdgpu_fence, base);83848484- if (__f->base.ops == &amdgpu_fence_ops)8585+ if (__f->base.ops == &amdgpu_fence_ops ||8686+ __f->base.ops == &amdgpu_job_fence_ops)8587 return __f;86888789 return NULL;···160158 }161159162160 seq = ++ring->fence_drv.sync_seq;163163- if (job != NULL && job->job_run_counter) {161161+ if (job && job->job_run_counter) {164162 /* reinit seq for resubmitted jobs */165163 fence->seqno = seq;166164 } else {167167- dma_fence_init(fence, &amdgpu_fence_ops,168168- &ring->fence_drv.lock,169169- adev->fence_context + ring->idx,170170- seq);171171- }172172-173173- if (job != NULL) {174174- /* mark this fence has a parent job */175175- set_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &fence->flags);165165+ if (job)166166+ dma_fence_init(fence, &amdgpu_job_fence_ops,167167+ &ring->fence_drv.lock,168168+ adev->fence_context + ring->idx, seq);169169+ else170170+ dma_fence_init(fence, &amdgpu_fence_ops,171171+ &ring->fence_drv.lock,172172+ adev->fence_context + ring->idx, seq);176173 }177174178175 amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,···622621}623622624623/**624624+ * amdgpu_fence_driver_clear_job_fences - clear job embedded fences of ring625625+ *626626+ * @ring: fence of the ring to be cleared627627+ *628628+ */629629+void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring)630630+{631631+ int i;632632+ struct dma_fence *old, **ptr;633633+634634+ for (i = 0; i <= ring->fence_drv.num_fences_mask; i++) {635635+ ptr = &ring->fence_drv.fences[i];636636+ old = rcu_dereference_protected(*ptr, 1);637637+ if (old && old->ops == &amdgpu_job_fence_ops)638638+ RCU_INIT_POINTER(*ptr, NULL);639639+ }640640+}641641+642642+/**625643 * amdgpu_fence_driver_force_completion - force signal latest fence of ring626644 *627645 * @ring: fence of the ring to signal···663643664644static const char *amdgpu_fence_get_timeline_name(struct dma_fence *f)665645{666666- struct amdgpu_ring *ring;646646+ return (const char *)to_amdgpu_fence(f)->ring->name;647647+}667648668668- if (test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &f->flags)) {669669- struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence);649649+static const char *amdgpu_job_fence_get_timeline_name(struct dma_fence *f)650650+{651651+ struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence);670652671671- ring = to_amdgpu_ring(job->base.sched);672672- } else {673673- ring = to_amdgpu_fence(f)->ring;674674- }675675- return (const char *)ring->name;653653+ return (const char *)to_amdgpu_ring(job->base.sched)->name;676654}677655678656/**···683665 */684666static bool amdgpu_fence_enable_signaling(struct dma_fence *f)685667{686686- struct amdgpu_ring *ring;668668+ if (!timer_pending(&to_amdgpu_fence(f)->ring->fence_drv.fallback_timer))669669+ amdgpu_fence_schedule_fallback(to_amdgpu_fence(f)->ring);687670688688- if (test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &f->flags)) {689689- struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence);671671+ return true;672672+}690673691691- ring = to_amdgpu_ring(job->base.sched);692692- } else {693693- ring = to_amdgpu_fence(f)->ring;694694- }674674+/**675675+ * amdgpu_job_fence_enable_signaling - enable signalling on job fence676676+ * @f: fence677677+ *678678+ * This is the simliar function with amdgpu_fence_enable_signaling above, it679679+ * only handles the job embedded fence.680680+ */681681+static bool amdgpu_job_fence_enable_signaling(struct dma_fence *f)682682+{683683+ struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence);695684696696- if (!timer_pending(&ring->fence_drv.fallback_timer))697697- amdgpu_fence_schedule_fallback(ring);685685+ if (!timer_pending(&to_amdgpu_ring(job->base.sched)->fence_drv.fallback_timer))686686+ amdgpu_fence_schedule_fallback(to_amdgpu_ring(job->base.sched));698687699688 return true;700689}···717692{718693 struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);719694720720- if (test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, &f->flags)) {721721- /* free job if fence has a parent job */722722- struct amdgpu_job *job;723723-724724- job = container_of(f, struct amdgpu_job, hw_fence);725725- kfree(job);726726- } else {727695 /* free fence_slab if it's separated fence*/728728- struct amdgpu_fence *fence;696696+ kmem_cache_free(amdgpu_fence_slab, to_amdgpu_fence(f));697697+}729698730730- fence = to_amdgpu_fence(f);731731- kmem_cache_free(amdgpu_fence_slab, fence);732732- }699699+/**700700+ * amdgpu_job_fence_free - free up the job with embedded fence701701+ *702702+ * @rcu: RCU callback head703703+ *704704+ * Free up the job with embedded fence after the RCU grace period.705705+ */706706+static void amdgpu_job_fence_free(struct rcu_head *rcu)707707+{708708+ struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);709709+710710+ /* free job if fence has a parent job */711711+ kfree(container_of(f, struct amdgpu_job, hw_fence));733712}734713735714/**···749720 call_rcu(&f->rcu, amdgpu_fence_free);750721}751722723723+/**724724+ * amdgpu_job_fence_release - callback that job embedded fence can be freed725725+ *726726+ * @f: fence727727+ *728728+ * This is the simliar function with amdgpu_fence_release above, it729729+ * only handles the job embedded fence.730730+ */731731+static void amdgpu_job_fence_release(struct dma_fence *f)732732+{733733+ call_rcu(&f->rcu, amdgpu_job_fence_free);734734+}735735+752736static const struct dma_fence_ops amdgpu_fence_ops = {753737 .get_driver_name = amdgpu_fence_get_driver_name,754738 .get_timeline_name = amdgpu_fence_get_timeline_name,···769727 .release = amdgpu_fence_release,770728};771729730730+static const struct dma_fence_ops amdgpu_job_fence_ops = {731731+ .get_driver_name = amdgpu_fence_get_driver_name,732732+ .get_timeline_name = amdgpu_job_fence_get_timeline_name,733733+ .enable_signaling = amdgpu_job_fence_enable_signaling,734734+ .release = amdgpu_job_fence_release,735735+};772736773737/*774738 * Fence debugfs
+1-3
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
···5353#define AMDGPU_FENCE_FLAG_INT (1 << 1)5454#define AMDGPU_FENCE_FLAG_TC_WB_ONLY (1 << 2)55555656-/* fence flag bit to indicate the face is embedded in job*/5757-#define AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT (DMA_FENCE_FLAG_USER_BITS + 1)5858-5956#define to_amdgpu_ring(s) container_of((s), struct amdgpu_ring, sched)60576158#define AMDGPU_IB_POOL_SIZE (1024 * 1024)···111114 struct dma_fence **fences;112115};113116117117+void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring);114118void amdgpu_fence_driver_force_completion(struct amdgpu_ring *ring);115119116120int amdgpu_fence_driver_init_ring(struct amdgpu_ring *ring,
+7
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
···246246{247247 int r;248248 struct amdgpu_device *adev = (struct amdgpu_device *)handle;249249+ bool idle_work_unexecuted;250250+251251+ idle_work_unexecuted = cancel_delayed_work_sync(&adev->vcn.idle_work);252252+ if (idle_work_unexecuted) {253253+ if (adev->pm.dpm_enabled)254254+ amdgpu_dpm_enable_uvd(adev, false);255255+ }249256250257 r = vcn_v1_0_hw_fini(adev);251258 if (r)
···120120121121int smu_v12_0_set_gfx_cgpg(struct smu_context *smu, bool enable)122122{123123- if (!(smu->adev->pg_flags & AMD_PG_SUPPORT_GFX_PG))123123+ /* Until now the SMU12 only implemented for Renoir series so here neen't do APU check. */124124+ if (!(smu->adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) || smu->adev->in_s0ix)124125 return 0;125126126127 return smu_cmn_send_smc_msg_with_param(smu,
···353353354354 if (ret)355355 return ret;356356+357357+ fobj = NULL;358358+ } else {359359+ fobj = dma_resv_shared_list(resv);356360 }357361358358- fobj = dma_resv_shared_list(resv);359359- fence = dma_resv_excl_fence(resv);360360-361361- if (fence) {362362- struct nouveau_channel *prev = NULL;363363- bool must_wait = true;364364-365365- f = nouveau_local_fence(fence, chan->drm);366366- if (f) {367367- rcu_read_lock();368368- prev = rcu_dereference(f->channel);369369- if (prev && (prev == chan || fctx->sync(f, prev, chan) == 0))370370- must_wait = false;371371- rcu_read_unlock();372372- }373373-374374- if (must_wait)375375- ret = dma_fence_wait(fence, intr);376376-377377- return ret;378378- }379379-380380- if (!exclusive || !fobj)381381- return ret;382382-383383- for (i = 0; i < fobj->shared_count && !ret; ++i) {362362+ /* Waiting for the exclusive fence first causes performance regressions363363+ * under some circumstances. So manually wait for the shared ones first.364364+ */365365+ for (i = 0; i < (fobj ? fobj->shared_count : 0) && !ret; ++i) {384366 struct nouveau_channel *prev = NULL;385367 bool must_wait = true;386368···380398381399 if (must_wait)382400 ret = dma_fence_wait(fence, intr);401401+ }402402+403403+ fence = dma_resv_excl_fence(resv);404404+ if (fence) {405405+ struct nouveau_channel *prev = NULL;406406+ bool must_wait = true;407407+408408+ f = nouveau_local_fence(fence, chan->drm);409409+ if (f) {410410+ rcu_read_lock();411411+ prev = rcu_dereference(f->channel);412412+ if (prev && (prev == chan || fctx->sync(f, prev, chan) == 0))413413+ must_wait = false;414414+ rcu_read_unlock();415415+ }416416+417417+ if (must_wait)418418+ ret = dma_fence_wait(fence, intr);419419+420420+ return ret;383421 }384422385423 return ret;
+3
drivers/i2c/i2c-dev.c
···535535 sizeof(rdwr_arg)))536536 return -EFAULT;537537538538+ if (!rdwr_arg.msgs || rdwr_arg.nmsgs == 0)539539+ return -EINVAL;540540+538541 if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)539542 return -EINVAL;540543
+9-2
drivers/input/joystick/spaceball.c
···1919#include <linux/module.h>2020#include <linux/input.h>2121#include <linux/serio.h>2222+#include <asm/unaligned.h>22232324#define DRIVER_DESC "SpaceTec SpaceBall 2003/3003/4000 FLX driver"2425···76757776 case 'D': /* Ball data */7877 if (spaceball->idx != 15) return;7979- for (i = 0; i < 6; i++)7878+ /*7979+ * Skip first three bytes; read six axes worth of data.8080+ * Axis values are signed 16-bit big-endian.8181+ */8282+ data += 3;8383+ for (i = 0; i < ARRAY_SIZE(spaceball_axes); i++) {8084 input_report_abs(dev, spaceball_axes[i],8181- (__s16)((data[2 * i + 3] << 8) | data[2 * i + 2]));8585+ (__s16)get_unaligned_be16(&data[i * 2]));8686+ }8287 break;83888489 case 'K': /* Button data */
+2-2
drivers/input/mouse/appletouch.c
···916916 set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);917917 set_bit(BTN_LEFT, input_dev->keybit);918918919919+ INIT_WORK(&dev->work, atp_reinit);920920+919921 error = input_register_device(dev->input);920922 if (error)921923 goto err_free_buffer;922924923925 /* save our data pointer in this interface device */924926 usb_set_intfdata(iface, dev);925925-926926- INIT_WORK(&dev->work, atp_reinit);927927928928 return 0;929929
+29-20
drivers/net/ethernet/amazon/ena/ena_netdev.c
···1288128812891289static int validate_tx_req_id(struct ena_ring *tx_ring, u16 req_id)12901290{12911291- struct ena_tx_buffer *tx_info = NULL;12911291+ struct ena_tx_buffer *tx_info;1292129212931293- if (likely(req_id < tx_ring->ring_size)) {12941294- tx_info = &tx_ring->tx_buffer_info[req_id];12951295- if (likely(tx_info->skb))12961296- return 0;12971297- }12931293+ tx_info = &tx_ring->tx_buffer_info[req_id];12941294+ if (likely(tx_info->skb))12951295+ return 0;1298129612991297 return handle_invalid_req_id(tx_ring, req_id, tx_info, false);13001298}1301129913021300static int validate_xdp_req_id(struct ena_ring *xdp_ring, u16 req_id)13031301{13041304- struct ena_tx_buffer *tx_info = NULL;13021302+ struct ena_tx_buffer *tx_info;1305130313061306- if (likely(req_id < xdp_ring->ring_size)) {13071307- tx_info = &xdp_ring->tx_buffer_info[req_id];13081308- if (likely(tx_info->xdpf))13091309- return 0;13101310- }13041304+ tx_info = &xdp_ring->tx_buffer_info[req_id];13051305+ if (likely(tx_info->xdpf))13061306+ return 0;1311130713121308 return handle_invalid_req_id(xdp_ring, req_id, tx_info, true);13131309}···1328133213291333 rc = ena_com_tx_comp_req_id_get(tx_ring->ena_com_io_cq,13301334 &req_id);13311331- if (rc)13351335+ if (rc) {13361336+ if (unlikely(rc == -EINVAL))13371337+ handle_invalid_req_id(tx_ring, req_id, NULL,13381338+ false);13321339 break;13401340+ }1333134113421342+ /* validate that the request id points to a valid skb */13341343 rc = validate_tx_req_id(tx_ring, req_id);13351344 if (rc)13361345 break;···14281427 u16 *next_to_clean)14291428{14301429 struct ena_rx_buffer *rx_info;14301430+ struct ena_adapter *adapter;14311431 u16 len, req_id, buf = 0;14321432 struct sk_buff *skb;14331433 void *page_addr;···14411439 rx_info = &rx_ring->rx_buffer_info[req_id];1442144014431441 if (unlikely(!rx_info->page)) {14441444- netif_err(rx_ring->adapter, rx_err, rx_ring->netdev,14451445- "Page is NULL\n");14421442+ adapter = rx_ring->adapter;14431443+ netif_err(adapter, rx_err, rx_ring->netdev,14441444+ "Page is NULL. qid %u req_id %u\n", rx_ring->qid, req_id);14451445+ ena_increase_stat(&rx_ring->rx_stats.bad_req_id, 1, &rx_ring->syncp);14461446+ adapter->reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID;14471447+ /* Make sure reset reason is set before triggering the reset */14481448+ smp_mb__before_atomic();14491449+ set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);14461450 return NULL;14471451 }14481452···1904189619051897 rc = ena_com_tx_comp_req_id_get(xdp_ring->ena_com_io_cq,19061898 &req_id);19071907- if (rc)18991899+ if (rc) {19001900+ if (unlikely(rc == -EINVAL))19011901+ handle_invalid_req_id(xdp_ring, req_id, NULL,19021902+ true);19081903 break;19041904+ }1909190519061906+ /* validate that the request id points to a valid xdp_frame */19101907 rc = validate_xdp_req_id(xdp_ring, req_id);19111908 if (rc)19121909 break;···40264013 max_num_io_queues = min_t(u32, max_num_io_queues, io_tx_cq_num);40274014 /* 1 IRQ for mgmnt and 1 IRQs for each IO direction */40284015 max_num_io_queues = min_t(u32, max_num_io_queues, pci_msix_vec_count(pdev) - 1);40294029- if (unlikely(!max_num_io_queues)) {40304030- dev_err(&pdev->dev, "The device doesn't have io queues\n");40314031- return -EFAULT;40324032- }4033401640344017 return max_num_io_queues;40354018}
···9999100100static struct workqueue_struct *i40e_wq;101101102102+static void netdev_hw_addr_refcnt(struct i40e_mac_filter *f,103103+ struct net_device *netdev, int delta)104104+{105105+ struct netdev_hw_addr *ha;106106+107107+ if (!f || !netdev)108108+ return;109109+110110+ netdev_for_each_mc_addr(ha, netdev) {111111+ if (ether_addr_equal(ha->addr, f->macaddr)) {112112+ ha->refcount += delta;113113+ if (ha->refcount <= 0)114114+ ha->refcount = 1;115115+ break;116116+ }117117+ }118118+}119119+102120/**103121 * i40e_allocate_dma_mem_d - OS specific memory alloc for shared code104122 * @hw: pointer to the HW structure···20542036 hlist_for_each_entry_safe(new, h, from, hlist) {20552037 /* We can simply free the wrapper structure */20562038 hlist_del(&new->hlist);20392039+ netdev_hw_addr_refcnt(new->f, vsi->netdev, -1);20572040 kfree(new);20582041 }20592042}···24022383 &tmp_add_list,24032384 &tmp_del_list,24042385 vlan_filters);23862386+23872387+ hlist_for_each_entry(new, &tmp_add_list, hlist)23882388+ netdev_hw_addr_refcnt(new->f, vsi->netdev, 1);23892389+24052390 if (retval)24062391 goto err_no_memory_locked;24072392···25382515 if (new->f->state == I40E_FILTER_NEW)25392516 new->f->state = new->state;25402517 hlist_del(&new->hlist);25182518+ netdev_hw_addr_refcnt(new->f, vsi->netdev, -1);25412519 kfree(new);25422520 }25432521 spin_unlock_bh(&vsi->mac_filter_hash_lock);···87418717}8742871887438719/**87208720+ * i40e_netif_set_realnum_tx_rx_queues - Update number of tx/rx queues87218721+ * @vsi: vsi structure87228722+ *87238723+ * This updates netdev's number of tx/rx queues87248724+ *87258725+ * Returns status of setting tx/rx queues87268726+ **/87278727+static int i40e_netif_set_realnum_tx_rx_queues(struct i40e_vsi *vsi)87288728+{87298729+ int ret;87308730+87318731+ ret = netif_set_real_num_rx_queues(vsi->netdev,87328732+ vsi->num_queue_pairs);87338733+ if (ret)87348734+ return ret;87358735+87368736+ return netif_set_real_num_tx_queues(vsi->netdev,87378737+ vsi->num_queue_pairs);87388738+}87398739+87408740+/**87448741 * i40e_vsi_open -87458742 * @vsi: the VSI to open87468743 *···87978752 goto err_setup_rx;8798875387998754 /* Notify the stack of the actual queue counts. */88008800- err = netif_set_real_num_tx_queues(vsi->netdev,88018801- vsi->num_queue_pairs);88028802- if (err)88038803- goto err_set_queues;88048804-88058805- err = netif_set_real_num_rx_queues(vsi->netdev,88068806- vsi->num_queue_pairs);87558755+ err = i40e_netif_set_realnum_tx_rx_queues(vsi);88078756 if (err)88088757 goto err_set_queues;88098758···1419014151 ret = i40e_config_netdev(vsi);1419114152 if (ret)1419214153 goto err_netdev;1415414154+ ret = i40e_netif_set_realnum_tx_rx_queues(vsi);1415514155+ if (ret)1415614156+ goto err_netdev;1419314157 ret = register_netdev(vsi->netdev);1419414158 if (ret)1419514159 goto err_netdev;···15493154511549415452 if (hw->aq.api_maj_ver == I40E_FW_API_VERSION_MAJOR &&1549515453 hw->aq.api_min_ver > I40E_FW_MINOR_VERSION(hw))1549615496- dev_info(&pdev->dev,1549715497- "The driver for the device detected a newer version of the NVM image v%u.%u than expected v%u.%u. Please install the most recent version of the network driver.\n",1545415454+ dev_dbg(&pdev->dev,1545515455+ "The driver for the device detected a newer version of the NVM image v%u.%u than v%u.%u.\n",1549815456 hw->aq.api_maj_ver,1549915457 hw->aq.api_min_ver,1550015458 I40E_FW_API_VERSION_MAJOR,
···18771877/***********************virtual channel routines******************/1878187818791879/**18801880- * i40e_vc_send_msg_to_vf18801880+ * i40e_vc_send_msg_to_vf_ex18811881 * @vf: pointer to the VF info18821882 * @v_opcode: virtual channel opcode18831883 * @v_retval: virtual channel return value18841884 * @msg: pointer to the msg buffer18851885 * @msglen: msg length18861886+ * @is_quiet: true for not printing unsuccessful return values, false otherwise18861887 *18871888 * send msg to VF18881889 **/18891889-static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,18901890- u32 v_retval, u8 *msg, u16 msglen)18901890+static int i40e_vc_send_msg_to_vf_ex(struct i40e_vf *vf, u32 v_opcode,18911891+ u32 v_retval, u8 *msg, u16 msglen,18921892+ bool is_quiet)18911893{18921894 struct i40e_pf *pf;18931895 struct i40e_hw *hw;···19051903 abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id;1906190419071905 /* single place to detect unsuccessful return values */19081908- if (v_retval) {19061906+ if (v_retval && !is_quiet) {19091907 vf->num_invalid_msgs++;19101908 dev_info(&pf->pdev->dev, "VF %d failed opcode %d, retval: %d\n",19111909 vf->vf_id, v_opcode, v_retval);···19331931 }1934193219351933 return 0;19341934+}19351935+19361936+/**19371937+ * i40e_vc_send_msg_to_vf19381938+ * @vf: pointer to the VF info19391939+ * @v_opcode: virtual channel opcode19401940+ * @v_retval: virtual channel return value19411941+ * @msg: pointer to the msg buffer19421942+ * @msglen: msg length19431943+ *19441944+ * send msg to VF19451945+ **/19461946+static int i40e_vc_send_msg_to_vf(struct i40e_vf *vf, u32 v_opcode,19471947+ u32 v_retval, u8 *msg, u16 msglen)19481948+{19491949+ return i40e_vc_send_msg_to_vf_ex(vf, v_opcode, v_retval,19501950+ msg, msglen, false);19361951}1937195219381953/**···27142695 * i40e_check_vf_permission27152696 * @vf: pointer to the VF info27162697 * @al: MAC address list from virtchnl26982698+ * @is_quiet: set true for printing msg without opcode info, false otherwise27172699 *27182700 * Check that the given list of MAC addresses is allowed. Will return -EPERM27192701 * if any address in the list is not valid. Checks the following conditions:···27292709 * addresses might not be accurate.27302710 **/27312711static inline int i40e_check_vf_permission(struct i40e_vf *vf,27322732- struct virtchnl_ether_addr_list *al)27122712+ struct virtchnl_ether_addr_list *al,27132713+ bool *is_quiet)27332714{27342715 struct i40e_pf *pf = vf->pf;27352716 struct i40e_vsi *vsi = pf->vsi[vf->lan_vsi_idx];27362717 int mac2add_cnt = 0;27372718 int i;2738271927202720+ *is_quiet = false;27392721 for (i = 0; i < al->num_elements; i++) {27402722 struct i40e_mac_filter *f;27412723 u8 *addr = al->list[i].addr;···27612739 !ether_addr_equal(addr, vf->default_lan_addr.addr)) {27622740 dev_err(&pf->pdev->dev,27632741 "VF attempting to override administratively set MAC address, bring down and up the VF interface to resume normal operation\n");27422742+ *is_quiet = true;27642743 return -EPERM;27652744 }27662745···27982775 (struct virtchnl_ether_addr_list *)msg;27992776 struct i40e_pf *pf = vf->pf;28002777 struct i40e_vsi *vsi = NULL;27782778+ bool is_quiet = false;28012779 i40e_status ret = 0;28022780 int i;28032781···28152791 */28162792 spin_lock_bh(&vsi->mac_filter_hash_lock);2817279328182818- ret = i40e_check_vf_permission(vf, al);27942794+ ret = i40e_check_vf_permission(vf, al, &is_quiet);28192795 if (ret) {28202796 spin_unlock_bh(&vsi->mac_filter_hash_lock);28212797 goto error_param;···2853282928542830error_param:28552831 /* send the response to the VF */28562856- return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_ADD_ETH_ADDR,28572857- ret);28322832+ return i40e_vc_send_msg_to_vf_ex(vf, VIRTCHNL_OP_ADD_ETH_ADDR,28332833+ ret, NULL, 0, is_quiet);28582834}2859283528602836/**
+4-1
drivers/net/ethernet/intel/iavf/iavf_main.c
···31233123 total_max_rate += tx_rate;31243124 num_qps += mqprio_qopt->qopt.count[i];31253125 }31263126- if (num_qps > IAVF_MAX_REQ_QUEUES)31263126+ if (num_qps > adapter->num_active_queues) {31273127+ dev_err(&adapter->pdev->dev,31283128+ "Cannot support requested number of queues\n");31273129 return -EINVAL;31303130+ }3128313131293132 ret = iavf_validate_tx_bandwidth(adapter, total_max_rate);31303133 return ret;
+5
drivers/net/ethernet/sfc/falcon/rx.c
···110110 struct ef4_rx_page_state *state;111111 unsigned index;112112113113+ if (unlikely(!rx_queue->page_ring))114114+ return NULL;113115 index = rx_queue->page_remove & rx_queue->page_ptr_mask;114116 page = rx_queue->page_ring[index];115117 if (page == NULL)···294292 unsigned int n_frags)295293{296294 struct ef4_rx_queue *rx_queue = ef4_channel_get_rx_queue(channel);295295+296296+ if (unlikely(!rx_queue->page_ring))297297+ return;297298298299 do {299300 ef4_recycle_rx_page(channel, rx_buf);
+5
drivers/net/ethernet/sfc/rx_common.c
···4545 unsigned int index;4646 struct page *page;47474848+ if (unlikely(!rx_queue->page_ring))4949+ return NULL;4850 index = rx_queue->page_remove & rx_queue->page_ptr_mask;4951 page = rx_queue->page_ring[index];5052 if (page == NULL)···115113 unsigned int n_frags)116114{117115 struct efx_rx_queue *rx_queue = efx_channel_get_rx_queue(channel);116116+117117+ if (unlikely(!rx_queue->page_ring))118118+ return;118119119120 do {120121 efx_recycle_rx_page(channel, rx_buf);
+6-4
drivers/net/ieee802154/atusb.c
···93939494 ret = usb_control_msg(usb_dev, pipe, request, requesttype,9595 value, index, data, size, timeout);9696- if (ret < 0) {9696+ if (ret < size) {9797+ ret = ret < 0 ? ret : -ENODATA;9898+9799 atusb->err = ret;98100 dev_err(&usb_dev->dev,99101 "%s: req 0x%02x val 0x%x idx 0x%x, error %d\n",···863861 if (!build)864862 return -ENOMEM;865863866866- ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),867867- ATUSB_BUILD, ATUSB_REQ_FROM_DEV, 0, 0,868868- build, ATUSB_BUILD_SIZE, 1000);864864+ /* We cannot call atusb_control_msg() here, since this request may read various length data */865865+ ret = usb_control_msg(atusb->usb_dev, usb_rcvctrlpipe(usb_dev, 0), ATUSB_BUILD,866866+ ATUSB_REQ_FROM_DEV, 0, 0, build, ATUSB_BUILD_SIZE, 1000);869867 if (ret >= 0) {870868 build[ret] = 0;871869 dev_info(&usb_dev->dev, "Firmware: build %s\n", build);
+2-2
drivers/net/phy/fixed_phy.c
···239239 /* Check if we have a GPIO associated with this fixed phy */240240 if (!gpiod) {241241 gpiod = fixed_phy_get_gpiod(np);242242- if (!gpiod)243243- return ERR_PTR(-EINVAL);242242+ if (IS_ERR(gpiod))243243+ return ERR_CAST(gpiod);244244 }245245246246 /* Get the next available PHY address, up to PHY_MAX_ADDR */
+6-3
drivers/net/usb/r8152.c
···96429642 netdev->hw_features &= ~NETIF_F_RXCSUM;96439643 }9644964496459645- if (udev->parent &&96469646- le16_to_cpu(udev->parent->descriptor.idVendor) == VENDOR_ID_LENOVO) {96479647- tp->lenovo_macpassthru = 1;96459645+ if (le16_to_cpu(udev->descriptor.idVendor) == VENDOR_ID_LENOVO) {96469646+ switch (le16_to_cpu(udev->descriptor.idProduct)) {96479647+ case DEVICE_ID_THINKPAD_THUNDERBOLT3_DOCK_GEN2:96489648+ case DEVICE_ID_THINKPAD_USB_C_DOCK_GEN2:96499649+ tp->lenovo_macpassthru = 1;96509650+ }96489651 }9649965296509653 if (le16_to_cpu(udev->descriptor.bcdDevice) == 0x3011 && udev->serial &&
···586586 * Commands like INQUIRY may transfer less data than587587 * requested by the initiator via bufflen. Set residual588588 * count to make upper layer aware of the actual amount589589- * of data returned.589589+ * of data returned. There are cases when controller590590+ * returns zero dataLen with non zero data - do not set591591+ * residual count in that case.590592 */591591- scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);593593+ if (e->dataLen && (e->dataLen < scsi_bufflen(cmd)))594594+ scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);592595 cmd->result = (DID_OK << 16);593596 break;594597
···353353 const char __user *buf, size_t count, loff_t *ppos)354354{355355 struct damon_ctx *ctx = file->private_data;356356+ struct damon_target *t, *next_t;356357 bool id_is_pid = true;357358 char *kbuf, *nrs;358359 unsigned long *targets;···398397 goto unlock_out;399398 }400399401401- /* remove targets with previously-set primitive */402402- damon_set_targets(ctx, NULL, 0);400400+ /* remove previously set targets */401401+ damon_for_each_target_safe(t, next_t, ctx) {402402+ if (targetid_is_pid(ctx))403403+ put_pid((struct pid *)t->id);404404+ damon_destroy_target(t);405405+ }403406404407 /* Configure the context for the address space type */405408 if (id_is_pid)
+56-9
mm/vmscan.c
···10211021 unlock_page(page);10221022}1023102310241024+static bool skip_throttle_noprogress(pg_data_t *pgdat)10251025+{10261026+ int reclaimable = 0, write_pending = 0;10271027+ int i;10281028+10291029+ /*10301030+ * If kswapd is disabled, reschedule if necessary but do not10311031+ * throttle as the system is likely near OOM.10321032+ */10331033+ if (pgdat->kswapd_failures >= MAX_RECLAIM_RETRIES)10341034+ return true;10351035+10361036+ /*10371037+ * If there are a lot of dirty/writeback pages then do not10381038+ * throttle as throttling will occur when the pages cycle10391039+ * towards the end of the LRU if still under writeback.10401040+ */10411041+ for (i = 0; i < MAX_NR_ZONES; i++) {10421042+ struct zone *zone = pgdat->node_zones + i;10431043+10441044+ if (!populated_zone(zone))10451045+ continue;10461046+10471047+ reclaimable += zone_reclaimable_pages(zone);10481048+ write_pending += zone_page_state_snapshot(zone,10491049+ NR_ZONE_WRITE_PENDING);10501050+ }10511051+ if (2 * write_pending <= reclaimable)10521052+ return true;10531053+10541054+ return false;10551055+}10561056+10241057void reclaim_throttle(pg_data_t *pgdat, enum vmscan_throttle_state reason)10251058{10261059 wait_queue_head_t *wqh = &pgdat->reclaim_wait[reason];···10891056 }1090105710911058 break;10591059+ case VMSCAN_THROTTLE_CONGESTED:10601060+ fallthrough;10921061 case VMSCAN_THROTTLE_NOPROGRESS:10931093- timeout = HZ/2;10621062+ if (skip_throttle_noprogress(pgdat)) {10631063+ cond_resched();10641064+ return;10651065+ }10661066+10671067+ timeout = 1;10681068+10941069 break;10951070 case VMSCAN_THROTTLE_ISOLATED:10961071 timeout = HZ/50;···33623321 if (!current_is_kswapd() && current_may_throttle() &&33633322 !sc->hibernation_mode &&33643323 test_bit(LRUVEC_CONGESTED, &target_lruvec->flags))33653365- reclaim_throttle(pgdat, VMSCAN_THROTTLE_WRITEBACK);33243324+ reclaim_throttle(pgdat, VMSCAN_THROTTLE_CONGESTED);3366332533673326 if (should_continue_reclaim(pgdat, sc->nr_reclaimed - nr_reclaimed,33683327 sc))···34273386 }3428338734293388 /*34303430- * Do not throttle kswapd on NOPROGRESS as it will throttle on34313431- * VMSCAN_THROTTLE_WRITEBACK if there are too many pages under34323432- * writeback and marked for immediate reclaim at the tail of34333433- * the LRU.33893389+ * Do not throttle kswapd or cgroup reclaim on NOPROGRESS as it will33903390+ * throttle on VMSCAN_THROTTLE_WRITEBACK if there are too many pages33913391+ * under writeback and marked for immediate reclaim at the tail of the33923392+ * LRU.34343393 */34353435- if (current_is_kswapd())33943394+ if (current_is_kswapd() || cgroup_reclaim(sc))34363395 return;3437339634383397 /* Throttle if making no progress at high prioities. */34393439- if (sc->priority < DEF_PRIORITY - 2)33983398+ if (sc->priority == 1 && !sc->nr_reclaimed)34403399 reclaim_throttle(pgdat, VMSCAN_THROTTLE_NOPROGRESS);34413400}34423401···34563415 unsigned long nr_soft_scanned;34573416 gfp_t orig_mask;34583417 pg_data_t *last_pgdat = NULL;34183418+ pg_data_t *first_pgdat = NULL;3459341934603420 /*34613421 * If the number of buffer_heads in the machine exceeds the maximum···35203478 /* need some check for avoid more shrink_zone() */35213479 }3522348034813481+ if (!first_pgdat)34823482+ first_pgdat = zone->zone_pgdat;34833483+35233484 /* See comment about same check for global reclaim above */35243485 if (zone->zone_pgdat == last_pgdat)35253486 continue;35263487 last_pgdat = zone->zone_pgdat;35273488 shrink_node(zone->zone_pgdat, sc);35283528- consider_reclaim_throttle(zone->zone_pgdat, sc);35293489 }34903490+34913491+ if (first_pgdat)34923492+ consider_reclaim_throttle(first_pgdat, sc);3530349335313494 /*35323495 * Restore to original mask to avoid the impact on the caller if we
+10-5
net/batman-adv/multicast.c
···13391339 * @bat_priv: the bat priv with all the soft interface information13401340 * @skb: The multicast packet to check13411341 * @orig: an originator to be set to forward the skb to13421342+ * @is_routable: stores whether the destination is routable13421343 *13431344 * Return: the forwarding mode as enum batadv_forw_mode and in case of13441345 * BATADV_FORW_SINGLE set the orig to the single originator the skb···13471346 */13481347enum batadv_forw_mode13491348batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,13501350- struct batadv_orig_node **orig)13491349+ struct batadv_orig_node **orig, int *is_routable)13511350{13521351 int ret, tt_count, ip_count, unsnoop_count, total_count;13531352 bool is_unsnoopable = false;13541353 unsigned int mcast_fanout;13551354 struct ethhdr *ethhdr;13561356- int is_routable = 0;13571355 int rtr_count = 0;1358135613591357 ret = batadv_mcast_forw_mode_check(bat_priv, skb, &is_unsnoopable,13601360- &is_routable);13581358+ is_routable);13611359 if (ret == -ENOMEM)13621360 return BATADV_FORW_NONE;13631361 else if (ret < 0)···13691369 ip_count = batadv_mcast_forw_want_all_ip_count(bat_priv, ethhdr);13701370 unsnoop_count = !is_unsnoopable ? 0 :13711371 atomic_read(&bat_priv->mcast.num_want_all_unsnoopables);13721372- rtr_count = batadv_mcast_forw_rtr_count(bat_priv, is_routable);13721372+ rtr_count = batadv_mcast_forw_rtr_count(bat_priv, *is_routable);1373137313741374 total_count = tt_count + ip_count + unsnoop_count + rtr_count;13751375···16891689 * @bat_priv: the bat priv with all the soft interface information16901690 * @skb: the multicast packet to transmit16911691 * @vid: the vlan identifier16921692+ * @is_routable: stores whether the destination is routable16921693 *16931694 * Sends copies of a frame with multicast destination to any node that signaled16941695 * interest in it, that is either via the translation table or the according···17021701 * is neither IPv4 nor IPv6. NET_XMIT_SUCCESS otherwise.17031702 */17041703int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,17051705- unsigned short vid)17041704+ unsigned short vid, int is_routable)17061705{17071706 int ret;17081707···17181717 return ret;17191718 }1720171917201720+ if (!is_routable)17211721+ goto skip_mc_router;17221722+17211723 ret = batadv_mcast_forw_want_rtr(bat_priv, skb, vid);17221724 if (ret != NET_XMIT_SUCCESS) {17231725 kfree_skb(skb);17241726 return ret;17251727 }1726172817291729+skip_mc_router:17271730 consume_skb(skb);17281731 return ret;17291732}
+6-4
net/batman-adv/multicast.h
···43434444enum batadv_forw_mode4545batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,4646- struct batadv_orig_node **mcast_single_orig);4646+ struct batadv_orig_node **mcast_single_orig,4747+ int *is_routable);47484849int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,4950 struct sk_buff *skb,···5251 struct batadv_orig_node *orig_node);53525453int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,5555- unsigned short vid);5454+ unsigned short vid, int is_routable);56555756void batadv_mcast_init(struct batadv_priv *bat_priv);5857···69687069static inline enum batadv_forw_mode7170batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,7272- struct batadv_orig_node **mcast_single_orig)7171+ struct batadv_orig_node **mcast_single_orig,7272+ int *is_routable)7373{7474 return BATADV_FORW_ALL;7575}···87858886static inline int8987batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb,9090- unsigned short vid)8888+ unsigned short vid, int is_routable)9189{9290 kfree_skb(skb);9391 return NET_XMIT_DROP;
+5-2
net/batman-adv/soft-interface.c
···198198 int gw_mode;199199 enum batadv_forw_mode forw_mode = BATADV_FORW_SINGLE;200200 struct batadv_orig_node *mcast_single_orig = NULL;201201+ int mcast_is_routable = 0;201202 int network_offset = ETH_HLEN;202203 __be16 proto;203204···301300send:302301 if (do_bcast && !is_broadcast_ether_addr(ethhdr->h_dest)) {303302 forw_mode = batadv_mcast_forw_mode(bat_priv, skb,304304- &mcast_single_orig);303303+ &mcast_single_orig,304304+ &mcast_is_routable);305305 if (forw_mode == BATADV_FORW_NONE)306306 goto dropped;307307···361359 ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid,362360 mcast_single_orig);363361 } else if (forw_mode == BATADV_FORW_SOME) {364364- ret = batadv_mcast_forw_send(bat_priv, skb, vid);362362+ ret = batadv_mcast_forw_send(bat_priv, skb, vid,363363+ mcast_is_routable);365364 } else {366365 if (batadv_dat_snoop_outgoing_arp_request(bat_priv,367366 skb))
+4
net/core/lwtunnel.c
···197197 nla_entype = nla_find(attrs, attrlen, RTA_ENCAP_TYPE);198198199199 if (nla_entype) {200200+ if (nla_len(nla_entype) < sizeof(u16)) {201201+ NL_SET_ERR_MSG(extack, "Invalid RTA_ENCAP_TYPE");202202+ return -EINVAL;203203+ }200204 encap_type = nla_get_u16(nla_entype);201205202206 if (lwtunnel_valid_encap_type(encap_type,
+43-6
net/ipv4/fib_semantics.c
···662662 return nhs;663663}664664665665+static int fib_gw_from_attr(__be32 *gw, struct nlattr *nla,666666+ struct netlink_ext_ack *extack)667667+{668668+ if (nla_len(nla) < sizeof(*gw)) {669669+ NL_SET_ERR_MSG(extack, "Invalid IPv4 address in RTA_GATEWAY");670670+ return -EINVAL;671671+ }672672+673673+ *gw = nla_get_in_addr(nla);674674+675675+ return 0;676676+}677677+665678/* only called when fib_nh is integrated into fib_info */666679static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,667680 int remaining, struct fib_config *cfg,···717704 return -EINVAL;718705 }719706 if (nla) {720720- fib_cfg.fc_gw4 = nla_get_in_addr(nla);707707+ ret = fib_gw_from_attr(&fib_cfg.fc_gw4, nla,708708+ extack);709709+ if (ret)710710+ goto errout;711711+721712 if (fib_cfg.fc_gw4)722713 fib_cfg.fc_gw_family = AF_INET;723714 } else if (nlav) {···731714 }732715733716 nla = nla_find(attrs, attrlen, RTA_FLOW);734734- if (nla)717717+ if (nla) {718718+ if (nla_len(nla) < sizeof(u32)) {719719+ NL_SET_ERR_MSG(extack, "Invalid RTA_FLOW");720720+ return -EINVAL;721721+ }735722 fib_cfg.fc_flow = nla_get_u32(nla);723723+ }736724737725 fib_cfg.fc_encap = nla_find(attrs, attrlen, RTA_ENCAP);726726+ /* RTA_ENCAP_TYPE length checked in727727+ * lwtunnel_valid_encap_type_attr728728+ */738729 nla = nla_find(attrs, attrlen, RTA_ENCAP_TYPE);739730 if (nla)740731 fib_cfg.fc_encap_type = nla_get_u16(nla);···927902 attrlen = rtnh_attrlen(rtnh);928903 if (attrlen > 0) {929904 struct nlattr *nla, *nlav, *attrs = rtnh_attrs(rtnh);905905+ int err;930906931907 nla = nla_find(attrs, attrlen, RTA_GATEWAY);932908 nlav = nla_find(attrs, attrlen, RTA_VIA);···938912 }939913940914 if (nla) {915915+ __be32 gw;916916+917917+ err = fib_gw_from_attr(&gw, nla, extack);918918+ if (err)919919+ return err;920920+941921 if (nh->fib_nh_gw_family != AF_INET ||942942- nla_get_in_addr(nla) != nh->fib_nh_gw4)922922+ gw != nh->fib_nh_gw4)943923 return 1;944924 } else if (nlav) {945925 struct fib_config cfg2;946946- int err;947926948927 err = fib_gw_from_via(&cfg2, nlav, extack);949928 if (err)···971940972941#ifdef CONFIG_IP_ROUTE_CLASSID973942 nla = nla_find(attrs, attrlen, RTA_FLOW);974974- if (nla && nla_get_u32(nla) != nh->nh_tclassid)975975- return 1;943943+ if (nla) {944944+ if (nla_len(nla) < sizeof(u32)) {945945+ NL_SET_ERR_MSG(extack, "Invalid RTA_FLOW");946946+ return -EINVAL;947947+ }948948+ if (nla_get_u32(nla) != nh->nh_tclassid)949949+ return 1;950950+ }976951#endif977952 }978953
···7575 return true;7676}77777878+struct ipv6_sr_hdr *seg6_get_srh(struct sk_buff *skb, int flags)7979+{8080+ struct ipv6_sr_hdr *srh;8181+ int len, srhoff = 0;8282+8383+ if (ipv6_find_hdr(skb, &srhoff, IPPROTO_ROUTING, NULL, &flags) < 0)8484+ return NULL;8585+8686+ if (!pskb_may_pull(skb, srhoff + sizeof(*srh)))8787+ return NULL;8888+8989+ srh = (struct ipv6_sr_hdr *)(skb->data + srhoff);9090+9191+ len = (srh->hdrlen + 1) << 3;9292+9393+ if (!pskb_may_pull(skb, srhoff + len))9494+ return NULL;9595+9696+ /* note that pskb_may_pull may change pointers in header;9797+ * for this reason it is necessary to reload them when needed.9898+ */9999+ srh = (struct ipv6_sr_hdr *)(skb->data + srhoff);100100+101101+ if (!seg6_validate_srh(srh, len, true))102102+ return NULL;103103+104104+ return srh;105105+}106106+107107+/* Determine if an ICMP invoking packet contains a segment routing108108+ * header. If it does, extract the offset to the true destination109109+ * address, which is in the first segment address.110110+ */111111+void seg6_icmp_srh(struct sk_buff *skb, struct inet6_skb_parm *opt)112112+{113113+ __u16 network_header = skb->network_header;114114+ struct ipv6_sr_hdr *srh;115115+116116+ /* Update network header to point to the invoking packet117117+ * inside the ICMP packet, so we can use the seg6_get_srh()118118+ * helper.119119+ */120120+ skb_reset_network_header(skb);121121+122122+ srh = seg6_get_srh(skb, 0);123123+ if (!srh)124124+ goto out;125125+126126+ if (srh->type != IPV6_SRCRT_TYPE_4)127127+ goto out;128128+129129+ opt->flags |= IP6SKB_SEG6;130130+ opt->srhoff = (unsigned char *)srh - skb->data;131131+132132+out:133133+ /* Restore the network header back to the ICMP packet */134134+ skb->network_header = network_header;135135+}136136+78137static struct genl_family seg6_genl_family;7913880139static const struct nla_policy seg6_genl_policy[SEG6_ATTR_MAX + 1] = {
+2-31
net/ipv6/seg6_local.c
···151151 return (struct seg6_local_lwt *)lwt->data;152152}153153154154-static struct ipv6_sr_hdr *get_srh(struct sk_buff *skb, int flags)155155-{156156- struct ipv6_sr_hdr *srh;157157- int len, srhoff = 0;158158-159159- if (ipv6_find_hdr(skb, &srhoff, IPPROTO_ROUTING, NULL, &flags) < 0)160160- return NULL;161161-162162- if (!pskb_may_pull(skb, srhoff + sizeof(*srh)))163163- return NULL;164164-165165- srh = (struct ipv6_sr_hdr *)(skb->data + srhoff);166166-167167- len = (srh->hdrlen + 1) << 3;168168-169169- if (!pskb_may_pull(skb, srhoff + len))170170- return NULL;171171-172172- /* note that pskb_may_pull may change pointers in header;173173- * for this reason it is necessary to reload them when needed.174174- */175175- srh = (struct ipv6_sr_hdr *)(skb->data + srhoff);176176-177177- if (!seg6_validate_srh(srh, len, true))178178- return NULL;179179-180180- return srh;181181-}182182-183154static struct ipv6_sr_hdr *get_and_validate_srh(struct sk_buff *skb)184155{185156 struct ipv6_sr_hdr *srh;186157187187- srh = get_srh(skb, IP6_FH_F_SKIP_RH);158158+ srh = seg6_get_srh(skb, IP6_FH_F_SKIP_RH);188159 if (!srh)189160 return NULL;190161···172201 struct ipv6_sr_hdr *srh;173202 unsigned int off = 0;174203175175- srh = get_srh(skb, 0);204204+ srh = seg6_get_srh(skb, 0);176205 if (srh && srh->segments_left > 0)177206 return false;178207
···647647 struct cfg80211_csa_settings settings;648648};649649650650+/**651651+ * struct mesh_table652652+ *653653+ * @known_gates: list of known mesh gates and their mpaths by the station. The654654+ * gate's mpath may or may not be resolved and active.655655+ * @gates_lock: protects updates to known_gates656656+ * @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr657657+ * @walk_head: linked list containing all mesh_path objects658658+ * @walk_lock: lock protecting walk_head659659+ * @entries: number of entries in the table660660+ */661661+struct mesh_table {662662+ struct hlist_head known_gates;663663+ spinlock_t gates_lock;664664+ struct rhashtable rhead;665665+ struct hlist_head walk_head;666666+ spinlock_t walk_lock;667667+ atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */668668+};669669+650670struct ieee80211_if_mesh {651671 struct timer_list housekeeping_timer;652672 struct timer_list mesh_path_timer;···741721 /* offset from skb->data while building IE */742722 int meshconf_offset;743723744744- struct mesh_table *mesh_paths;745745- struct mesh_table *mpp_paths; /* Store paths for MPP&MAP */724724+ struct mesh_table mesh_paths;725725+ struct mesh_table mpp_paths; /* Store paths for MPP&MAP */746726 int mesh_paths_generation;747727 int mpp_paths_generation;748728};
+1-21
net/mac80211/mesh.h
···127127 u32 path_change_count;128128};129129130130-/**131131- * struct mesh_table132132- *133133- * @known_gates: list of known mesh gates and their mpaths by the station. The134134- * gate's mpath may or may not be resolved and active.135135- * @gates_lock: protects updates to known_gates136136- * @rhead: the rhashtable containing struct mesh_paths, keyed by dest addr137137- * @walk_head: linked list containing all mesh_path objects138138- * @walk_lock: lock protecting walk_head139139- * @entries: number of entries in the table140140- */141141-struct mesh_table {142142- struct hlist_head known_gates;143143- spinlock_t gates_lock;144144- struct rhashtable rhead;145145- struct hlist_head walk_head;146146- spinlock_t walk_lock;147147- atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */148148-};149149-150130/* Recent multicast cache */151131/* RMC_BUCKETS must be a power of 2, maximum 256 */152132#define RMC_BUCKETS 256···288308void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);289309void mesh_path_flush_pending(struct mesh_path *mpath);290310void mesh_path_tx_pending(struct mesh_path *mpath);291291-int mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);311311+void mesh_pathtbl_init(struct ieee80211_sub_if_data *sdata);292312void mesh_pathtbl_unregister(struct ieee80211_sub_if_data *sdata);293313int mesh_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr);294314void mesh_path_timer(struct timer_list *t);